db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1132861 - in /db/derby/code/branches/10.8: ./ java/testing/org/apache/derbyTesting/junit/BaseTestCase.java java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
Date Tue, 07 Jun 2011 04:47:21 GMT
Author: kristwaa
Date: Tue Jun  7 04:47:20 2011
New Revision: 1132861

URL: http://svn.apache.org/viewvc?rev=1132861&view=rev
Log:
DERBY-5262: Running JUnit tests with Java 1.4.2 fails if the package private tests are on
the classpath

Merged fix from trunk (r1132860).

Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  7 04:47:20 2011
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.7:1061570,1061578,1082235
-/db/derby/code/trunk:1063809,1088633,1091000,1091221,1091285,1092067,1092795,1094315,1094572,1094728,1096741,1096890,1097247,1097249,1097460,1097469,1097471,1101839,1102826,1103681,1103718,1125305,1126358,1127825,1127883,1129136,1129764,1129797,1130632,1130895,1131272,1132546,1132664
+/db/derby/code/trunk:1063809,1088633,1091000,1091221,1091285,1092067,1092795,1094315,1094572,1094728,1096741,1096890,1097247,1097249,1097460,1097469,1097471,1101839,1102826,1103681,1103718,1125305,1126358,1127825,1127883,1129136,1129764,1129797,1130632,1130895,1131272,1132546,1132664,1132860

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1132861&r1=1132860&r2=1132861&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
Tue Jun  7 04:47:20 2011
@@ -625,6 +625,36 @@ public abstract class BaseTestCase
     }
    
     /**
+     * Returns the major version of the class specification version supported
+     * by the running JVM.
+     * <ul>
+     *  <li>48 = Java 1.4</li>
+     *  <li>49 = Java 1.5</li>
+     *  <li>50 = Java 1.6</li>
+     *  <li>51 = Java 1.7</li>
+     * </ul>
+     *
+     * @return Major version of class version specification, i.e. 49 for 49.0,
+     *      or -1 if the version can't be obtained for some reason.
+     */
+    public static int getClassVersionMajor() {
+        String tmp = getSystemProperty("java.class.version");
+        if (tmp == null) {
+            println("VM doesn't have property java.class.version");
+            return -1;
+        }
+        // Is String.split safe to use by now?
+        int dot = tmp.indexOf('.');
+        int major = -1;
+        try {
+            major = Integer.parseInt(tmp.substring(0, dot));
+        } catch (NumberFormatException nfe) {
+            // Ignore, return -1.
+        }
+        return major;
+    }
+
+    /**
      * Check if we have old style (before Sun Java 1.7) Solaris interruptible
      * IO. On Sun Java 1.5 >= update 22 and Sun Java 1.6 this can be disabled
      * with Java option {@code -XX:-UseVMInterruptibleIO}. On Sun Java 1.7 it

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java?rev=1132861&r1=1132860&r2=1132861&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
Tue Jun  7 04:47:20 2011
@@ -291,8 +291,12 @@ public final class SecurityManagerSetup 
             classPathSet.setProperty("derbyTesting.jaxpjar", jaxp);
 
 		URL testing = getURL(SecurityManagerSetup.class);
-        URL ppTesting = getURL("org.apache.derby.PackagePrivateTestSuite");
-		
+        URL ppTesting = null;
+        // Only try to load PackagePrivateTestSuite if the running JVM is
+        // Java 1.5 or newer (class version 49 = Java 1.5).
+        if (BaseTestCase.getClassVersionMajor() >= 49) {
+            ppTesting = getURL("org.apache.derby.PackagePrivateTestSuite");
+        }
 		boolean isClasspath = testing.toExternalForm().endsWith("/");
 		if (isClasspath) {
 			classPathSet.setProperty("derbyTesting.codeclasses",



Mime
View raw message