db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r410665 [2/2] - in /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests: master/ master/DerbyNetClient/ suites/ tests/jdbcapi/ util/
Date Wed, 31 May 2006 20:53:51 GMT
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out?rev=410665&r1=410664&r2=410665&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out Wed May 31 13:53:51 2006
@@ -1,7 +1,17 @@
+Running JDBC 3.0 connection checks on Nested
+  holdability     true
+JDBC 3.0 savepoint OK
 Running connection checks on Nested
   isolation level 2
   auto commit     false
   read only       false
+setTypeMap(EMPTY_MAP) - ok
+setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
+setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
+method calls on a closed connection
+Nested <closedconn>.close() no error
+Nested <closedconn>.createStatement() 08003 - No current connection.
+Nested <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Running JDBC 3.0 connection checks on DriverManager 
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
@@ -16,10 +26,10 @@
 DriverManager  <closedconn>.close() no error
 DriverManager  <closedconn>.createStatement() 08003 - No current connection.
 DriverManager  <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedDataSource
+Running JDBC 3.0 connection checks on DataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedDataSource
+Running connection checks on DataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -28,13 +38,13 @@
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 method calls on a closed connection
-EmbeddedDataSource <closedconn>.close() no error
-EmbeddedDataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedSimpleDataSource
+DataSource <closedconn>.close() no error
+DataSource <closedconn>.createStatement() 08003 - No current connection.
+DataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on SimpleDataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedSimpleDataSource
+Running connection checks on SimpleDataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -43,13 +53,13 @@
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 method calls on a closed connection
-EmbeddedSimpleDataSource <closedconn>.close() no error
-EmbeddedSimpleDataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedSimpleDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedConnectionPoolDataSource
+SimpleDataSource <closedconn>.close() no error
+SimpleDataSource <closedconn>.createStatement() 08003 - No current connection.
+SimpleDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on ConnectionPoolDataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedConnectionPoolDataSource
+Running connection checks on ConnectionPoolDataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -59,13 +69,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(1):connectionClosed
 method calls on a closed connection
-EmbeddedConnectionPoolDataSource <closedconn>.close() no error
-EmbeddedConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedConnectionPoolDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedConnectionPoolDataSource
+ConnectionPoolDataSource <closedconn>.close() no error
+ConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
+ConnectionPoolDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on ConnectionPoolDataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedConnectionPoolDataSource
+Running connection checks on ConnectionPoolDataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -75,22 +85,22 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(1):connectionClosed
 method calls on a closed connection
-EmbeddedConnectionPoolDataSource <closedconn>.close() no error
-EmbeddedConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedConnectionPoolDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+ConnectionPoolDataSource <closedconn>.close() no error
+ConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
+ConnectionPoolDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Changes rolled back OK in auto closed pooled connection
 EVENT(1):connectionClosed
 expected SQL Exception: No current connection.
 expected SQL Exception: No current connection.
-Start testPoolReset EmbeddedConnectionPoolDataSource
+Start testPoolReset ConnectionPoolDataSource
 IDENTITY_VAL_LOCAL=1
 IDENTITY_VAL_LOCAL=2
 IDENTITY_VAL_LOCAL=3
-End testPoolReset EmbeddedConnectionPoolDataSource
-Running JDBC 3.0 connection checks on EmbeddedXADataSource
+End testPoolReset ConnectionPoolDataSource
+Running JDBC 3.0 connection checks on XADataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedXADataSource
+Running connection checks on XADataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -100,21 +110,31 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(3):connectionClosed
 method calls on a closed connection
-EmbeddedXADataSource <closedconn>.close() no error
-EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+XADataSource <closedconn>.close() no error
+XADataSource <closedconn>.createStatement() 08003 - No current connection.
+XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Changes rolled back OK in auto closed local XAConnection
 EVENT(3):connectionClosed
-Start testPoolReset EmbeddedXADataSource
+Start testPoolReset XADataSource
 IDENTITY_VAL_LOCAL=1
 IDENTITY_VAL_LOCAL=2
 IDENTITY_VAL_LOCAL=3
-End testPoolReset EmbeddedXADataSource
+End testPoolReset XADataSource
 ERROR XJ015: Derby system shutdown.
+Running JDBC 3.0 connection checks on Nested
+  holdability     true
+JDBC 3.0 savepoint OK
 Running connection checks on Nested
   isolation level 2
   auto commit     false
   read only       false
+setTypeMap(EMPTY_MAP) - ok
+setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
+setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
+method calls on a closed connection
+Nested <closedconn>.close() no error
+Nested <closedconn>.createStatement() 08003 - No current connection.
+Nested <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Running JDBC 3.0 connection checks on DriverManager 
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
@@ -129,10 +149,10 @@
 DriverManager  <closedconn>.close() no error
 DriverManager  <closedconn>.createStatement() 08003 - No current connection.
 DriverManager  <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedDataSource
+Running JDBC 3.0 connection checks on DataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedDataSource
+Running connection checks on DataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -141,9 +161,9 @@
 setTypeMap(null) - ok XJ081 - Invalid value 'null' passed as parameter 'map' to method 'java.sql.Connection.setTypeMap'
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 method calls on a closed connection
-EmbeddedDataSource <closedconn>.close() no error
-EmbeddedDataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+DataSource <closedconn>.close() no error
+DataSource <closedconn>.createStatement() 08003 - No current connection.
+DataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
 Running JDBC 3.0 connection checks on EmbeddedSimpleDataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
@@ -159,10 +179,10 @@
 EmbeddedSimpleDataSource <closedconn>.close() no error
 EmbeddedSimpleDataSource <closedconn>.createStatement() 08003 - No current connection.
 EmbeddedSimpleDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedConnectionPoolDataSource
+Running JDBC 3.0 connection checks on ConnectionPoolDataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedConnectionPoolDataSource
+Running connection checks on ConnectionPoolDataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -172,13 +192,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(2):connectionClosed
 method calls on a closed connection
-EmbeddedConnectionPoolDataSource <closedconn>.close() no error
-EmbeddedConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedConnectionPoolDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedConnectionPoolDataSource
+ConnectionPoolDataSource <closedconn>.close() no error
+ConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
+ConnectionPoolDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on ConnectionPoolDataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedConnectionPoolDataSource
+Running connection checks on ConnectionPoolDataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -188,13 +208,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(2):connectionClosed
 method calls on a closed connection
-EmbeddedConnectionPoolDataSource <closedconn>.close() no error
-EmbeddedConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedConnectionPoolDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedXADataSource
+ConnectionPoolDataSource <closedconn>.close() no error
+ConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
+ConnectionPoolDataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on XADataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedXADataSource
+Running connection checks on XADataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -204,13 +224,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(4):connectionClosed
 method calls on a closed connection
-EmbeddedXADataSource <closedconn>.close() no error
-EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on EmbeddedXADataSource
+XADataSource <closedconn>.close() no error
+XADataSource <closedconn>.createStatement() 08003 - No current connection.
+XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on XADataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on EmbeddedXADataSource
+Running connection checks on XADataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -220,14 +240,14 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(4):connectionClosed
 method calls on a closed connection
-EmbeddedXADataSource <closedconn>.close() no error
-EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+XADataSource <closedconn>.close() no error
+XADataSource <closedconn>.createStatement() 08003 - No current connection.
+XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
 EVENT(5):connectionClosed
