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 142416 - [65cat] JUnit test run fails
Summary: [65cat] JUnit test run fails
Status: VERIFIED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 blocker with 1 vote (vote)
Assignee: Jan Lahoda
URL:
Keywords: REGRESSION
Depends on: 144051
Blocks:
  Show dependency tree
 
Reported: 2008-07-31 14:10 UTC by ulfzibis
Modified: 2010-08-14 22:07 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Perhaps this helps (from .\build\test\results\) (30.19 KB, text/xml)
2008-07-31 15:48 UTC, ulfzibis
Details
Platforms (6.65 KB, application/x-compressed)
2008-08-12 20:33 UTC, ulfzibis
Details
SpeedTest compiled by 200808120201 (8.22 KB, application/octet-stream)
2008-08-14 13:02 UTC, ulfzibis
Details
ant verbose 200808120201 log (57.09 KB, text/plain)
2008-08-14 17:02 UTC, ulfzibis
Details
ant debug 200808120201 log (106.46 KB, text/plain)
2008-08-14 17:04 UTC, ulfzibis
Details
ant verbose 200807040101 log (58.21 KB, text/plain)
2008-08-14 17:06 UTC, ulfzibis
Details
ant debug 200807040101 log (105.80 KB, text/plain)
2008-08-14 17:07 UTC, ulfzibis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ulfzibis 2008-07-31 14:10:03 UTC
[ JDK VERSION : 1.6.0_07 ]

Testcase: initializationError0(SpeedTest):        Caused an ERROR
Test class should have public zero-argument constructor
java.lang.Exception: Test class should have public zero-argument
constructor
       at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
       at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
Caused by: java.lang.NoSuchMethodException: SpeedTest.<init>()
       at java.lang.Class.getConstructor0(Class.java:2706)
       at java.lang.Class.getConstructor(Class.java:1657)


I didn't have it in NB 6.1.
For the sources see:
http://www.netbeans.org/issues/show_bug.cgi?id=141914
(Which should be fixed for 200807301401)
Comment 1 Milos Kleint 2008-07-31 14:17:56 UTC
CoS>jlahoda
Comment 2 ulfzibis 2008-07-31 14:35:17 UTC
It also works fine in 6.5M1.
Comment 3 Jan Lahoda 2008-07-31 14:37:02 UTC
Could you please attach the full exception? Also, I was not able to reproduce (I simply executed Run File on SpeedTest
from the project and it worked OK), could you please provide some details on how exactly can this issue be reproduced?
Thanks.
Comment 4 ulfzibis 2008-07-31 15:43:44 UTC
I can't find out more about the exception than this:

init:
deps-jar:
compile:
compile-test-single:
Testsuite: SpeedTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0,172 sec

Testcase: initializationError0(SpeedTest):        Caused an ERROR
Test class should have public zero-argument constructor
java.lang.Exception: Test class should have public zero-argument constructor
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
Caused by: java.lang.NoSuchMethodException: SpeedTest.<init>()
        at java.lang.Class.getConstructor0(Class.java:2706)
        at java.lang.Class.getConstructor(Class.java:1657)


Test SpeedTest FAILED
C:\Projects\nio_charset\nbproject\build-impl.xml:614: Some tests failed; see details above.
BUILD FAILED (total time: 2 seconds)

Should I send you any other information?
Comment 5 ulfzibis 2008-07-31 15:48:09 UTC
Created attachment 66185 [details]
Perhaps this helps (from .\build\test\results\)
Comment 6 Jan Lahoda 2008-08-12 13:01:32 UTC
Sorry, but I still cannot reproduce. This is what I did:
1. in /tmp:
svn checkout https://java-nio-charset-enhanced.dev.java.net/svn/java-nio-charset-enhanced/trunk java-nio-charset-enhanced
2. Opened /tmp/java-nio-charset-enhanced in the IDE, opened Project/Properties, changed the platform to my default 1.6
3. Opened SpeedTest, ran the file (this used CoS). All tests passed.
4. Went to Project/Properties/Compile, disabled CoS.
5. ran SpeedTest again (without CoS). All tests passed.
6. "Test" whole project failed because of compilation errors in MapCalculator

I am afraid I will need detailed steps to reproduce.
Comment 7 ulfzibis 2008-08-12 20:29:06 UTC
Hi Jan,

I did a new try:

 1. Installed build 200808120201 with new userdir.
 2. Started build 200808120201 without import. + Tools->Plugins->Settings "Force install into shared directories"
 3. Versioning->Subversion->Checkout https://java-nio-charset-enhanced.dev.java.net/svn/java-nio-charset-enhanced/trunk
    to \Projects\nio_charset_2\ (note: without last token "java-nio-charset-enhanced").
 4. Closed IDE to resolve broken references by copying old ..\config\Services\Platforms\org-netbeans-api-java-Platform\*
    ("JDK 1.6.0-b105 debug" is normal JDK 1.6.0-b105 + additional sources from /jdk1.6.0/src/j2se/src/share/classes/)
 5. Copied also from old IDE: ..\config\Favorites\* ..\config\Toolbars\*
 6. Started IDE.
 7. Compiled SpeedTest.java (had to work around issue 143637).
 8. Also compiled MapCalculator.java (wondering, I had no compile errors. Can you send me your errors?).
 9. Ran SpeedTest (this used CoS). --> Had errors as discribed above.
