Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 11297 invoked from network); 25 Aug 2006 21:22:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 Aug 2006 21:22:23 -0000 Received: (qmail 90316 invoked by uid 500); 25 Aug 2006 21:22:23 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 90293 invoked by uid 500); 25 Aug 2006 21:22:23 -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 90279 invoked by uid 99); 25 Aug 2006 21:22:23 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Aug 2006 14:22:23 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Aug 2006 14:22:21 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 813871A981A; Fri, 25 Aug 2006 14:22:01 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060825212201.813871A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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: + *
    + *
  • tests.lang + *
  • tests.jdbcapi + *
  • tests.tools + *
  • tests.jdbc4 (Java SE 6 only) + *
+ */ +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: + *
    + *
  • suites.AllPackages + *
+ */ +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: + *
    + *
  • suites.AllPackages + *
+ */ +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 @@ - + - + + + + + + + + + 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;