db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r464607 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/suites/ functionTests/tests/lang/ junit/
Date Mon, 16 Oct 2006 18:19:54 GMT
Author: djd
Date: Mon Oct 16 11:19:53 2006
New Revision: 464607

URL: http://svn.apache.org/viewvc?view=rev&rev=464607
Log:
DERBY-1952 (partial) Setup methods in TestConfiguration to allow tests' suite() methods to
add tests that
run in the client/server configuration. Change TimeHandlingTest and LangScripts to use these
methods
so that by themselves they run embedded and network server tests.
Remove the Client and Embedded top-level suites as that choice is now driven into a test itself.

Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Client.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Embedded.java
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java?view=diff&rev=464607&r1=464606&r2=464607
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java
Mon Oct 16 11:19:53 2006
@@ -38,13 +38,9 @@
 
         TestSuite suite = new TestSuite("All");
         
-        // All embedded tests
-        suite.addTest(Embedded.suite());
+        // All package tests
+        suite.addTest(AllPackages.suite());
         
-        // All Derby client tests
-        suite.addTest(Client.suite());
-
         return suite;
-        
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java?view=diff&rev=464607&r1=464606&r2=464607
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
Mon Oct 16 11:19:53 2006
@@ -24,6 +24,7 @@
 
 import org.apache.derbyTesting.functionTests.util.ScriptTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * LangScripts runs SQL scripts (.sql files) in the lang package
