db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r398594 - in /db/derby/code/trunk/java: client/org/apache/derby/client/ client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ testing/org/apache/derbyTesting/functionTests/suites/ testing/org/apache/derbyTesting/functionTes...
Date Mon, 01 May 2006 13:40:03 GMT
Author: rhillegas
Date: Mon May  1 06:40:00 2006
New Revision: 398594

URL: http://svn.apache.org/viewcvs?rev=398594&view=rev
Log:
DERBY-1180: Commit Kristian's derby-1180-4c-logicalconnection_and_tests.diff patch, adding
vacuous implementations for missing signatures.

Added:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java  
(with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
  (with props)
Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
    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/EmbeddedBrokeredConnectionWrapperTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java Mon
May  1 06:40:00 2006
@@ -206,7 +206,9 @@
         if (logicalConnection_ != null) {
             logicalConnection_.closeWithoutRecyclingToPool();
         }
-        logicalConnection_ = new org.apache.derby.client.am.LogicalConnection(physicalConnection_,
this);
+        logicalConnection_ = ClientDriver.getFactory().newLogicalConnection(
+                                                        physicalConnection_,
+                                                        this);
     }
 
     public synchronized void addConnectionEventListener(javax.sql.ConnectionEventListener
listener) {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java
Mon May  1 06:40:00 2006
@@ -63,6 +63,15 @@
             int type,int concurrency,int holdability) throws SqlException;
     
     /**
+     * This method returns an instance of LogicalConnection
+     * (or LogicalConnection40) which implements java.sql.Connection.
+     */
+    LogicalConnection newLogicalConnection(
+                    org.apache.derby.client.am.Connection physicalConnection,
+                    ClientPooledConnection pooledConnection)
+        throws SqlException;
+    
+    /**
      * This method returns an instance of PreparedStatement
      * (or PreparedStatement40) which implements java.sql.PreparedStatement
      */

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java Mon
May  1 06:40:00 2006
@@ -33,7 +33,7 @@
 // only the Pooled Connection instance will maintain a handle to the physical connection.
 
 public class LogicalConnection implements java.sql.Connection {
-    private Connection physicalConnection_ = null; // reset to null when the logical connection
is closed.
+    protected Connection physicalConnection_ = null; // reset to null when the logical connection
is closed.
     private org.apache.derby.client.ClientPooledConnection pooledConnection_ = null;
 
     public LogicalConnection(Connection physicalConnection,
@@ -119,7 +119,7 @@
     // this method doesn't wrap in the standard way, because it went out without a throws
clause.
     // Unlike all other LogicalConnection methods, if the physical connection is null, it
won't throw an exception, but will return false.
 
-    private void checkForNullPhysicalConnection() throws SQLException {
+    protected void checkForNullPhysicalConnection() throws SQLException {
         if (physicalConnection_ == null) {
             SqlException se = new SqlException(null, 
                 new ClientMessageId(SQLState.NO_CURRENT_CONNECTION));

Added: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java?rev=398594&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java Mon
May  1 06:40:00 2006
@@ -0,0 +1,125 @@
+/*
+
+   Derby - Class org.apache.derby.client.am.LogicalConnection40
+
+   Copyright (c) 2006 The Apache Software Foundation or its licensors, where applicable.
+
+   Licensed 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.client.am;
+
+import java.sql.BaseQuery;
+import java.sql.Blob;
+import java.sql.ClientInfoException;
+import java.sql.Clob;
+import java.sql.NClob;
+import java.sql.SQLXML;
+import java.sql.SQLException;
+import java.sql.Wrapper;
+import java.util.Properties;
+
+import org.apache.derby.client.ClientPooledConnection;
+import org.apache.derby.shared.common.reference.SQLState;
+
+/**
+ * A simple delegation wrapper handle for a physical connection.
+ * This class only contains JDBC 4.0 specific methods.
+ *
+ * NOTE: All non-implemented JDBC 4.0 methods are located here, but when they
+ *       are implemented, they should be moved to the superclass if possible.
+ */
+public class LogicalConnection40
+    extends LogicalConnection {
+
+    public LogicalConnection40(Connection physicalConnection,
+                               ClientPooledConnection pooledConnection) 
+        throws SqlException {
+        super(physicalConnection, pooledConnection);
+    }
+
+    public Blob createBlob()
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("createBlob()");
+    }
+
+    public Clob createClob()
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("createClob()");
+    }
+    
+    public NClob createNClob()
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("createNClob()");
+    }
+
+    public <T extends BaseQuery>T createQueryObject(Class<T> ifc)
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("createQueryObject(Class<T>)");
+    }
+    
+    public SQLXML createSQLXML()
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("createSQLXML()");
+    }
+
+    public Properties getClientInfo()
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("getClientInfo()");
+    }
+    
+    public String getClientInfo(String name)
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("getClientInfo(String)");
+    }
+
+    public boolean isValid(int timeout)
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("isValid(int)");
+    }
+   
+    public boolean isWrapperFor(Class<?> interfaces)
+        throws SQLException {
+        checkForNullPhysicalConnection();
+        return interfaces.isInstance(this);
+    }
+
+    public void setClientInfo(Properties properties)
+        throws ClientInfoException {
+        SQLException sqle = 
+            SQLExceptionFactory.notImplemented("setClientInfo(Properties)");
+        throw new ClientInfoException(sqle.getMessage(), 
+                                      sqle.getSQLState(), 
+                                      (Properties)properties.clone());
+    }
+    
+    public void setClientInfo(String name, String value)
+        throws SQLException {
+        throw SQLExceptionFactory.notImplemented("setClientInfo(String,String)");
+    }
+    
+    public <T>T unwrap(Class<T> interfaces)
+        throws SQLException {
+        checkForNullPhysicalConnection();
+        // Derby does not implement non-standard methods on JDBC objects
+        try {
+            return interfaces.cast(this);
+        } catch (ClassCastException cce) {
+            throw new SqlException(null,
+                                   new ClientMessageId(SQLState.UNABLE_TO_UNWRAP),
+                                   interfaces).getSQLException();
+        }
+    }
+    
+} // End class LogicalConnection40

Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
Mon May  1 06:40:00 2006
@@ -26,6 +26,7 @@
 import org.apache.derby.client.ClientPooledConnection;
 import org.apache.derby.client.am.CallableStatement;
 import org.apache.derby.client.am.ClientJDBCObjectFactory;
