Re: What version of JUnit, again? - Mailing list pgsql-jdbc
From | David Ventimiglia |
---|---|
Subject | Re: What version of JUnit, again? |
Date | |
Msg-id | CALaE=t8GsvScUB2J1M7LJJqaEK9e+O_o2=vXxVciLeZqc9-DxQ@mail.gmail.com Whole thread Raw |
In response to | Re: What version of JUnit, again? (Sehrope Sarkuni <sehrope@jackdb.com>) |
Responses |
Re: What version of JUnit, again?
|
List | pgsql-jdbc |
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">
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@jackdb.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-vmIt'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/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@fastcrypt.com> wrote:Is junit on the classpath ?On 3 August 2014 20:15, David Ventimiglia <dventimi@gmail.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 secondsOn Sun, Aug 3, 2014 at 5:07 PM, Dave Cramer <pg@fastcrypt.com> wrote:Pretty sure I use 3.8.2Can you provide me with the errors you are getting ?On 3 August 2014 16:53, David Ventimiglia <dventimi@gmail.com> wrote: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!On the other hand, the pgjdbc Ant build.xml file specifies JUnit 3.8.2.:An example of such a test is SingleCertValidatingFactoryTest.java in pgjdbc/org/postgresql/test/ssl directory (presumably other tests are like this).Hi,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.
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
<artifact:dependencies pathId="dependency.classpath" useScope="test">
<dependency groupId="junit" artifactId="junit" version="3.8.2" scope="test"/>
</artifact:dependencies>
Best,
David Ventimiglia
pgsql-jdbc by date: