db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r494951 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests: lang/RoutineTest.java lang/TimeHandlingTest.java tools/IJRunScriptTest.java
Date Wed, 10 Jan 2007 19:41:46 GMT
Author: djd
Date: Wed Jan 10 11:41:45 2007
New Revision: 494951

URL: http://svn.apache.org/viewvc?view=rev&rev=494951
Log:
DERBY-2213 Change RoutineTest and TimeHandlingTest not to depend on derbytools.jar.
Ensure IJRunScriptTest runs only if derbytools.jar is present.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IJRunScriptTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java?view=diff&rev=494951&r1=494950&r2=494951
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Wed Jan 10 11:41:45 2007
@@ -24,6 +24,7 @@
 import java.io.UnsupportedEncodingException;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.sql.Time;
 import java.sql.Types;
 
@@ -65,24 +66,24 @@
      */
     public void testFunctionNullHandling() throws SQLException, UnsupportedEncodingException
     {
+        Statement s = createStatement();
+        
         // Create three simple functions that take an integer and
         // return its value as a VARCHAR().
-        int errors = runSQLCommands(
+        s.executeUpdate(
         "CREATE FUNCTION SV_NOCALL(INTEGER) RETURNS VARCHAR(10) " +
            "RETURNS NULL ON NULL INPUT " +
            "EXTERNAL NAME 'java.lang.String.valueOf'  " +
-           "LANGUAGE JAVA PARAMETER STYLE JAVA; " +
+           "LANGUAGE JAVA PARAMETER STYLE JAVA");
            
-        "CREATE FUNCTION SV_CALL(INTEGER) RETURNS VARCHAR(10) " +
+        s.executeUpdate("CREATE FUNCTION SV_CALL(INTEGER) RETURNS VARCHAR(10) " +
           "CALLED ON NULL INPUT " +
           "EXTERNAL NAME 'java.lang.String.valueOf' " +
-          "LANGUAGE JAVA PARAMETER STYLE JAVA; " +
+          "LANGUAGE JAVA PARAMETER STYLE JAVA");
           
-        "CREATE FUNCTION SV_DEFAULT(INTEGER) RETURNS VARCHAR(10) " +
+        s.executeUpdate("CREATE FUNCTION SV_DEFAULT(INTEGER) RETURNS VARCHAR(10) " +
           "EXTERNAL NAME 'java.lang.String.valueOf' " +
-          "LANGUAGE JAVA PARAMETER STYLE JAVA; ");
-        
-        assertEquals("errors running DDL", 0, errors);
+          "LANGUAGE JAVA PARAMETER STYLE JAVA");
         
         // Simple cases of calling each function individually
         // Test each function with non-NULL and NULL values.
@@ -116,22 +117,20 @@
         ps.close();
         
         // Test that any single argument being null causes NULL to be returned.
-        errors = runSQLCommands(
+        s.executeUpdate(
                 "CREATE FUNCTION CONCAT_NOCALL(VARCHAR(10), VARCHAR(10)) " +
                    "RETURNS VARCHAR(20) " +
                    "RETURNS NULL ON NULL INPUT " +
                    "EXTERNAL NAME '" +
                    RoutineTest.class.getName() + ".concat'  " +
-                   "LANGUAGE JAVA PARAMETER STYLE JAVA; " +
+                   "LANGUAGE JAVA PARAMETER STYLE JAVA");
+         s.executeUpdate(
                 "CREATE FUNCTION CONCAT_CALL(VARCHAR(10), VARCHAR(10)) " +
                    "RETURNS VARCHAR(20) " +
                    "CALLED ON NULL INPUT " +
                    "EXTERNAL NAME '" +
                    RoutineTest.class.getName() + ".concat'  " +
-                   "LANGUAGE JAVA PARAMETER STYLE JAVA; "
-                   
-        );  
-        assertEquals("errors running DDL", 0, errors);
+                   "LANGUAGE JAVA PARAMETER STYLE JAVA");
         
         ps = prepareStatement("VALUES CONCAT_NOCALL(?, ?)");
         ps.setString(1, "good");
@@ -215,22 +214,21 @@
         
         // Nested calls with SQL types that do not need casts
         // and map to primitive types. This had issues see DERBY-479
-        errors = runSQLCommands(
+        s.executeUpdate(
                 "CREATE FUNCTION SAME_NOCALL(INTEGER) " +
                    "RETURNS INTEGER " +
                    "RETURNS NULL ON NULL INPUT " +
                    "EXTERNAL NAME '" +
                    RoutineTest.class.getName() + ".same'  " +
-                   "LANGUAGE JAVA PARAMETER STYLE JAVA; " +
+                   "LANGUAGE JAVA PARAMETER STYLE JAVA");
+        
+        s.executeUpdate(
                 "CREATE FUNCTION SAME_CALL(INTEGER) " +
                    "RETURNS INTEGER " +
                    "CALLED ON NULL INPUT " +
                    "EXTERNAL NAME '" +
                    RoutineTest.class.getName() + ".same'  " +
-                   "LANGUAGE JAVA PARAMETER STYLE JAVA; "
-                   
-        );  
-        assertEquals("errors running DDL", 0, errors);
+                   "LANGUAGE JAVA PARAMETER STYLE JAVA");
         
         ps = prepareStatement("VALUES SAME_NOCALL(SAME_NOCALL(?))");
         ps.setInt(1, 41);
@@ -260,22 +258,21 @@
         assertStatementError("39004", ps); // Can't pass NULL into primitive type
         ps.close();
 
-        errors = runSQLCommands(
+        s.executeUpdate(
                 "CREATE FUNCTION NOON_NOCALL(TIME) " +
                    "RETURNS TIME " +
                    "RETURNS NULL ON NULL INPUT " +
                    "EXTERNAL NAME '" +
                    RoutineTest.class.getName() + ".nullAtNoon'  " +
-                   "LANGUAGE JAVA PARAMETER STYLE JAVA; " +
+                   "LANGUAGE JAVA PARAMETER STYLE JAVA");
+        
+        s.executeUpdate(
                 "CREATE FUNCTION NOON_CALL(TIME) " +
                    "RETURNS TIME " +
                    "CALLED ON NULL INPUT " +
                    "EXTERNAL NAME '" +
                    RoutineTest.class.getName() + ".nullAtNoon'  " +
-                   "LANGUAGE JAVA PARAMETER STYLE JAVA; "
-                   
-        );  
-        assertEquals("errors running DDL", 0, errors);
+                   "LANGUAGE JAVA PARAMETER STYLE JAVA");
         
         // Function maps:
         // NULL to 11:00:00 (if null can be passed)
@@ -347,6 +344,8 @@
         ps.setTime(1, null); // NULL->11:00:00->11:30:00
         JDBC.assertSingleValueResultSet(ps.executeQuery(), "11:30:00");
         ps.close();
+        
+        s.close();
     }
     
     /*

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java?view=diff&rev=494951&r1=494950&r2=494951
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
Wed Jan 10 11:41:45 2007
@@ -138,7 +138,9 @@
     protected void setUp() throws UnsupportedEncodingException, SQLException
     {
         cal = Calendar.getInstance();
-        runSQLCommands("DELETE FROM TIME_ALL;");
+        Statement s  = createStatement();
+        s.executeUpdate("DELETE FROM TIME_ALL");
+        s.close();
     }
     
     /**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IJRunScriptTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IJRunScriptTest.java?view=diff&rev=494951&r1=494950&r2=494951
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IJRunScriptTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IJRunScriptTest.java
Wed Jan 10 11:41:45 2007
@@ -31,6 +31,7 @@
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.Derby;
 
 /**
  * Test the ij.runScript api method.
@@ -40,9 +41,13 @@
     
     public static Test suite()
     {
-        TestSuite suite = new TestSuite("IJRunScriptTest");
-        suite.addTestSuite(IJRunScriptTest.class);
-        return new CleanDatabaseTestSetup(suite);
+        if (Derby.hasTools()) {
+            TestSuite suite = new TestSuite("IJRunScriptTest");
+            suite.addTestSuite(IJRunScriptTest.class);
+            return new CleanDatabaseTestSetup(suite);
+        }
+        
+        return new TestSuite("empty: no tools support");
     }
     
     public IJRunScriptTest(String name)



Mime
View raw message