db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r436957 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/suites/ junit/
Date Fri, 25 Aug 2006 21:21:59 GMT
Author: djd
Date: Fri Aug 25 14:21:58 2006
New Revision: 436957

URL: http://svn.apache.org/viewvc?rev=436957&view=rev
Log:
DERBY-1555 (partial) Add some top level JUnit suites that run all the tests in the packages
(AllPackages),
all the tests in Embedded and (Derby) Client configurations and run All the configurations.
Also adds the logic in TestConfiguration to switch configurations to Client.
Just a checkpoint (incremental development), more work needed, see some failures running All.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Client.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Embedded.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Added: 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?rev=436957&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java
Fri Aug 25 14:21:58 2006
@@ -0,0 +1,50 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.suites.All
+
+   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.suites;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseTestCase;
+
+public class All extends BaseTestCase {
+      
+    /**
+     * Use suite method instead.
+     */
+    private All(String name) {
+        super(name);
+    }
+
+    public static Test suite() throws Exception {
+
+        TestSuite suite = new TestSuite("All");
+        
+        // All embedded tests
+        suite.addTest(Embedded.suite());
+        
+        // All Derby client tests
+        suite.addTest(Client.suite());
+
+        return suite;
+        
+    }
+}

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

Added: 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?rev=436957&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
Fri Aug 25 14:21:58 2006
@@ -0,0 +1,83 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.suites.AllPackages
+
+   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.suites;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+
+/**
+ * All package suites for the function tests.
+ * 
+ * Suites added:
+ * <UL>
+ * <LI> tests.lang
+ * <LI> tests.jdbcapi
+ * <LI> tests.tools
+ * <LI> tests.jdbc4 (Java SE 6  only)
+ * </UL>
+ */
+public class AllPackages extends BaseTestCase {
+    /**
+     * Use suite method instead.
+     */
+    private AllPackages(String name) {
+        super(name);
+    }
+
+    public static Test suite() throws Exception {
+
+        TestSuite suite = new TestSuite("AllPackages");
+        
+        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.tools._Suite.suite());
+
+        // Suites that are compiled using Java SE 6 target need to
+        // be added this way, otherwise creating the suite
+        // will throw an invalid class version error
+        if (JDBC.vmSupportsJDBC4())
+        {
+            suite.addTest(
+                    addSuiteByReflection(
+                            "org.apache.derbyTesting.functionTests.tests.jdbc4._Suite"));
+        }
+
+        return suite;
+    }
+    
+    /**
+     * Get a class's set of tests from its suite method through reflection.
+     */
+    private static Test addSuiteByReflection(String className) throws Exception
+    {
+        Class clz = Class.forName(className);
+        
+        Method sm = clz.getMethod("suite", null);
+              
+        return (Test) sm.invoke(null, null);
+    }
+
+}

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

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Client.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Client.java?rev=436957&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Client.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Client.java
Fri Aug 25 14:21:58 2006
@@ -0,0 +1,57 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.suites.Client
+
+   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.suites;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * All function tests running in Derby Client.
+ * 
+ * Suites added:
+ * <UL>
+ * <LI> suites.AllPackages
+ * </UL>
+ */
+class Client extends BaseTestCase {
+    /**
+     * Use suite method instead.
+     */
+    private Client(String name) {
+        super(name);
+    }
+
+    public static Test suite() throws Exception {
+
+        TestSuite suite = new TestSuite("Client");
+        
+        // Run all the packages tests under the Derby client
+        suite.addTest(TestConfiguration.derbyClientServerDecorator(AllPackages.class));
+       
+        return suite;
+    }
+}

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

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Embedded.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Embedded.java?rev=436957&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Embedded.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/Embedded.java
Fri Aug 25 14:21:58 2006
@@ -0,0 +1,53 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.suites.Embedded
+
+   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.suites;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseTestCase;
+
+/**
+ * All function tests running in Embedded.
+ * 
+ * Suites added:
+ * <UL>
+ * <LI> suites.AllPackages
+ * </UL>
+ */
+class Embedded extends BaseTestCase {
+    /**
+     * Use suite method instead.
+     */
+    private Embedded(String name) {
+        super(name);
+    }
+
+    public static Test suite() throws Exception {
+
+        TestSuite suite = new TestSuite("Embedded");
+        
+        // Run all the tests under the default embedded configuration
+        suite.addTest(AllPackages.suite());
+        
+        return suite;
+    }
+}

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/build.xml?rev=436957&r1=436956&r2=436957&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/build.xml
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/build.xml
Fri Aug 25 14:21:58 2006
@@ -36,13 +36,34 @@
   <property file="${properties.dir}/compilepath.properties"/> 
 
 <!-- Targets -->
-  <target name="suites" depends="copyfiles"/>
+  <target name="suites" depends="junitsuites,copyfiles"/>
 
   <target name="copyfiles">
     <copy todir="${out.dir}/${derby.testing.suites.dir}">
       <fileset dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/suites" includes="*.runall,*.properties,*.exclude,*.policy"/>
     </copy>
   </target>
