This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 74160 - SPI for pluggable JUnit support implementations
Summary: SPI for pluggable JUnit support implementations
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Marian Petras
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 42349
  Show dependency tree
 
Reported: 2006-03-29 16:18 UTC by Marian Petras
Modified: 2006-10-06 10:51 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
architecture description (17.07 KB, application/x-compressed)
2006-03-29 16:21 UTC, Marian Petras
Details
Javadoc of the SPI (50.29 KB, application/x-compressed)
2006-03-29 16:22 UTC, Marian Petras
Details
Javadoc of the SPI - fixed (51.59 KB, application/x-compressed)
2006-03-29 17:05 UTC, Marian Petras
Details
Javadoc of the SPI - modified - uses JMI (69.34 KB, application/x-compressed)
2006-03-30 16:00 UTC, Marian Petras
Details
architecture description - updated (30.83 KB, application/x-compressed)
2006-04-04 08:44 UTC, Marian Petras
Details
JUnit API & API-changes - updated (61.10 KB, application/x-compressed)
2006-04-04 08:51 UTC, Marian Petras
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Petras 2006-03-29 16:18:16 UTC
Create an SPI to allow different JUnit support implementations for different
project types.

The demand is induced by the fact that different types of projects (based on
various platform - J2SE, J2ME, ...) require different support for JUnit. In
particular, this SPI should fulfil a requirement that J2ME support is needed, as
reported in issue #42349 ("JUnit should support enhancment to J2MEJUnit").

This SPI defines an interface for pluggable implementations of JUnit support. It
allows to plug in implementation of two basic features of the JUnit module:
  - navigation between source classes and corresponding test classes
  - generating test class skeletons

The SPI is represented by a single interface called JUnitPlugin - see the
attachment. The interface is in a newly introduced package.

For now, the SPI will be declared as a friend API between the JUnit module and
mobility modules. It is considered unstable (development) API.
Comment 1 Jesse Glick 2006-03-29 16:21:26 UTC
No attachment yet, is it coming?
Comment 2 Marian Petras 2006-03-29 16:21:30 UTC
Created attachment 29479 [details]
architecture description
Comment 3 Marian Petras 2006-03-29 16:22:22 UTC
Created attachment 29480 [details]
Javadoc of the SPI
Comment 4 Pavel Buzek 2006-03-29 16:31:02 UTC
Is this really planned for nb 5.5 or for the trunk (nb 6.0)?
Comment 5 Marian Petras 2006-03-29 16:33:18 UTC
It is really planned for NB 5.5. The Mobility team needs it for support of J2ME
Unit.
Comment 6 Jesse Glick 2006-03-29 16:45:09 UTC
[jglick01] Is there any plan to include some of this functionality in
UnitTestForSourceQuery (e.g. the get*Element methods), or is this intended to
remain part of the junit module friend SPI for the foreseeable future?

[jglick02] There is a dead link to "part ID specification". Whatever this page
is, can its contents just be included in the class Javadoc for JUnitPlugin?

Also, if it is a real data structure I think it would be better expressed using
a final Java class rather than a String.

[jglick03] The params arg to createTests should probably be

  Map<CreateTestParam,Object>

where

  enum CreateTestParam {CLASS_NAME, ...}

BTW why the strange values for the current constants (99310 etc.)?
Comment 7 _ tball 2006-03-29 17:04:12 UTC
Planned for 5.5 by whom?  Trung is trying really hard to keep the requirements
list to a minimum for 5.5 so it won't slip again.  That means that even
important requirements which are not part of the original list cannot be considered.
Comment 8 Marian Petras 2006-03-29 17:04:18 UTC
ad [jglick01]:
No, we do not plan to include it into UnitTestForSourceQuery, at least not for
NB 5.5. We expect some "feedback" from our first implementations of the API and
we will decide then.

ad [jglick02]:
I will attach a fixed Javadoc.