-Running JDBC 3.0 connection checks on Global EmbeddedXADataSource
+Running JDBC 3.0 connection checks on Global XADataSource
   holdability     false
 JDBC 3.0 savepoint SQL Exception: Cannot rollback a global transaction using the Connection, commit processing must go thru XAResource interface.
-Running connection checks on Global EmbeddedXADataSource
+Running connection checks on Global XADataSource
   isolation level 2
   auto commit     false
   read only       false
@@ -236,13 +256,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(5):connectionClosed
 method calls on a closed connection
-Global EmbeddedXADataSource <closedconn>.close() no error
-Global EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-Global EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on Global EmbeddedXADataSource
+Global XADataSource <closedconn>.close() no error
+Global XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Global XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on Global XADataSource
   holdability     false
 JDBC 3.0 savepoint SQL Exception: Cannot rollback a global transaction using the Connection, commit processing must go thru XAResource interface.
-Running connection checks on Global EmbeddedXADataSource
+Running connection checks on Global XADataSource
   isolation level 2
   auto commit     false
   read only       false
@@ -251,13 +271,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(5):connectionClosed
 method calls on a closed connection
-Global EmbeddedXADataSource <closedconn>.close() no error
-Global EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-Global EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on Switch to local EmbeddedXADataSource
+Global XADataSource <closedconn>.close() no error
+Global XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Global XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on Switch to local XADataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on Switch to local EmbeddedXADataSource
+Running connection checks on Switch to local XADataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -267,13 +287,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(5):connectionClosed
 method calls on a closed connection
-Switch to local EmbeddedXADataSource <closedconn>.close() no error
-Switch to local EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-Switch to local EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on Switch to local EmbeddedXADataSource
+Switch to local XADataSource <closedconn>.close() no error
+Switch to local XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Switch to local XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on Switch to local XADataSource
   holdability     true
 JDBC 3.0 savepoint SQL Exception: Cannot issue savepoint when autoCommit is on.
-Running connection checks on Switch to local EmbeddedXADataSource
+Running connection checks on Switch to local XADataSource
   isolation level 2
   auto commit     true
   read only       false
@@ -283,13 +303,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(5):connectionClosed
 method calls on a closed connection
-Switch to local EmbeddedXADataSource <closedconn>.close() no error
-Switch to local EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-Switch to local EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on Switch to global EmbeddedXADataSource
+Switch to local XADataSource <closedconn>.close() no error
+Switch to local XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Switch to local XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on Switch to global XADataSource
   holdability     false
 JDBC 3.0 savepoint SQL Exception: Cannot rollback a global transaction using the Connection, commit processing must go thru XAResource interface.
-Running connection checks on Switch to global EmbeddedXADataSource
+Running connection checks on Switch to global XADataSource
   isolation level 2
   auto commit     false
   read only       false
@@ -299,13 +319,13 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(5):connectionClosed
 method calls on a closed connection
-Switch to global EmbeddedXADataSource <closedconn>.close() no error
-Switch to global EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-Switch to global EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
-Running JDBC 3.0 connection checks on Switch to global EmbeddedXADataSource
+Switch to global XADataSource <closedconn>.close() no error
+Switch to global XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Switch to global XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Running JDBC 3.0 connection checks on Switch to global XADataSource
   holdability     false
 JDBC 3.0 savepoint SQL Exception: Cannot rollback a global transaction using the Connection, commit processing must go thru XAResource interface.
-Running connection checks on Switch to global EmbeddedXADataSource
+Running connection checks on Switch to global XADataSource
   isolation level 2
   auto commit     false
   read only       false
@@ -315,9 +335,9 @@
 setTypeMap(map) - ok 0A000 - Feature not implemented: no details.
 EVENT(5):connectionClosed
 method calls on a closed connection
-Switch to global EmbeddedXADataSource <closedconn>.close() no error
-Switch to global EmbeddedXADataSource <closedconn>.createStatement() 08003 - No current connection.
-Switch to global EmbeddedXADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
+Switch to global XADataSource <closedconn>.close() no error
+Switch to global XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Switch to global XADataSource <closedstmt>.execute() XJ012 - 'Statement' already closed.
 initial local
   holdability     true
   isolation level READ_COMMITTED
@@ -645,6 +665,7 @@
 acxs 1
 acxs 2
 autocommitxastart expected  : XAException - null
+Expected XA error code: -9
 acxs 3
 testing jira 95 for DataSource; ok - expected exception: XCY00
 testing jira 95 for XADataSource; ok - expected exception: XCY00
@@ -855,4 +876,22 @@
 CALLABLE STATEMENT HOLDABILITY false
 CONNECTION(held) HOLDABILITY true
 PASS XA HOLDABILITY TEST
+**Test holdability state for: PooledConnection **
+PASS: Holdability matches expected holdability:HOLD_CURSORS_OVER_COMMIT
+** Test autoCommit state for: PooledConnection**
+PASS: autoCommit reset on getConnection
+done creating  table
+*** Test isolation level reset on PooledConnection.getConnection()***
+setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED
+PASS: No lock timeout occurs for READ_UNCOMMITTED
+Get a new connection with PooledConnection.getConnection()
+Isolation level should be reset to READ_COMMITTED
+PASS: Expected lock timeout for READ_COMMITTED
+done creating  table
+*** Test isolation level reset on XAConnection.getConnection()***
+setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED
+PASS: No lock timeout occurs for READ_UNCOMMITTED
+Get a new connection with XAConnection.getConnection()
+Isolation level should be reset to READ_COMMITTED
+PASS: Expected lock timeout for READ_COMMITTED
 Completed checkDataSource30

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall?rev=410665&r1=410664&r2=410665&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall Wed May 31 13:53:51 2006
@@ -2,3 +2,4 @@
 jdbcapi/xaStateTran.sql
 jdbcapi/XATest.java
 jdbcapi/lobStreams.java
+jdbcapi/checkDataSource.java

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?rev=410665&r1=410664&r2=410665&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java Wed May 31 13:53:51 2006
@@ -20,43 +20,89 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.apache.derby.jdbc.EmbeddedSimpleDataSource;
-import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource;
-import org.apache.derby.jdbc.EmbeddedXADataSource;
-
+import java.io.Serializable;
+import java.sql.CallableStatement;
 import java.sql.Connection;
-import java.sql.ResultSet;
+import java.sql.DriverManager;
 import java.sql.PreparedStatement;
-import java.sql.CallableStatement;
-import java.sql.Statement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Properties;
 
+import javax.sql.ConnectionEvent;
+import javax.sql.ConnectionEventListener;
+import javax.sql.ConnectionPoolDataSource;
 import javax.sql.DataSource;
-import javax.sql.XADataSource;
 import javax.sql.PooledConnection;
 import javax.sql.XAConnection;
-import javax.sql.ConnectionPoolDataSource;
-import javax.transaction.xa.XAResource;
+import javax.sql.XADataSource;
 import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
-import javax.sql.ConnectionEventListener;
-import javax.sql.ConnectionEvent;
+
+import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource;
+import org.apache.derby.jdbc.EmbeddedDataSource;
+import org.apache.derby.jdbc.EmbeddedXADataSource;
 import org.apache.derby.tools.JDBCDisplayUtil;
 import org.apache.derby.tools.ij;
