db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r473175 - in /db/derby/code/trunk: ./ java/testing/org/apache/derbyTesting/functionTests/suites/ java/testing/org/apache/derbyTesting/functionTests/tests/store/ java/testing/org/apache/derbyTesting/junit/
Date Fri, 10 Nov 2006 03:36:33 GMT
Author: djd
Date: Thu Nov  9 19:36:32 2006
New Revision: 473175

URL: http://svn.apache.org/viewvc?view=rev&rev=473175
Log:
DERBY-1952 DERBY-2047 Convert store/BootAllTest to run as a standard JUNit test and
not within the harness. Added a store._Suite and hooked it into the suites.All and
the ant junit-all target.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
  (with props)
Modified:
    db/derby/code/trunk/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?view=diff&rev=473175&r1=473174&r2=473175
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Thu Nov  9 19:36:32 2006
@@ -1654,6 +1654,10 @@
       <param name="derby.junit.testname"
              value="org.apache.derbyTesting.functionTests.tests.jdbcapi._Suite"/>
     </antcall>
+    <antcall target="junit-oneclass">
+      <param name="derby.junit.testname"
+             value="org.apache.derbyTesting.functionTests.tests.store._Suite"/>
+    </antcall>
   </target>
 
   <target name="junitreport" depends="junit-all"> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java?view=diff&rev=473175&r1=473174&r2=473175
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
Thu Nov  9 19:36:32 2006
@@ -54,6 +54,7 @@
         suite.addTest(org.apache.derbyTesting.functionTests.tests.derbynet._Suite.suite());
         suite.addTest(org.apache.derbyTesting.functionTests.tests.lang._Suite.suite());
         suite.addTest(org.apache.derbyTesting.functionTests.tests.jdbcapi._Suite.suite());
+        suite.addTest(org.apache.derbyTesting.functionTests.tests.store._Suite.suite());
         suite.addTest(org.apache.derbyTesting.functionTests.tests.tools._Suite.suite());
 
         // Suites that are compiled using Java SE 6 target need to

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall?view=diff&rev=473175&r1=473174&r2=473175
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storemore.runall
Thu Nov  9 19:36:32 2006
@@ -35,4 +35,4 @@
 store/onlineBackupTest4.sql
 store/BackupPathTests.java
 store/LogDeviceTest.java
-store/BootAllTest.junit
+

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java?view=diff&rev=473175&r1=473174&r2=473175
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BootAllTest.java
Thu Nov  9 19:36:32 2006
@@ -21,27 +21,83 @@
 
 package org.apache.derbyTesting.functionTests.tests.store;
 
-import org.apache.derbyTesting.functionTests.util.TestUtil;
-import org.apache.derbyTesting.junit.BaseJDBCTestCase;
-
-import junit.framework.*;
-import java.sql.*;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
 import java.util.Properties;
-import java.util.Arrays;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.JDBCClient;
+import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * Tests for the system property "derby.system.bootAll"
  *
  * DERBY-1296 - Setting property derby.system.bootAll causes an Exception
  * 
