Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7D75C9CE7 for ; Tue, 8 Nov 2011 13:25:11 +0000 (UTC) Received: (qmail 17274 invoked by uid 500); 8 Nov 2011 13:25:11 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 17253 invoked by uid 500); 8 Nov 2011 13:25:11 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 17246 invoked by uid 99); 8 Nov 2011 13:25:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Nov 2011 13:25:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Nov 2011 13:25:06 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E5DA523888FD; Tue, 8 Nov 2011 13:24:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: rhillegas@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111108132444.E5DA523888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + 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 @@ + + + @@ -55,10 +58,7 @@ - - - - + - + - + - -