db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r509419 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit: DropDatabaseSetup.java TestConfiguration.java
Date Tue, 20 Feb 2007 03:24:13 GMT
Author: djd
Date: Mon Feb 19 19:24:12 2007
New Revision: 509419

URL: http://svn.apache.org/viewvc?view=rev&rev=509419
Log:
DERBY-2295 Change DropDatabaseSetup to be explicit about which database it is removing and
ensure that database is shutdown first. Does not assume the current database
is the one to be shutdown.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java?view=diff&rev=509419&r1=509418&r2=509419
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
Mon Feb 19 19:24:12 2007
@@ -23,34 +23,40 @@
 import java.security.AccessController;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.List;
+
+import javax.sql.DataSource;
 
 import junit.extensions.TestSetup;
 import junit.framework.Test;
 
 /**
- * Shutdown and drop the current database at tearDown time.
+ * Shutdown and drop the database identified by the logical
+ * name passed in when creating this decorator.
  *
  */
-class DropDatabaseSetup extends BaseJDBCTestSetup {
+class DropDatabaseSetup extends TestSetup {
 
-    DropDatabaseSetup(Test test) {
+    private final String logicalDBName;
+    DropDatabaseSetup(Test test, String logicalDBName) {
         super(test);
+        this.logicalDBName = logicalDBName;
      }
     
     /**
-     * Drop the last database added to the list of used databases.
+     * Shutdown the database and then remove all of its files.
      */
     protected void tearDown() throws Exception {
         
+        TestConfiguration config = TestConfiguration.getCurrent();
+        
         // Ensure the database is booted
         // since that is what shutdownDatabase() requires.
-        getConnection().close();
-        super.tearDown();
-        
-        TestConfiguration.getCurrent().shutdownDatabase();
-
-        ArrayList usedDbs = TestConfiguration.getCurrent().getUsedDatabaseNames();
-        String dbName = (String) usedDbs.get(usedDbs.size()-1);
+        config.openConnection(logicalDBName).close();
+        String dbName = config.getPhysicalDatabaseName(logicalDBName);
+        DataSource ds = JDBCDataSource.getDataSource(dbName);
+        JDBCDataSource.shutdownDatabase(ds);
+             
         dbName = dbName.replace('/', File.separatorChar);
         
         String dsh = BaseTestCase.getSystemProperty("derby.system.home");
@@ -93,11 +99,11 @@
                 if (entry.isDirectory()) {
                     removeDir(entry);
                 } else {
-                    assertTrue(entry.delete());
+                    assertTrue(entry.getPath(), entry.delete());
                 }
             }
         }
 
-        assertTrue(dir.delete());
+        assertTrue(dir.getPath(), dir.delete());
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?view=diff&rev=509419&r1=509418&r2=509419
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Mon Feb 19 19:24:12 2007
@@ -25,6 +25,7 @@
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
+import java.util.List;
 import java.util.Properties;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -312,7 +313,7 @@
     {
         String dbName = generateUniqueDatabaseName();
 
-        return new DatabaseChangeSetup(new DropDatabaseSetup(test), dbName, dbName, true);
+        return new DatabaseChangeSetup(new DropDatabaseSetup(test, dbName), dbName, dbName,
true);
     }
     
     /**
@@ -333,7 +334,7 @@
      */
     public static TestSetup additionalDatabaseDecorator(Test test, String logicalDbName)
     {
-        return new DatabaseChangeSetup(new DropDatabaseSetup(test),
+        return new DatabaseChangeSetup(new DropDatabaseSetup(test, logicalDbName),
                                        logicalDbName,
                                        generateUniqueDatabaseName(),
                                        false);
@@ -763,12 +764,13 @@
     }
     
     /**
-     * Return the names of all used databases.
+     * Return the physical name for a database
+     * given its logical name.
      * 
-     * @return The ArrayList containing the database names.
+     * @return Physical name of the database.
      */
-    public ArrayList getUsedDatabaseNames() {
-        return usedDbNames;
+    String getPhysicalDatabaseName(String logicalName) {
+        return (String) logicalDbMapping.get(logicalName);
     }
 
     /**



Mime
View raw message