db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r541038 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Wed, 23 May 2007 19:21:39 GMT
Author: djd
Date: Wed May 23 12:21:38 2007
New Revision: 541038

URL: http://svn.apache.org/viewvc?view=rev&rev=541038
Log:
Cleanup some language JUnit tests, some minor cleanups on decorateSQL() methods
such as not closing the passed in Statement (it is closed by the decorator)
and closing other objects created in the method. Change a couple of the 
language tests to only run embedded since they are testing server side logic.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StalePlansTest.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=541038&r1=541037&r2=541038
==============================================================================
--- 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
Wed May 23 12:21:38 2007
@@ -672,9 +672,12 @@
             return "'" + str + "'";
     }
 
+    /**
+     * Testing server-side behaviour so run in embedded only.
+     */
     public static Test suite() {
 
-        return TestConfiguration.defaultSuite(CastingTest.class);
+        return TestConfiguration.embeddedSuite(CastingTest.class);
 
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
Wed May 23 12:21:38 2007
@@ -191,19 +191,12 @@
     }
 
     /**
-     * Create a suite of tests.
+     * Create a suite of tests, run only in embedded since
+     * this is testing server-side behaviour.
      **/
     public static Test suite() {
-        TestSuite suite = new TestSuite("CoalesceTest");
-        suite.addTest(baseSuite("CoalesceTest:embedded"));
-        suite.addTest(TestConfiguration.clientServerDecorator(baseSuite("CoalesceTest:client")));
-        return suite;
-    }
-
-    protected static Test baseSuite(String name) {
-        TestSuite suite = new TestSuite(name);
-        suite.addTestSuite(CoalesceTest.class);
-
+        Test suite = TestConfiguration.embeddedSuite(CoalesceTest.class);
+        
         return new CleanDatabaseTestSetup(suite) 
         {
             protected void decorateSQL(Statement stmt) throws SQLException
@@ -230,7 +223,6 @@
                     createSQL.append(SQLData[SQLTypes.length - 1][row]+")");
                     stmt.executeUpdate(createSQL.toString());
                 }
-                stmt.close();
             }
         };
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Wed May 23 12:21:38 2007
@@ -84,11 +84,13 @@
       DataSource ds = JDBCDataSource.getDataSourceLogical("defaultdb");
       JDBCDataSource.setBeanProperty(ds, "connectionAttributes", 
                   "create=true");
-      setUpTable(ds);
+
       
       Connection conn = ds.getConnection();
       conn.setAutoCommit(false);
       Statement s = conn.createStatement();
