db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r514846 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/casting.out suites/derbylang.runall tests/lang/CastingTest.java
Date Mon, 05 Mar 2007 20:11:14 GMT
Author: kmarsden
Date: Mon Mar  5 12:11:13 2007
New Revision: 514846

URL: http://svn.apache.org/viewvc?view=rev&rev=514846
Log:
DERBY-2382 convert casting.java to JUnit.
Add testing for explicit cast output.  Remove casting.java from derbylang

Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/casting.out
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall?view=diff&rev=514846&r1=514845&r2=514846
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
Mon Mar  5 12:11:13 2007
@@ -8,7 +8,6 @@
 lang/altertable.sql
 lang/authorize.sql
 lang/autoincrement.sql
-lang/casting.java
 lang/checkConstraint.sql
 lang/closed.java
 lang/coalesceTests.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java?view=diff&rev=514846&r1=514845&r2=514846
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java
Mon Mar  5 12:11:13 2007
@@ -7,10 +7,15 @@
 
 import junit.framework.Test;
 
+import org.apache.derby.tools.JDBCDisplayUtil;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
+/**
+ * @author kmarsden
+ *
+ */
 public class CastingTest extends BaseJDBCTestCase {
 
     public CastingTest(String name) {
@@ -222,7 +227,31 @@
 
 
 };
-
+   /*
+    * explicitCastValues is a table of expected values for the testExplicitCasts fixture
+    * System.out.print statements in testExplicitCast were used to generate this table
+    * and  remain in comments in testExplicitCasts in case it needs to be regenerated.
+    */ 
+    private static final String[][] explicitCastValues = {
+    /*SMALLINT*/ {"0","0","0","0.00000","0.0","0.0","0                                  
                        ","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception"},
+    /*INTEGER*/ {"11","11","11","11.00000","11.0","11.0","11                            
                             ","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception"},
+    /*BIGINT*/ {"22","22","22","22.00000","22.0","22.0","22                             
                            ","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception"},
+    /*DECIMAL(10,5)*/ {"3","3","3","3.30000","3.3","3.3","3.30000                       
                             ","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception"},
+    /*REAL*/ {"4","4","4","4.40000","4.4","4.400000095367432","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception"},
+    /*DOUBLE*/ {"5","5","5","5.50000","5.5","5.5","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception"},
+    /*CHAR(60)*/ {"0","11","22","3.30000","Exception","Exception","7                    
                                      ","8                                               
           ","9                                                           ","Exception","Exception","Exception","13
                                                         ","2000-01-01","15:30:20","2000-01-01
15:30:20.0","Exception"},
+    /*VARCHAR(60)*/ {"0","11","22","3.30000","Exception","Exception","7                 
                                         ","8","9","Exception","Exception","Exception","13","2000-01-01","15:30:20","2000-01-01
15:30:20.0","Exception"},
+    /*LONG VARCHAR*/ {"Exception","Exception","Exception","Exception","Exception","Exception","7
                                                          ","8","9","Exception","Exception","Exception","13","Exception","Exception","Exception","Exception"},
+    /*CHAR(60) FOR BIT DATA*/ {"Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","10aa20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020","10bb20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020","10cc20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020","Exception","Exception","Exception","Exception","01dd20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020"},
+    /*VARCHAR(60) FOR BIT DATA*/ {"Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","10aa20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020","10bb","10cc","Exception","Exception","Exception","Exception","01dd"},
+    /*LONG VARCHAR FOR BIT DATA*/ {"Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","10aa20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020","10bb","10cc","Exception","Exception","Exception","Exception","01dd"},
+    /*CLOB(1k)*/ {"Exception","Exception","Exception","Exception","Exception","Exception","13
                                                         ","13","13","Exception","Exception","Exception","13","Exception","Exception","Exception","Exception"},
+    /*DATE*/ {"Exception","Exception","Exception","Exception","Exception","Exception","2000-01-01
                                                 ","2000-01-01","Exception","Exception","Exception","Exception","Exception","2000-01-01","Exception","Exception","Exception"},
+    /*TIME*/ {"Exception","Exception","Exception","Exception","Exception","Exception","15:30:20
                                                   ","15:30:20","Exception","Exception","Exception","Exception","Exception","Exception","15:30:20","Exception","Exception"},
+    /*TIMESTAMP*/ {"Exception","Exception","Exception","Exception","Exception","Exception","2000-01-01
15:30:20.0                                       ","2000-01-01 15:30:20.0","Exception","Exception","Exception","Exception","Exception","2000-01-01","15:30:20","2000-01-01
15:30:20.0","Exception"},
+    /*BLOB(1k)*/ {"Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","Exception","01dd"}
+    };
+    
     protected void setUp() throws SQLException {
         Connection conn = getConnection();
         Statement scb = conn.createStatement();
@@ -235,19 +264,8 @@
                     + " )";
 
             scb.executeUpdate(createSQL);
+            
         }
-
-        scb.close();
-        conn.commit();
-    }
-
-    public void testAssignments() throws SQLException {
-
-        Connection conn = getConnection();
-
-        Statement scb = conn.createStatement();
-        ResultSet rs = null;
-
         // * testing literal inserts
 
         for (int dataOffset = 0; dataOffset < SQLData[0].length; dataOffset++)
@@ -265,6 +283,18 @@
                     
                 }
             }
+        scb.close();
+        conn.commit();
+    }
+
+    public void testAssignments() throws SQLException {
+
+        Connection conn = getConnection();
+
+        Statement scb = conn.createStatement();
+        ResultSet rs = null;
+
+     
         // Try to insert each sourceType into the targetType table
         for (int dataOffset = 0; dataOffset < SQLData[0].length; dataOffset++)
             for (int sourceType = 0; sourceType < SQLTypes.length; sourceType++) {
@@ -313,6 +343,7 @@
         for (int sourceType = 0; sourceType < SQLTypes.length; sourceType++) {
 
             String sourceTypeName = SQLTypes[sourceType];
+            //System.out.print("/*" + sourceTypeName + "*/ {");
             for (int dataOffset = 0; dataOffset < SQLData[0].length; dataOffset++)
                 for (int targetType = 0; targetType < SQLTypes.length; targetType++) {
                     String query = null;
@@ -329,15 +360,35 @@
                                 + SQLTypes[sourceType] + ") AS "
                                 + SQLTypes[targetType] + " )";
                         rs = s.executeQuery(query);
-                        JDBC.assertDrainResults(rs);
+                        rs.next();
+                        String val = rs.getString(1);
+                        if (dataOffset == 0)
+                            assertNull(val);
+                        else
+                        {
+                            //System.out.print("\"" + val + "\"");
+                            assertEquals(val,explicitCastValues[sourceType][targetType]);
+                        }
                         checkSupportedCast(sourceType, targetType);
                     } catch (SQLException se) {
+                        if (dataOffset != 0)
+                        {
+                            //System.out.print("\"Exception\"");
+                        }
                         String sqlState = se.getSQLState();
                         if (!isSupportedCast(sourceType, targetType)) {
                             assertTrue(isCastException(se));
                         } else
                             throw se;
                     }
+                    /*
+                    if (dataOffset > 0)
+                        if (targetType == SQLTypes.length -1)
+                            System.out.println("},");
+                        else 
+                            System.out.print(",");
+                     */
+
                 }
         }
 
@@ -362,7 +413,9 @@
                         + " WHERE c = " + SQLData[type][dataOffset];
 
                 rs = scb.executeQuery(compareSQL);
-                JDBC.assertDrainResults(rs);
+                //JDBC.assertDrainResults(rs);
+                // should return 1 row
+                assertTrue(rs.next());
             } catch (SQLException se) {
                 // literal comparisons are ok for everything but Lob and long
                 assertTrue(isLongType(type));
@@ -395,10 +448,10 @@
                                 + " WHERE c = CAST(" + convertString + " AS "
                                 + sourceTypeName + ")";
 
-                        // System.out.println(compareSQL);
+                    
                         rs = scb.executeQuery(compareSQL);
                         JDBC.assertDrainResults(rs);
-                        // JDBCDisplayUtil.DisplayResults(System.out,rs,conn);
+                        
                         checkSupportedComparison(sourceType, targetType);
 
                     } catch (SQLException se) {



Mime
View raw message