Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3558B118D7 for ; Thu, 24 Apr 2014 07:44:12 +0000 (UTC) Received: (qmail 41476 invoked by uid 500); 24 Apr 2014 07:44:11 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 41270 invoked by uid 500); 24 Apr 2014 07:44:02 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 41255 invoked by uid 99); 24 Apr 2014 07:44:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2014 07:44:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2014 07:44:00 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A83B52388868; Thu, 24 Apr 2014 07:43:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140424074336.A83B52388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 );