Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 52ECCF3FB for ; Thu, 4 Apr 2013 09:04:57 +0000 (UTC) Received: (qmail 89127 invoked by uid 500); 4 Apr 2013 09:04:57 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 89109 invoked by uid 500); 4 Apr 2013 09:04:57 -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 89099 invoked by uid 99); 4 Apr 2013 09:04:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Apr 2013 09:04:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Apr 2013 09:04:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3D42123889BB; Thu, 4 Apr 2013 09:04:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1464373 - in /db/derby/code/branches/10.9: ./ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ClosedObjectTest.java Date: Thu, 04 Apr 2013 09:04:33 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130404090433.3D42123889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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");