-
+	  <target name="junitsuites" 
+	          description="Build Derby JUnit suites">
+	    <javac
+	      source="1.3"
+	      target="1.3"
+	      bootclasspath="${empty}"
+	      nowarn="on"
+	      debug="${debug}"
+	      depend="${depend}"
+	      deprecation="${deprecation}"
+	      optimize="${optimize}"
+	      proceed="${proceed}"
+	      verbose="${verbose}" 
+	      srcdir="${derby.testing.src.dir}"
+	      destdir="${out.dir}">
+	      <classpath>
+	        <pathelement path="${compile.classpath}"/>
+	        <pathelement path="${junit}"/>
+	      </classpath>
+	      <include name="${derby.testing.functest.dir}/suites/*.java"/>
+	    </javac>
+	  </target>
 </project>
 

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java?rev=436957&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java
Fri Aug 25 14:21:58 2006
@@ -0,0 +1,27 @@
+package org.apache.derbyTesting.junit;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+final class ChangeConfigurationSetup extends TestSetup {
+    
+    private final TestConfiguration config;
+    private TestConfiguration old;
+    
+    ChangeConfigurationSetup(TestConfiguration config, Test test)
+    {
+        super(test);
+        this.config = config;
+    }
+    
+    protected void setUp()
+    {
+        old = TestConfiguration.getCurrent();
+        TestConfiguration.setCurrent(config);
+    }
+    
+    protected void tearDown()
+    {
+        TestConfiguration.setCurrent(old);
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=436957&r1=436956&r2=436957&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
Fri Aug 25 14:21:58 2006
@@ -20,6 +20,7 @@
 package org.apache.derbyTesting.junit;
 
 import java.io.File;
+import java.lang.reflect.Method;
 import java.security.*;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -67,12 +68,11 @@
      * Set this Thread's current configuration for running tests.
      * @param config Configuration to set it to.
      */
-    private static void setCurrent(TestConfiguration config)
+    static void setCurrent(TestConfiguration config)
     {
         CURRENT_CONFIG.set(config);
     }
     /**
-     * WORK IN PROGRESS
      * 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 and shut it
@@ -84,19 +84,67 @@
      * The previous TestConfiguration is restored at tearDown.
      * @param tests
      * @return
+     * @throws Exception 
      */
-    public static Test derbyClientServerDecorator(Test tests)
+    public static Test derbyClientServerDecorator(Class suite) throws Exception
     {
         TestConfiguration config = TestConfiguration.getCurrent();
         
-        // Already in the correct configuration, do nothing.
-        if (config.getJDBCClient().isDerbyNetClient())
-            return tests;
+        TestConfiguration derbyClientConfig =
+            new TestConfiguration(config, JDBCClient.DERBYNETCLIENT,
+                    DEFAULT_HOSTNAME, DEFAULT_PORT);
+        
+        TestConfiguration.setCurrent(derbyClientConfig);
         
-        TestConfiguration derbyClientConfig = null;
-            // new TestConfiguration(config, JDBCClient.DERBYNETCLIENT);
+        Test test = addSuiteByReflection(suite);
         
-        return null;
+        TestConfiguration.setCurrent(config);
+            
+        test = new NetworkServerTestSetup(test);
+            
+        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);
+    }  
+    
+    
+    /**
+     * Default embedded configuration
+     *
+     */
+    private TestConfiguration() {
+        this.dbName = DEFAULT_DBNAME;
+        this.userName = DEFAULT_USER_NAME;
+        this.userPassword = DEFAULT_USER_PASSWORD;
+        this.hostName = null;
+        this.port = -1;
+        this.singleLegXA = false;
+        
+        this.jdbcClient = JDBCClient.EMBEDDED;
+        url = createJDBCUrlWithDatabaseName(dbName);
+ 
+    }
+    
+    private TestConfiguration(TestConfiguration copy, JDBCClient client,
+            String hostName, int port)
+    {
+        this.dbName = copy.dbName;
+        this.userName = copy.userName;
+        this.userPassword = copy.userPassword;
+
+        this.isVerbose = copy.isVerbose;
+        this.singleLegXA = copy.singleLegXA;
+        this.port = port;
+        
+        this.jdbcClient = client;
+        this.hostName = hostName;
+        
+        this.url = createJDBCUrlWithDatabaseName(dbName);
     }
 
     /**
@@ -106,7 +154,7 @@
      */
     private TestConfiguration(Properties props) 
         throws NumberFormatException {
-		systemStartupProperties = props;
+
         dbName = props.getProperty(KEY_DBNAME, DEFAULT_DBNAME);
         userName = props.getProperty(KEY_USER_NAME, DEFAULT_USER_NAME);
         userPassword = props.getProperty(KEY_USER_PASSWORD, 
@@ -141,14 +189,6 @@
     }
 
     /**
-     * Get the given system property as specified at startup.
-     */
-	private	String	getSystemStartupProperty( String key )
-	{
-		return systemStartupProperties.getProperty( key );
-	}
-
-    /**
      * Get the system properties in a privileged block.
      *
      * @return the system properties.
@@ -390,7 +430,6 @@
     /**
      * Immutable data members in test configuration
      */
-	private	final Properties systemStartupProperties;
     private final String dbName;
     private final String url;
     private final String userName; 



Mime
View raw message