db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1589624 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/lang/LuceneSupportPermsTest.java junit/DropDatabaseSetup.java junit/TestConfiguration.java
Date Thu, 24 Apr 2014 07:43:36 GMT
Author: kahatlen
Date: Thu Apr 24 07:43:36 2014
New Revision: 1589624

URL: http://svn.apache.org/r1589624
Log:
DERBY-6546: Database can't be dropped on Windows using the decoration of LuceneSupportPermsTest

Move database shutdown from the tearDown() method of the test case to
DropDatabaseTestSuite so that no intermediate decorators reboot the
database before it is dropped.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
    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/functionTests/tests/lang/LuceneSupportPermsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java?rev=1589624&r1=1589623&r2=1589624&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
Thu Apr 24 07:43:36 2014
@@ -155,19 +155,12 @@ public class LuceneSupportPermsTest exte
         Test        secureTest = new SecurityManagerSetup( suite, POLICY_FILE );
         Test        authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication
             ( secureTest, LEGAL_USERS, "LuceneSupportPermissions" );
-        Test        authorizedTest = TestConfiguration.sqlAuthorizationDecoratorSingleUse(
authenticatedTest, DB_NAME, false );
+        Test        authorizedTest = TestConfiguration.sqlAuthorizationDecoratorSingleUse(
authenticatedTest, DB_NAME, true );
         Test        localizedTest = new LocaleTestSetup( authorizedTest, new Locale( LANGUAGE,
COUNTRY ) );
 
         return localizedTest;
     }
 
-    protected void tearDown()
-        throws Exception
-    {
-        TestConfiguration.getCurrent().shutdownEngine();
-        super.tearDown();
-    }
-
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // TESTS

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?rev=1589624&r1=1589623&r2=1589624&view=diff
==============================================================================
--- 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
Thu Apr 24 07:43:36 2014
@@ -32,17 +32,33 @@ import org.apache.derbyTesting.functionT
  */
 class DropDatabaseSetup extends BaseTestSetup {
 
-    final String logicalDBName;
+    private final String logicalDBName;
+    private final boolean shutdownBeforeDrop;
+
     DropDatabaseSetup(Test test, String logicalDBName) {
+        this(test, logicalDBName, true);
+    }
+
+    DropDatabaseSetup(Test test, String logicalDBName, boolean shutdown) {
         super(test);
         this.logicalDBName = logicalDBName;
-     }
+        this.shutdownBeforeDrop = shutdown;
+    }
     
     /**
      * Shutdown the database and then remove all of its files.
      */
+    @Override
     protected void tearDown() throws Exception {
-        
+        if (shutdownBeforeDrop) {
+            shutdownDatabase();
+        }
+
+        removeDatabase();
+    }
+
+    private void shutdownDatabase() throws SQLException {
+
         TestConfiguration config = TestConfiguration.getCurrent();
         
         // Ensure the database is booted
@@ -72,8 +88,6 @@ class DropDatabaseSetup extends BaseTest
             DataSource ds = JDBCDataSource.getDataSourceLogical(logicalDBName);
             JDBCDataSource.shutdownDatabase(ds);
         }
-
-        removeDatabase();
     }
 
     void removeDatabase()

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?rev=1589624&r1=1589623&r2=1589624&view=diff
==============================================================================
--- 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
Thu Apr 24 07:43:36 2014
@@ -759,13 +759,7 @@ public final class TestConfiguration {
         String dbName = generateUniqueDatabaseName();
 
         return new DatabaseChangeSetup(
-            new DropDatabaseSetup(test, dbName)
-            {
-                protected void tearDown() throws Exception {
-                    // test responsible for shutdown
-                    removeDatabase();
-                }
-            },
+            new DropDatabaseSetup(test, dbName, false),
             dbName, dbName, true);
     }
 
@@ -833,13 +827,7 @@ public final class TestConfiguration {
         )
     {
         return new DatabaseChangeSetup(
-            new DropDatabaseSetup(test, logicalDbName)
-            {
-                protected void tearDown() throws Exception {
-                    // the test is responsible for shutdown
-                    removeDatabase();
-                }
-            },
+            new DropDatabaseSetup(test, logicalDbName, false),
             logicalDbName,
             generateUniqueDatabaseName(),
             defaultDB);
@@ -863,13 +851,7 @@ public final class TestConfiguration {
         String logicalDbName, String physicalDbName )
     {
         return new DatabaseChangeSetup(
-            new DropDatabaseSetup(test, logicalDbName)
-            {
-                protected void tearDown() throws Exception {
-                    // the test is responsible for shutdown
-                    removeDatabase();
-                }
-            },
+            new DropDatabaseSetup(test, logicalDbName, false),
             logicalDbName,
             physicalDbName,
             false);
@@ -950,18 +932,25 @@ public final class TestConfiguration {
      */
     public static Test sqlAuthorizationDecoratorSingleUse(Test test)
     {
-        return sqlAuthorizationDecoratorSingleUse( test, DEFAULT_DBNAME_SQL, true );
+        return sqlAuthorizationDecoratorSingleUse(
+                test, DEFAULT_DBNAME_SQL, false);
     }
     
     /**
-     * Same as sqlAuthorizationDecoratorSingleUse, except that you can name the database
yourself.
+     * Same as sqlAuthorizationDecoratorSingleUse, except that you can name
+     * the database yourself, and you can choose whether or not the decorator
+     * should shut down the database before it attempts to drop it.
      *
      * @param test Test to be decorated
+     * @param dbName The name of the database to use in the test
+     * @param shutdownDatabase Whether or not to shut down the database
+     *   before it is dropped
      * @return decorated test.
      *
      * @see TestConfiguration#sqlAuthorizationDecorator(Test test)
      */
-    public static Test sqlAuthorizationDecoratorSingleUse(Test test, String dbName, boolean
removeDatabase)
+    public static Test sqlAuthorizationDecoratorSingleUse(
+            Test test, String dbName, boolean shutdownDatabase)
     {
         // Set the SQL authorization mode as a database property
         // with a modified DatabasePropertyTestSetup that does not
@@ -971,17 +960,8 @@ public final class TestConfiguration {
         Test setSQLAuthMode = DatabasePropertyTestSetup.getNoTeardownInstance(
                 test, sqlAuth, true);
 
-        if ( removeDatabase )
-        {
-            setSQLAuthMode =
-                new DropDatabaseSetup(setSQLAuthMode, dbName)
-                {
-                    protected void tearDown() throws Exception {
-                        // test responsible for shutdown
-                        removeDatabase();
-                    }
-                };
-        }
+        setSQLAuthMode = new DropDatabaseSetup(
+                setSQLAuthMode, dbName, shutdownDatabase);
         
         setSQLAuthMode = new DatabaseChangeSetup
             ( setSQLAuthMode, dbName, dbName, true );



Mime
View raw message