How to get junit on classpath?
Nick Williams
nicholas+openjdk at nicholaswilliams.net
Tue Jul 30 18:40:39 PDT 2013
DOPE! I totally goofed on this one. I didn't read the whole stack trace. If I had, I would have seen this:
[stacktrace]
Caused by: java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
[stacktrace]
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
[stacktrace]
JUnit started requiring Hamcrest as of JUnit 4.4, but through JUnit 4.8.2 Hamcrest was bundled in the JUnit JAR (which is a no-no). Starting with JUnit 4.9 (including my 4.11) Hamcrest is no longer bundled (as it should be) and you have to download/attach Hamcrest separately.
Skeptical about my chances, I put hamcrest.jar in $JT_HOME/lib assuming it wouldn't work, and it didn't. I wasn't surprised. I downgraded to the JUnit 4.8.2 JAR and it's working now. Jtreg might want to start looking for hamcrest.jar now, too. JUnit 4.8.2 is three years old.
N
On Jul 30, 2013, at 5:39 PM, Nick Williams wrote:
> Yep! Those are the ones failing.
>
> I'm using JUnit 4.11, and the junit.jar DOES contain org.junit.runner.JUnitCore.
>
> I tried -J-Djunit.jar=/usr/share/java/jtreg/lib/junit.jar in jtreg but it didn't make a difference. I'm using the Makefile to run tests (that's what the JDK readme says to do, and I don't dare venture away from that lol). Looking at the output, the executed process doesn't include the words "junit" anywhere so Makefile apparently isn't using the jtreg startup script.
>
> I'm not ever sure how I would go about setting the system property if I'm running from the Makefile.
>
> N
>
> On Jul 30, 2013, at 5:05 PM, Jonathan Gibbons wrote:
>
>> FWIW, these are the tests that use JUnit,
>>
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/ThrowExceptionsTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/PrivateInvokeTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/RicochetTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/InvokeGenericTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/MethodHandlesTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/PermuteArgsTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/MethodTypeTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/BigArityTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/ClassValueTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/JavaDocExamplesTest.java
>> /w/jjg/work/tl/jdk/test/java/lang/invoke/AccessControlTest.java
>> /w/jjg/work/tl/jdk/test/sun/invoke/util/ValueConversionsTest.java
>>
>> -- Jon
>>
>> On 07/30/2013 02:43 PM, Nick Williams wrote:
>>> I'm getting this error on many tests in JDK:
>>>
>>> java.lang.Exception: No JUnit 4 driver (install junit.jar next to jtreg.jar)
>>> [stack trace]
>>>
>>> As you can see, junit.jar is installed next to jtreg.jar:
>>>
>>> nickwilliams:jtreg Nicholas$ echo $JT_HOME
>>> /usr/share/java/jtreg
>>> nickwilliams:jtreg Nicholas$ cd $JT_HOME
>>> nickwilliams:jtreg Nicholas$ ls -al
>>> total 64
>>> drwxr-xr-x 12 root wheel 408 Jul 30 12:29 .
>>> drwxr-xr-x 15 root wheel 510 Jul 30 12:29 ..
>>> -rw-r--r-- 1 root wheel 994 Jul 30 12:29 COPYRIGHT
>>> -rw-r--r-- 1 root wheel 19241 Jul 30 12:29 LICENSE
>>> -rw-r--r-- 1 root wheel 3790 Jul 30 12:29 README
>>> drwxr-xr-x 3 root wheel 102 Jul 30 12:29 doc
>>> drwxr-xr-x 4 root wheel 136 Jul 30 12:29 legal
>>> drwxr-xr-x 7 root wheel 238 Jul 30 12:29 lib
>>> drwxr-xr-x 3 root wheel 102 Jul 30 12:29 linux
>>> -rw-r--r-- 1 root wheel 73 Jul 30 12:29 release
>>> drwxr-xr-x 3 root wheel 102 Jul 30 12:29 solaris
>>> drwxr-xr-x 3 root wheel 102 Jul 30 12:29 win32
>>> nickwilliams:jtreg Nicholas$ ls -al lib
>>> total 13200
>>> drwxr-xr-x 7 root wheel 238 Jul 30 12:29 .
>>> drwxr-xr-x 12 root wheel 408 Jul 30 12:29 ..
>>> -rw-r-xr-x@ 1 root wheel 4613089 Jul 30 12:29 javatest.jar
>>> -rw-r--r--@ 1 root wheel 508396 Jul 30 12:29 jh.jar
>>> -r--r--r-- 1 root wheel 542604 Jul 30 12:29 jtreg.jar
>>> -rw-r--r--@ 1 root wheel 245039 Jul 30 12:29 junit.jar
>>> -rw-r--r--@ 1 root wheel 835600 Jul 30 12:29 testng.jar
>>>
>>> I even tried setting the CLASSPATH system variable, to no avail. Made no difference one way or the other.
>>>
>>> nickwilliams:test Nicholas$ echo $CLASSPATH
>>> /usr/share/java/jtreg/lib/javatest.jar:/usr/share/java/jtreg/lib/jh.jar:/usr/share/java/jtreg/lib/junit.jar:/usr/share/java/jtreg/lib/testng.jar
>>>
>>> I'm running JDK8 tests using Makefile.
>>>
>>> Thoughts?
>>>
>>> Nick
>>
>
More information about the jtreg-use
mailing list