Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 27950 invoked from network); 7 Feb 2011 14:55:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Feb 2011 14:55:01 -0000 Received: (qmail 83492 invoked by uid 500); 7 Feb 2011 14:55:01 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 83409 invoked by uid 500); 7 Feb 2011 14:55:00 -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 83230 invoked by uid 99); 7 Feb 2011 14:54:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Feb 2011 14:54:59 +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; Mon, 07 Feb 2011 14:54:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3D7FC23889E5; Mon, 7 Feb 2011 14:54:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1067954 - in /db/derby/code/trunk: java/client/org/apache/derby/jdbc/ java/engine/org/apache/derby/jdbc/ java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ tool... Date: Mon, 07 Feb 2011 14:54:31 -0000 To: derby-commits@db.apache.org From: rhillegas@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110207145432.3D7FC23889E5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rhillegas Date: Mon Feb 7 14:54:31 2011 New Revision: 1067954 URL: http://svn.apache.org/viewvc?rev=1067954&view=rev Log: DERBY-4869: Add JDBC 4.1 getParentLogger() method to Derby's implementations of Driver and CommonDataSource. Added: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver40.java (with props) db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java (with props) db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40Test.java (with props) db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java (with props) db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java (with props) Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource40.java db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java db/derby/code/trunk/tools/jar/dnc.properties db/derby/code/trunk/tools/jar/extraDBMSclasses.properties Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java (original) +++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java Mon Feb 7 14:54:31 2011 @@ -22,6 +22,8 @@ package org.apache.derby.jdbc; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; import javax.sql.DataSource; import org.apache.derby.client.am.ClientMessageId; import org.apache.derby.client.am.SqlException; @@ -76,4 +78,20 @@ public class ClientConnectionPoolDataSou SQLState.UNABLE_TO_UNWRAP), interfaces).getSQLException(); } } + + //////////////////////////////////////////////////////////////////// + // + // INTRODUCED BY JDBC 4.1 IN JAVA 7 + // + //////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() + throws SQLFeatureNotSupportedException + { + throw (SQLFeatureNotSupportedException) + ( + new SqlException( null, new ClientMessageId(SQLState.NOT_IMPLEMENTED), "getParentLogger" ) + ).getSQLException(); + } + } Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource40.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource40.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource40.java (original) +++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource40.java Mon Feb 7 14:54:31 2011 @@ -22,6 +22,8 @@ package org.apache.derby.jdbc; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; import javax.sql.DataSource; import org.apache.derby.client.am.ClientMessageId; import org.apache.derby.client.am.SqlException; @@ -138,5 +140,20 @@ public class ClientDataSource40 extends interfaces).getSQLException(); } } + + //////////////////////////////////////////////////////////////////// + // + // INTRODUCED BY JDBC 4.1 IN JAVA 7 + // + //////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() + throws SQLFeatureNotSupportedException + { + throw (SQLFeatureNotSupportedException) + ( + new SqlException( null, new ClientMessageId(SQLState.NOT_IMPLEMENTED), "getParentLogger" ) + ).getSQLException(); + } } Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java (original) +++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java Mon Feb 7 14:54:31 2011 @@ -47,7 +47,24 @@ public class ClientDriver implements jav // Keep track of the registere driver so that we can deregister it if we're a stored proc. static private ClientDriver registeredDriver__ = null; - static { + static + { + try { + // + // We'd rather load this slightly more capable driver. + // But if the vm level doesn't support it, then we fall + // back on the JDBC3 level driver. + // + Class.forName( "org.apache.derby.jdbc.ClientDriver40" ); + } + catch (Throwable e) + { + registerMe( new ClientDriver() ); + } + } + + protected static void registerMe( ClientDriver me ) + { // This may possibly hit the race-condition bug of java 1.1. // The Configuration static clause should execute before the following line does. if (Configuration.exceptionsOnLoadResources != null) { @@ -57,7 +74,7 @@ public class ClientDriver implements jav exceptionsOnLoadDriver__); } try { - registeredDriver__ = new ClientDriver(); + registeredDriver__ = me; java.sql.DriverManager.registerDriver(registeredDriver__); } catch (java.sql.SQLException e) { // A null log writer is passed, because jdbc 1 sql exceptions are automatically traced Added: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver40.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver40.java?rev=1067954&view=auto ============================================================================== --- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver40.java (added) +++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver40.java Mon Feb 7 14:54:31 2011 @@ -0,0 +1,58 @@ +/* + + Derby - Class org.apache.derby.jdbc.ClientDriver40 + + 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.derby.jdbc; + +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; + +import org.apache.derby.client.am.ClientMessageId; +import org.apache.derby.client.am.SqlException; +import org.apache.derby.shared.common.reference.SQLState; + +/** + *

