You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2007/02/05 23:44:41 UTC
svn commit: r503909 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting:
functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
functionTests/util/HarnessJavaTest.java junit/SystemPropertyTestSetup.java
Author: djd
Date: Mon Feb 5 14:44:40 2007
New Revision: 503909
URL: http://svn.apache.org/viewvc?view=rev&rev=503909
Log:
Add a JUnit "adapter" test that runs old harness ".java" tests comparing them to a single canon/master
file much like the ScriptTestCase class. Add an concrete implementation for the ".java" tests in
jdbcapi. Currently an experiment/work in progress, is not hooked into the suites.All and none of the tests
listed by JDBCHarnessJavaTest are removed from being run with the old harness.
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java (with props)
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java?view=auto&rev=503909
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java Mon Feb 5 14:44:40 2007
@@ -0,0 +1,123 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.jdbcapi.JDBCHarnessJavaTest
+
+ 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.jdbcapi;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.functionTests.util.HarnessJavaTest;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Run a jdbcapi '.java' test from the old harness in the Junit infrastructure.
+ * The test's output is compared to a master file using the facilities
+ * of the super class CanonTestCase.
+ * <BR>
+ * This allows a faster switch to running all tests under a single
+ * JUnit infrastructure. Running a test using this class does not
+ * preclude it from being converted to a real JUnit assert based test.
+ *
+ */
+public class JDBCHarnessJavaTest extends HarnessJavaTest {
+
+ /**
+ * Tests that run in both client and embedded.
+ * Ideally both for a test of JDBC api functionality.
+ */
+ private static final String[] JDBCAPI_TESTS_BOTH =
+ {
+ // from old jdbc20.runall
+ // "batchUpdate", runs in embedded only
+ "connectionJdbc20",
+ // "statementJdbc20", runs in embedded only
+ "resultsetJdbc20",
+ "StmtCloseFunTest",
+ // "dataSourceReference",
+
+ // from old jdbcapi.runall
+ // "checkDriver", TODO: investigate failure/convert
+ "derbyStress",
+ // "nullSQLText", TODO: investigate failure/convert
+ "prepStmtMetaData",
+ //"resultset", TODO: investigate failure/convert
+ // "resultsetStream", TODO: investigate failure/convert needs ext files
+ "maxfieldsize",
+ //"LOBTest", TODO: investigate failure/convert
+ // "parameterMapping", TODO: investigate failure/convert
+ // "setTransactionIsolation", TODO: investigate failure/convert
+ "SetQueryTimeoutTest",
+ "prepStmtNull",
+ "testRelative",
+ "rsgetXXXcolumnNames",
+
+ // from old jdk14.runall
+ //"autoGeneratedJdbc30", TODO: investigate failure/convert
+ //"checkDataSource30", TODO: investigate failure/convert
+ "parameterMetaDataJdbc30",
+ // "statementJdbc30", runs in embedded only
+ "savepointJdbc30_JSR169",
+ "savepointJdbc30_XA",
+
+ // from old xa.runall
+ //"checkDataSource", TODO: investigate failure/convert
+ "dataSourcePermissions",
+ //"XATest" TODO: investigate failure/convert
+ };
+
+ /**
+ * Tests that only run in embedded.
+ */
+ private static final String[] JDBCAPI_TESTS_EMEBDDED=
+ {
+ // excluded from derby client in old harness
+ "batchUpdate",
+ "statementJdbc20",
+ "statementJdbc30",
+ };
+
+ private JDBCHarnessJavaTest(String name) {
+ super(name);
+ }
+
+ protected String getArea() {
+ return "jdbcapi";
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("jdbcapi: old harness java tests");
+ suite.addTest(baseSuite("embedded", JDBCAPI_TESTS_BOTH));
+ suite.addTest(baseSuite("embedded", JDBCAPI_TESTS_EMEBDDED));
+
+ //suite.addTest(TestConfiguration.clientServerDecorator(
+ // baseSuite("clientserver", JDBCAPI_TESTS_BOTH)));
+ return suite;
+ }
+
+ private static Test baseSuite(String which, String[] set) {
+ TestSuite suite = new TestSuite("jdbcapi: " + which);
+ for (int i = 0; i < set.length; i++)
+ {
+ suite.addTest(decorate(new JDBCHarnessJavaTest(set[i])));
+ }
+ return suite;
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java?view=auto&rev=503909
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java Mon Feb 5 14:44:40 2007
@@ -0,0 +1,138 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.util.HarnessJavaTest
+
+ 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.util;
+
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.util.Properties;
+
+import junit.framework.Test;
+
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
+import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Run a '.java' test from the old harness in the Junit infrastructure.
+ * The test's output is compared to a master file using the facilities
+ * of the super class CanonTestCase.
+ * <BR>
+ * This allows a faster switch to running all tests under a single
+ * JUnit infrastructure. Running a test using this class does not
+ * preclude it from being converted to a real JUnit assert based test.
+ *
+ */
+public abstract class HarnessJavaTest extends CanonTestCase {
+
+ private static final Object[] MAIN_ARG = new Object[] {new String[0]};
+ private static final Class[] MAIN_ARG_TYPE = new Class[] {MAIN_ARG[0].getClass()};
+
+ /**
+ * Create a test, the name corresonds to the class name
+ * of the test (without any package information).
+ * @param name
+ */
+ protected HarnessJavaTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Return the folder of the test, such as 'jdbcapi' or 'lang'.
+ * @return
+ */
+ protected abstract String getArea();
+
+ public void runTest() throws Throwable
+ {
+
+ String testClassName =
+ "org.apache.derbyTesting.functionTests.tests."
+ + getArea() + "." + getName();
+
+
+ String canon =
+ "org/apache/derbyTesting/functionTests/master/"
+ + getName() + ".out";
+
+
+ PrintStream out = System.out;
+ PrintStream testOut = new PrintStream(getOutputStream());
+ setSystemOut(testOut);
+
+ Class test = Class.forName(testClassName);
+
+ Method main = test.getDeclaredMethod("main", MAIN_ARG_TYPE);
+
+ main.invoke(null, MAIN_ARG);
+
+ setSystemOut(out);
+
+ compareCanon(canon);
+ }
+
+ /**
+ * Decorate a HarnessJavaTest test. Any sub-class must
+ * call this decorator when adding a test to a suite.
+ * This sets up the ij system properties to setup
+ * the default connection to be to the default database.
+ * The lock timeouts are also shortened and the test
+ * will start in a clean database.
+ */
+ protected static Test decorate(HarnessJavaTest test)
+ {
+ Test dtest = new SystemPropertyTestSetup(test, new Properties())
+ {
+ protected void setUp() throws java.lang.Exception
+ {
+ newValues.setProperty(
+ "ij.database",
+ TestConfiguration.getCurrent().getJDBCUrl());
+ super.setUp();
+ }
+ };
+
+ dtest = DatabasePropertyTestSetup.setLockTimeouts(dtest, 4, 6);
+ dtest = new CleanDatabaseTestSetup(dtest);
+
+ return dtest;
+ }
+
+ /**
+ * Need to capture System.out so that we can compare it.
+ * @param out
+ */
+ private void setSystemOut(final PrintStream out)
+ {
+ AccessController.doPrivileged
+ (new java.security.PrivilegedAction(){
+
+ public Object run(){
+ System.setOut(out);
+ return null;
+
+ }
+
+ }
+ );
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/HarnessJavaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java?view=diff&rev=503909&r1=503908&r2=503909
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java Mon Feb 5 14:44:40 2007
@@ -34,7 +34,7 @@
*/
public class SystemPropertyTestSetup extends TestSetup {
- private Properties newValues;
+ protected Properties newValues;
private Properties oldValues;
/**