db-derby-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?view=rev&rev=541033
Log:
Cleanup CreateTableFromQueryTest to create its base tables once per run rather
than once per fixture.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CreateTableFromQueryTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CreateTableFromQueryTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CreateTableFromQueryTest.java?view=diff&rev=541033&r1=541032&r2=541033
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CreateTableFromQueryTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CreateTableFromQueryTest.java
Wed May 23 12:06:29 2007
@@ -32,7 +32,9 @@
 import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
 import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * Test for creating tables using a query expression.
@@ -53,9 +55,20 @@
     */
     public static Test suite()
     {
-        final TestSuite suite = new TestSuite("CreateTableFromQueryTest");
-        suite.addTestSuite(CreateTableFromQueryTest.class);
-        return suite;
+        Test test = TestConfiguration.embeddedSuite(CreateTableFromQueryTest.class);
+        return new CleanDatabaseTestSetup(test) {
+
+            protected void decorateSQL(Statement stmt) throws SQLException
+            {
+                // create base tables t1 and t2       
+                stmt.executeUpdate(
+                    "create table t1(i int not null, s smallint, f float, dp "
+                    + "double precision, v varchar(10) not null)");
+
+                stmt.executeUpdate("create table t2 (a int, s varchar(5))");
+
+            }
+        };
     }
 
     /**
@@ -275,22 +288,16 @@
                 columnNames.length, col);
         stmt.executeUpdate("drop table t3");
     }
-
+    
     /**
      * Set the fixture up with base tables t1 and t2.
      */
     protected void setUp() throws SQLException
     {    
-        getConnection().setAutoCommit(false);
+       getConnection().setAutoCommit(false);
 
         stmt = createStatement();
 
-        // create base tables t1 and t2       
-        stmt.executeUpdate(
-            "create table t1(i int not null, s smallint, f float, dp "
-            + "double precision, v varchar(10) not null)");
-
-        stmt.executeUpdate("create table t2 (a int, s varchar(5))");
     }
     
     /**
@@ -299,26 +306,8 @@
      */
     protected void tearDown() throws Exception
     {
-        // drop tables
-        try {
-            stmt.execute("drop table t1");
-        } catch (SQLException e) {
-            assertSQLState("42Y55", e);
-        }
-
-        try {
-            stmt.execute("drop table t2");
-        } catch (SQLException e) {
-            assertSQLState("42Y55", e);
-        }
-
-        try {
-            stmt.execute("drop table t3");
-        } catch (SQLException e) {
-            assertSQLState("42Y55", e);
-        }
-
         stmt.close();
+        getConnection().commit();
 
         super.tearDown();
     }



Mime
View raw message