db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1199234 - in /db/derby/code/trunk: ./ java/testing/org/apache/derbyTesting/functionTests/tests/lang/ java/testing/org/apache/derbyTesting/junit/
Date Tue, 08 Nov 2011 13:24:44 GMT
Author: rhillegas
Date: Tue Nov  8 13:24:43 2011
New Revision: 1199234

URL: http://svn.apache.org/viewvc?rev=1199234&view=rev
Log:
DERBY-5496: Compile the JUnit infrastructure package against the small device classpath, rather
than the jdk 1.4 classpath.

Modified:
    db/derby/code/trunk/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UnaryArithmeticParameterTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/J2EEDataSource.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JAXPFinder.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/RuntimeStatisticsParser.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Tue Nov  8 13:24:43 2011
@@ -345,6 +345,7 @@
 
     <echo message="${checkEvent} compilerPropsAlreadySet = ${compilerPropsAlreadySet}"/>
     <echo message="${checkEvent} compilerLevel16 = ${compilerLevel16}"/>
+    <echo message="${checkEvent} compile.classpath = ${compile.classpath}"/>
     <echo message="${checkEvent} jsr169compile.classpath = ${jsr169compile.classpath}"/>
     <echo message="${checkEvent} j14lib = ${j14lib}"/>
     <echo message="${checkEvent} java14compile.classpath = ${java14compile.classpath}"/>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UnaryArithmeticParameterTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UnaryArithmeticParameterTest.java?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UnaryArithmeticParameterTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UnaryArithmeticParameterTest.java
Tue Nov  8 13:24:43 2011
@@ -1,6 +1,6 @@
 /*
 
-Derby - Class org.apache.derbyTesting.functionTests.tests.lang.unaryArithmeticParameterTest
+Derby - Class org.apache.derbyTesting.functionTests.tests.lang.UnaryArithmeticParameterTest
 
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
@@ -81,9 +81,9 @@ public class UnaryArithmeticParameterTes
 	}
 	/**
 	 * Test using parameters with unary minus and unary plus
-	 * @throws SQLException
+	 * @throws Exception
 	 */