-
-import java.io.*;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import javax.naming.*;
-import javax.naming.directory.*;
+import org.apache.derbyTesting.functionTests.util.TestUtil;
 
 public class checkDataSource
 { 
-    protected static Hashtable conns = new Hashtable();
+	// Only test connection toString values for embedded.
+	// Client connection toString values are not correlated at this time and just 
+	// use default toString
+	// These tests are exempted from other frameworks
+	private boolean testConnectionToString = TestUtil.isEmbeddedFramework();
+	
+	// Only embedded supports SimpleDataSource (JSR169).  
+	// These tests are exempted from other frameworks
+	private boolean testSimpleDataSource = TestUtil.isEmbeddedFramework();
+
+	// for a PooledConnection.getConnection() the connection gets closed.
+	// Embedded automatically rolls back any activity on the connection.
+	// Client requires the user to rollback and gives an SQLException  
+	// java.sql.Connection.close() requested while a transaction is in progress
+	// This has been filed as DERBY-1004 
+	private  boolean needRollbackBeforePCGetConnection = 
+		TestUtil.isDerbyNetClientFramework(); 
+	
+	// DERBY-1035 With client, Connection.getTransactionIsolation() return value is 
+	// wrong after changing the isolation level with an SQL statement such as 
+	// "set current isolation = RS"
+	// Tests for setting isolation level this way only run in embedded for now.
+	private boolean canSetIsolationWithStatement = TestUtil.isEmbeddedFramework();
+	  
+	//	 DERBY-1148 - Client Connection state does not
+	// get set properly when joining a global transaction.
+	private static boolean isolationSetProperlyOnJoin = TestUtil.isEmbeddedFramework();
+	
+	// DERBY-1183 getCursorName not correct after first statement execution
+	private static boolean hasGetCursorNameBug = TestUtil.isDerbyNetClientFramework();
+	
+    // DERBY-1326 - Network server may abandon sessions when Derby system is shutdown
+    // and this causes intermittent hangs in the client
+	private static boolean hangAfterSystemShutdown = TestUtil.isDerbyNetClientFramework();
 
+	/**
+     * A hashtable of opened connections.  This is used when checking to
+     * make sure connection strings are unique; we need to make sure all
+     * the connections are closed when we are done, so they are stored
+     * in this hashtable
+     */
+	protected static Hashtable conns = new Hashtable();
+
+    /** The expected format of a connection string. In English:
+     * "<classname>@<hashcode> (XID=<xid>), (SESSION = <sessionid>),
+     *  (DATABASE=<dbname>), (DRDAID = <drdaid>)"
+     */
+    private static final String CONNSTRING_FORMAT = "\\S+@[0-9]+ " +
+        "\\(XID = .*\\), \\(SESSIONID = [0-9]+\\), " +
+        "\\(DATABASE = [A-Za-z]+\\), \\(DRDAID = .+\\)";
+    
 	public static void main(String[] args) throws Exception {
 
         try
@@ -73,7 +119,7 @@
 	}
 
 
-	public checkDataSource() throws Exception {
+	public checkDataSource() {
 	}
 
 	protected void runTest(String[] args) throws Exception {
@@ -84,40 +130,53 @@
 
 		dmc.createStatement().executeUpdate("create table y(i int)");
 
-		dmc.createStatement().executeUpdate("create procedure checkConn2(in dsname varchar(20)) parameter style java language java modifies SQL Data external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.checkDataSource.checkNesConn'");
+		dmc.createStatement().executeUpdate(
+                "create procedure checkConn2(in dsname varchar(20)) " +
+                "parameter style java language java modifies SQL DATA " +
+                "external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi." +
+                this.getNestedMethodName() +
+                "'");
 		CallableStatement cs = dmc.prepareCall("call checkConn2(?)");
 		cs.setString(1,"Nested");
 		cs.execute();
 		
 
 		checkConnection("DriverManager ", dmc);
-		checkJBMSToString();
+		if (testConnectionToString)
+			checkJBMSToString();
 
 
-		EmbeddedDataSource dscs = new EmbeddedDataSource();
-		dscs.setDatabaseName("wombat");
-		checkToString(dscs);
+		Properties attrs = new Properties();
+		attrs.setProperty("databaseName", "wombat");
+		DataSource dscs = TestUtil.getDataSource(attrs);
+		
+		if (testConnectionToString) 
+				checkToString(dscs);
 
 		DataSource ds = dscs;
 
-		checkConnection("EmbeddedDataSource", ds.getConnection());
+		checkConnection("DataSource", ds.getConnection());
+		 
+		DataSource dssimple = null;
+		if (testSimpleDataSource)
+		{
+			dssimple = TestUtil.getSimpleDataSource(attrs);
+			ds = dssimple;
+			checkConnection("SimpleDataSource", ds.getConnection());
+		}
+
+		ConnectionPoolDataSource dsp = TestUtil.getConnectionPoolDataSource(attrs);
 		
-		EmbeddedSimpleDataSource dssimple = new EmbeddedSimpleDataSource();
-		dssimple.setDatabaseName("wombat");
-		ds = dssimple;
-		checkConnection("EmbeddedSimpleDataSource", ds.getConnection());		
-
-		EmbeddedConnectionPoolDataSource dscsp = new EmbeddedConnectionPoolDataSource();
-		dscsp.setDatabaseName("wombat");
-		//dscsp.setConnectionAttributes("unicode=true");
-		ConnectionPoolDataSource dsp = dscsp;
-		checkToString(dsp);
+		
+		if (testConnectionToString) 
+			checkToString(dsp);
+	
 
 		PooledConnection pc = dsp.getPooledConnection();
 		pc.addConnectionEventListener(new EventCatcher(1));
 
-		checkConnection("EmbeddedConnectionPoolDataSource", pc.getConnection());
-		checkConnection("EmbeddedConnectionPoolDataSource", pc.getConnection());
+		checkConnection("ConnectionPoolDataSource", pc.getConnection());
+		checkConnection("ConnectionPoolDataSource", pc.getConnection());
 
 		// BUG 4471 - check outstanding updates are rolled back.
 		Connection c1 = pc.getConnection();
@@ -132,7 +191,9 @@
 
 		// this update should be rolled back
 		s.executeUpdate("insert into t values(2)");
-
+		if (needRollbackBeforePCGetConnection)
+			c1.rollback();
+		
 		c1 = pc.getConnection();
 
 		ResultSet rs = c1.createStatement().executeQuery("select count(*) from t");
@@ -162,20 +223,16 @@
 		pc.close();
 		pc = null;
 
-		testPoolReset("EmbeddedConnectionPoolDataSource", dsp.getPooledConnection());
-
-
-		EmbeddedXADataSource dscsx = new EmbeddedXADataSource();
-		dscsx.setDatabaseName("wombat");
-		//dscsx.setConnectionAttributes("unicode=true");
+		testPoolReset("ConnectionPoolDataSource", dsp.getPooledConnection());
 
-		XADataSource dsx = dscsx;
-		checkToString(dsx);
+		XADataSource dsx = TestUtil.getXADataSource(attrs);
+		if (testConnectionToString)
+			checkToString(dsx);
 
 		XAConnection xac = dsx.getXAConnection();
 		xac.addConnectionEventListener(new EventCatcher(3));
 
-		checkConnection("EmbeddedXADataSource", xac.getConnection());
+		checkConnection("XADataSource", xac.getConnection());
 
 		// BUG 4471 - check outstanding updates are rolled back wi XAConnection.
 		c1 = xac.getConnection();
@@ -188,7 +245,9 @@
 
 		// this update should be rolled back
 		s.executeUpdate("insert into t values(2)");
-
+		if (needRollbackBeforePCGetConnection)
+			c1.rollback();
+		
 		c1 = xac.getConnection();
 
 		rs = c1.createStatement().executeQuery("select count(*) from t");
@@ -203,14 +262,16 @@
 		xac.close();
 		xac = null;
 
-		testPoolReset("EmbeddedXADataSource", dsx.getXAConnection());
+		testPoolReset("XADataSource", dsx.getXAConnection());
 
 
-
-		try {
-			DriverManager.getConnection("jdbc:derby:;shutdown=true");
-		} catch (SQLException sqle) {
-			JDBCDisplayUtil.ShowSQLException(System.out, sqle);
+		// DERBY-1326 - hang in client after Derby system shutdown
+		if(! hangAfterSystemShutdown) {
+			try {
+				TestUtil.getConnection("","shutdown=true");
+			} catch (SQLException sqle) {
+				JDBCDisplayUtil.ShowSQLException(System.out, sqle);
+			}
 		}
 
 		dmc = ij.startJBMS();
@@ -222,24 +283,28 @@
 
 		checkConnection("DriverManager ", dmc);
 
-		// reset ds back to the EmbeddedDataSource
+		// reset ds back to the Regular DataSource
 		ds = dscs;
-		checkConnection("EmbeddedDataSource", ds.getConnection());
+		checkConnection("DataSource", ds.getConnection());
 		
 		// and back to EmbeddedSimpleDataSource
-		ds = dssimple;
-		checkConnection("EmbeddedSimpleDataSource", dssimple.getConnection());
+		if(TestUtil.isEmbeddedFramework())
+		{
+			// JSR169 (SimpleDataSource) is only available on embedded.
+			ds = dssimple;
+			checkConnection("EmbeddedSimpleDataSource", dssimple.getConnection());
+		}
 		
 		pc = dsp.getPooledConnection();
 		pc.addConnectionEventListener(new EventCatcher(2));
-		checkConnection("EmbeddedConnectionPoolDataSource", pc.getConnection());
-		checkConnection("EmbeddedConnectionPoolDataSource", pc.getConnection());
+		checkConnection("ConnectionPoolDataSource", pc.getConnection());
+		checkConnection("ConnectionPoolDataSource", pc.getConnection());
 
 		// test "local" XAConnections
 		xac = dsx.getXAConnection();
 		xac.addConnectionEventListener(new EventCatcher(4));
-		checkConnection("EmbeddedXADataSource", xac.getConnection());
-		checkConnection("EmbeddedXADataSource", xac.getConnection());
+		checkConnection("XADataSource", xac.getConnection());
+		checkConnection("XADataSource", xac.getConnection());
 		xac.close();
 
 		// test "global" XAConnections
@@ -250,19 +315,19 @@
 		xar.start(xid, XAResource.TMNOFLAGS);
 		Connection xacc = xac.getConnection();
 		xacc.close();
-		checkConnection("Global EmbeddedXADataSource", xac.getConnection());
-		checkConnection("Global EmbeddedXADataSource", xac.getConnection());
+		checkConnection("Global XADataSource", xac.getConnection());
+		checkConnection("Global XADataSource", xac.getConnection());
 
 		xar.end(xid, XAResource.TMSUCCESS);
 
-		checkConnection("Switch to local EmbeddedXADataSource", xac.getConnection());
-		checkConnection("Switch to local EmbeddedXADataSource", xac.getConnection());
+		checkConnection("Switch to local XADataSource", xac.getConnection());
+		checkConnection("Switch to local XADataSource", xac.getConnection());
 
 		Connection backtoGlobal = xac.getConnection();
 
 		xar.start(xid, XAResource.TMJOIN);
-		checkConnection("Switch to global EmbeddedXADataSource", backtoGlobal);
-		checkConnection("Switch to global EmbeddedXADataSource", xac.getConnection());
+		checkConnection("Switch to global XADataSource", backtoGlobal);
+		checkConnection("Switch to global XADataSource", xac.getConnection());
 		xar.end(xid, XAResource.TMSUCCESS);
 		xar.commit(xid, true);
 
@@ -301,7 +366,9 @@
 		// and isolation level from the transaction,
 		// holdability remains that of this handle.
 		xar.start(xid, XAResource.TMJOIN);
-		printState("re-join X1", cs1);
+		// DERBY-1148
+		if (isolationSetProperlyOnJoin)
+			printState("re-join X1", cs1);
 		xar.end(xid, XAResource.TMSUCCESS);
 
 		// should be the same as the reset local
@@ -318,7 +385,9 @@
 
 		xar.start(xid, XAResource.TMJOIN);
 		cs1 = xac.getConnection();
-		printState("re-join with new handle X1", cs1);
+		// DERBY-1148
+		if (isolationSetProperlyOnJoin)
+			printState("re-join with new handle X1", cs1);
 		cs1.close();
 		xar.end(xid, XAResource.TMSUCCESS);
 
@@ -329,7 +398,9 @@
 		cs1.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
 		printState("pre-X1 commit - local", cs1);
 		xar.start(xid, XAResource.TMJOIN);
-		printState("pre-X1 commit - X1", cs1);
+		// DERBY-1148
+		if (isolationSetProperlyOnJoin)
+			printState("pre-X1 commit - X1", cs1);
 		xar.end(xid, XAResource.TMSUCCESS);
 		printState("post-X1 end - local", cs1);
 		xar.commit(xid, true);
@@ -346,58 +417,8 @@
 		cs1.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
 		printState("setTransactionIsolation in local", cs1);
 
-    System.out.println("Issue SQL to change isolation in local transaction");
-		s.executeUpdate("set current isolation = RR");
-		printState("SQL to change isolation in local", cs1);
-
-		xid = new cdsXid(1, (byte) 35, (byte) 47);
-		xar.start(xid, XAResource.TMNOFLAGS);
-		printState("1st global(new)", cs1);
-		xar.end(xid, XAResource.TMSUCCESS);
-
-		printState("local", cs1);
-    System.out.println("Issue SQL to change isolation in local transaction");
-		s.executeUpdate("set current isolation = RS");
-		printState("SQL to change isolation in local", cs1);
-		
-		// DERBY-1325 - Isolation level of local connection does not get reset after ending 
-		// a global transaction that was joined/resumed if the isolation level was changed 
-		// using SQL 
-		xar.start(xid, XAResource.TMJOIN);
-		printState("1st global(existing)", cs1);
-		xar.end(xid, XAResource.TMSUCCESS);
-		printState("local", cs1);
-		// DERBY-1325 end test 
-		
-		Xid xid2 = new cdsXid(1, (byte) 93, (byte) 103);
-		xar.start(xid2, XAResource.TMNOFLAGS);
-		printState("2nd global(new)", cs1);
-		xar.end(xid2, XAResource.TMSUCCESS);
-
-		xar.start(xid, XAResource.TMJOIN);
-		printState("1st global(existing)", cs1);
-		xar.end(xid, XAResource.TMSUCCESS);
-
-		printState("local", cs1);
-
-		xar.start(xid, XAResource.TMJOIN);
-		printState("1st global(existing)", cs1);
-    System.out.println("Issue SQL to change isolation in 1st global transaction");
-		s.executeUpdate("set current isolation = UR");
-		printState("change isolation of existing 1st global transaction", cs1);
-		xar.end(xid, XAResource.TMSUCCESS);
-
-		printState("local", cs1);
-
-		xar.start(xid2, XAResource.TMJOIN);
-		printState("2nd global(existing)", cs1);
-		xar.end(xid2, XAResource.TMSUCCESS);
-
-		xar.rollback(xid2);
-		printState("(After 2nd global rollback) local", cs1);
-
-		xar.rollback(xid);
-		printState("(After 1st global rollback) local", cs1);
+		if (canSetIsolationWithStatement)
+			testSetIsolationWithStatement(s, xar, cs1);
 
 		// now check re-use of *Statement objects across local/global connections.
 		System.out.println("TESTING RE_USE OF STATEMENT OBJECTS");
@@ -594,11 +615,16 @@
 		rs4 = s4.executeQuery("select i from autocommitxastart");
 		rs4.next(); System.out.println("acxs " + rs4.getInt(1));
 		rs4.next(); System.out.println("acxs " + rs4.getInt(1));
-
+		
+		 // Get a new xid to begin another transaction. 
+		 // This should give XAER_OUTSIDE exception because
+		 // the resource manager is busy in the local transaction
+		 xid4a = new cdsXid(4, (byte) 93, (byte) 103);
 		try {
 			xac4.getXAResource().start(xid4a, XAResource.TMNOFLAGS);
 		} catch (XAException xae) {
 			showXAException("autocommitxastart expected ", xae);
+			System.out.println("Expected XA error code: " + xae.errorCode);
 		}
 		rs4.next(); System.out.println("acxs " + rs4.getInt(1));
 		rs4.close();
@@ -636,11 +662,79 @@
 		} catch (Exception e) {
 				System.out.println("; wrong, unexpected exception: " + e.toString());
 		}
-
+		// skip testDSRequestAuthentication for  client because of these 
+		// two issues:
+		// DERBY-1130 : Client should not allow databaseName to be set with
+		// setConnectionAttributes
+		// DERBY-1131 : Deprecate  Derby DataSource property attributesAsPassword
+		if (TestUtil.isDerbyNetClientFramework())
+			return;
 		testDSRequestAuthentication();
 		
 	}
 
+	/**
+	 * @param s
+	 * @param xar
+	 * @param conn
+	 * @throws SQLException
+	 * @throws XAException
+	 */
+	private void testSetIsolationWithStatement(Statement s, XAResource xar, Connection conn) throws SQLException, XAException {
+		Xid xid;
+		System.out.println("Issue SQL to change isolation in local transaction");
+			s.executeUpdate("set current isolation = RR");
+			printState("SQL to change isolation in local", conn);
+
+			xid = new cdsXid(1, (byte) 35, (byte) 47);
+			xar.start(xid, XAResource.TMNOFLAGS);
+			printState("1st global(new)", conn);
+			xar.end(xid, XAResource.TMSUCCESS);
+
+			printState("local", conn);
+		System.out.println("Issue SQL to change isolation in local transaction");
+			s.executeUpdate("set current isolation = RS");
+			printState("SQL to change isolation in local", conn);
+
+			// DERBY-1325 - Isolation level of local connection does not get reset after ending 
+			// a global transaction that was joined/resumed if the isolation level was changed 
+			// using SQL 
+			xar.start(xid, XAResource.TMJOIN);
+			printState("1st global(existing)", conn);
+			xar.end(xid, XAResource.TMSUCCESS);
+			printState("local", conn);
+			// DERBY-1325 end test 
+			
+			Xid xid2 = new cdsXid(1, (byte) 93, (byte) 103);
+			xar.start(xid2, XAResource.TMNOFLAGS);
+			printState("2nd global(new)", conn);
+			xar.end(xid2, XAResource.TMSUCCESS);
+
+			xar.start(xid, XAResource.TMJOIN);
+			printState("1st global(existing)", conn);
+			xar.end(xid, XAResource.TMSUCCESS);
+
+			printState("local", conn);
+
+			xar.start(xid, XAResource.TMJOIN);
+			printState("1st global(existing)", conn);
+		System.out.println("Issue SQL to change isolation in 1st global transaction");
+			s.executeUpdate("set current isolation = UR");
+			printState("change isolation of existing 1st global transaction", conn);
+			xar.end(xid, XAResource.TMSUCCESS);
+
+			printState("local", conn);
+
+			xar.start(xid2, XAResource.TMJOIN);
+			printState("2nd global(existing)", conn);
+			xar.end(xid2, XAResource.TMSUCCESS);
+			xar.rollback(xid2);
+			printState("(After 2nd global rollback) local", conn);
+
+			xar.rollback(xid);
+			printState("(After 1st global rollback) local", conn);
+	}
+
 	protected void showXAException(String tag, XAException xae) {
 
 		System.out.println(tag + " : XAException - " + xae.getMessage());
@@ -676,7 +770,10 @@
 	}
 	protected PreparedStatement createFloatStatementForStateChecking(Connection conn, String sql) throws SQLException {
 		PreparedStatement s = internalCreateFloatStatementForStateChecking(conn, sql);
-		s.setCursorName("StokeNewington");
+		// Need to make a different cursor name here because of DERBY-1036
+		// client won't allow duplicate name.
+		//s.setCursorName("StokeNewington");
+		s.setCursorName("LondonNW17");
 		s.setFetchDirection(ResultSet.FETCH_REVERSE);
 		s.setFetchSize(888);
 		s.setMaxFieldSize(317);
@@ -687,7 +784,9 @@
 	}
 	protected CallableStatement createFloatCallForStateChecking(Connection conn, String sql) throws SQLException {
 		CallableStatement s = internalCreateFloatCallForStateChecking(conn, sql);
-		s.setCursorName("StokeNewington");
+		//DERBY-1036 - need a new name
+		//s.setCursorName("StokeNewington");
+		s.setCursorName("districtInLondon");
 		s.setFetchDirection(ResultSet.FETCH_REVERSE);
 		s.setFetchSize(999);
 		s.setMaxFieldSize(137);
@@ -702,6 +801,16 @@
 	protected CallableStatement internalCreateFloatCallForStateChecking(Connection conn, String sql) throws SQLException {
 		return conn.prepareCall(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
 	}
+    
+    /**
+     * Return the Java class and method for the procedure
+     * for the nested connection test.
+     * checkDataSource 30 will override.
+     */
+    protected String getNestedMethodName()
+    {
+        return "checkDataSource.checkNesConn";
+    }
 
 	static String rsType(int type) {
 		switch (type) {
@@ -770,7 +879,15 @@
 	}
 
 	private static void resultSetQuery(String tag, ResultSet rs) throws SQLException {
-		System.out.print(tag + ": ru(" + rs.getCursorName() + ") contents");
+		String cursorName = rs.getCursorName();
+		//	DERBY-1183 client cursor name is not correct.
+		// need to truncate the cursor number of the generated name as it might
+		// not be consistent.
+		if (hasGetCursorNameBug && cursorName.startsWith("SQL_CUR"))
+		{
+			cursorName = cursorName.substring(0,13);
+		}
+		System.out.print(tag + ": ru(" + cursorName + ") contents");
 		while (rs.next()) {
 			System.out.print(" {" + rs.getInt(1) + "}");
 		}
@@ -794,33 +911,9 @@
 
 	//calling checkConnection - for use in a procedure to get a nested connection.
 	public static void checkNesConn (String dsName) throws SQLException {
-		checkConnectionS(dsName, DriverManager.getConnection("jdbc:default:connection"));
-			
-	}
-
-	public static void checkConnectionS(String dsName, Connection conn) throws SQLException {
-
-		System.out.println("Running connection checks on " + dsName);
-
-		//System.out.println("  url             " + conn.getMetaData().getURL());
-		System.out.println("  isolation level " + conn.getTransactionIsolation());
-		System.out.println("  auto commit     " + conn.getAutoCommit());
-		System.out.println("  read only       " + conn.isReadOnly());
-
-		// when 4729 is fixed, remove the startsWith() clause
-		if (dsName.endsWith("DataSource") && !dsName.startsWith("Global"))
-			System.out.println("  has warnings    " + (conn.getWarnings() != null));
-
-		checkStatementS(conn, conn.createStatement());
-		checkStatementS(conn, conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY));
-
-		Connection c1 = conn.getMetaData().getConnection();
-		if (c1 != conn)
-			System.out.println("FAIL incorrect connection object returned for DatabaseMetaData.getConnection()");
-
-		checkConnectionPreCloseS(dsName, conn);
-		conn.close();
-	}
+        Connection conn = DriverManager.getConnection("jdbc:default:connection");
+        new checkDataSource().checkConnection(dsName, conn);			
+    }
 
 	public void checkConnection(String dsName, Connection conn) throws SQLException {
 
@@ -836,8 +929,8 @@
 			System.out.println("  has warnings    " + (conn.getWarnings() != null));
 
 		Statement s1 = conn.createStatement();
-		checkStatement(conn, s1);
-		checkStatement(conn, conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY));
+		checkStatement(dsName, conn, s1);
+		checkStatement(dsName, conn, conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY));
 
 		Connection c1 = conn.getMetaData().getConnection();
 		if (c1 != conn)
@@ -895,7 +988,7 @@
     /**
      * Make sure this connection's string is unique (DERBY-243)
      */
-    protected void checkToString(Connection conn) throws Exception
+    protected static void checkToString(Connection conn) throws Exception
     {
         String str = conn.toString();
 
@@ -911,7 +1004,7 @@
      * Clear out and close connections in the connections
      * hashtable. 
      */
-    protected void clearConnections() throws SQLException
+    protected static void clearConnections() throws SQLException
     {
         java.util.Iterator it = conns.values().iterator();
         while ( it.hasNext() )
@@ -926,7 +1019,7 @@
      * Get connections  using ij.startJBMS() and make sure
      * they're unique
      */
-    protected void checkJBMSToString() throws Exception
+    protected static void checkJBMSToString() throws Exception
     {
         clearConnections();
         // Open ten connections rather than just two to
@@ -947,7 +1040,7 @@
      * Check uniqueness of connection strings coming from a
      * DataSouce
      */
-    protected void checkToString(DataSource ds) throws Exception
+    protected static void checkToString(DataSource ds) throws Exception
     {
         clearConnections();
         
@@ -966,7 +1059,7 @@
      * We want to check the PooledConnection as well as the
      * underlying physical connection. 
      */
-    protected void checkToString(ConnectionPoolDataSource pds)
+    protected static void checkToString(ConnectionPoolDataSource pds)
         throws Exception
     {
         int numConnections = 10;
@@ -1006,26 +1099,12 @@
             pc.close();
         }
         pooledConns.clear();
-        
-        // Now check that two connections from the same 
-        // PooledConnection have the same string value
-        PooledConnection pc = pds.getPooledConnection();
-        Connection conn = pc.getConnection();
-        String str = conn.toString();
-        conn = pc.getConnection();
-        if ( ! conn.toString().equals(str) )
-        {
-            throw new Exception("Two connections from the " +
-              "same pooled connection have different string " +
-              "values: " + str + ", " + conn.toString());
-        }
-        pc.close();
     }
     
     /**
      * Check uniqueness of strings for an XA data source
      */
-    protected void checkToString(XADataSource xds) throws Exception
+    protected static void checkToString(XADataSource xds) throws Exception
     {
         int numConnections = 10;
         
@@ -1064,35 +1143,7 @@
             xc.close();
         }
         xaConns.clear();
-        
-        // Now check that two connections from the same 
-        // XAConnection have the same string value
-        XAConnection xc = xds.getXAConnection();
-        Connection conn = xc.getConnection();
-        String str = conn.toString();
-        conn = xc.getConnection();
-        if ( ! conn.toString().equals(str) )
-        {
-            throw new Exception("Two connections from the " +
-              "same pooled connection have different string " +
-              "values: " + str + ", " + conn.toString());
-        }
-        xc.close();
     }
-    
-	protected static void checkConnectionPreCloseS(String dsName, Connection conn) throws SQLException {
-		if (dsName.endsWith("DataSource")) {
-
-			// see if setting the state is carried over to any future connection from the
-			// data source object.
-			try {
-				conn.setReadOnly(true);
-			} catch (SQLException sqle) {
-				// cannot set read-only in an active transaction, & sometimes
-				// connections are active at this point.
-			}
-		}
-	}
 
 	protected void checkConnectionPreClose(String dsName, Connection conn) throws SQLException {
 		if (dsName.endsWith("DataSource")) {
@@ -1108,23 +1159,7 @@
 		}
 	}
 
-	protected static void checkStatementS(Connection conn, Statement s) throws SQLException {
-
-		Connection c1 = s.getConnection();
-		if (c1 != conn)
-			System.out.println("FAIL incorrect connection object returned for Statement.getConnection()");
-
-		s.addBatch("insert into y values 1");
-		s.addBatch("insert into y values 2,3");
-		int[] states = s.executeBatch();
-		if (states[0] != 1)
-			System.out.println("FAIL invalid update count for first batch statement");
-		if (states[1] != 2)
-			System.out.println("FAIL invalid update count for second batch statement");
-
-		s.close();
-	}
-	protected void checkStatement(Connection conn, Statement s) throws SQLException {
+	protected void checkStatement(String dsName, Connection conn, Statement s) throws SQLException {
 
 		Connection c1 = s.getConnection();
 		if (c1 != conn)
@@ -1138,6 +1173,10 @@
 		if (states[1] != 2)
 			System.out.println("FAIL invalid update count for second batch statement");
 
+        ResultSet rs = s.executeQuery("VALUES 1");
+        if (rs.getStatement() != s)
+            System.out.println(dsName + " FAIL incorrect Statement object returned for ResultSet.getStatement");
+        rs.close();
 		s.close();
 	}
 

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java?rev=410665&r1=410664&r2=410665&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java Wed May 31 13:53:51 2006
@@ -20,38 +20,34 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource;
-import org.apache.derby.jdbc.EmbeddedXADataSource;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.PreparedStatement;
 import java.sql.CallableStatement;
-import java.sql.Statement;
-import java.sql.SQLException;
+import java.sql.Connection;
 import java.sql.DriverManager;
-import java.sql.Savepoint;
 import java.sql.ParameterMetaData;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
 
-import javax.sql.DataSource;
-import javax.sql.XADataSource;
-import javax.sql.XAConnection;
 import javax.sql.ConnectionPoolDataSource;
-import javax.transaction.xa.XAResource;
+import javax.sql.PooledConnection;
+import javax.sql.XAConnection;
+import javax.sql.XADataSource;
 import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
-import javax.sql.ConnectionEventListener;
-import javax.sql.ConnectionEvent;
-import org.apache.derby.tools.JDBCDisplayUtil;
-import org.apache.derby.tools.ij;
 
-import java.io.*;
-import java.util.Hashtable;
+import org.apache.derby.tools.JDBCDisplayUtil;
+import org.apache.derbyTesting.functionTests.util.TestUtil;
 
-import javax.naming.*;
-import javax.naming.directory.*;
 
+/**
+ * Extends checkDataSource to provide testing of JDBC 3.0 specific
+ * methods for the embedded DataSource implementations.
+ * @author djd
+ *
+ */
 public class checkDataSource30 extends checkDataSource
 { 
 
@@ -62,12 +58,15 @@
 
 		tester.runTest(args);
 		tester.checkXAHoldability();
+		
+		testDerby1144();
+
 		System.out.println("Completed checkDataSource30");
 
 	}
 
 
-	public checkDataSource30() throws Exception {
+	public checkDataSource30() {
 	}
 
 	public void checkConnection(String dsName, Connection conn) throws SQLException {
@@ -155,9 +154,11 @@
 	private void checkXAHoldability() {
 		System.out.println("START XA HOLDABILITY TEST");
 		try {
-			EmbeddedXADataSource dscsx = new EmbeddedXADataSource();
-			dscsx.setDatabaseName("wombat");
-
+			Properties attrs = new Properties();
+			attrs.setProperty("databaseName", "wombat");
+			attrs.setProperty("connectionAttributes", "create=true");
+			XADataSource dscsx =  TestUtil.getXADataSource(attrs);
+		
 			XAConnection xac = dscsx.getXAConnection("fred", "wilma");
 			XAResource xr = xac.getXAResource();
 			Xid xid = getXid(25, (byte) 21, (byte) 01);
@@ -298,8 +299,7 @@
 			} catch (SQLException sqle) {
 				System.out.println("Expected SQLException(setHoldability) " + sqle.getMessage());
 			}
-
-			// try to create a statement with held attributes
+			
             // JDBC 4.0 (proposed final draft) section 16.1.3.1 allows Statements to
             // be created with a different holdability if the driver cannot support it.
             // In this case the driver does not support holdability in a global transaction
@@ -369,4 +369,302 @@
 		}
 		System.out.flush();
 	}
+    
+    /**
+     * Perform connection checks on the default connection
+     * using checkDataSourc30.
+     */
+    public static void checkNesConn30(String dsName) throws SQLException {
+        Connection conn = DriverManager.getConnection("jdbc:default:connection");
+        new checkDataSource30().checkConnection(dsName, conn);            
+    }
+
+    
+    /**
+     * USe checkNesConn30 for the procedure, will
+     * cause the 30 checks to be invoked as well. 
+     */
+    protected String getNestedMethodName()
+    {
+        return "checkDataSource30.checkNesConn30";
+    }
+    
+    
+    /**
+     * Tests for DERBY-1144
+     * 
+     * This test tests that holdability, autocomit, and transactionIsolation are
+     * reset  on getConnection for PooledConnections obtaind from connectionPoolDataSources 
+     * 
+     * DERBY-1134 has been filed for more comprehensive testing of client connection state. 
+     * 
+     * @throws SQLException
+     */
+    public static void testDerby1144() throws SQLException
+    {
+    	Connection conn = null;
+    	PooledConnection pc1 = null;
+		Properties p = new Properties();
+		
+		p.put("databaseName","sample");
+		p.put("connectionAttributes","create=true");
+		p.put("user","APP");
+		p.put("password","pw");
+		
+        // Test holdability   
+        ConnectionPoolDataSource ds = TestUtil.getConnectionPoolDataSource(p);
+        pc1 = ds.getPooledConnection();
+        testPooledConnHoldability("PooledConnection", pc1);
+        pc1.close();
+        
+        // Test autocommit
+        pc1 = ds.getPooledConnection();
+        testPooledConnAutoCommit("PooledConnection", pc1);
+        pc1.close();
+        
+        // Test pooled connection isolation
+		ds = TestUtil.getConnectionPoolDataSource(p);
+		pc1 = ds.getPooledConnection();
+		testPooledConnIso("PooledConnection" , pc1);   
+        pc1.close();
+       
+        // Test xa connection isolation
+		XADataSource xds = TestUtil.getXADataSource(p);
+    	XAConnection xpc1 = xds.getXAConnection();        
+        testPooledConnIso("XAConnection", xpc1);                 
+        xpc1.close();
+      }
+  
+    
+	/**
+	 * Make sure autocommit gets reset on PooledConnection.getConnection()
+	 * @param desc		description of connection
+	 * @param pc1		pooled connection to test
+	 * @throws SQLException
+	 */
+	private static void testPooledConnAutoCommit(String desc, PooledConnection pc1) throws SQLException {
+		System.out.println("\n** Test autoCommit state for: " + desc + "**");
+		Connection conn  = pc1.getConnection();
+		conn.setAutoCommit(true);
+		// reset the connection and see if the autocommit 
+		conn = pc1.getConnection();
+		boolean autocommit  = conn.getAutoCommit();
+		if (autocommit != true)
+		{
+			new Exception("FAIL: autoCommit not reset on getConnection").printStackTrace(System.out);			
+		}
+		else 
+		{
+			System.out.println("PASS: autoCommit reset on getConnection");
+		}
+		conn.close();
+	}
+
+
+	/**
+	 * Test Holdability gets reset on PooledConnection.getConnection()
+	 * @param desc
+	 * @param pc1
+	 * @throws SQLException
+	 */
+	private static void testPooledConnHoldability(String desc, PooledConnection pc1) 
+	throws SQLException { 
+		System.out.println("\n**Test holdability state for: " + desc + " **");
+		Connection conn  = pc1.getConnection();
+		conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);
+		// reset the connection and see if the holdability gets reset
+		// to HOLD_CURSORS_OVER_COMMIT
+		conn = pc1.getConnection();
+		checkConnHoldability(conn, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+		conn.close();
+	}
+	
+
+
+	/**
+	 * Verify connection holdablity is expected holdability
+	 * @param conn
+	 * @param expectedHoldability 
+	 * 	 * @throws SQLException
+	 */
+	private static void checkConnHoldability(Connection conn, 
+				int expectedHoldability) throws SQLException {
+		int holdability = conn.getHoldability();
+		if (holdability != expectedHoldability)
+		{
+			new Exception("FAIL: Holdability:" + translateHoldability(holdability) +
+					" does not match expected holdability:" +
+						translateHoldability(expectedHoldability)).printStackTrace(System.out);			
+		}
+		else 
+		{
+			System.out.println("PASS: Holdability matches expected holdability:" +
+					translateHoldability(expectedHoldability));
+		}
+	}
+
+
+	/**
+	 * Test that isolation is reset on PooledConnection.getConnection()
+	 * @param pooledConnType   Descripiton of the type of pooled connection
+	 * @param pc
+	 * @throws SQLException
+	 */
+	private static void testPooledConnIso(String pooledConnType, PooledConnection pc)
+	 throws SQLException {
+			 Connection conn = pc.getConnection();
+             
+			 setupDerby1144Table(conn);
+			 System.out.println("*** Test isolation level reset on " + pooledConnType+ ".getConnection()***");;			 
+			 System.out.println("\nsetTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED");
+			 conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
+			 checkIsoLocks(conn,Connection.TRANSACTION_READ_UNCOMMITTED);
+			 
+			 conn.close();
+			 System.out.println("\nGet a new connection with " + pooledConnType+ ".getConnection()");
+			 System.out.println("Isolation level should be reset to READ_COMMITTED");
+			 Connection newconn = pc.getConnection();
+			 checkIsoLocks(newconn,Connection.TRANSACTION_READ_COMMITTED);
+			 
+      
+	}
+
+
+	/**
+	 * Make a simple table for DERBY-1144 tests
+	 * @param conn
+	 * @throws SQLException
+	 */
+	private static void  setupDerby1144Table(Connection conn) throws SQLException
+	{
+		Statement stmt = conn.createStatement();
+		try {
+			stmt.executeUpdate("DROP TABLE TAB1");
+		}
+		catch (SQLException e)
+		{
+			// ignore drop error
+		}
+		stmt.executeUpdate("CREATE TABLE TAB1(COL1 INT NOT NULL)");
+		stmt.executeUpdate("INSERT INTO TAB1 VALUES(1)");
+		stmt.executeUpdate("INSERT INTO TAB1 VALUES(2)");
+
+        System.out.println("done creating  table");
+             conn.commit ();
+    }
+
+
+	
+	
+	/* 
+	 * Checks locks for designated isolation level on the connection.
+	 * Currently only supports TRANSACTION_READ_COMMITTED and 
+	 * TRANSACTION_READ_UNCOMMITTED
+	 * @param conn   Connection to test
+	 * @param isoLevel expected isolation level
+	 *
+	 */
+	private static void checkIsoLocks(Connection conn, int expectedIsoLevel)
+	{
+		try {
+			int conniso = conn.getTransactionIsolation();
+			if (conniso !=  expectedIsoLevel)
+			{
+				new  Exception("FAIL: Connection isolation level " + 
+						translateIso(conniso) + 
+						" does not match expected level " +
+						translateIso(expectedIsoLevel));
+			}			
+
+			boolean selectTimedOut  = selectTimesoutDuringUpdate(conn);
+			switch (conniso) {
+				case Connection.TRANSACTION_READ_UNCOMMITTED:
+					if (selectTimedOut)
+						new Exception("FAIL: Unexpected lock timeout for READ_UNCOMMITTED").printStackTrace(System.out);
+					else
+						System.out.println("PASS: No lock timeout occurs for READ_UNCOMMITTED");
+					case Connection.TRANSACTION_READ_COMMITTED:
+					if (selectTimedOut)	
+						System.out.println("PASS: Expected lock timeout for READ_COMMITTED");
+					else
+						new Exception("FAIL: Did not get lock timeout for READ_COMMITTED");
+					default:
+						new Exception("No test support for isolation level" + 
+									translateIso(conniso));
+			}
+		} catch (SQLException se) {
+			se.printStackTrace();	
+		}
+	}
+	
+	/**
+	 * Determine if a select on this connection during update will timeout.
+	 * Used to establish isolation level.  If the connection isolation level
+	 * is <code> Connection.TRANSACTION_READ_UNCOMMITTED </code> it will not
+	 * timeout.  Otherwise it should.  
+	 * 
+	 * @param conn   Connection to test.
+	 * @return  true if the select got a lock timeout, false otherwise.
+	 */
+	private static boolean selectTimesoutDuringUpdate(Connection conn) 	{
+	 Connection updateConn = null;
+	
+		try {
+		
+		conn.setAutoCommit(false);
+		// create another connection and do an update but don't commit
+		updateConn = TestUtil.getConnection("sample","create=true");
+		updateConn.setAutoCommit(false);
+		
+		
+		// First update the rows on the update connection
+		Statement upStmt = updateConn.createStatement();
+		upStmt.executeUpdate("update tab1 set col1 = 3");
+
+		// now see if we can select them
+
+		Statement stmt = conn.createStatement();
+		ResultSet rs = stmt.executeQuery("Select * from tab1");
+		while (rs.next()){};
+		rs.close();
+
+		}
+		catch (SQLException e)
+		{
+			if (e.getSQLState().equals("40XL1"))
+			{
+				// If we got a lock timeout this is not read uncommitted
+				return true;
+			}	
+
+		}
+		finally {
+
+			try {
+				conn.rollback();
+				updateConn.rollback();
+			}catch (SQLException  se) {
+				se.printStackTrace();
+			}
+		}
+		return false;
+		
+	}
+	
+	/**
+	 * Translate holdability int readable format.
+	 * 
+	 * @param holdability   holdability to translate.
+	 * @return  "HOLD_CURSORS_OVER_COMMIT" or "CLOSE_CURSORS_AT_COMMIT"
+	 */
+	public static String translateHoldability(int holdability)
+	{
+		switch (holdability)
+		{
+			case ResultSet.HOLD_CURSORS_OVER_COMMIT : return  "HOLD_CURSORS_OVER_COMMIT";
+			case ResultSet.CLOSE_CURSORS_AT_COMMIT : return  "CLOSE_CURSORS_AT_COMMIT";
+		}
+		return "UNKNOWN_HOLDABILTY";
+	}    
+
 }

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?rev=410665&r1=410664&r2=410665&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy Wed May 31 13:53:51 2006
@@ -65,12 +65,23 @@
 };
 
 //
+// Permissions for the tests (derbyTesting.jar)
+// We are liberal here, it's not a goal to make the test harness
+// or tests secure.
+//
+grant codeBase "${csinfo.codejar}derbyTesting.jar" {
+  // Access all properties using System.getProperties
+  permission java.util.PropertyPermission "*", "read, write";
+};
+
+//
 // super-set of the jar permissions for running out of the classes directory
 //
 grant codeBase "${csinfo.codeclasses}" {
 
   permission java.util.PropertyPermission "derby.*", "read";
   permission java.lang.RuntimePermission "createClassLoader";
+  permission java.util.PropertyPermission "*", "read, write";
    
   permission java.io.FilePermission "${derby.system.home}${/}derby.properties", "read";
   permission java.io.FilePermission "${derby.system.home}${/}derby.log", "read, write, delete";



Mime
View raw message