db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1082282 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java
Date Wed, 16 Mar 2011 19:56:27 GMT
Author: kahatlen
Date: Wed Mar 16 19:56:27 2011
New Revision: 1082282

URL: http://svn.apache.org/viewvc?rev=1082282&view=rev
Log:
DERBY-5107: BasicInMemoryDbTest depends on implicit ordering of test cases

Use helper methods that ensure created databases are dropped between each test case, and also
load the JDBC driver explicitly in test cases that used to require that an earlier test case
had already loaded the driver implicitly.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java?rev=1082282&r1=1082281&r2=1082282&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/BasicInMemoryDbTest.java
Wed Mar 16 19:56:27 2011
@@ -68,6 +68,20 @@ public class BasicInMemoryDbTest
     public void tearDown()
             throws Exception {
         dbm.cleanUp();
+        super.tearDown();
+    }
+
+    /**
+     * Helper method to make sure the driver is loaded. May be needed when
+     * calling DriverManager.getConnection() directly since the driver may
+     * not already be loaded (in particular when running from classes so that
+     * driver auto-loading doesn't come into play), or it may have been
+     * unloaded by an engine shutdown in an earlier test case.
+     */
+    private void loadDriver() throws SQLException {
+        // If we get a default connection through the framework, the driver
+        // will be loaded implicitly.
+        getConnection();
     }
 
     /**
@@ -206,7 +220,7 @@ public class BasicInMemoryDbTest
      */
     public void testEnginehutdown()
             throws SQLException {
-        DriverManager.getConnection("jdbc:derby:memory:/tmp/myDB;create=true");
+        dbm.createDatabase("/tmp/myDB");
         try {
             DriverManager.getConnection(
                     "jdbc:derby:;shutdown=true");
@@ -216,7 +230,7 @@ public class BasicInMemoryDbTest
         }
         // Another hack, to make sure later tests in this class doesn't fail.
         // Get a connection to the default database to reload the engine.
-        getConnection();
+        loadDriver();
     }
 
     /**
@@ -259,6 +273,7 @@ public class BasicInMemoryDbTest
      */
     public void testDelete()
             throws SQLException {
+            loadDriver();
             Connection conCreate = DriverManager.getConnection(
                     "jdbc:derby:memory:deleteDbSimple;create=true");
             Statement stmt = dbm.createStatement(conCreate);
@@ -308,6 +323,7 @@ public class BasicInMemoryDbTest
      */
     public void testDeleteWhenInUse()
             throws IOException, SQLException {
+        loadDriver();
         Connection con = DriverManager.getConnection(
                 "jdbc:derby:memory:deleteDb;create=true");
         PreparedStatement ps = dbm.prepareStatement(con,



Mime
View raw message