commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r349007 - /jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java
Date Fri, 25 Nov 2005 19:52:13 GMT
Author: niallp
Date: Fri Nov 25 11:52:05 2005
New Revision: 349007

URL: http://svn.apache.org/viewcvs?rev=349007&view=rev
Log:
Exclude JDBC test if JDK < 1.4 (HSQLDB 1.7.2 uses classes introduced in JDK 1.4)

I upgraded the HSQLDB version from 1.7.1 to 1.7.2 because of the change I made to JDBCResources
to close the Connection properly (HSQLDB < 1.7.2 shuts down the database when all connections
are closed) caused the JDBCResources test case to fail! However now the tests fail under JDK
1.3, so I've added a test to not run if pre JDK 1.4.

Modified:
    jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java

Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java?rev=349007&r1=349006&r2=349007&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java
(original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java
Fri Nov 25 11:52:05 2005
@@ -30,6 +30,7 @@
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.StringTokenizer;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -78,6 +79,11 @@
 
     // Set up instance variables required by this test case
     public void setUp() throws Exception {
+        if (isPre14JVM()) {
+            System.out.println("WARNING: CANNOT TEST with HSQLDB 1.7.2 ON PRE1.4 JVM");
+            return;
+        }
+
         factory = new JDBCResourcesFactory();
         resources = factory.getResources(NAME, getBase());
 		
@@ -118,6 +124,9 @@
     public void tearDown() {
         resources = null;
         factory = null;
+        if (isPre14JVM()) {
+            return;
+        }
         try{
         	runSql(new String[]{"drop table resources"});
 			con.close();
@@ -127,6 +136,41 @@
         }
 
     }
+    public void testInherit() throws Exception {
+        if (!isPre14JVM()) {
+            super.testInherit();
+        }
+    }
+    public void testLocaleList() {
+        if (!isPre14JVM()) {
+            super.testLocaleList();
+        }
+    }
+    public void testMissing() throws Exception {
+        if (!isPre14JVM()) {
+            super.testMissing();
+        }
+    }
+    public void testSpecific() throws Exception {
+        if (!isPre14JVM()) {
+            super.testSpecific();
+        }
+    }
+    public void testKeys() throws Exception {
+        if (!isPre14JVM()) {
+            super.testKeys();
+        }
+    }
+    public void testPristine() {
+        if (!isPre14JVM()) {
+            super.testPristine();
+        }
+    }
+    public void testRelease() throws Exception {
+        if (!isPre14JVM()) {
+            super.testRelease();
+        }
+    }
 
 
     // ------------------------------------------------ Individual Test Methods
@@ -167,5 +211,20 @@
 		} catch(SQLException ex) {
 			fail("SQLException: " + ex.getMessage());
 		}	
+    }
+
+    private boolean isPre14JVM() {
+        // some pre 1.4 JVM have buggy WeakHashMap implementations 
+        // this is used to test for those JVM
+        String version = System.getProperty("java.specification.version");
+        StringTokenizer tokenizer = new StringTokenizer(version,".");
+        if (tokenizer.nextToken().equals("1")) {
+            String minorVersion = tokenizer.nextToken();
+            if (minorVersion.equals("0")) return true;
+            if (minorVersion.equals("1")) return true;
+            if (minorVersion.equals("2")) return true;
+            if (minorVersion.equals("3")) return true;
+        }
+        return false;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message