db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1492116 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/services/info/JVMInfo.java testing/org/apache/derbyTesting/functionTests/util/TestUtil.java testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
Date Wed, 12 Jun 2013 08:37:57 GMT
Author: kahatlen
Date: Wed Jun 12 08:37:57 2013
New Revision: 1492116

URL: http://svn.apache.org/r1492116
Log:
DERBY-6213: Deprecate support for Java 5 and CDC

Remove constants for no longer supported Java versions in JVMInfo.

Remove checks for Java version where same action would be taken
for all supported Java versions.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java?rev=1492116&r1=1492115&r2=1492116&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java Wed Jun
12 08:37:57 2013
@@ -44,9 +44,9 @@ public abstract class JVMInfo
 		<UL>
 		<LI> 1 - not used was JDK 1.1
 		<LI> 2 - not used, was for JDK 1.2 and 1.3
-		<LI> 4 - J2SE_14 - JDK 1.4.0 or 1.4.1
-		<LI> 5 - J2SE_142 - JDK 1.4.2
-		<LI> 6 - J2SE_15 - JDK 1.5
+        <LI> 4 - not used, was for JDK 1.4.0 or 1.4.1
+        <LI> 5 - not used, was for JDK 1.4.2
+        <LI> 6 - not used, was for JDK 1.5
 		<LI> 7 - J2SE_16 - JDK 1.6
         <LI> 8 - J2SE_17 - JDK 1.7
         <LI> 9 - J2SE_18 - JDK 1.8
@@ -54,9 +54,6 @@ public abstract class JVMInfo
 	*/
 	public static final int JDK_ID;
 
-	public static final int J2SE_14 = 4;
-	public static final int J2SE_142 = 5;
-	public static final int J2SE_15 = 6; // aka J2SE 5.0
 	public static final int J2SE_16 = 7; // Java SE 6, not J2SE
     public static final int J2SE_17 = 8; // Java SE 7
     public static final int J2SE_18 = 9;
@@ -74,33 +71,21 @@ public abstract class JVMInfo
 		// 
 		// Otherwise, see if we recognize what is set in java.version.
 		// If we don't recognize that, or if the property is not set, assume
-		// version 1.4.
+        // version 1.6, which is the lowest level we support.
 		//
 		String javaVersion;
 
 		try {
-			javaVersion = System.getProperty("java.specification.version", "1.4");
+            javaVersion =
+                System.getProperty("java.specification.version", "1.6");
 
 		} catch (SecurityException se) {
 			// some vms do not know about this property so they
 			// throw a security exception when access is restricted.
-			javaVersion = "1.4";
+            javaVersion = "1.6";
 		}
 
-        if (javaVersion.equals("1.4"))
-        {
-            String vmVersion = System.getProperty("java.version", "1.4.0");
-
-            if (JVMInfo.vmCheck(vmVersion, "1.4.0") || JVMInfo.vmCheck(vmVersion, "1.4.1"))
-                id = J2SE_14;
-            else
-                id = J2SE_142;
-        }
-        else if (javaVersion.equals("1.5"))
-        {
-            id = J2SE_15;
-        }
-        else if (javaVersion.equals("1.6"))
+        if (javaVersion.equals("1.6"))
         {
             id = J2SE_16;
         }
