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/01/11 19:25:11 UTC
svn commit: r495318 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests:
suites/jdbc40.runall tests/jdbc4/VerifySignatures.java
tests/jdbc4/_Suite.java
Author: djd
Date: Thu Jan 11 10:25:10 2007
New Revision: 495318
URL: http://svn.apache.org/viewvc?view=rev&rev=495318
Log:
DERBY-1952 (partial) Refactor VerifySignatures to run as a single test case per
configuration and thus not rely on the old test harness. Added the test to
jdbc4._Suite and removed from the old jdbc40 harness suite.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall?view=diff&rev=495318&r1=495317&r2=495318
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall Thu Jan 11 10:25:10 2007
@@ -3,4 +3,3 @@
jdbc4/TestResultSetMethods.java
jdbc4/AutoloadBooting.junit
jdbc4/AutoloadTest.junit
-jdbc4/VerifySignatures.junit
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java?view=diff&rev=495318&r1=495317&r2=495318
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/VerifySignatures.java Thu Jan 11 10:25:10 2007
@@ -32,7 +32,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.derbyTesting.functionTests.util.TestUtil;
-import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.BaseTestCase;
import org.apache.derbyTesting.junit.J2EEDataSource;
import org.apache.derbyTesting.junit.JDBCDataSource;
import org.apache.derbyTesting.junit.TestConfiguration;
@@ -41,8 +41,12 @@
* JUnit test which checks that all methods specified by the
* interfaces in JDBC 4.0 are implemented. The test requires JVM 1.6
* to run.
+ * Even though this class uses JDBC it extends BaseTestCase as
+ * it handles getting connections itself and thus does not
+ * need the utility methods or connecion handlng provided by
+ * BaseJDBCTestCase.
*/
-public class VerifySignatures extends BaseJDBCTestCase {
+public class VerifySignatures extends BaseTestCase {
/**
* All the java.sql and javax.sql interfaces specified by JDBC 4.0.
@@ -89,17 +93,23 @@
/**
* Creates a new instance.
*/
- public VerifySignatures() {
- super("VerifySignatures");
+ public VerifySignatures(String name) {
+ super(name);
}
/**
* Build a suite of tests to be run.
*
* @return a test suite
- * @exception SQLException if a database error occurs
*/
- public static Test suite() throws SQLException {
+ public static Test suite() {
+
+ return TestConfiguration.defaultSuite(VerifySignatures.class);
+ }
+
+ public void testAllJDBCObjects()
+ throws NoSuchMethodException, SQLException
+ {
// set of all implementation/interface pairs found
Set<ClassInfo> classes = new HashSet<ClassInfo>();
@@ -110,8 +120,6 @@
DriverManager.getDriver(TestConfiguration.getCurrent().getJDBCUrl()).getClass(),
java.sql.Driver.class);
- TestSuite suite = new TestSuite("VerifySignatures suite");
-
// all interfaces for which tests have been generated
Set<Class> interfaces = new HashSet<Class>();
@@ -126,12 +134,22 @@
}
}
for (Method method : methods) {
- suite.addTest(new MethodTestCase(pair.derbyImplementation,
- method));
+ checkImplementationMethod(pair.derbyImplementation,
+ method);
}
}
- suite.addTest(new InterfaceCoverageTestCase(interfaces));
- return suite;
+
+ // Now ensure all interfaces were covered.
+ // get the declared set of interfaces Derby is
+ // expected to implement.
+ Set<Class> jdbcInterfaces = getInterfacesToCheck();
+
+ // remove from it all that were tested.
+ jdbcInterfaces.removeAll(interfaces);
+
+ // and the resultin set should be empty if we tested all!
+ assertTrue("Unchecked interfaces: " + jdbcInterfaces,
+ jdbcInterfaces.isEmpty());
}
/**
@@ -344,41 +362,7 @@
}
return set;
}
-
- /**
- * Test case which checks that a class implements a specific
- * method.
- */
- private static class MethodTestCase extends TestCase {
- /** The Derby implementation class which is tested. */
- private final Class derbyImplementation;
- /** The method that should be implemented. */
- private final Method ifaceMethod;
-
- /**
- * Creates a new <code>MethodTestCase</code> instance.
- *
- * @param imp the class to test
- * @param method the method to look for
- */
- private MethodTestCase(Class imp, Method method) {
- super("MethodTestCase{Class=" + imp.getName() +
- ",Method=" + method + "}");
- derbyImplementation = imp;
- ifaceMethod = method;
- }
-
- /**
- * Run the test. Check that the method is implemented and that
- * its signature is correct.
- *
- * @exception NoSuchMethodException if the method is not found
- */
- public void runTest() throws NoSuchMethodException {
- checkImplementationMethod(derbyImplementation, ifaceMethod);
- }
- }
-
+
/**
* checks that a class implements a specific method.
* @param derbyImplementation The Derby implementation class which is tested
@@ -437,28 +421,14 @@
return null;
}
- /**
- * Test case which checks that all relevant JDBC interfaces are
- * covered by the test.
- */
- private static class InterfaceCoverageTestCase extends TestCase {
-
- /** The interfaces that have been tested by
- * <code>MethodTestCase</code>. */
- private final Set<Class> checkedInterfaces;
- /** All JDBC interfaces whose implementations are relevant to
- * test. */
- private final Set<Class> jdbcInterfaces;
-
/**
- * Creates a new <code>InterfaceCoverageTestCase</code> instance.
+ * Returns the declared set of JDBC interfaces that
+ * Derby implements.
*
- * @param interfaces the interfaces that have been tested
*/
- private InterfaceCoverageTestCase(Set<Class> interfaces) {
- super("InterfaceCoverageTestCase");
- checkedInterfaces = interfaces;
- jdbcInterfaces = new HashSet<Class>(Arrays.asList(JDBC_INTERFACES));
+ private static Set<Class> getInterfacesToCheck() {
+
+ Set<Class> jdbcInterfaces = new HashSet<Class>(Arrays.asList(JDBC_INTERFACES));
// Remove the interfaces that we know we haven't checked.
@@ -483,18 +453,9 @@
// application code, not in Derby code.
jdbcInterfaces.remove(javax.sql.ConnectionEventListener.class);
jdbcInterfaces.remove(javax.sql.StatementEventListener.class);
+
+ return jdbcInterfaces;
}
-
- /**
- * Run the test. Check that all relevant interfaces have been
- * tested.
- */
- public void runTest() {
- jdbcInterfaces.removeAll(checkedInterfaces);
- assertTrue("Unchecked interfaces: " + jdbcInterfaces,
- jdbcInterfaces.isEmpty());
- }
- }
/**
* Data structure holding a Derby implementation class and the
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java?view=diff&rev=495318&r1=495317&r2=495318
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java Thu Jan 11 10:25:10 2007
@@ -69,11 +69,7 @@
suite.addTest(TestJDBC40Exception.suite());
suite.addTest(UnsupportedVetter.suite());
suite.addTest(XA40Test.suite());
-
- // This test is a little strange in its suite
- // method in that it accesses
- // the database to determine the set of tests to run.
- // suite.addTest(VerifySignatures.suite());
+ suite.addTest(VerifySignatures.suite());
return suite;
}