+      
+      setUpTable(s);
 
       //The collation should be UCS_BASIC for this database
       checkLangBasedQuery(s, 
@@ -199,10 +201,12 @@
       checkLangBasedQuery(s, "SELECT MIN(NAME) minName FROM CUSTOMER ORDER BY minName ",
       		new String[][] {{"Acorn"}});   
 
-      s.close();
+
       conn.commit();
 
-      dropTable(ds);
+      dropTable(s);
+      s.close();
+      conn.close();
       }
       
   /**
@@ -213,11 +217,13 @@
       DataSource ds = JDBCDataSource.getDataSourceLogical("poldb");
       JDBCDataSource.setBeanProperty(ds, "connectionAttributes", 
                   "create=true;territory=pl;collation=TERRITORY_BASED");
-      setUpTable(ds);
+
       
       Connection conn = ds.getConnection();
       conn.setAutoCommit(false);
       Statement s = conn.createStatement();
+      
+      setUpTable(s);
 
       //The collation should be TERRITORY_BASED for this database
       checkLangBasedQuery(s, 
@@ -360,10 +366,13 @@
       checkLangBasedQuery(s, "SELECT MIN(NAME) minName FROM CUSTOMER ORDER BY minName ",
       		new String[][] {{"aacorn"}});   
 
-      s.close();
+
       conn.commit();
 
-      dropTable(ds);
+      dropTable(s);
+      s.close();
+      conn.close();
+      
       }    
   
 
@@ -376,11 +385,12 @@
       DataSource ds = JDBCDataSource.getDataSourceLogical("nordb");
       JDBCDataSource.setBeanProperty(ds, "connectionAttributes", 
                   "create=true;territory=no;collation=TERRITORY_BASED");
-      setUpTable(ds);
+
       
       Connection conn = ds.getConnection();
       conn.setAutoCommit(false);
       Statement s = conn.createStatement();
+      setUpTable(s);
 
       //The collation should be TERRITORY_BASED for this database
       checkLangBasedQuery(s, 
@@ -520,10 +530,12 @@
       checkLangBasedQuery(s, "SELECT MIN(NAME) minName FROM CUSTOMER ORDER BY minName ",
       		new String[][] {{"Acorn"}});   
 
-      s.close();
+
       conn.commit();
 
-      dropTable(ds);
+      dropTable(s);
+      s.close();
+      conn.close();
       }
   
 
@@ -536,11 +548,12 @@
       DataSource ds = JDBCDataSource.getDataSourceLogical("endb");
       JDBCDataSource.setBeanProperty(ds, "connectionAttributes", 
                   "create=true;territory=en;collation=TERRITORY_BASED");
-      setUpTable(ds);
+
       
       Connection conn = ds.getConnection();
       conn.setAutoCommit(false);
       Statement s = conn.createStatement();
+      setUpTable(s);
 
       //The collation should be TERRITORY_BASED for this database
       checkLangBasedQuery(s, 
@@ -683,18 +696,20 @@
       checkLangBasedQuery(s, "SELECT MIN(NAME) minName FROM CUSTOMER ORDER BY minName ",
       		new String[][] {{"aacorn"}});   
       
-      s.close();
+
       conn.commit();
       
-      dropTable(ds);
+      dropTable(s);
+      s.close();
+      conn.close();
       }
 
-private void setUpTable(DataSource ds) throws SQLException {
-	Connection conn = ds.getConnection();
-	Statement s = conn.createStatement();
+private void setUpTable(Statement s) throws SQLException {
+
     s.execute("CREATE TABLE CUSTOMER(ID INT, NAME VARCHAR(40))");
+    
+    Connection conn = s.getConnection();
 
-    conn.setAutoCommit(false);
     PreparedStatement ps = conn.prepareStatement("INSERT INTO CUSTOMER VALUES(?,?)");
     for (int i = 0; i < NAMES.length; i++)
     {
@@ -705,15 +720,12 @@
 
     conn.commit();
     ps.close();
-    s.close();
 }
 
-private void dropTable(DataSource ds) throws SQLException {
-	Connection conn = ds.getConnection();
-	Statement s = conn.createStatement();
+private void dropTable(Statement s) throws SQLException {
 	
     s.execute("DROP TABLE CUSTOMER");     
-    s.close();
+    s.getConnection().commit();
 }
 
 /**
@@ -735,9 +747,13 @@
     	JDBC.assertFullResultSet(rs,expectedResult);
 }
     
+  /**
+   * Tests only need to run in embedded since collation
+   * is a server side operation.
+   */
   public static Test suite() {
 
-        Test test =  TestConfiguration.defaultSuite(CollationTest.class);
+        Test test =  TestConfiguration.embeddedSuite(CollationTest.class);
         test = TestConfiguration.additionalDatabaseDecorator(test, "defaultdb");
         test = TestConfiguration.additionalDatabaseDecorator(test, "endb");
         test = TestConfiguration.additionalDatabaseDecorator(test, "nordb");

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
Wed May 23 12:21:38 2007
@@ -731,7 +731,7 @@
     
     public static Test suite() {
 
-        Test test =  TestConfiguration.defaultSuite(CollationTest2.class);
+        Test test =  TestConfiguration.embeddedSuite(CollationTest2.class);
         test = TestConfiguration.additionalDatabaseDecorator(
                     test, TEST_DATABASE[TEST_DEFAULT]);
         test = TestConfiguration.additionalDatabaseDecorator(

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java
Wed May 23 12:21:38 2007
@@ -903,7 +903,6 @@
                 		for (int i = 0; i < TABLES.length; i++) {
                     			s.execute(TABLES[i]);
                 		}
-                        	s.close();
             		}
         	};
     	} 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java
Wed May 23 12:21:38 2007
@@ -90,7 +90,6 @@
 				s.execute("create table t2 ( s smallint, c char(10), r real, ts timestamp )");
                                 s.execute("create table t3 (i int not null constraint t3pk
primary key, b char(10))");
 				s.execute("create table t4 (c1 int)");	
-                        	s.close();
             		}
         	};
     	} 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
Wed May 23 12:21:38 2007
@@ -600,7 +600,6 @@
                 s.execute("insert into t2 values '123 ', 'abc ', '123', 'abc'") ;
                 s.execute("insert into t3 values (1,1), (2,2), (2,2), (3,3), (null, null),
(5,100)");
 
-                s.close();
               }
             }; 
         return wrapper;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
Wed May 23 12:21:38 2007
@@ -504,7 +504,6 @@
                     ResultSetsFromPreparedStatementTest.apply(ps, emp);
                     c.commit();
                     ps.close();
-                    s.close();
 
                     // No, cannot do this here. Will crash
                     // CleanDatabaseTestSetup.setUp()

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java
Wed May 23 12:21:38 2007
@@ -725,8 +725,6 @@
                                 + "                   ('f', 6), ('g', 7), ('h', 8), ('i',
9),"
                                 + "                   ('j', 10), ('k', 11), ('l', 12), ('m',
13)");
 
-                
-                getConnection().setAutoCommit(false);
             }
         };
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StalePlansTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StalePlansTest.java?view=diff&rev=541038&r1=541037&r2=541038
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StalePlansTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StalePlansTest.java
Wed May 23 12:21:38 2007
@@ -68,6 +68,7 @@
                 for (int i = 0; i < 64; i++) {
                     ps.executeUpdate();
                 }
+                ps.close();
             }
         };
     }



Mime
View raw message