@@ -113,9 +98,9 @@ public abstract class JVMInfo
         }
         else
         {
-            // aussme our lowest support unless the java spec
+            // Assume our lowest support unless the java spec
             // is greater than our highest level.
-            id = J2SE_14;
+            id = J2SE_16;
 
             try {
 
@@ -129,24 +114,12 @@ public abstract class JVMInfo
 	}
 
 	/**
-		Check the vmVersion against a speciifc value.
-		Sun jvms are of the form
-	*/
-	private static boolean vmCheck(String vmVersion, String id)
-	{
-		return vmVersion.equals(id) || vmVersion.startsWith(id + "_");
-	}
-
-	/**
 		Return Derby's understanding of the virtual machine's environment.
 	*/
 	public static String derbyVMLevel()
 	{
 		switch (JDK_ID)
 		{
-		case J2SE_14: return "J2SE 1.4 - JDBC 3.0";
-		case J2SE_142: return "J2SE 1.4.2 - JDBC 3.0";
-		case J2SE_15: return "J2SE 5.0 - JDBC 3.0";
         case J2SE_16: return "Java SE 6 - JDBC 4.1";
         case J2SE_17: return "Java SE 7 - JDBC 4.1";
         case J2SE_18: return "Java SE 8 - JDBC 4.1";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java?rev=1492116&r1=1492115&r2=1492116&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
Wed Jun 12 08:37:57 2013
@@ -35,9 +35,10 @@ import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.security.PrivilegedActionException;
+import javax.sql.ConnectionPoolDataSource;
 import javax.sql.DataSource;
+import javax.sql.XADataSource;
 
-import org.apache.derby.iapi.services.info.JVMInfo;
 import org.apache.derbyTesting.functionTests.harness.JavaVersionHolder;
 import org.apache.derbyTesting.functionTests.harness.RunTest;
 
@@ -105,7 +106,6 @@ public class TestUtil {
 	private static String XA_DATASOURCE_STRING = "XA";
 	private static String CONNECTION_POOL_DATASOURCE_STRING = "ConnectionPool";
 	private static String REGULAR_DATASOURCE_STRING = "";
-	private static String JSR169_DATASOURCE_STRING = "Simple";
 	
 	// Methods for making framework dependent decisions in tests.
 
@@ -312,26 +312,13 @@ public class TestUtil {
 	 *                will mean ds.setDatabaseName("wombat") will be called
 	 *  @return datasource for current framework
 	 */
-	public static javax.sql.DataSource getDataSource(Properties attrs)
+    public static DataSource getDataSource(Properties attrs)
 	{
-		String classname;
-		if(HAVE_DRIVER_CLASS)
-		{
-			classname = getDataSourcePrefix() + REGULAR_DATASOURCE_STRING + "DataSource";
-			classname = checkForJDBC40Implementation(classname);
-			return (javax.sql.DataSource) getDataSourceWithReflection(classname, attrs);
-		}
-		else
-			return getSimpleDataSource(attrs);
-		
+        String classname =
+            getDataSourcePrefix() + REGULAR_DATASOURCE_STRING + "DataSource40";
+        return (DataSource) getDataSourceWithReflection(classname, attrs);
 	}
 
-	public static DataSource getSimpleDataSource(Properties attrs)
-	{
-		String classname = getDataSourcePrefix() + JSR169_DATASOURCE_STRING + "DataSource";
-		return (javax.sql.DataSource) getDataSourceWithReflection(classname, attrs);
-	}
-	
 	/**
 	 * Get an xa  data source for the appropriate framework
 	 * @param attrs  A set of attribute values to set on the datasource.
@@ -340,12 +327,11 @@ public class TestUtil {
 	 *                will mean ds.setDatabaseName("wombat") will be called
 	 *  @return datasource for current framework
 	 */
-	public static javax.sql.XADataSource getXADataSource(Properties attrs)
+    public static XADataSource getXADataSource(Properties attrs)
 	{
-		
-		String classname = getDataSourcePrefix() + XA_DATASOURCE_STRING + "DataSource";
-		classname = checkForJDBC40Implementation(classname);
-		return (javax.sql.XADataSource) getDataSourceWithReflection(classname, attrs);
+        String classname =
+            getDataSourcePrefix() + XA_DATASOURCE_STRING + "DataSource40";
+        return (XADataSource) getDataSourceWithReflection(classname, attrs);
 	}
 
 	
@@ -357,35 +343,14 @@ public class TestUtil {
 	 *                will mean ds.setDatabaseName("wombat") will be called
 	 *  @return datasource for current framework
 	 */
-	public static javax.sql.ConnectionPoolDataSource getConnectionPoolDataSource(Properties
attrs)
+    public static ConnectionPoolDataSource
+            getConnectionPoolDataSource(Properties attrs)
 	{
-		String classname = getDataSourcePrefix() + CONNECTION_POOL_DATASOURCE_STRING + "DataSource";
-                classname = checkForJDBC40Implementation(classname);
-		return (javax.sql.ConnectionPoolDataSource) getDataSourceWithReflection(classname, attrs);
-	}
-        
-        /**
-         * returns the class name for the JDBC40 implementation
-         * if present. otherwise returns the class name of the class
-         * written for the lower jdk versions
-         * @param classname String
-         * @return String containing the name of the appropriate 
-         *         implementation
-         */
-        public static String checkForJDBC40Implementation(String classname) {
-                String classname_ = classname;
-                // The JDBC 4.0 implementation of the  
-                // interface is suffixed with "40". Use it if it is available 
-                // and the JVM version is at least 1.6.
-                if (JVMInfo.JDK_ID >= JVMInfo.J2SE_16) {
-                        String classname40 = classname_ + "40";
-                        try {
-                                Class.forName(classname40);
-                                classname_ = classname40;
-                        } catch (ClassNotFoundException e) {}
-                }
-                return classname_;
-        }
+        String classname = getDataSourcePrefix() +
+                CONNECTION_POOL_DATASOURCE_STRING + "DataSource40";
+        return (ConnectionPoolDataSource)
+                getDataSourceWithReflection(classname, attrs);
+	}
 
 	public static String getDataSourcePrefix()
 		{

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java?rev=1492116&r1=1492115&r2=1492116&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
Wed Jun 12 08:37:57 2013
@@ -23,7 +23,6 @@ package org.apache.derbyTesting.unitTest
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.derby.iapi.services.info.JVMInfo;
 import org.apache.derby.shared.common.sanity.AssertFailure;
 import org.apache.derbyTesting.junit.BaseTestCase;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
@@ -76,7 +75,7 @@ public class AssertFailureTest extends B
 
     /**
      * Test that AssertFailure's message string is correct when we have
-     * permisssion to do thread dumps. Must be run with correct permissions, ie.
+     * permission to do thread dumps. Must be run with correct permissions, ie.
      * with java.lang.RuntimePermission "getStackTrace" and
      * java.lang.RuntimePermission "modifyThreadGroup".
      */
@@ -87,25 +86,17 @@ public class AssertFailureTest extends B
 
         // Assert that the string is correct, by checking that
         // it starts the right way.
-        if (JVMInfo.JDK_ID >= JVMInfo.J2SE_15) {
-            String expected = "---------------\n" +
+        String expected = "---------------\n" +
             		"Stack traces for all live threads:\nThread name=";
 
-            assertTrue("String not correct. Expected to start with:\n<"
+        assertTrue("String not correct. Expected to start with:\n<"
                 + expected + ">...\nWas:\n<" + s + ">.\n" ,
                 s.startsWith(expected));
-
-        } else {
-            String expected = "(Skipping thread dump because it is not " +
-            		"supported on JVM 1.4)";
-
-            assertEquals("String not correct.", expected, s.trim());
-        }
     }
 
     /**
      * Test that AssertFailure's log entry is correct when we DON'T have
-     * permisssion to to thread dumps. Must be run with correct permissions, ie.
+     * permission to to thread dumps. Must be run with correct permissions, ie.
      * WITHOUT java.lang.RuntimePermission "getStackTrace" and
      * java.lang.RuntimePermission "modifyThreadGroup";
      */
@@ -116,18 +107,10 @@ public class AssertFailureTest extends B
 
         // Assert that the string is correct, by checking that is starts
         // the right way.
-        if (JVMInfo.JDK_ID >= JVMInfo.J2SE_15) {
-            String expected = "(Skipping thread dump because of insufficient " +
+        String expected = "(Skipping thread dump because of insufficient " +
             		"permissions:\njava.security.AccessControlException:";
 
-            assertTrue("String not correct. Expected: <" + expected +
+        assertTrue("String not correct. Expected: <" + expected +
                 ">\nWas:\n<" + s + ">", s.startsWith(expected));
-
-        } else {
-            String expected = "(Skipping thread dump because it is not " +
-                "supported on JVM 1.4)";
-
-            assertEquals("String not correct.", expected, s.trim());
-        }
     }
 }



Mime
View raw message