-		public void testParametersForUnaryMinusAndPlus() throws SQLException {
+		public void testParametersForUnaryMinusAndPlus() throws Exception {
 			PreparedStatement ps = prepareStatement("insert into t1 values(?,+?,-?,?)");
 			ps.setInt(1,3);
 			ps.setInt(2,3);
@@ -126,9 +126,9 @@ public class UnaryArithmeticParameterTes
 			}
 		/**
 		 * Tests ABS function with Unary plus and Unary minus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testABSWithUnaryMinusAndPlus() throws SQLException {
+		public void testABSWithUnaryMinusAndPlus() throws Exception {
 			Statement s = createStatement();
 			s.execute("CREATE FUNCTION ABS_FUNCT(P1 INT) RETURNS INT CALLED ON NULL INPUT EXTERNAL
NAME 'java.lang.Math.abs' LANGUAGE JAVA PARAMETER STYLE JAVA");
 			PreparedStatement ps = prepareStatement("select * from t1 where -? = abs_funct(+?)");
@@ -145,9 +145,9 @@ public class UnaryArithmeticParameterTes
 		}	
 		/**
 		 * Tests MAX function with Unary plus and Unary minus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testMAXWithUnaryMinusAndPlus() throws SQLException{
+		public void testMAXWithUnaryMinusAndPlus() throws Exception{
 			Statement s = createStatement();
 			s.execute("CREATE FUNCTION MAX_CNI(P1 INT, P2 INT) RETURNS INT CALLED ON NULL INPUT EXTERNAL
NAME 'java.lang.Math.max' LANGUAGE JAVA PARAMETER STYLE JAVA");
 			PreparedStatement ps = prepareStatement("select * from t1 where -? = max_cni(-5,-1)");
@@ -180,9 +180,9 @@ public class UnaryArithmeticParameterTes
 			}
 		/**
 		 * Tests BETWEEN with unary minus and unary plus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testBETWEENWithUnaryMinusAndPlus() throws SQLException{
+		public void testBETWEENWithUnaryMinusAndPlus() throws Exception{
 			PreparedStatement ps = prepareStatement("select * from t1 where c11 between -? and +?");
 			ps.setInt(1,-1);
 			ps.setInt(2,1);
@@ -194,9 +194,9 @@ public class UnaryArithmeticParameterTes
 		}
 		/**
 		 * Tests NOT IN with unary minus and unary plus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testNOTINWithUnaryMinusAndPlus() throws SQLException{
+		public void testNOTINWithUnaryMinusAndPlus() throws Exception{
 			PreparedStatement ps = prepareStatement("select * from t1 where +? not in (-?, +?, 2,
?)");
 			ps.setInt(1,-11);
 			ps.setInt(2,1);
@@ -218,9 +218,9 @@ public class UnaryArithmeticParameterTes
 		}
 		/**
 		 * Tests operators with Unary plus and unary Minus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testOperatorsWithUnaryMinusAndPlus() throws SQLException{
+		public void testOperatorsWithUnaryMinusAndPlus() throws Exception{
 			PreparedStatement ps = prepareStatement("select * from t1 where +? < c12");
 			ps.setInt(1,0);
 			int[] expectedTypes=new int[]{Types.SMALLINT};
@@ -251,9 +251,9 @@ public class UnaryArithmeticParameterTes
 		}
 		/**
 		 * Tests Casting with unary plus and unary minus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testCastWithUnaryMinusAndPlus()throws SQLException{
+		public void testCastWithUnaryMinusAndPlus()throws Exception{
 			PreparedStatement ps = prepareStatement("select cast(-? as smallint), cast(+? as int)
from t1");
 			ps.setInt(1,2);
 			ps.setInt(2,2);
@@ -265,9 +265,9 @@ public class UnaryArithmeticParameterTes
 		}
 		/**
 		 * Tests NullIf with unary minus and unary plus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testNullIfWithUnaryMinusAndPlus() throws SQLException{
+		public void testNullIfWithUnaryMinusAndPlus() throws Exception{
 			PreparedStatement ps = prepareStatement("select nullif(-?,c11) from t1");
 			ps.setInt(1,22);
 			int[] expectedTypes= new int[]{Types.INTEGER};
@@ -278,9 +278,9 @@ public class UnaryArithmeticParameterTes
 		}
 		/**
 		 * Tests SQRT with unary minus and unary plus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testSQRTWithUnaryMinusAndPlus() throws SQLException{
+		public void testSQRTWithUnaryMinusAndPlus() throws Exception{
 			PreparedStatement ps = prepareStatement("select sqrt(-?) from t1");
 			ps.setInt(1,-64);
 			int[] expectedTypes= new int[]{Types.DOUBLE};
@@ -291,9 +291,9 @@ public class UnaryArithmeticParameterTes
 		}
 		/**
 		 * Tests "select case when -?=c11 then -? else c12 end from t1"
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testSelectWithUnaryMinusAndPlus() throws SQLException{
+		public void testSelectWithUnaryMinusAndPlus() throws Exception{
 			PreparedStatement ps =prepareStatement("select case when -?=c11 then -? else c12 end from
t1");
 			ps.setInt(1,1);
 			ps.setInt(2,22);
@@ -305,9 +305,9 @@ public class UnaryArithmeticParameterTes
 		}
 		/**
 		 * Negative tests for unary minus and unary plus
-		 * @throws SQLException
+		 * @throws Exception
 		 */
-		public void testExpectedErrors() throws SQLException{
+		public void testExpectedErrors() throws Exception{
 			assertCompileError("42X34","select * from t1 where c11 = any (select -? from t2)");
 			
 			// -?/+? at the beginning and/ at the end of where clause

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/J2EEDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/J2EEDataSource.java?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/J2EEDataSource.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/J2EEDataSource.java Tue
Nov  8 13:24:43 2011
@@ -1,6 +1,6 @@
 /*
  *
- * Derby - Class org.apache.derbyTesting.junit.JDBCDataSource
+ * Derby - Class org.apache.derbyTesting.junit.J2EEDataSource
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JAXPFinder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JAXPFinder.java?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JAXPFinder.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JAXPFinder.java Tue Nov
 8 13:24:43 2011
@@ -1,6 +1,6 @@
 /*
  *
- * Derby - Class org.apache.derbyTesting.functionTests.util.JAXPFinder
+ * Derby - Class org.apache.derbyTesting.junit.JAXPFinder
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java Tue Nov  8 13:24:43
2011
@@ -20,6 +20,7 @@
 package org.apache.derbyTesting.junit;
 
 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.sql.*;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -44,34 +45,25 @@ public class JDBC {
      */
     public static class GeneratedId {
         public boolean equals(Object o) {
-            // unless JSR169, use String.matches...
-            if (JDBC.vmSupportsJDBC3()) 
+            String tmpstr = (String)o;
+            boolean b = true;
+            if (!(o instanceof String))
+                b = false;
+            if (!(tmpstr.startsWith("SQL")))
+                b = false;
+            if (tmpstr.length() != 18)
+                b = false;
+            for (int i=3 ; i<18 ; i++)
             {
-                return o instanceof String &&
-                ((String) o).matches("SQL[0-9]{15}");
-            }
-            else
-            {
-                String tmpstr = (String)o;
-                boolean b = true;
-                if (!(o instanceof String))
-                    b = false;
-                if (!(tmpstr.startsWith("SQL")))
-                    b = false;
-                if (tmpstr.length() != 18)
-                    b = false;
-                for (int i=3 ; i<18 ; i++)
+                if (Character.isDigit(tmpstr.charAt(i)))
+                    continue;
+                else
                 {
-                    if (Character.isDigit(tmpstr.charAt(i)))
-                        continue;
-                    else
-                    {
-                        b = false;
-                        break;
-                    }
+                    b = false;
+                    break;
                 }
-            return b;
             }
+            return b;
         }
         public String toString() {
             return "xxxxGENERATED-IDxxxx";
@@ -781,18 +773,28 @@ public class JDBC {
      * @param expectedTypes Array of expected parameter types.
      */
     public static void assertParameterTypes (PreparedStatement ps,
-	        int[] expectedTypes) throws SQLException
+	        int[] expectedTypes) throws Exception
 	    {
-		ParameterMetaData pmd = ps.getParameterMetaData();
-	        int actualParams = pmd.getParameterCount();
+            if ( vmSupportsJSR169() )
+            {
+                Assert.fail( "The assertParameterTypes() method only works on platforms which
support ParameterMetaData." );
+            }
+
+            Object pmd = ps.getClass().getMethod( "getParameterMetaData", null ).invoke(
 ps, null );
+            int actualParams = ((Integer) pmd.getClass().getMethod( "getParameterCount",
null ).invoke( pmd, null )).intValue();
 
 	        Assert.assertEquals("Unexpected parameter count:",
-	                expectedTypes.length, pmd.getParameterCount());
+	                expectedTypes.length, actualParams );
+
+            Method  getParameterType = pmd.getClass().getMethod( "getParameterType", new
Class[] { Integer.TYPE } );
 
 	        for (int i = 0; i < actualParams; i++)
 	        {
-	            Assert.assertEquals("Types do not match for parameter " + (i+1),
-	                    expectedTypes[i], pmd.getParameterType(i+1));
+	            Assert.assertEquals
+                    ("Types do not match for parameter " + (i+1),
+                     expectedTypes[i],
+                     ((Integer) getParameterType.invoke( pmd, new Object[] { new Integer(
i + 1 ) } )).intValue()
+                     );
 	        }
 	    }
     

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/RuntimeStatisticsParser.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/RuntimeStatisticsParser.java?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/RuntimeStatisticsParser.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/RuntimeStatisticsParser.java
Tue Nov  8 13:24:43 2011
@@ -417,17 +417,8 @@ public class RuntimeStatisticsParser {
         if (startStartIndex >= 0 && endStartIndex >= 0)
         {
             String positionLines = statistics.substring(startStartIndex, endStartIndex);
-            if (JDBC.vmSupportsJSR169())
-            {
-                // do something else then split.
-                String [] startPositionLines = Utilities.split(positionLines, '\n');
-                return startPositionLines;
-            }
-            else
-            {
-                String [] startPositionLines = positionLines.split("\n");
-                return startPositionLines;
-            }
+            
+            return Utilities.split(positionLines, '\n');
         }
         else 
             return null;
@@ -445,17 +436,8 @@ public class RuntimeStatisticsParser {
         if (startStopIndex >= 0 && endStopIndex >= 0)
         {
             String positionLines = statistics.substring(startStopIndex, endStopIndex);
-            if (JDBC.vmSupportsJSR169())
-            {
-                // do something else then split.
-                String [] stopPositionLines = Utilities.split(positionLines, '\n');
-                return stopPositionLines;
-            }
-            else
-            {
-                String [] stopPositionLines = positionLines.split("\n");
-                return stopPositionLines;
-            }
+            
+            return Utilities.split(positionLines, '\n');
         }
         else 
             return null;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java Tue Nov
 8 13:24:43 2011
@@ -1,6 +1,6 @@
 /*
 
-   Derby - Class org.apache.derby.impl.services.bytecode.CodeChunk
+   Derby - Class org.apache.derbyTesting.junit.XATestUtil
 
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XML.java Tue Nov  8 13:24:43
2011
@@ -340,6 +340,15 @@ public class XML {
         if (!classpathHasJAXP())
             return null;
 
-        return JAXPFinder.getJAXPParserLocation();
+        try {
+            Class   jaxpFinderClass = Class.forName( "org.apache.derbyTesting.junit.JAXPFinder"
);
+            Method  locatorMethod = jaxpFinderClass.getDeclaredMethod( "getJAXPParserLocation",
null );
+
+            return (String) locatorMethod.invoke(  null, null );
+        }
+        catch (Exception e)
+        {
+            throw new UnsupportedOperationException( e.getClass().getName() + ": " + e.getMessage()
);
+        }
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml?rev=1199234&r1=1199233&r2=1199234&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/build.xml Tue Nov  8 13:24:43
2011
@@ -48,6 +48,9 @@
   <property file="${user.home}/properties/derbytesting.properties"/>
   <property file="${ant.home}/properties/derbytesting.properties"/>
 
+  <!-- Classes which must be compiled against JDK 1.4 or higher -->
+  <property name="junit.14.classes" value="${derby.testing.junit.dir}/JAXPFinder.java,${derby.testing.junit.dir}/ConnectionPoolDataSourceConnector.java,${derby.testing.junit.dir}/J2EEDataSource.java,${derby.testing.junit.dir}/DriverManagerConnector.java,${derby.testing.junit.dir}/XADataSourceConnector.java,${derby.testing.junit.dir}/XATestUtil.java,${derby.testing.junit.dir}/BigDecimalHandler.java"/>
+
   <!-- Release and Version info -->
   <property file="${properties.dir}/release.properties"/>
 
@@ -55,10 +58,7 @@
  
   <target name="junitcomponents" 
           description="Build Derby JUnit test components">
-    <!-- We only compile junit/JAXPFinder.java against JDK 1.4   -->
-    <!-- because it relies on a JAXP class that is part of 1.4   -->
-    <!-- but it is not part of 1.3.                              -->
-    <!-- This needs to be revisited. The second javac invocation fails against the jsr169
classpath -->
+    <!-- Here we compile the classes which WILL run on small device platforms -->
     <javac
       source="1.4"
       target="1.4"
@@ -69,15 +69,17 @@
       deprecation="${deprecation}"
       optimize="${optimize}"
       proceed="${proceed}"
-      verbose="${verbose}"
+      verbose="${verbose}" 
       srcdir="${derby.testing.src.dir}"
+      includes="${derby.testing.junit.dir}/**/*.java"
+      excludes="${junit.14.classes}"
       destdir="${out.dir}">
       <classpath>
-        <pathelement path="${java14compile.classpath}"/>
+        <pathelement path="${compile.classpath}"/>
         <pathelement path="${junit}"/>
       </classpath>
-	  <include name="${derby.testing.junit.dir}/JAXPFinder.java"/>
     </javac>
+    <!-- Here we compile the classes which will NOT run on small device platforms -->
     <javac
       source="1.4"
       target="1.4"
@@ -88,15 +90,14 @@
       deprecation="${deprecation}"
       optimize="${optimize}"
       proceed="${proceed}"
-      verbose="${verbose}" 
+      verbose="${verbose}"
       srcdir="${derby.testing.src.dir}"
+	  includes="${junit.14.classes}"
       destdir="${out.dir}">
       <classpath>
         <pathelement path="${java14compile.classpath}"/>
         <pathelement path="${junit}"/>
       </classpath>
-      <include name="${derby.testing.junit.dir}/**/*.java"/>
-      <exclude name="${derby.testing.junit.dir}/JAXPFinder.java"/>
     </javac>
   </target>
 



Mime
View raw message