Re: What version of JUnit, again?

From: David Ventimiglia <dventimi(at)gmail(dot)com>
To: Sehrope Sarkuni <sehrope(at)jackdb(dot)com>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: What version of JUnit, again?
Date: 2014-08-04 01:00:42
Message-ID: CALaE=t_rNQeAVmsF_bzEMgqiyo=xn3vyttcBZD1sb96syV-JXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Spoke too soon. That produced a different error with your test (see
below).

Testsuite: org.postgresql.test.ssl.SingleCertValidatingFactoryTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec

Null Test: Caused an ERROR
junit/framework/JUnit4TestAdapterCache
java.lang.NoClassDefFoundError: junit/framework/JUnit4TestAdapterCache
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

On Sun, Aug 3, 2014 at 5:55 PM, David Ventimiglia <dventimi(at)gmail(dot)com>
wrote:

> Indeed. The JUnit4 jar seems to include the old-style JUnit packages.
> Since I also have JUnit4 in my Maven repository, then in the build.xml file
> for the pgjdbc project, I changed it to use JUnit version="4.0" instead of
> version="3.8.2" and it worked fine (see patch below).
>
> diff --git a/build.xml b/build.xml
> index 9ce437d..956fb9c 100644
> --- a/build.xml
> +++ b/build.xml
> @@ -108,7 +108,7 @@
> </patternset>
>
>
> <artifact:dependencies pathId="dependency.classpath" useScope="test">
> - <dependency groupId="junit" artifactId="junit" version="3.8.2"
> scope="test"/>
> + <dependency groupId="junit" artifactId="junit" version="4.0"
> scope="test"/>
> </artifact:dependencies>
>
> <target name="check_versions">
>
>
>
> On Sun, Aug 3, 2014 at 5:46 PM, Sehrope Sarkuni <sehrope(at)jackdb(dot)com>
> wrote:
>
>> The original unit tests use only junit 3.8.
>>
>> I wrote the newer SSL tests for the SingleCertValidatingFactory to use
>> the newer version of junit (and using annotations etc) as the expectation
>> was that it's only included in a JDBC 4/JDK5+ environment.
>>
>> I'll see if I can dig up my local config for running it when I get to my
>> computer but I think I just used used the Ubuntu packages for junit 4 and
>> manually add them to the CLASSPATH env variable.
>>
>> You should be able to run the original tests with just the newer junit on
>> the CLASSPATH.
>>
>> You might also want to take a peek at:
>> https://github.com/jackdb/pgjdbc-test-vm
>>
>> It's what I originally used to test the SSL factory patches. It sets up a
>> bunch of PG servers in a VM with know SSL configurations and users for
>> testing. It can also be used for testing the rest of the driver.
>>
>> Regards,
>> Sehrope Sarkuni
>> Founder & CEO | JackDB, Inc. | http://www.jackdb.com/
>>
>> On Aug 3, 2014, at 8:32 PM, David Ventimiglia <dventimi(at)gmail(dot)com> wrote:
>>
>> I have no CLASSPATH environment variable. As for the classpath that is
>> used by Ant, it's my assumption that's handled by Ant and/or Maven. What I
>> can tell you are these things.
>>
>> - I'm on Ubuntu Linux, a Debian-based distro, where typically I
>> install things using the package manager rather than by direct download.
>> - Therefore, I've both JUnit (3.8.2) and JUnit4 (4.0.0) "installed"
>> courtesy of the apt-get package manager. But they're not on any CLASSPATH
>> and Ant and Maven were unaware of them.
>> - Within the pgjdbc project, I ran `ant' as instructed. That failed,
>> because the build.xml file has a dependency on JUnit 3.8.2.
>> - Helpfully, the Ant build error included instructions for how to
>> satisfy the JUnit dependency (see below). I found the JUnit 3.8.2 JAR file
>> that apt-get had installed on my system and fed that path into the Maven
>> command.
>> - Ran `ant' again. This time, because the JUnit dependency had been
>> satisfied, it successfully built the JDBC driver. But because it didn't
>> run any tests, it didn't trigger any run-time error.
>> - Ran `ant test' and got the errors that I sent you.
>> - Noticed that the SingleCertValidatingFactoryTest class (if nothing
>> else) imports from org.junit, which I understood to be a JUnit4 package
>> (but maybe I'm wrong).
>> - I became confused.
>>
>> The Maven command to install the JUnit jar was:
>>
>> mvn install:install-file -DgroupId=junit -DartifactId=junit
>> -Dversion=3.8.2 -Dpackaging=jar -Dfile=/usr/share/java/junit-3.8.2.jar
>>
>> I assure you that the jar file is a bona fide JUnit 3.8.2 jar file.
>>
>>
>> On Sun, Aug 3, 2014 at 5:19 PM, Dave Cramer <pg(at)fastcrypt(dot)com> wrote:
>>
>>> Is junit on the classpath ?
>>>
>>>
>>>
>>> Dave Cramer
>>>
>>> dave.cramer(at)credativ(dot)ca
>>> http://www.credativ.ca
>>>
>>>
>>> On 3 August 2014 20:15, David Ventimiglia <dventimi(at)gmail(dot)com> wrote:
>>>
>>>> You bet. They're in the attached errors.txt file and also pasted in
>>>> below.
>>>>
>>>> Buildfile: /home/dventimi/work/pgjdbc/build.xml
>>>>
>>>> prepare:
>>>>
>>>> check_versions:
>>>>
>>>> check_driver:
>>>>
>>>> driver:
>>>>
>>>> compile:
>>>> [javac] /home/dventimi/work/pgjdbc/build.xml:243: warning:
>>>> 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set
>>>> to false for repeatable builds
>>>>
>>>> artifact-version:
>>>> [echo] Artifact version string: postgresql-9.4-1200.jdbc41
>>>>
>>>> jar:
>>>>
>>>> testjar:
>>>> [mkdir] Created dir: /home/dventimi/work/pgjdbc/build/tests
>>>> [javac] /home/dventimi/work/pgjdbc/build.xml:451: warning:
>>>> 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set
>>>> to false for repeatable builds
>>>> [javac] Compiling 84 source files to
>>>> /home/dventimi/work/pgjdbc/build/tests
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:3:
>>>> error: package org.junit does not exist
>>>> [javac] import org.junit.Assert;
>>>> [javac] ^
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:4:
>>>> error: package org.junit does not exist
>>>> [javac] import org.junit.Test;
>>>> [javac] ^
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:5:
>>>> error: package org.junit does not exist
>>>> [javac] import org.junit.Before;
>>>> [javac] ^
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:6:
>>>> error: package org.junit does not exist
>>>> [javac] import org.junit.BeforeClass;
>>>> [javac] ^
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:7:
>>>> error: package org.junit.runners does not exist
>>>> [javac] import org.junit.runners.Parameterized;
>>>> [javac] ^
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:8:
>>>> error: package org.junit.runners.Parameterized does not exist
>>>> [javac] import org.junit.runners.Parameterized.Parameters;
>>>> [javac] ^
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:9:
>>>> error: package org.junit.runner does not exist
>>>> [javac] import org.junit.runner.RunWith;
>>>> [javac] ^
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:23:
>>>> error: cannot find symbol
>>>> [javac] @RunWith(Parameterized.class)
>>>> [javac] ^
>>>> [javac] symbol: class RunWith
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:42:
>>>> error: cannot find symbol
>>>> [javac] @Parameters
>>>> [javac] ^
>>>> [javac] symbol: class Parameters
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:181:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:203:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:213:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:223:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:240:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:257:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:274:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:307:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:327:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:351:
>>>> error: cannot find symbol
>>>> [javac] @Test
>>>> [javac] ^
>>>> [javac] symbol: class Test
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:141:
>>>> error: cannot find symbol
>>>> [javac] Assert.assertEquals(1, rs.getInt(1));
>>>> [javac] ^
>>>> [javac] symbol: variable Assert
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:147:
>>>> error: cannot find symbol
>>>> [javac] Assert.assertEquals(sslExpected, sslActual);
>>>> [javac] ^
>>>> [javac] symbol: variable Assert
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac]
>>>> /home/dventimi/work/pgjdbc/org/postgresql/test/ssl/SingleCertValidatingFactoryTest.java:172:
>>>> error: cannot find symbol
>>>> [javac] Assert.fail("Expected exception " +
>>>> expectedThrowable.getName() + " but it did not occur.");
>>>> [javac] ^
>>>> [javac] symbol: variable Assert
>>>> [javac] location: class SingleCertValidatingFactoryTest
>>>> [javac] Note: Some input files use or override a deprecated API.
>>>> [javac] Note: Recompile with -Xlint:deprecation for details.
>>>> [javac] Note: Some input files use unchecked or unsafe operations.
>>>> [javac] Note: Recompile with -Xlint:unchecked for details.
>>>> [javac] 22 errors
>>>>
>>>> BUILD FAILED
>>>> /home/dventimi/work/pgjdbc/build.xml:451: Compile failed; see the
>>>> compiler error output for details.
>>>>
>>>> Total time: 12 seconds
>>>>
>>>>
>>>>
>>>> On Sun, Aug 3, 2014 at 5:07 PM, Dave Cramer <pg(at)fastcrypt(dot)com> wrote:
>>>>
>>>>> Pretty sure I use 3.8.2
>>>>>
>>>>> Can you provide me with the errors you are getting ?
>>>>>
>>>>> Dave Cramer
>>>>>
>>>>> dave.cramer(at)credativ(dot)ca
>>>>> http://www.credativ.ca
>>>>>
>>>>>
>>>>> On 3 August 2014 16:53, David Ventimiglia <dventimi(at)gmail(dot)com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I'm a little confused as to what version of JUnit I'm supposed to be
>>>>>> using in order to build/test the Postgresql JDBC driver. This page says
>>>>>> that "JUnit at least 3.7 is needed."
>>>>>>
>>>>>> http://jdbc.postgresql.org/development/development.html
>>>>>>
>>>>>> But, there's a big between JUnit 3.8 and earlier and JUnit 4. The
>>>>>> former has components in packages junit.framework while the latter has
>>>>>> components in org.junit and so test that directly import on or the other of
>>>>>> those packages are sensitive to the version of JUnit you're using.
>>>>>>
>>>>>> An example of such a test is SingleCertValidatingFactoryTest.java in
>>>>>> pgjdbc/org/postgresql/test/ssl directory (presumably other tests are like
>>>>>> this).
>>>>>>
>>>>>> On the other hand, the pgjdbc Ant build.xml file specifies JUnit
>>>>>> 3.8.2.:
>>>>>>
>>>>>> <artifact:dependencies pathId="dependency.classpath"
>>>>>> useScope="test">
>>>>>> <dependency groupId="junit" artifactId="junit" version="3.8.2"
>>>>>> scope="test"/>
>>>>>> </artifact:dependencies>
>>>>>>
>>>>>> Presumably, this is why running `ant test' in pgjdbc fails for me
>>>>>> with compilation errors. I confess, I'm not an expert with Ant and Maven,
>>>>>> so maybe I've done something wrong. But, exactly waht version of JUnit
>>>>>> should I be using? Thanks!
>>>>>>
>>>>>> Best,
>>>>>> David Ventimiglia
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Sehrope Sarkuni 2014-08-04 01:32:36 Re: What version of JUnit, again?
Previous Message David Ventimiglia 2014-08-04 00:55:04 Re: What version of JUnit, again?