ad [jglick03]:
Yes, that (the enum) sounds reasonable. I will change it.
Comment 9 Marian Petras 2006-03-29 17:05:12 UTC
Created attachment 29485 [details]
Javadoc of the SPI - fixed
Comment 10 Jesse Glick 2006-03-29 18:36:46 UTC
[jglick02a] The part ID grammar is rather complex. I would much rather see it be
handled by proper Java classes which can do syntax checking and throw IAE when
appropriate - otherwise typos and subtle misinterpretations seem quite likely.
Do I need to put spaces after commas between multiple method params? What is the
syntax for array parameters? For constructors, if they are supported? For
generic type parameters? Does this syntax differ from that used by Javadoc in
its URLs and if so how? Etc. Also consider whether using JVM syntax would not be
more precise, esp. in the presence of generics (and the possibility of methods
overloaded by return type). Probably you want someone from the Retouche team to
review this to make sure it actually corresponds to the possible named members
in a standard javac AST - CCing Hrebejk.

[jglick04] How could a FileID for a Java source file contain ':' or '\\'? These
characters are illegal in Java package or class names. (Note: using a proper
data structure as in [jglick02a] would obviate the need to have any escape syntax.)

[jglick03 cont'd] Attached Javadoc does not seem to be different for
createTests, did you really change it?
Comment 11 Marian Petras 2006-03-29 18:57:52 UTC
ad [jglick03 cont'd]:
No, I did not change it. By "fixed" I meant that the broken link is fixed.
Comment 12 Marian Petras 2006-03-29 18:59:43 UTC
tball: It is planned by the Mobility Team. I will ask their manager to explain it.
Comment 13 Marian Petras 2006-03-29 21:11:48 UTC
ad [jglick02a]:
Ok, the only simple solution I can think of for now is using the JMI interface.
So, instead of a single complex string, there would be a couple

    (FileObject, NamedElement)

The current implementation of the navigation actions (Go to Test, Go to Tested
Class) is based on these. When creating the SPI, I decided not to use it because
I've heard that future of JMI is not clear. So using JMI in the JUnit SPI would
work well (I think) but it might be one-release-only SPI.

Before I elaborate on the idea, I would like to know - is using JMI acceptable?

ad [jglick04]:
You are right. I made it overly general - these characters will not be allowed.
Comment 14 Martin Ryzl 2006-03-30 06:06:13 UTC
add tball - Requested for 5.5 by Mobility team. It was in Mobility Pack plans
since 4.0, last time in plans for 5.0 and accepted by Arseniy's group and then
it was postponed under condition it would get into next release. Quite simple
SPI has been blocking us for long time and since the schedule of 6.0 is unclear
we agreed to put it in 5.5. I don't believe this may cause 5.5 slip.
Comment 15 Marian Petras 2006-03-30 16:00:22 UTC
Created attachment 29503 [details]
Javadoc of the SPI - modified - uses JMI
Comment 16 Marian Petras 2006-03-30 16:05:35 UTC
I have posted a modified SPI.

It is modified in that methods

    String getUnitTestElement(String javaPartId);
    String getTestedElement(String javaTestPartId);

are replaced with

    Location getTestLocation(Location sourceLocation);
    Location getTestedLocation(Location testLocation);

where Location is essentially a data structure for storage of items (FileObject,
NamedElement).
Comment 17 Marian Petras 2006-03-30 23:19:46 UTC
What do you think about the change? Thanks.
Comment 18 Jesse Glick 2006-03-30 23:21:29 UTC
Looks OK to me, not sure if anyone else is reviewing.
Comment 19 Jaroslav Tulach 2006-03-31 05:41:05 UTC
I am reviewing, but I do not understand the junit problematic much and without 
some examples/tests I can only nitpick:

Y01. apichanges document - that would describe evolution, which is likely to 
happen, please specify that there was an initial release on the day when you 
integrate, also list this module in nbuild/project.properties as one having 
friend API

Y02. arch document has some picture, but it is broken on my computer

Y03. the usecases in the arch document should also show code snippets of how 
to achieve them in the api.

Y04. please use somewhere in arch.xml <arch group="lookup" >this interface is 
being looked up in project's lookups

Y05. I would propose to make the JUnitPlugin interface an abstract class with 
protected methods, so it is clear that nobody else than JUnit module can call 
them. I prefer this, even this may need a use of "trampoline" inside the JUnit 
module.

Y06. I suggest to write some tests. Just a simple impl of the JUnitPlugin 
showing what the expected calls are likely to be and in which order.
Comment 20 Tomas Hurka 2006-04-03 08:27:37 UTC
Marian, 
AFAICT Location is useless. Why do you need NamedElement _and_ FileObject? According to your 
architecture description I think that org.netbeans.jmi.javamodel.Feature should be used instead of 
Location.
Comment 21 Marian Petras 2006-04-04 08:44:50 UTC
Created attachment 29580 [details]
architecture description - updated
Comment 22 Marian Petras 2006-04-04 08:51:25 UTC
Created attachment 29581 [details]
JUnit API & API-changes - updated
Comment 23 Marian Petras 2006-04-04 08:55:52 UTC
ad Y01: I have created the API-changes document - it is part of the Javadoc
archive I just attached.

ad Y02: I just attached a .zip containing both the HTML file and the image.
        (I have also updated the project's build.xml so that the image
        is copied to the build directory automatically).

ad Y03: I will add some code snippets.

ad Y04: I _replaced_ <api group="java"> with <api group="lookup">.
        Is it right or should I do something else?

ad Y05: Done.

ad Y06: I will write some tests.
Comment 24 Marian Petras 2006-04-04 09:03:34 UTC
Regarding the question by Tomas Hurka: One supported scenario is that the user
wants to jump to a test file for the current source file but the there is no
specific Java element specified (e.g. if the cursor of the source code editor is
in the initial comment of a Java file). That's why the API does not rely only on
Java elements. The two parameters of the Location constructor are: FileObject -
mandatory, Java element - optional.

During a face-to-face discussion with Tomas Hurka, we agree to replace
NamedElement with Feature. This change is already reflected in the most recently
attached Javadoc.
Comment 25 Jaroslav Tulach 2006-04-04 16:55:18 UTC
All sounds well except:

ad Y04: I _replaced_ <api group="java"> with <api group="lookup">.
        Is it right or should I do something else?

What I wanted to suggest is to include both. 
<api group="java" url=".../package-summary.html">some description</api>
as a list of all classes that the API offers and
<api group="lookup" url=".../TheClass.html">TheClass is searched in {@link 
Project} lookup</api>

You definitely need the group="java" otherwise bottom of your overview page in 
javadoc looks ugly. I prefer to add the lookup group as well, one day will be 
able to generate list all interfaces that one can put into some lookup, 
hopefully.

Comment 26 Marian Petras 2006-04-07 17:07:55 UTC
arch.xml now contains two <api> elements, one with group="java", one with
group="lookup".
Comment 27 Marian Petras 2006-04-07 18:42:41 UTC
Committed to the trunk.

Modified files (part 1 - new SPI):

junit/src/org/netbeans/modules/junit/plugin/JUnitPlugin.java (1.1 - init. rev.)
junit/nbproject/project.properties   (1.6)
junit/nbproject/project.xml   (1.12)
junit/build.xml   (1.60)
junit/manifest.mf   (1.45)
junit/apichanges.xml   (1.1 - initial revision)
junit/arch.xml   (1.5)
junit/arch/JUnitPlugin.png   (1.1 - initial revision)
ide/golden/friend-packages.txt   (1.17)

Modified files (part 2 - default impl. switched to the new SPI):

junit/src/org/netbeans/modules/junit/:
                          Bundle.properties   (1.75)
                          CreateTestAction.java   (1.53)
                          DefaultPlugin.java   (1.1 - initial revision)
                          GoToOppositeAction.java   (1.8)
                          JUnitPluginTrampoline.java   (1.1 - initial revision)
                          OpenTestAction.java   (1.23)
                          TestCreator.java   (1.59)
                          TestUtil.java   (1.34)
junit/src/org/netbeans/modules/junit/wizards/:
                          EmptyTestCaseWizardIterator.java   (1.13)
                          Bundle.properties   (1.8)
                          SimpleTestCaseWizardIterator.java   (1.17)
                          TestSuiteWizardIterator.java   (1.12)

Modified files (part 3 - small changes due to transition to JDK 1.5):

junit/src/org/netbeans/modules/junit/:
                          ProgressIndicator.java   (1.5)
junit/src/org/netbeans/modules/junit/output/:
                          ResultWindow.java   (1.10)

Diffs:

Part 1:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/plugin/JUnitPlugin.java?rev=1.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/nbproject/project.properties?r1=1.5&r2=1.6&diff_format=u
http://junit.netbeans.org/source/browse/junit/nbproject/project.xml?r1=1.11&r2=1.12&diff_format=u
http://junit.netbeans.org/source/browse/junit/build.xml?r1=1.59&r2=1.60&diff_format=u
http://junit.netbeans.org/source/browse/junit/manifest.mf?r1=1.44&r2=1.45&diff_format=u
http://junit.netbeans.org/source/browse/junit/apichanges.xml?rev=1.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/arch.xml?r1=1.4&r2=1.5&diff_format=u
http://junit.netbeans.org/source/browse/junit/arch/JUnitPlugin.png?rev=1.1&content-type=text/vnd.viewcvs-markup
http://ide.netbeans.org/source/browse/ide/golden/friend-packages.txt?r1=1.16&r2=1.17&diff_format=u

Part 2:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/Bundle.properties?r1=1.74&r2=1.75&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/CreateTestAction.java?r1=1.52&r2=1.53&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/DefaultPlugin.java?rev=1.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/GoToOppositeAction.java?r1=1.7&r2=1.8&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/JUnitPluginTrampoline.java?rev=1.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/OpenTestAction.java?r1=1.22&r2=1.23&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/TestCreator.java?r1=1.58&r2=1.59&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/TestUtil.java?r1=1.33&r2=1.34&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/wizards/EmptyTestCaseWizardIterator.java?r1=1.12&r2=1.13&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/wizards/Bundle.properties?r1=1.7&r2=1.8&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/wizards/SimpleTestCaseWizardIterator.java?r1=1.16&r2=1.17&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/wizards/TestSuiteWizardIterator.java?r1=1.11&r2=1.12&diff_format=u

Part 3:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/ProgressIndicator.java?r1=1.4&r2=1.5&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/ResultWindow.java?r1=1.9&r2=1.10&diff_format=u
Comment 28 Marian Petras 2006-04-09 12:17:47 UTC
One more file changed - module "junit" added to the list of javadocs dedicated
just for friend usage (config.javadoc.friend):

   nbbuild/build.properties   (1.381)

Diff:
http://nbbuild.netbeans.org/source/browse/nbbuild/build.properties?r1=1.380&r2=1.381&diff_format=u
Comment 29 Marian Petras 2006-04-11 14:23:09 UTC
There was a bug in the patch - see issue #74744 ("NPE from
EmptyTestCaseWizardIterator.instantiate").

The bug is fixed now - the (simple) fix changed the following files:

    junit/src/org/netbeans/modules/junit/wizards/:
                                       EmptyTestCaseWizardIterator.java   (1.14)
                                       SimpleTestCaseWizardIterator.java   (1.18)
Comment 30 Marian Petras 2006-04-11 14:48:54 UTC
Another trivial bug caused by integration of the SPI - see issue #74817 ("Create
Test dialog: Javadoc comment generated even when not checked").

Modified file:
    junit/src/org/netbeans/modules/junit/TestCreator.java   (1.60)
Comment 31 Marian Mirilovic 2006-10-06 09:50:12 UTC
Too late for NB 5.5 - I guess.
Comment 32 Marian Petras 2006-10-06 10:51:03 UTC
It is already committed to 'release55' on 21 April. Apparently, I forgot to
leave a note here. Here it is:

Committed to branch 'release55'.

Modified files (part 1 - new SPI):

junit/src/org/netbeans/modules/junit/plugin/JUnitPlugin.java (1.2.2.1 - new)
junit/nbproject/project.properties   (1.5.34.1)
junit/nbproject/project.xml   (1.8.2.1.2.1)
junit/build.xml   (1.56.12.1.2.1)
junit/manifest.mf   (1.41.2.1.2.1)
junit/apichanges.xml   (1.1.2.1 - new)
junit/arch.xml   (1.3.28.1)
junit/arch/JUnitPlugin.png   (1.1.2.1 - initial revision)
ide/golden/friend-packages.txt   (1.15.4.1.2.69)

Modified files (part 2 - default impl. switched to the new SPI):

junit/src/org/netbeans/modules/junit/:
                          Bundle.properties   (1.64.2.2.2.1)
                          CreateTestAction.java   (1.51.8.1.2.1)
                          DefaultPlugin.java   (1.2.2.1 - new)
                          GoToOppositeAction.java   (1.2.2.2.2.1)
                          JUnitPluginTrampoline.java   (1.1.2.1 - new)
                          OpenTestAction.java   (1.22.22.1)
                          TestCreator.java   (1.53.8.2.2.1)
                          TestUtil.java   (1.31.26.1)
junit/src/org/netbeans/modules/junit/wizards/:
                          EmptyTestCaseWizardIterator.java   (1.12.58.1)
                          Bundle.properties   (1.7.52.1)
                          SimpleTestCaseWizardIterator.java   (1.16.58.1)
                          TestSuiteWizardIterator.java   (1.11.58.1)

Modified files (part 3 - small changes due to transition to JDK 1.5):

junit/src/org/netbeans/modules/junit/:
                          ProgressIndicator.java   (1.4.28.1)
junit/src/org/netbeans/modules/junit/output/:
                          ResultWindow.java   (1.1.4.3.2.1)

Diffs:

Part 1:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/plugin/JUnitPlugin.java?rev=1.2.2.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/nbproject/project.properties?r1=1.5&r2=1.5.34.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/nbproject/project.xml?r1=1.8&r2=1.8.2.1.2.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/build.xml?r1=1.56&r2=1.56.12.1.2.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/manifest.mf?r1=1.41&r2=1.41.2.1.2.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/apichanges.xml?rev=1.1.2.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/arch.xml?r1=1.3&r2=1.3.28.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/arch/JUnitPlugin.png?rev=1.2.2.1&content-type=text/vnd.viewcvs-markup
http://ide.netbeans.org/source/browse/ide/golden/friend-packages.txt?r1=1.15.4.1.2.68&r2=1.15.4.1.2.69&diff_format=u

Part 2:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/Bundle.properties?r1=1.64.2.2&r2=1.64.2.2.2.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/CreateTestAction.java?r1=1.51&r2=1.51.8.1.2.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/DefaultPlugin.java?rev=1.2.2.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/GoToOppositeAction.java?r1=1.2.2.2&r2=1.2.2.2.2.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/JUnitPluginTrampoline.java?rev=1.1.2.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/OpenTestAction.java?r1=1.22&r2=1.22.22.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/TestCreator.java?r1=1.53.8.2&r2=1.53.8.2.2.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/TestUtil.java?r1=1.31&r2=1.31.26.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/wizards/EmptyTestCaseWizardIterator.java?r1=1.12&r2=1.12.58.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/wizards/Bundle.properties?r1=1.7&r2=1.7.52.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/wizards/SimpleTestCaseWizardIterator.java?r1=1.16&r2=1.16.58.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/wizards/TestSuiteWizardIterator.java?r1=1.11&r2=1.11.58.1&diff_format=u

Part 3:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/ProgressIndicator.java?r1=1.4&r2=1.4.28.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/ResultWindow.java?r1=1.1.4.3&r2=1.1.4.3.2.1&diff_format=u