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 ka...@apache.org on 2013/04/04 11:04:33 UTC
svn commit: r1464373 - in /db/derby/code/branches/10.9: ./
java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ClosedObjectTest.java
Author: kahatlen
Date: Thu Apr 4 09:04:32 2013
New Revision: 1464373
URL: http://svn.apache.org/r1464373
Log:
DERBY-6147: ClosedObjectTest fails on the 10.9 branch when running on Java 8
Merged revision 1464367 from trunk.
Modified:
db/derby/code/branches/10.9/ (props changed)
db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ClosedObjectTest.java
Propchange: db/derby/code/branches/10.9/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1464367
Modified: db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ClosedObjectTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ClosedObjectTest.java?rev=1464373&r1=1464372&r2=1464373&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ClosedObjectTest.java (original)
+++ db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ClosedObjectTest.java Thu Apr 4 09:04:32 2013
@@ -91,8 +91,26 @@ public class ClosedObjectTest extends Ba
try {
Object object = decorator_.getClosedObject();
+ String implClassName = object.getClass().getName();
+
// update name of test with real class name
- name_ = object.getClass() + "." + method_.getName();
+ name_ = implClassName + "." + method_.getName();
+
+ // DERBY-6147: If the test runs on a newer version of the JVM
+ // than the JDBC driver supports, we should skip those methods
+ // that are not implemented.
+ //
+ // Limit the check to platforms that support JDBC 4 or higher
+ // since the isImplemented() method uses a method only available
+ // in Java 5 and higher. We know that all JDBC 3 and JSR-169
+ // methods are implemented, so no tests need to be skipped on
+ // those older platforms anyway.
+ if (JDBC.vmSupportsJDBC4() && !isImplemented()) {
+ println("Skipping testing of " + method_ + " on " +
+ implClassName + " because it is not implemented");
+ name_ += "_SKIPPED";
+ return;
+ }
method_.invoke(object,
getNullArguments(method_.getParameterTypes()));
@@ -114,6 +132,34 @@ public class ClosedObjectTest extends Ba
}
}
+ /**
+ * Check if the JDBC interface method tested by this test case is
+ * actually implemented by the Derby object being tested.
+ */
+ private boolean isImplemented() throws NoSuchMethodException {
+ // Check if the method is implemented in one of the Derby classes
+ // that the JDBC object belongs to.
+ for (Class c = decorator_.getClosedObject().getClass();
+ c != null; c = c.getSuperclass()) {
+ if (c.getName().startsWith("org.apache.derby.")) {
+ try {
+ Method m = c.getDeclaredMethod(
+ method_.getName(), method_.getParameterTypes());
+ if (!m.isSynthetic()) {
+ // Found a real implementation of the method.
+ return true;
+ }
+ } catch (NoSuchMethodException e) {
+ // Method was not declared in this class. Try again in
+ // the superclass.
+ }
+ }
+ }
+
+ // No implementation was found.
+ return false;
+ }
+
/** Creates a suite with all tests in the class. */
public static Test suite() {
TestSuite suite = new TestSuite("ClosedObjectTest suite");