@@ -48,7 +49,8 @@
 		};
 
     /**
-     * Language SQL scripts (.sql files) that run under Derby's client configurations.
+     * Language SQL scripts (.sql files) that run under Derby's client
+     * and emebdded configurations.
      */
     private static final String[] DERBY_TESTS = {
         "bit2",
@@ -82,15 +84,21 @@
 	 * Return the suite that runs all the langauge SQL scripts.
 	 */
 	public static Test suite() {
+        
         TestSuite suite = new TestSuite();
         suite.addTest(getSuite(SQL_LANGUAGE_TESTS));
+        suite.addTest(getSuite(DERBY_TESTS));
+        suite.addTest(getSuite(EMBEDDED_TESTS));
         
-        if (usingEmbedded() || usingDerbyNetClient())
-            suite.addTest(getSuite(DERBY_TESTS));
-        
-        if (usingEmbedded())
-            suite.addTest(getSuite(EMBEDDED_TESTS));
+        // Set up the scripts run with the network client
+        TestSuite clientTests = new TestSuite();
+        clientTests.addTest(getSuite(SQL_LANGUAGE_TESTS));
+        clientTests.addTest(getSuite(DERBY_TESTS));
+        Test client = TestConfiguration.derbyClientServerDecorator(clientTests);
         
+        // add those client tests into the top-level suite.
+        suite.addTest(client);
+
         return suite;
     }
     

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java?view=diff&rev=464607&r1=464606&r2=464607
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
Mon Oct 16 11:19:53 2006
@@ -37,6 +37,7 @@
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 
 public class TimeHandlingTest extends BaseJDBCTestCase {
@@ -66,10 +67,22 @@
     private Calendar cal;
 
 
+    /**
+     * Runs the tests in the default embedded configuration and then
+     * the client server configuration.
+     * @return
+     */
     public static Test suite()
     {
         TestSuite suite = new TestSuite(TimeHandlingTest.class);
         
+        // Once DERBY-889 is fixed the methods should be renamed
+        // and these lines removed so they are added under the default mechanism.
+        suite.addTest(new TimeHandlingTest("derby889testInertTime"));
+        suite.addTest(new TimeHandlingTest("derby889testCurrentTime"));
+        
+        suite.addTest(TestConfiguration.derbyClientServerDecorator(TimeHandlingTest.class));
+        
         return new CleanDatabaseTestSetup(suite) {
             protected void decorateSQL(Statement s) throws SQLException {
                
@@ -135,10 +148,14 @@
      * fetched and compared to a value calculated from the identifier.
      * The returned values are fetched using checkTimeValue thus inheriting
      * all the checks within that method.
+     * <BR>
+     * Once DERBY-889 is fixed this test should be renamed so that it
+     * loses the prefix derby889 (and the specific adding of this test
+     * in the suite() method removed.
      * @throws SQLException
      * @throws UnsupportedEncodingException 
      */
-    public void testInertTime() throws SQLException, UnsupportedEncodingException
+    public void derby889testInertTime() throws SQLException, UnsupportedEncodingException
     {
         getConnection().setAutoCommit(false);
         // Insert a set of time values, 
@@ -235,10 +252,14 @@
      * that (subject to the resolution) the returned value
      * is correctly between the start time of the statement
      * execution and the first fetch or completion.
+     * <BR>
+     * Once DERBY-889 is fixed this test should be renamed so that it
+     * loses the prefix derby889 (and the specific adding of this test
+     * in the suite() method removed.
      * @throws SQLException
      * @throws InterruptedException 
      */
-    public void testCurrentTime() throws SQLException, InterruptedException
+    public void derby889testCurrentTime() throws SQLException, InterruptedException
     {      
         currentFunctionTests(Types.TIME, CURRENT_TIME_FUNCTIONS);      
     }

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=464607&r1=464606&r2=464607
==============================================================================
--- 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 Oct 16 11:19:53 2006
@@ -29,6 +29,7 @@
 
 import junit.framework.Test;
 import junit.framework.TestCase;
+import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.functionTests.util.TestDataSourceFactory;
 
@@ -110,8 +111,9 @@
         if (BaseTestCase.getSystemProperty("derby.system.home") != null)
             assumeHarness = true;
         
-        // for now always assume harness - still testing this code
-        assumeHarness = true;
+        // If forced into single leg XA, assume harness
+        if (DERBY_HARNESS_CONFIG.isSingleLegXA())
+            assumeHarness = true;
 
         DEFAULT_CONFIG = assumeHarness ? DERBY_HARNESS_CONFIG : JUNIT_CONFIG;
         runningInDerbyHarness = assumeHarness;
@@ -165,33 +167,40 @@
      * The previous TestConfiguration is restored at tearDown.
      * @param tests
      * @return
-     * @throws Exception 
      */
-    public static Test derbyClientServerDecorator(Class suite) throws Exception
+    public static Test derbyClientServerDecorator(Class suiteClass)
+    {           
+        return derbyClientServerDecorator(new TestSuite(suiteClass));
+    }
+    /**
+     * Return a decorator for the passed in tests that sets the
+     * configuration for the client to be Derby's JDBC client
+     * and to start the network server at setUp if it is not
+     * already started.
+     * <BR>
+     * The database configuration (name etc.) is based upon
+     * the previous configuration.
+     * <BR>
+     * The previous TestConfiguration is restored at tearDown.
+     * @param tests
+     * @return
+     */
+    public static Test derbyClientServerDecorator(Test suite)
     {
+        if (JDBC.vmSupportsJSR169())
+            return new TestSuite();
+            
         TestConfiguration config = TestConfiguration.getCurrent();
         
         TestConfiguration derbyClientConfig =
             new TestConfiguration(config, JDBCClient.DERBYNETCLIENT,
                     DEFAULT_HOSTNAME, DEFAULT_PORT);
-        
-        TestConfiguration.setCurrent(derbyClientConfig);
-        
-        Test test = addSuiteByReflection(suite);
-        
-        TestConfiguration.setCurrent(config);
-            
-        test = new NetworkServerTestSetup(test);
+                   
+        Test test = new NetworkServerTestSetup(suite);
             
         return new ChangeConfigurationSetup(derbyClientConfig, test);
 
     }
-    private static Test addSuiteByReflection(Class clz) throws Exception
-    {
-        Method sm = clz.getMethod("suite", null);
-              
-        return (Test) sm.invoke(null, null);
-    }  
     
     public static Test changeUserDecorator(Test test, String user, String password)
     {



Mime
View raw message