+import org.apache.derby.client.am.LogicalConnection;
 import org.apache.derby.client.am.ParameterMetaData;
 import org.apache.derby.client.am.PreparedStatement;
 import org.apache.derby.client.am.Configuration;
@@ -71,6 +72,16 @@
             int holdability) throws SqlException {
         return new CallableStatement(agent,connection,sql,type,
                 concurrency,holdability);
+    }
+   
+    /**
+     * Returns an instance of org.apache.derby.client.am.LogicalConnection
+     */
+    public LogicalConnection newLogicalConnection(
+                    org.apache.derby.client.am.Connection physicalConnection,
+                    ClientPooledConnection pooledConnection)
+        throws SqlException {
+        return new LogicalConnection(physicalConnection, pooledConnection);
     }
     
     /**

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java
Mon May  1 06:40:00 2006
@@ -27,6 +27,8 @@
 import org.apache.derby.client.am.ColumnMetaData;
 import org.apache.derby.client.am.ColumnMetaData40;
 import org.apache.derby.client.am.ClientJDBCObjectFactory;
+import org.apache.derby.client.am.LogicalConnection;
+import org.apache.derby.client.am.LogicalConnection40;
 import org.apache.derby.client.am.PreparedStatement;
 import org.apache.derby.client.am.PreparedStatement40;
 import org.apache.derby.client.am.ParameterMetaData;
@@ -82,6 +84,17 @@
         return new CallableStatement40(agent,connection,sql,type,concurrency,
                 holdability);
     }
+
+    /**
+     * Returns an instance of org.apache.derby.client.am.LogicalConnection40
+     */
+    public LogicalConnection newLogicalConnection(
+                    org.apache.derby.client.am.Connection physicalConnection,
+                    ClientPooledConnection pooledConnection)
+        throws SqlException {
+        return new LogicalConnection40(physicalConnection, pooledConnection);
+    }
+    
     /**
      * Returns an instance of org.apache.derby.client.am.CallableStatement40
      */

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
Mon May  1 06:40:00 2006
@@ -25,8 +25,6 @@
 largedata/LobLimits.java
 jdbc4/TestDbMetaData.java
 jdbc4/TestJDBC40Exception.java