+ * create & shutdown three databases as well as the default
+ * shutdown the engine
+ * set "derby.system.bootAll"
+ * check at least four databases are listed in the driver info
+ * 
+ * Test drops the three databases after their use as it uses
+ * the singleUseDatabaseDecorator.
+ * 
+ * Test is written to be tolerant of other databases in the system.
+ * 
  */
 public class BootAllTest  extends BaseJDBCTestCase {
-
-    private Driver driver;
-    private String databases[] = new String[] {"wombat1", "wombat2", "wombat3"};
     
-    final static String DATABASE_SHUT_DOWN = "08006";
-    final static String ALL_DATABASES_SHUT_DOWN = "XJ015";
+    public static Test suite() {
+        
+        TestSuite suite = new TestSuite("BootAllTest");
+        
+        // Test uses driver manager so JDBC 2 required.
+        if (JDBC.vmSupportsJDBC2())
+        {           
+            // Suite to create the third (inner) database and
+            // perform the actual test (will be run last)
+            TestSuite db3 = new TestSuite("db3");
+            db3.addTest(new BootAllTest("createShutdownDatabase"));
+            db3.addTest(new BootAllTest("shutdownDerby"));
+            
+            Properties ba = new Properties();
+            ba.setProperty("derby.system.bootAll", "true");
+            
+            db3.addTest(new SystemPropertyTestSetup(
+                    new BootAllTest("testSettingBootAllPropertyWithHomePropertySet"),
+                    ba));
+            
+            // Suite to create the second database (middle) and
+            // embed in it the third database suite.
+            TestSuite db2 = new TestSuite("db2");
+            db2.addTest(new BootAllTest("createShutdownDatabase"));
+            db2.addTest(TestConfiguration.singleUseDatabaseDecorator(db3));
+            
+            // Suite to create the first database (outer) and
+            // embed in it the second database suite.
+            TestSuite db1 = new TestSuite("db1");
+            db1.addTest(new BootAllTest("createShutdownDatabase"));
+            db1.addTest(TestConfiguration.singleUseDatabaseDecorator(db2));
+            
+            // Add the default database in as well, this will ensure
+            // that databases at the root level get booted as well
+            // as those at sub-levels
+            suite.addTest(new BootAllTest("createShutdownDatabase"));
+            
+            // add the first database into the actual suite.
+            suite.addTest(TestConfiguration.singleUseDatabaseDecorator(db1)); 
+        }
+        
+        return suite;
+    }
+
 
     /**
      * Creates a new instance of BootAllTest
@@ -49,47 +105,18 @@
     public BootAllTest(String name) {
         super(name);
     }
-
-    /**
-     * Create the databases
-     */
-    public void setUp() throws Exception {
-        for (int i = 0; i < databases.length; i++) {
-            Connection con = openConnection(databases[i]);
-            con.close();
-            try {
-                openConnection(databases[i] + ";shutdown=true");
-            } catch (SQLException se) {
-                assertEquals("Expected exception on setUp " + se.getSQLState(), 
-                        DATABASE_SHUT_DOWN, se.getSQLState());
-            }
-        }
-        String url = getTestConfiguration().getJDBCUrl("");
-        driver = DriverManager.getDriver(url);
-        DriverManager.deregisterDriver(driver);
-        try {
-            driver.connect(url + ";shutdown=true", null);
-        } catch (SQLException se) {
-            assertEquals("Expected exception on tearDown " + se.getSQLState(), 
-                    ALL_DATABASES_SHUT_DOWN, se.getSQLState());
-        }
+    
+    public void createShutdownDatabase() throws SQLException
+    {
+        getConnection().close();
+        getTestConfiguration().shutdownDatabase();
+    }
+    
+    public void shutdownDerby() {
+        getTestConfiguration().shutdownEngine();
         System.runFinalization();
         System.gc();
-    }
 
-    /**
-     * Shutdown all databases
-     */
-    public void tearDown() throws Exception {
-        String driverName = getTestConfiguration().getJDBCClient().getJDBCDriverName();
-        Class.forName(driverName);
-        println("Teardown of: " + getName());
-        try {
-            openConnection(";shutdown=true");
-        } catch (SQLException se) {
-            assertEquals("Expected exception on tearDown " + se.getSQLState(), 
-                    ALL_DATABASES_SHUT_DOWN, se.getSQLState());
-        }
     }
 
     /**
@@ -105,37 +132,37 @@
     public void testSettingBootAllPropertyWithHomePropertySet() 
             throws Exception 
     {
-        String returnedDatabases[] = null;
-
-        setSystemProperty("derby.system.bootAll", "true");
+        JDBCClient embedded = getTestConfiguration().getJDBCClient();
 
-        String driverName = getTestConfiguration().getJDBCClient().getJDBCDriverName();
-        String url = getTestConfiguration().getJDBCUrl("");
+        String driverName = embedded.getJDBCDriverName();
+        String url = embedded.getUrlBase();
+        
+        // Ensure the engine is not booted.
+        try {
+            DriverManager.getDriver(url);
+            fail("Derby is booted!");
+        } catch (SQLException e) {
+       }
 
         Class.forName(driverName).newInstance();
-        DriverManager.registerDriver(driver);
 
         Driver driver = DriverManager.getDriver(url);
 
         DriverPropertyInfo[] attributes = driver.getPropertyInfo(url, null);
+        
+        String returnedDatabases[] = null;
         for (int i = 0; i < attributes.length; i++) {
             if (attributes[i].name.equalsIgnoreCase("databaseName")) {
                 returnedDatabases = attributes[i].choices;
             }
         }
-
-        Arrays.sort(returnedDatabases);
-
-        assertEquals("The number of databases should be", 
-                databases.length, 
-                returnedDatabases.length);
-
-        for (int i = 0; i < databases.length; i++) {
-            assertEquals("Database names should be", 
-                    databases[i], 
-                    returnedDatabases[i]);
-        }
-
+        
+        // We expect at least four databases to be booted,
+        // but it could be more if other tests have left databases
+        // around.
+        assertNotNull(returnedDatabases);
+        assertTrue("Fewer databases booted than expected",
+                returnedDatabases.length >= 1);
     }
     
 }

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?view=auto&rev=473175
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
Thu Nov  9 19:36:32 2006
@@ -0,0 +1,56 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.store._Suite
+
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License
+*/
+package org.apache.derbyTesting.functionTests.tests.store;
+
+import org.apache.derbyTesting.junit.BaseTestCase;
+import junit.framework.Test; 
+import junit.framework.TestSuite;
+
+/**
+ * Suite to run all JUnit tests in this package:
+ * org.apache.derbyTesting.functionTests.tests.lang
+ * <P>
+ * All tests are run "as-is", just as if they were run
+ * individually. Thus this test is just a collection
+ * of all the JUNit tests in this package (excluding itself).
+ * While the old test harness is in use, some use of decorators
+ * may be required.
+ *
+ */
+public class _Suite extends BaseTestCase  {
+
+    /**
+     * Use suite method instead.
+     */
+    private _Suite(String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+
+        TestSuite suite = new TestSuite("store");
+        
+        suite.addTest(BootAllTest.suite());
+        
+        return suite;
+    }
+}
\ No newline at end of file

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=473175&r1=473174&r2=473175
==============================================================================
--- 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 Nov  9 19:36:32 2006
@@ -30,7 +30,7 @@
  * Shutdown and drop the current database at tearDown time.
  *
  */
-class DropDatabaseSetup extends TestSetup {
+class DropDatabaseSetup extends BaseJDBCTestSetup {
 
     DropDatabaseSetup(Test test) {
         super(test);
@@ -39,7 +39,11 @@
     /**
      * Drop the current database.
      */
-    protected void tearDown() throws Exception {  
+    protected void tearDown() throws Exception {
+        
+        // Ensure the database is booted
+        // since that is what shutdownDatabase() requires.
+        getConnection().close();
         super.tearDown();
         
         TestConfiguration.getCurrent().shutdownDatabase();



Mime
View raw message