10. Went to Project->Properties->Compile, disabled CoS.
11. Ran SpeedTest again (without CoS). --> Had errors as discribed above.
12. Opened Project->Properties, changed the platform to my default 1.6
13. Ran SpeedTest again (without CoS, default platform). --> Had errors as discribed above.
Comment 8 ulfzibis 2008-08-12 20:33:14 UTC
Created attachment 67174 [details]
Platforms
Comment 9 Jan Lahoda 2008-08-14 09:59:59 UTC
One needs to use non-default platform to compile the MapCalculator (so the compiler is forked).

I tried to comment-out the @RunWith(Parameterized.class) in SpeedTest, and the error appeared. So it seems that for some
reason the annotation is not part of the .class file that is being executed. I checked the .class file produced by
NetBeans, and it seems to contain the annotation.
Comment 10 ulfzibis 2008-08-14 13:00:17 UTC
> One needs to use non-default platform to compile the MapCalculator (so the compiler is forked).

Reason: Issue 130352
Can anybody explain me what fork exactly means, and how it's enabled properly in contrast to this lousy workaround?
It's annoying this additional non-default platform stuff. I always have to explain this to people using my sources after
their first failed try.

> I tried to comment-out the @RunWith(Parameterized.class) in SpeedTest, and the error appeared.

I can reproduce this with my 6.5M1, but with 200808120201 the error appears always.

> So it seems that for some reason the annotation is not part of the .class file that is being executed. I checked
> the .class file produced by NetBeans, and it seems to contain the annotation.

The "SpeedTest.class" produced by my 6.5M1 and 200808120201 are identical. But the error only occurs, if I run it by
200808120201. I will attach it for your evaluation.

What other information can I give you?
Comment 11 ulfzibis 2008-08-14 13:02:32 UTC
Created attachment 67405 [details]
SpeedTest compiled by 200808120201
Comment 12 Jan Lahoda 2008-08-14 15:43:44 UTC
Debugging output from ant might help (ideally from both NB6.1/NB6.5M1 and trunk with CoS disabled).
Comment 13 ulfzibis 2008-08-14 16:20:17 UTC
Sorry, is not possible because of issue 143945.

Any further ideas?

Comment 14 ulfzibis 2008-08-14 17:02:33 UTC
Created attachment 67437 [details]
ant verbose 200808120201 log
Comment 15 ulfzibis 2008-08-14 17:04:49 UTC
Created attachment 67438 [details]
ant debug 200808120201 log
Comment 16 ulfzibis 2008-08-14 17:06:36 UTC
Created attachment 67439 [details]
ant verbose 200807040101 log
Comment 17 ulfzibis 2008-08-14 17:07:57 UTC
Created attachment 67440 [details]
ant debug 200807040101 log
Comment 18 ulfzibis 2008-08-14 20:13:32 UTC
As you see, now I was successful in logging the ant debug output.
Comment 19 Jan Lahoda 2008-08-15 10:55:28 UTC
Ok, I (think I) found out what is the problem. If one executes the tests in such a way that the build/test/classes is on
the bootclasspath, but junit-4.1.jar is not (which is the default behavior of the java-nio-charset-enhanced project on
Windows and NB6.5M2+), the RunWith annotation cannot be resolved and the test crashes (the class is apparently loaded
OK, the annotation seems to be simply ignored). Having junit on classpath is (of course) not enough. Note:
-the junit-4.1.jar has been moved from java2 cluster into platform* cluster (presumably to support simple tests). So the
reference to "${netbeans.home}/../java2/modules/ext/junit-4.1.jar" in project.properties is not correct and is ignored.
-the value of "run.test.jvmargs.xbootclasspath" property uses ';' as path.separator, which is not recognized on Linux
(':' is used as path.separator on UNIX), so the value is invalid on Linux and the tests passes (because both the test
classes and junit are loaded from the classpath).

To reproduce on Linux, I had to replace ';' with ':' in "run.test.jvmargs.xbootclasspath" and "run.jvmargs" properties.

I quick (although not completely correct) fix is to refer to junit as: "${netbeans.home}/modules/ext/junit-4.1.jar"
Comment 20 ulfzibis 2008-08-15 14:06:16 UTC
Wow, not easy to find. Very tricky.

Thanks Jan.

... I've filed issue 144051.

Comment 21 ulfzibis 2010-08-14 22:07:01 UTC
Using ${path.separator} instead : or ; helps