-#Tests BrokeredConnection class which is presnt only on the embedded side
-jdbc4/EmbeddedBrokeredConnectionWrapperTest.junit
 #temporarily disable checkDataSourceTests with client
 #failing (hanging?)  on jdk 1.5/jdk 1.6
 jdbcapi/checkDataSource.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- 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
Mon May  1 06:40:00 2006
@@ -13,6 +13,5 @@
 jdbc4/StatementTest.junit
 jdbc4/DataSourceTest.junit
 jdbc4/ResultSetMetaDataTest.junit
-jdbc4/EmbeddedBrokeredConnectionWrapperTest.junit
 jdbc4/ParameterMetaDataWrapperTest.junit
 jdbc4/AutoloadTest.junit

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java?rev=398594&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
Mon May  1 06:40:00 2006
@@ -0,0 +1,376 @@
+/*
+ 
+   Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.ConnectionTest
+ 
+   Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ 
+   Licensed 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 junit.framework.*;
+
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.sql.*;
+import java.util.Properties;
+import javax.sql.*;
+
+/**
+ * Tests for the JDBC 4.0 specific methods in the connection object(s).
+ *
+ * This class defines all test methods in <code>ConnectionTest</code>, and 
+ * overrides <code>setUp</code> in subclasses to run these tests with different
+ * types of connection objects. To see what connection types are tested, look
+ * at the <code>suite</code> method.
+ *
+ * In addition, the <code>getName</code> method is overridden in the subclasses
+ * to be able to see with what connection type the tests fail/run with.
+ */
+public class ConnectionTest
+    extends BaseJDBCTestCase {
+
+    /** 
+     * Default connection used by the tests. 
+     * The setup of the connection can be overridden in the <code>setUp</code>

+     * method in the subclasses.
+     */
+    protected Connection con = null;
+
+    /**
+     * Create a test with the given name.
+     * 
+     * @param name name of the test.
+     */
+    public ConnectionTest(String name) {
+        super(name);
+    }
+    
+    /**
+     * Obtain a "regular" connection that the tests can use.
+     */
+    public void setUp() 
+        throws SQLException {
+        con = getConnection(); 
+    }
+
+    public void tearDown() 
+        throws SQLException {
+        if (con != null && !con.isClosed()) {
+            con.rollback();
+            con.close();
+        }
+        con = null;
+    }
+   
+    //------------------------- T E S T  M E T H O D S ------------------------
+    
+    public void embeddedCreateBlobNotImplemented()
+        throws SQLException {
+        try {
+            con.createBlob();
+            fail("createBlob() should not be implemented");
+        } catch (SQLFeatureNotSupportedException sfnse) {
+            // Do nothing, we are fine
+        }
+    }
+    
+    public void embeddedCreateClobNotImplemented()
+        throws SQLException {
+        try {
+            con.createClob();
+            fail("createClob() should not be implemented");
+        } catch (SQLFeatureNotSupportedException sfnse) {
+            // Do nothing, we are fine
+        }
+    }
+
+    public void testCreateNClobNotImplemented()
+        throws SQLException {
+        try {
+            con.createNClob();
+            fail("createNClob() should not be implemented");
+        } catch (SQLFeatureNotSupportedException sfnse) {
+            // Do nothing, we are fine
+        }
+    }
+
+    /**
+     * Simply test that the method is implemented.
+     * If the method actually does what is should, is not yet tested
+     * (there are missing implementations).
+     */
+    public void testCreateQueryObjectIsImplemented()
+        throws SQLException {
+        con.createQueryObject(TestQuery.class);
+    }
+
+    public void testCreateSQLXMLNotImplemented()
+        throws SQLException {
+        try {
+            con.createSQLXML();
+            fail("createSQLXML() should not be implemented");
+        } catch (SQLFeatureNotSupportedException sfnse) {
+            // Do nothing, we are fine
+        }
+    }
+
+    public void testGetClientInfoNotImplemented()
+        throws SQLException {
+        try {
+            con.getClientInfo();
+            fail("getClientInfo() should not be implemented");
+        } catch (SQLFeatureNotSupportedException sfnse) {
+            // Do nothing, we are fine
+        }
+    }
+    
+    public void testGetClientInfoStringNotImplemented()
+        throws SQLException {
+        try {
+            con.getClientInfo(null);
+            fail("getClientInfo(String) should not be implemented");
+        } catch (SQLFeatureNotSupportedException sfnse) {
+            // Do nothing, we are fine
+        }
+    }
+
+    public void testIsWrapperReturnsFalse()
+        throws SQLException {
+        assertFalse(con.isWrapperFor(ResultSet.class));
+    }
+
+    public void testIsWrapperReturnsTrue()
+        throws SQLException {
+        assertTrue(con.isWrapperFor(Connection.class));
+    }
+
+    public void testSetClientInfoPropertiesNotImplemented()
+        throws SQLException {
+        try {
+            con.setClientInfo(new Properties());
+            fail("setClientInfo(Properties) should not be implemented");
+        } catch (ClientInfoException cie) {
+            assertSQLState("Invalid SQL state for unimplemented method",
+                           "0A000", // Can this be added to SQLStateConstants?
+                           cie); 
+        }
+    }
+
+    public void testSetClientInfoStringNotImplemented()
+        throws SQLException {
+        try {
+            con.setClientInfo("name", "value");
+            fail("setClientInfo(String,String) should not be implemented");
+        } catch (SQLFeatureNotSupportedException sfnse) {
+            // Do nothing, we are fine
+        }
+    }
+    
+    public void testUnwrapValid()
+        throws SQLException {
+        Connection unwrappedCon = con.unwrap(Connection.class);
+    }
+
+    public void testUnwrapInvalid()
+        throws SQLException {
+        try {
+            ResultSet unwrappedRs = con.unwrap(ResultSet.class);
+            fail("unwrap should have thrown an exception");
+        } catch (SQLException sqle) {
+            assertSQLState("Incorrect SQL state when unable to unwrap",
+                           SQLStateConstants.UNABLE_TO_UNWRAP,
+                           sqle);
+        }
+    }
+        
+    //------------------ E N D  O F  T E S T  M E T H O D S -------------------
+
+    /**
+     * Create suite containing client-only tests.
+     */
+    private static TestSuite clientSuite() {
+        TestSuite clientSuite = new TestSuite();
+        return clientSuite; 
+    }
+    
+    /**
+     * Create suite containing embedded-only tests.
+     */
+    private static TestSuite embeddedSuite() {
+        TestSuite embeddedSuite = new TestSuite();
+        embeddedSuite.addTest(new ConnectionTest(
+                    "embeddedCreateBlobNotImplemented"));
+        embeddedSuite.addTest(new ConnectionTest(
+                    "embeddedCreateClobNotImplemented"));
+        return embeddedSuite;
+    }
+    
+    /**
+     * Create a test suite containing tests for various connection types.
+     */
+    public static Test suite() {
+        TestSuite topSuite = new TestSuite("ConnectionTest top suite");
+        // Add suite for "regular" Connection tests.
+        TestSuite baseConnSuite = 
+            new TestSuite(ConnectionTest.class, "ConnectionTest suite");
+        // Add suite for PooledConnection tests.
+        TestSuite pooledConnSuite =
+            new TestSuite(PooledConnectionTest.class,
+                          "PooledConnectionTest suite");
+        // Add suite for XAConnection tests.
+        TestSuite xaConnSuite =
+            new TestSuite(XAConnectionTest.class, "XAConnectionTest suite");
+        
+        // Add client only tests
+        // NOTE: JCC is excluded
+        if (usingDerbyNetClient()) {
+            TestSuite clientSuite = clientSuite();
+            clientSuite.setName("ConnectionTest client-only suite");
+            baseConnSuite.addTest(clientSuite);
+            clientSuite = clientSuite();
+            clientSuite.setName("PooledConnectionTest client-only suite");
+            pooledConnSuite.addTest(clientSuite);
+            clientSuite = clientSuite();
+            clientSuite.setName("XAConnectionTest client-only suite");
+            xaConnSuite.addTest(clientSuite);
+        }
+        // Add embedded only tests
+        if (usingEmbedded()) {
+            TestSuite embeddedSuite = embeddedSuite();
+            embeddedSuite.setName("ConnectionTest embedded-only suite");
+            baseConnSuite.addTest(embeddedSuite);
+            embeddedSuite = embeddedSuite();
+            embeddedSuite.setName("PooledConnectionTest embedded-only suite");
+            pooledConnSuite.addTest(embeddedSuite);
+            embeddedSuite = embeddedSuite();
+            embeddedSuite.setName("XAConnectionTest embedded-only suite");
+            xaConnSuite.addTest(embeddedSuite);
+        }
+        topSuite.addTest(baseConnSuite);
+        topSuite.addTest(pooledConnSuite);
+        topSuite.addTest(xaConnSuite);
+        return topSuite;
+    }
+    
+    /**
+     * Tests for the real connection in a <code>PooledConnection</code>.
+     *
+     * This class subclasses <code>ConnectionTest</code>, and runs the test-
+     * methods implemented there. By doing this, we don't have to duplicate
+     * the test code. We only run the tests with a different type of 
+     * connection.
+     */
+    public static class PooledConnectionTest 
+        extends ConnectionTest {
+
+        /**
+         * Create a test with the given name.
+         * 
+         * @param name name of the test.
+         */
+        public PooledConnectionTest(String name) {
+            super(name);
+        }
+
+        /**
+         * Return name of the test, with "_POOLED" appended.
+         * Must override this method to be able to separate which connection
+         * the failure happened with, since the test methods are all in the
+         * superclass.
+         *
+         * @return the name of the test method in <code>ConnectionTest</code>,
+         *      appended with the string "_POOLED".
+         */
+        public String getName() {
+            return super.getName() + "_POOLED";
+        }
+
+        /**
+         * Obtain a connection to test through 
+         * <code>ConnectionPoolDatasource</code> and 
+         * <code>PooledConnection</code>.
+         * Currently, the connection obtained will be either a 
+         * <code>LogicalConnection<code> or a <code>BrokeredConnection</code>,
+         * depending on whether we run in embedded or client mode.
+         */
+        public void setUp()
+            throws SQLException {
+            //The ConnectionPoolDataSource object
+            //used to get a PooledConnection object
+            ConnectionPoolDataSource cpDataSource = getConnectionPoolDataSource();
+            PooledConnection pConn = cpDataSource.getPooledConnection();
+            //doing a getConnection() returns a Connection object
+            //that internally contains a BrokeredConnection40 object
+            //this is then used to check the wrapper object
+            con = pConn.getConnection();
+        }
+        
+    } // End class PooledConnectionTest
+
+    /**
+     * Tests for the real connection in <code>XAConnection</code>.
+     *
+     * This class subclasses <code>ConnectionTest</code>, and runs the test-
+     * methods implemented there. By doing this, we don't have to duplicate
+     * the test code. We only run the tests with a different type of 
+     * connection.
+     */
+    public static class XAConnectionTest
+        extends ConnectionTest {
+
+        /**
+         * Create a test with the given name.
+         * 
+         * @param name name of the test.
+         */
+        public XAConnectionTest(String name) {
+            super(name);
+        }
+
+        /**
+         * Return name of the test, with "_XA" appended.
+         * Must override this method to be able to separate which connection
+         * the failure happened with, since the test methods are all in the
+         * superclass.
+         *
+         * @return the name of the test method in <code>ConnectionTest</code>,
+         *      appended with the string "_XA".
+         */
+        public String getName() {
+            return super.getName() + "_XA";
+        }
+
+        /**
+         * Obtain a connection to test through <code>XADataSource</code> and

+         * <code>XAConnection</code>.
+         * Currently, the connection obtained will be either a 
+         * <code>LogicalConnection<code> or a <code>BrokeredConnection</code>,
+         * depending on whether we run in embedded or client mode.
+         */
+        public void setUp()
+            throws SQLException {
+            // Use a XADataSource to obtain a XAConnection object, and
+            // finally a "real" connection.
+            con = getXADataSource().getXAConnection().getConnection();
+        }
+        
+    } // End class XAConnectionTest
+    
+} // End class BaseJDBCTestCase

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java
Mon May  1 06:40:00 2006
@@ -1,135 +0,0 @@
-/*
- 
-   Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.EmbeddedBrokeredConnectionWrapperTest
- 
-   Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
- 
-   Licensed 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.*;
-import javax.sql.*;
-import junit.framework.*;
-import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
-import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
-
-public class EmbeddedBrokeredConnectionWrapperTest extends BaseJDBCTestCase {
-    //Classes that will be used in this test
-    private PooledConnection  pConn   = null;
-    private Connection        conn    = null;
-    
-    /**
-     *
-     * Create a test with the given name.
-     *
-     * @param name name of the test.
-     *
-     */
-    public EmbeddedBrokeredConnectionWrapperTest(String name) {
-        super(name);
-    }
-    
-    /**
-     * Create the classes that will be used in the
-     * test
-     *
-     */
-    public void setUp() throws SQLException {
-        //The ConnectionPoolDataSource object
-        //used to get a PooledConnection object
-        ConnectionPoolDataSource cpDataSource = getConnectionPoolDataSource();
-        pConn = cpDataSource.getPooledConnection();
-        //doing a getConnection() returns a Connection object 
-        //that internally contains a BrokeredConnection40 object
-        //this is then used to check the wrapper object
-        conn = pConn.getConnection();
-    }
-    
-    /**
-     * uninitialize pConn and conn 
-     */
-    public void tearDown() throws SQLException {
-        if(conn != null && !conn.isClosed()) {
-            conn.rollback();
-            conn.close();
-        }
-        if(pConn != null) {
-            pConn.close();
-        }
-    }
-    
-    /**
-     *
-     * Tests the wrapper methods isWrapperFor and unwrap. Test
-     * for the case when isWrapperFor returns true and we call unwrap
-     * The test is right now being run in the embedded case only
-     *
-     */
-    public void testisWrapperReturnsTrue() throws SQLException {
-        Class<Connection> wrap_class = Connection.class;
-        
-        //The if should return true enabling us  to call the unwrap method
-        //without throwing  an exception
-        if(conn.isWrapperFor(wrap_class)) {
-            try {
-                Connection conn1 =
-                        (Connection)conn.unwrap(wrap_class);
-            }
-            catch(SQLException sqle) {
-                fail("Unwrap wrongly throws a SQLException");
-            }
-        } else {
-            fail("isWrapperFor wrongly returns false");
-        }
-    }
-    
-    /**
-     *
-     * Tests the wrapper methods isWrapperFor and unwrap. Test
-     * for the case when isWrapperFor returns false and we call unwrap
-     * The test is right now being run in the embedded case only
-     *
-     */
-    public void testisWrapperReturnsFalse() throws SQLException {
-        Class<ResultSet> wrap_class = ResultSet.class;
-        
-        //returning false is the correct behaviour in this case
-        //Generate a message if it returns true
-        if(conn.isWrapperFor(wrap_class)) {
-            fail("isWrapperFor wrongly returns true");
-        } else {
-            try {
-                ResultSet rs1 = (ResultSet)
-                conn.unwrap(wrap_class);
-                fail("unwrap does not throw the expected " +
-                        "exception");
-            } catch (SQLException sqle) {
-                //calling unwrap in this case throws an SQLException
-                //check that this SQLException has the correct SQLState
-                if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
-                    throw sqle;
-                }
-            }
-        }
-    }
-    
-    /**
-     * Return suite with all tests of the class.
-     */
-    public static Test suite() {
-        return (new TestSuite(EmbeddedBrokeredConnectionWrapperTest.class,
-                              "EmbeddedBrokeredConnectionWrapperTest suite"));
-    }
-}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java?rev=398594&r1=398593&r2=398594&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
Mon May  1 06:40:00 2006
@@ -30,14 +30,10 @@
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Connection;
-import java.sql.CallableStatement;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
-import java.sql.NClob;
 import java.sql.SQLException;
