Author: mamta Date: Tue Sep 8 20:10:57 2009 New Revision: 812669 URL: http://svn.apache.org/viewvc?rev=812669&view=rev Log: DERBY-4361 It was not enough to just the shutdown the database in Windows in order to be able to delete the log file later. The engine needed to be brought down too. I added code in JDBCDataSource for shutting down the engine and used this new method from the ClassLoaderBootTest to shut the engine down. Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java?rev=812669&r1=812668&r2=812669&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/ClassLoaderBootTest.java Tue Sep 8 20:10:57 2009 @@ -178,18 +178,19 @@ Connection conn1 = ds_1.getConnection(); // now attemp to boot using another class loader. setThreadLoader(loader_2); + DataSource ds_2 = JDBCDataSource.getDataSource(); try { - DataSource ds_2 = JDBCDataSource.getDataSource(); ds_2.getConnection(); fail("booted database that was already booted by another CLR"); } catch (SQLException e) { SQLException ne = e.getNextException(); assertPreventDualBoot(ne); + JDBCDataSource.shutEngine(ds_2); } - // shutdown the database. + // shutdown the engine. setThreadLoader(loader_1); - JDBCDataSource.shutdownDatabase(ds_1); + JDBCDataSource.shutEngine(ds_1); } @@ -211,11 +212,10 @@ setThreadLoader(loader_2); DataSource ds_2 = JDBCDataSource.getDataSource(); ds_2.getConnection(); - // shutdown the database. - JDBCDataSource.shutdownDatabase(ds_2); - } - - + // shutdown the engine for both the class loaders. + JDBCDataSource.shutEngine(ds_2); + JDBCDataSource.shutEngine(ds_1); +} private void setThreadLoader(final ClassLoader which) { Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java?rev=812669&r1=812668&r2=812669&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java Tue Sep 8 20:10:57 2009 @@ -25,6 +25,8 @@ import java.util.HashMap; import java.util.Iterator; +import javax.sql.DataSource; + import junit.framework.Assert; /** @@ -265,4 +267,22 @@ clearStringBeanProperty(ds, "shutdownDatabase"); } } + + /** + * Shutdown the engine described by this data source. + * The shutdownDatabase property is cleared by this method. + */ + public static void shutEngine(javax.sql.DataSource ds) throws SQLException { + setBeanProperty(ds, "shutdownDatabase", "shutdown"); + JDBCDataSource.setBeanProperty(ds, "databaseName", ""); + try { + ds.getConnection(); + Assert.fail("Engine failed to shut down"); + } catch (SQLException e) { + BaseJDBCTestCase.assertSQLState("Engine shutdown", "XJ015", e); + } finally { + clearStringBeanProperty(ds, "shutdownDatabase"); + } + } + }