+ * Adds driver functionality which is only visible from JDBC 4.0 onward. + *

+ */ +public class ClientDriver40 extends ClientDriver +{ + static + { + registerMe( new ClientDriver40() ); + } + + //////////////////////////////////////////////////////////////////// + // + // INTRODUCED BY JDBC 4.1 IN JAVA 7 + // + //////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() + throws SQLFeatureNotSupportedException + { + getFactory(); + throw (SQLFeatureNotSupportedException) + ( + new SqlException( null, new ClientMessageId(SQLState.NOT_IMPLEMENTED), "getParentLogger" ) + ).getSQLException(); + } +} Propchange: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver40.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java (original) +++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java Mon Feb 7 14:54:31 2011 @@ -22,6 +22,8 @@ package org.apache.derby.jdbc; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; import javax.sql.DataSource; import javax.sql.XAConnection; import org.apache.derby.client.ClientXAConnection40; @@ -84,4 +86,20 @@ public class ClientXADataSource40 extend SQLState.UNABLE_TO_UNWRAP), interfaces).getSQLException(); } } + + //////////////////////////////////////////////////////////////////// + // + // INTRODUCED BY JDBC 4.1 IN JAVA 7 + // + //////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() + throws SQLFeatureNotSupportedException + { + throw (SQLFeatureNotSupportedException) + ( + new SqlException( null, new ClientMessageId(SQLState.NOT_IMPLEMENTED), "getParentLogger" ) + ).getSQLException(); + } + } Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java Mon Feb 7 14:54:31 2011 @@ -74,8 +74,24 @@ public class AutoloadedDriver implements static { + try { + // + // We'd rather load this slightly more capable driver. + // But if the vm level doesn't support it, then we fall + // back on the JDBC3 level driver. + // + Class.forName( "org.apache.derby.jdbc.AutoloadedDriver40" ); + } + catch (Throwable e) + { + registerMe( new AutoloadedDriver() ); + } + } + + protected static void registerMe( AutoloadedDriver me ) + { try { - _autoloadedDriver = new AutoloadedDriver(); + _autoloadedDriver = me; DriverManager.registerDriver( _autoloadedDriver ); activeautoloadeddriver = true; } Added: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java?rev=1067954&view=auto ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java (added) +++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java Mon Feb 7 14:54:31 2011 @@ -0,0 +1,52 @@ +/* + + Derby - Class org.apache.derby.jdbc.AutoloadedDriver40 + + 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.derby.jdbc; + +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; + +import org.apache.derby.impl.jdbc.Util; + +/** + * Adds driver functionality which is only visible from JDBC 4.0 onward. + */ +public class AutoloadedDriver40 extends AutoloadedDriver +{ + static + { + registerMe( new AutoloadedDriver40() ); + } + + //////////////////////////////////////////////////////////////////// + // + // INTRODUCED BY JDBC 4.1 IN JAVA 7 + // + //////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() + throws SQLFeatureNotSupportedException + { + throw (SQLFeatureNotSupportedException) Util.notImplemented( "getParentLogger()" ); + } +} + + Propchange: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java Mon Feb 7 14:54:31 2011 @@ -21,6 +21,8 @@ package org.apache.derby.jdbc; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; import javax.sql.ConnectionPoolDataSource; import javax.sql.DataSource; import javax.sql.PooledConnection; @@ -90,4 +92,17 @@ public class EmbeddedConnectionPoolDataS interfaces); } } + + //////////////////////////////////////////////////////////////////// + // + // INTRODUCED BY JDBC 4.1 IN JAVA 7 + // + //////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() + throws SQLFeatureNotSupportedException + { + throw (SQLFeatureNotSupportedException) Util.notImplemented( "getParentLogger()" ); + } + } Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java Mon Feb 7 14:54:31 2011 @@ -22,6 +22,8 @@ package org.apache.derby.jdbc; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; import javax.sql.DataSource; import org.apache.derby.impl.jdbc.Util; @@ -219,4 +221,17 @@ public class EmbeddedDataSource40 extend interfaces); } } + + //////////////////////////////////////////////////////////////////// + // + // INTRODUCED BY JDBC 4.1 IN JAVA 7 + // + //////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() + throws SQLFeatureNotSupportedException + { + throw (SQLFeatureNotSupportedException) Util.notImplemented( "getParentLogger()" ); + } + } Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java Mon Feb 7 14:54:31 2011 @@ -24,6 +24,8 @@ package org.apache.derby.jdbc; import org.apache.derby.iapi.jdbc.ResourceAdapter; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; import javax.sql.DataSource; import javax.sql.XAConnection; import javax.sql.XADataSource; @@ -98,5 +100,17 @@ public class EmbeddedXADataSource40 exte interfaces); } } + + //////////////////////////////////////////////////////////////////// + // + // INTRODUCED BY JDBC 4.1 IN JAVA 7 + // + //////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() + throws SQLFeatureNotSupportedException + { + throw (SQLFeatureNotSupportedException) Util.notImplemented( "getParentLogger()" ); + } } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java Mon Feb 7 14:54:31 2011 @@ -294,6 +294,38 @@ public class DataSourceTest extends Base } /** + *

+ * Test the new method added by JDBC 4.1. + *

+ */ + public void test_jdbc4_1() throws Exception + { + DataSource ds = JDBCDataSource.getDataSource(); + ConnectionPoolDataSource cpds = J2EEDataSource.getConnectionPoolDataSource(); + XADataSource xads = J2EEDataSource.getXADataSource(); + + vetDSjdbc4_1( ds ); + vetDSjdbc4_1( cpds ); + vetDSjdbc4_1( xads ); + } + private void vetDSjdbc4_1( CommonDataSource cds ) throws Exception + { + println( "Vetting a " + cds.getClass().getName() ); + + Wrapper41DataSource wrapper = new Wrapper41DataSource( cds ); + + try { + wrapper.getParentLogger(); + fail( "Should raise an Unimplemented Feature exception." ); + } + catch (SQLException se) + { + assertEquals( SQLFeatureNotSupportedException.class.getName(), se.getClass().getName() ); + } + } + + + /** * Return suite with all tests of the class. */ public static Test suite() { Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40Test.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40Test.java?rev=1067954&view=auto ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40Test.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40Test.java Mon Feb 7 14:54:31 2011 @@ -0,0 +1,105 @@ +/* + + Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.Driver40Test + + 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.jdbc4; + +import java.sql.Driver; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.derbyTesting.junit.BaseJDBCTestCase; +import org.apache.derbyTesting.junit.TestConfiguration; + + +/** + * Tests of javax.sql.Driver for JDBC40 and up. + */ + +public class Driver40Test extends BaseJDBCTestCase +{ + /////////////////////////////////////////////////////////////////////////////////// + // + // CONSTANTS + // + /////////////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////////////// + // + // STATE + // + /////////////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////////////// + // + // CONSTRUCTOR + // + /////////////////////////////////////////////////////////////////////////////////// + + public Driver40Test(String name) { super( name ); } + + /////////////////////////////////////////////////////////////////////////////////// + // + // JUnit BEHAVIOR + // + /////////////////////////////////////////////////////////////////////////////////// + + /** + * Return suite with all tests of the class. + */ + public static Test suite() + { + return TestConfiguration.defaultSuite(Driver40Test.class); + } + + /////////////////////////////////////////////////////////////////////////////////// + // + // TESTS + // + /////////////////////////////////////////////////////////////////////////////////// + + + /** + *

+ * Test new method added by JDBC 4.1. + *

+ */ + public void test_jdbc4_1() throws Exception + { + Driver driver = DriverManager.getDriver( getTestConfiguration().getJDBCClient().getUrlBase() ); + println( "Testing a " + driver.getClass().getName() ); + + Wrapper41Driver wrapper = new Wrapper41Driver( driver ); + + try { + wrapper.getParentLogger(); + fail( "Should raise an Unimplemented Feature exception." ); + } + catch (SQLException se) + { + assertEquals( SQLFeatureNotSupportedException.class.getName(), se.getClass().getName() ); + } + } + +} Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40Test.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java?rev=1067954&view=auto ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java Mon Feb 7 14:54:31 2011 @@ -0,0 +1,116 @@ +/* + + Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.Wrapper41DataSource + + 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.jdbc4; + +import java.sql.SQLException; +import java.util.logging.Logger; +import javax.sql.CommonDataSource; + +import org.apache.derby.jdbc.EmbeddedDataSource40; +import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40; +import org.apache.derby.jdbc.EmbeddedXADataSource40; +import org.apache.derby.jdbc.ClientDataSource40; +import org.apache.derby.jdbc.ClientConnectionPoolDataSource40; +import org.apache.derby.jdbc.ClientXADataSource40; + +/** + * A wrapper around the methods added by JDBC 4.1. + * We can eliminate this class after Java 7 goes GA and we are allowed + * to use the Java 7 compiler to build our released versions of derbyTesting.jar. + */ +public class Wrapper41DataSource +{ + /////////////////////////////////////////////////////////////////////// + // + // STATE + // + /////////////////////////////////////////////////////////////////////// + + private EmbeddedDataSource40 _embedded; + private ClientDataSource40 _netclient; + private EmbeddedConnectionPoolDataSource40 _ecpds; + private EmbeddedXADataSource40 _exads; + private ClientConnectionPoolDataSource40 _ccpds; + private ClientXADataSource40 _cxads; + + + /////////////////////////////////////////////////////////////////////// + // + // CONSTRUCTORS + // + /////////////////////////////////////////////////////////////////////// + + public Wrapper41DataSource( Object wrapped ) throws Exception + { + if ( wrapped instanceof EmbeddedDataSource40 ) { _embedded = (EmbeddedDataSource40 ) wrapped; } + else if ( wrapped instanceof ClientDataSource40 ) { _netclient = (ClientDataSource40) wrapped; } + else if ( wrapped instanceof EmbeddedConnectionPoolDataSource40 ) { _ecpds = (EmbeddedConnectionPoolDataSource40) wrapped; } + else if ( wrapped instanceof EmbeddedXADataSource40 ) { _exads = (EmbeddedXADataSource40) wrapped; } + else if ( wrapped instanceof ClientConnectionPoolDataSource40 ) { _ccpds = (ClientConnectionPoolDataSource40) wrapped; } + else if ( wrapped instanceof ClientXADataSource40 ) { _cxads = (ClientXADataSource40) wrapped; } + else { throw nothingWrapped(); } + } + + /////////////////////////////////////////////////////////////////////// + // + // JDBC 4.1 BEHAVIOR + // + /////////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() throws SQLException + { + if ( _embedded != null ) { return _embedded.getParentLogger(); } + else if ( _netclient != null ) { return _netclient.getParentLogger(); } + else if ( _ecpds != null ) { return _ecpds.getParentLogger(); } + else if ( _exads != null ) { return _exads.getParentLogger(); } + else if ( _ccpds != null ) { return _ccpds.getParentLogger(); } + else if ( _cxads != null ) { return _cxads.getParentLogger(); } + else { throw nothingWrapped(); } + } + + /////////////////////////////////////////////////////////////////////// + // + // OTHER PUBLIC BEHAVIOR + // + /////////////////////////////////////////////////////////////////////// + + public CommonDataSource getWrappedObject() throws SQLException + { + if ( _embedded != null ) { return _embedded; } + else if ( _netclient != null ) { return _netclient; } + else if ( _ecpds != null ) { return _ecpds; } + else if ( _exads != null ) { return _exads; } + else if ( _ccpds != null ) { return _ccpds; } + else if ( _cxads != null ) { return _cxads; } + else { throw nothingWrapped(); } + } + + /////////////////////////////////////////////////////////////////////// + // + // MINIONS + // + /////////////////////////////////////////////////////////////////////// + + private SQLException nothingWrapped() { return new SQLException( "Nothing wrapped!" ); } + +} + Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41DataSource.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java?rev=1067954&view=auto ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java Mon Feb 7 14:54:31 2011 @@ -0,0 +1,95 @@ +/* + + Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.Wrapper41Driver + + 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.jdbc4; + +import java.sql.Driver; +import java.sql.SQLException; +import java.util.logging.Logger; + +import org.apache.derby.jdbc.AutoloadedDriver40; +import org.apache.derby.jdbc.ClientDriver40; + +/** + * A wrapper around the methods added by JDBC 4.1. + * We can eliminate this class after Java 7 goes GA and we are allowed + * to use the Java 7 compiler to build our released versions of derbyTesting.jar. + */ +public class Wrapper41Driver +{ + /////////////////////////////////////////////////////////////////////// + // + // STATE + // + /////////////////////////////////////////////////////////////////////// + + private AutoloadedDriver40 _embedded; + private ClientDriver40 _netclient; + + /////////////////////////////////////////////////////////////////////// + // + // CONSTRUCTORS + // + /////////////////////////////////////////////////////////////////////// + + public Wrapper41Driver( Object wrapped ) throws Exception + { + if ( wrapped instanceof AutoloadedDriver40 ) { _embedded = (AutoloadedDriver40) wrapped; } + else if ( wrapped instanceof ClientDriver40 ) { _netclient = (ClientDriver40) wrapped; } + else { throw nothingWrapped(); } + } + + /////////////////////////////////////////////////////////////////////// + // + // JDBC 4.1 BEHAVIOR + // + /////////////////////////////////////////////////////////////////////// + + public Logger getParentLogger() throws SQLException + { + if ( _embedded != null ) { return _embedded.getParentLogger(); } + else if ( _netclient != null ) { return _netclient.getParentLogger(); } + else { throw nothingWrapped(); } + } + + /////////////////////////////////////////////////////////////////////// + // + // OTHER PUBLIC BEHAVIOR + // + /////////////////////////////////////////////////////////////////////// + + public Driver getWrappedObject() throws SQLException + { + if ( _embedded != null ) { return _embedded; } + else if ( _netclient != null ) { return _netclient; } + else { throw nothingWrapped(); } + } + + /////////////////////////////////////////////////////////////////////// + // + // MINIONS + // + /////////////////////////////////////////////////////////////////////// + + private SQLException nothingWrapped() { return new SQLException( "Nothing wrapped!" ); } + +} + Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java ------------------------------------------------------------------------------ svn:eol-style = native 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?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- 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 Mon Feb 7 14:54:31 2011 @@ -76,6 +76,7 @@ public class _Suite extends BaseTestCase suite.addTest(Derby3650Test.suite()); suite.addTest(Derby2017LayerBTest.suite()); suite.addTest(AbortTest.suite()); + suite.addTest(Driver40Test.suite()); return suite; } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java Mon Feb 7 14:54:31 2011 @@ -217,6 +217,11 @@ public class DriverTest extends BaseJDBC assertEquals(dbmd.getDriverMajorVersion(), driver.getMajorVersion()); assertEquals(dbmd.getDriverMinorVersion(), driver.getMinorVersion()); + + // test that the driver is one of the special 40 versions if we are running + // on Java 6 or higher + println( "Driver is a " + driver.getClass().getName() ); + assertEquals( JDBC.vmSupportsJDBC4(), driver.getClass().getName().endsWith( "40" ) ); conn.close(); } Modified: db/derby/code/trunk/tools/jar/dnc.properties URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/dnc.properties?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/tools/jar/dnc.properties (original) +++ db/derby/code/trunk/tools/jar/dnc.properties Mon Feb 7 14:54:31 2011 @@ -14,6 +14,7 @@ # limitations under the License. derby.module.client.driver=org.apache.derby.jdbc.ClientDriver +derby.module.client.40driver=org.apache.derby.jdbc.ClientDriver40 derby.module.client.dsfactory=org.apache.derby.client.ClientDataSourceFactory derby.module.client.cpds=org.apache.derby.jdbc.ClientConnectionPoolDataSource derby.module.client.xads=org.apache.derby.jdbc.ClientXADataSource Modified: db/derby/code/trunk/tools/jar/extraDBMSclasses.properties URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/extraDBMSclasses.properties?rev=1067954&r1=1067953&r2=1067954&view=diff ============================================================================== --- db/derby/code/trunk/tools/jar/extraDBMSclasses.properties (original) +++ db/derby/code/trunk/tools/jar/extraDBMSclasses.properties Mon Feb 7 14:54:31 2011 @@ -52,6 +52,7 @@ derby.module.core.csds_simple=org.apache derby.module.core.csds.jdk16=org.apache.derby.jdbc.EmbeddedDataSource40 derby.module.core.csxads.jdk16=org.apache.derby.jdbc.EmbeddedXADataSource40 derby.module.core.cscpds.jdk16=org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40 +derby.module.core.ad.jdk16=org.apache.derby.jdbc.AutoloadedDriver40 derby.module.database.consistency.checker=org.apache.derby.iapi.db.ConsistencyChecker derby.module.database.optimizer.trace=org.apache.derby.iapi.db.OptimizerTrace