-import java.sql.SQLXML;
 import java.sql.Statement;
-import java.util.Properties;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.drda.NetworkServerControl;
 import org.apache.derby.tools.ij;
@@ -61,33 +57,6 @@
         conn = connIn;
     }
     
-    void t_createClob() {
-        Clob clob;
-        try {
-            clob = conn.createClob();
-            System.out.println("unimplemented exception not thrown in code");
-        } catch(SQLException e) {
-            if(SQLState.NOT_IMPLEMENTED.equals (e.getSQLState())) {
-                System.out.println("Unexpected SQLException"+e);
-            }
-            
-        } catch(Exception e) {
-            System.out.println("Unexpected exception caught in function"+e);
-        }
-    }
-    void t_createBlob() {
-        Blob blob;
-        try {
-            blob = conn.createBlob();
-            System.out.println("unimplemented exception not thrown in code");
-        } catch(SQLException e) {
-            if(SQLState.NOT_IMPLEMENTED.equals (e.getSQLState())) {
-                System.out.println("Unexpected SQLException"+e);
-            }
-        } catch(Exception e) {
-            System.out.println("Unexpected exception caught in function"+e);
-        }
-    }
     /**
      * Test the createClob method implementation in the Connection interface 
      * in the Network Client
@@ -157,34 +126,6 @@
         }
     }
     
-    void t_createNClob() {
-        NClob nclob;
-        try {
-            nclob = conn.createNClob();
-            System.out.println("unimplemented exception not thrown in code");
-        } catch(SQLException e) {
-            if(SQLState.NOT_IMPLEMENTED.equals (e.getSQLState())) {
-                System.out.println("Unexpected SQLException"+e);
-            }
-        } catch(Exception e) {
-            System.out.println("Unexpected exception caught in function"+e);
-        }
-    }
-    void t_createSQLXML() {
-        SQLXML sqlXML;
-        try {
-            sqlXML = conn.createSQLXML();
-            System.out.println("unimplemented exception not thrown in code");
-        } catch(SQLException e) {
-            if(SQLState.NOT_IMPLEMENTED.equals (e.getSQLState())) {
-                System.out.println("Unexpected SQLException"+e);
-            }
-        } catch(Exception e) {
-            System.out.println("Unexpected exception caught in function"+e);
-        }
-        
-    }
-
     /**
      * Test the Connection.isValid method
      */
@@ -343,140 +284,14 @@
         }
     }
 
-    void t_setClientInfo1(){
-        try {
-            conn.setClientInfo("prop1","value1");
-            System.out.println("unimplemented exception not thrown in code");
-        } catch(SQLException e) {
-            if(SQLState.NOT_IMPLEMENTED.equals (e.getSQLState())) {
-                System.out.println("Unexpected SQLException"+e);
-            }
-        } catch(Exception e) {
-            System.out.println("Unexpected exception caught in function"+e);
-        }
-    }
-    
-    void t_setClientInfo2(){
-        try {
-            Properties p = new Properties();
-            conn.setClientInfo(p);
-            System.out.println("unimplemented exception not thrown in code");
-        } catch(SQLException e) {
-            if(SQLState.NOT_IMPLEMENTED.equals (e.getSQLState())) {
-                System.out.println("Unexpected SQLException"+e);
-            }
-        } catch(Exception e) {
-            System.out.println("Unexpected exception caught in function"+e);
-        }
-    }
-    
-    void t_getClientInfo1(){
-        String info;
-        try {
-            info = conn.getClientInfo("prop1");
-            System.out.println("unimplemented exception not thrown in code");
-        } catch(SQLException e) {
-            if(SQLState.NOT_IMPLEMENTED.equals (e.getSQLState())) {
-                System.out.println("Unexpected SQLException"+e);
-            }
-        } catch(Exception e) {
-            System.out.println("Unexpected exception caught in function"+e);
-        }
-        
-    }
-    
-    void t_getClientInfo2(){
-        Properties p=null;
-        try {
-            p = conn.getClientInfo();
-            System.out.println("unimplemented exception not thrown in code");
-        } catch(SQLException e) {
-            if(SQLState.NOT_IMPLEMENTED.equals (e.getSQLState())) {
-                System.out.println("Unexpected SQLException"+e);
-            }
-        } catch(Exception e) {
-            System.out.println("Unexpected exception caught in function"+e);
-        }
-    }
-    
-    /**
-     * Tests the wrapper methods isWrapperFor and unwrap. There are two cases
-     * to be tested
-     * Case 1: isWrapperFor returns true and we call unwrap
-     * Case 2: isWrapperFor returns false and we call unwrap
-     */
-    void t_wrapper() {
-        //test for the case when isWrapper returns true
-        //Begin test for Case1:
-        Class<Connection> wrap_class = Connection.class;
-        
-        //The if method succeeds enabling us to call the unwrap method without 
-        //throwing an exception
-        try {
-            if(conn.isWrapperFor(wrap_class)) {
-                Connection conn1 = 
-                        (Connection)conn.unwrap(wrap_class);
-            }
-            else {
-                System.out.println("isWrapperFor wrongly returns false");
-            }
-        }
-        catch(SQLException sqle) {
-            sqle.printStackTrace();
-        }
-        
-        //Begin test for case2
-        //test for the case when isWrapper returns false
-        //using some class that will return false when 
-        //passed to isWrapperFor
-        Class<CallableStatement> wrap_class1 = CallableStatement.class;
-
-        try {
-            //returning false is the correct behaviour in this case
-            //Generate a message if it returns true
-            if(conn.isWrapperFor(wrap_class1)) {
-                System.out.println("isWrapperFor wrongly returns true");
-            }
-            else {
-                CallableStatement stmt1 = (CallableStatement)
-                                           conn.unwrap(wrap_class1);
-                System.out.println("unwrap does not throw the expected " +
-                                   "exception");
-            }
-        }
-        catch (SQLException sqle) {
-            //calling unwrap in this case throws an SQLException 
-            //ensure that this SQLException has the correct SQLState
-            if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
-                sqle.printStackTrace();
-            }
-        }
-    }
-    
     public void startTestConnectionMethods_Client() {
         t_createClob_Client();
         t_createBlob_Client();
-        t_createNClob();
-        t_createSQLXML();
         t_isValid();
-        t_setClientInfo1();
-        t_setClientInfo2();
-        t_getClientInfo1();
-        t_getClientInfo2();
-        t_wrapper();
     }
     
     public void startTestConnectionMethods_Embedded() {
-        t_createClob();
-        t_createBlob();
-        t_createNClob();
-        t_createSQLXML();
         t_isValid();
-        t_setClientInfo1();
-        t_setClientInfo2();
-        t_getClientInfo1();
-        t_getClientInfo2();
-        t_wrapper();
     }
 
     /**



Mime
View raw message