You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2006/02/17 15:42:01 UTC

svn commit: r378532 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/DerbyNetClient/checkDataSource30.out suites/DerbyNetClient.exclude tests/jdbcapi/checkDataSource.java tests/jdbcapi/checkDataSource30.java

Author: kmarsden
Date: Fri Feb 17 06:41:59 2006
New Revision: 378532

URL: http://svn.apache.org/viewcvs?rev=378532&view=rev
Log:
DERBY-435 jdbapi/checkDataSource30.java test should be changed or extended to test client DataSources
 patch 2 - checkDataSource30 holdability testing for client
 
- Enables the checkDataSource30 test for holdability tests that are currently passing.
  There appear to be several holdability bugs associated with network XA in additon to DERBY-966.

- Makes some progress toward getting checkDataSource.java to run with client, but it is not enabled yet.
  - Changed to only run connection toString tests for embedded.
  - Changed to only test SimpleDataSource for embedded
 - Changed to perform an explicit rollback of active transactions for client before performing a PooledConnection.getConnection()
  I think this is an issue with embedded that it allows a PooledConnection.getConnection() with an active transaction, instead of throwing an error if the transaction is active.



Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out   (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out?rev=378532&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out Fri Feb 17 06:41:59 2006
@@ -0,0 +1,41 @@
+START XA HOLDABILITY TEST
+By default, autocommit is true for a connection
+Default holdability for a connection is HOLD_CURSORS_OVER_COMMIT
+CONNECTION(not in xa transaction yet) HOLDABILITY true
+Notice that autocommit now is false for connection because it is part of the global transaction
+Autocommit on Connection inside global transaction has been set correctly to false
+CONNECTION(non-xa) HOLDABILITY false
+STATEMENT HOLDABILITY false
+STATEMENT HOLDABILITY false
+STATEMENT HOLDABILITY true
+PREPARED STATEMENT HOLDABILITY true
+CALLABLE STATEMENT HOLDABILITY true
+H@1 id 1
+H@2 id 2
+H@3 id 3
+CONNECTION(xa) HOLDABILITY false
+STATEMENT(this one was created with holdability false, outside the global transaction. Check it's holdability inside global transaction) HOLDABILITY false
+STATEMENT(this one was created with holdability true, outside the global transaction. Check it's holdability inside global transaction) HOLDABILITY true
+STATEMENT(this one was created with default holdability inside this global transaction. Check it's holdability) HOLDABILITY false
+PREPAREDSTATEMENT(this one was created with default holdability inside this global transaction. Check it's holdability) HOLDABILITY false
+CALLABLESTATEMENT(this one was created with default holdability inside this global transaction. Check it's holdability) HOLDABILITY false
+X@1 id 1
+X@2 id 2
+Expected SQLException No current connection. : 
+Expected SQLException Invalid operation: result set closed
+resume XA transaction and keep using rs
+Check holdability of various jdbc objects after resuming XA transaction
+CONNECTION(xa) HOLDABILITY false
+STATEMENT(this one was created with holdability false, outside the global transaction. Check it's holdability inside global transaction) HOLDABILITY false
+STATEMENT(this one was created with holdability true, outside the global transaction. Check it's holdability inside global transaction) HOLDABILITY true
+STATEMENT(this one was created with default holdability inside the global transaction when it was first started. Check it's holdability) HOLDABILITY false
+PREPAREDSTATEMENT(this one was created with default holdability inside the global transaction when it was first started. Check it's holdability) HOLDABILITY false
+CALLABLESTATEMENT(this one was created with default holdability inside the global transaction when it was first started. Check it's holdability) HOLDABILITY false
+STATEMENT(this one was created with default holdability after the global transaction was resumed. Check it's holdability) HOLDABILITY false
+PREPAREDSTATEMENT(this one was created with default holdability after the global transaction was resumed. Check it's holdability) HOLDABILITY false
+CALLABLESTATEMENT(this one was created with default holdability after the global transaction was resumed. Check it's holdability) HOLDABILITY false
+Expected SQLException Invalid operation: result set closed
+Expected SQLException Invalid operation: result set closed
+Set connection to hold 
+CONNECTION(held) HOLDABILITY true
+Completed checkDataSource30

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
------------------------------------------------------------------------------
    svn:eol-style = native

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=378532&r1=378531&r2=378532&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 Fri Feb 17 06:41:59 2006
@@ -4,7 +4,6 @@
 # excluding statementJdbc20.java because this tests fetch_reverse throughout the test
 # excluding jdbcapi/testRelative.java because it is a new test that requires debugging with the IBM Driver
 # excluding jdbcapi/resultsetJdbc30.java because the features tested are not implemented by Derby Client
-# excluding jdbcapi/checkDataSource30.java - Client behaves differently. Need to look into this
 # excluding jdbcapi/statementJdbc30.java - Client behaves differently. Need to look into this
 # excluding jdbcapi/dataSourceReference.java - client side only tests, tests all data sources
 #           regardless of framework
@@ -16,7 +15,6 @@
 jdbcapi/statementJdbc20.java
 jdbcapi/testRelative.java
 jdbcapi/resultsetJdbc30.java
-jdbcapi/checkDataSource30.java
 jdbcapi/statementJdbc30.java
 jdbcapi/dataSourceReference.java
 largedata/LobLimits.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?rev=378532&r1=378531&r2=378532&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java Fri Feb 17 06:41:59 2006
@@ -64,6 +64,24 @@
  */
 public class checkDataSource
 { 
+	// 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 static boolean testConnectionToString = TestUtil.isEmbeddedFramework();
+	
+	// Only embedded supports SimpleDataSource (JSR169).  
+	// These tests are exempted from other frameworks
+	private static 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
+	// I think client is right here (kmarsden), the user should have to rollback 
+	private static boolean needRollbackBeforePCGetConnection = 
+		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
@@ -132,25 +150,35 @@
 		
 
 		checkConnection("DriverManager ", dmc);
-		checkJBMSToString();
+		if (testConnectionToString)
+			checkJBMSToString();
 
 
 		Properties attrs = new Properties();
 		attrs.setProperty("databaseName", "wombat");
 		DataSource dscs = TestUtil.getDataSource(attrs);
 		
-		checkToString(dscs);
+		if (testConnectionToString) 
+				checkToString(dscs);
 
 		DataSource ds = dscs;
 
 		checkConnection("DataSource", ds.getConnection());
-		
-		DataSource dssimple = TestUtil.getSimpleDataSource(attrs);
-		ds = dssimple;
-		checkConnection("SimpleDataSource", ds.getConnection());		
+		 
+		DataSource dssimple = null;
+		if (testSimpleDataSource)
+		{
+			dssimple = TestUtil.getSimpleDataSource(attrs);
+			ds = dssimple;
+			checkConnection("SimpleDataSource", ds.getConnection());
+		}
 
 		ConnectionPoolDataSource dsp = TestUtil.getConnectionPoolDataSource(attrs);
-		checkToString(dsp);
+		
+		
+		if (testConnectionToString) 
+			checkToString(dsp);
+	
 
 		PooledConnection pc = dsp.getPooledConnection();
 		SecurityCheck.inspect(pc, "javax.sql.PooledConnection");
@@ -172,7 +200,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");
@@ -205,7 +235,8 @@
 		testPoolReset("ConnectionPoolDataSource", dsp.getPooledConnection());
 
 		XADataSource dsx = TestUtil.getXADataSource(attrs);
-		checkToString(dsx);
+		if (testConnectionToString)
+			checkToString(dsx);
 
 		XAConnection xac = dsx.getXAConnection();
 		SecurityCheck.inspect(xac, "javax.sql.XAConnection");
@@ -224,7 +255,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");
@@ -264,8 +297,12 @@
 		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));

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java?rev=378532&r1=378531&r2=378532&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java Fri Feb 17 06:41:59 2006
@@ -52,9 +52,11 @@
 	public static void main(String[] args) throws Exception {
 
 		checkDataSource30 tester = new checkDataSource30();
-
-
-		tester.runTest(args);
+		// portions of this test do not run yet with client and so
+		// are enabled only for embedded with 
+		//  if (TestUtil.isEmbeddedFramework())blocks
+		if (TestUtil.isEmbeddedFramework())
+			tester.runTest(args);
 		tester.checkXAHoldability();
 		
 		// Print a report on System.out of the issues
@@ -156,6 +158,7 @@
 		try {
 			Properties attrs = new Properties();
 			attrs.setProperty("databaseName", "wombat");
+			attrs.setProperty("connectionAttributes", "create=true");
 			XADataSource dscsx =  TestUtil.getXADataSource(attrs);
 		
 			XAConnection xac = dscsx.getXAConnection("fred", "wilma");
@@ -168,8 +171,13 @@
 			//start a global transaction and default holdability and autocommit will be switched to match Derby XA restrictions
 			xr.start(xid, XAResource.TMNOFLAGS);
 			System.out.println("Notice that autocommit now is " + conn1.getAutoCommit() + " for connection because it is part of the global transaction");
-			System.out.println("Notice that connection's holdability at this point is CLOSE_CURSORS_AT_COMMIT because it is part of the global transaction");
-			System.out.println("CONNECTION(in xa transaction) HOLDABILITY " + (conn1.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
+			if (TestUtil.isEmbeddedFramework())
+			{
+				// run only for embedded
+				// Network XA BUG: getHoldability does not return CLOSE_CURSORS_AT_COMMIT for global transaction
+				System.out.println("Notice that connection's holdability at this point is CLOSE_CURSORS_AT_COMMIT because it is part of the global transaction");
+				System.out.println("CONNECTION(in xa transaction) HOLDABILITY " + (conn1.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
+			}
 			xr.end(xid, XAResource.TMSUCCESS);
 			conn1.commit();
 			conn1.close();
@@ -177,7 +185,11 @@
 			xid = getXid(27, (byte) 21, (byte) 01);
 			xr.start(xid, XAResource.TMNOFLAGS);
 			conn1 = xac.getConnection();
-			System.out.println("CONNECTION(in xa transaction) HOLDABILITY " + (conn1.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
+			if (TestUtil.isEmbeddedFramework())
+			{
+				// Network XA BUG: getHoldability in a xa transaction returns true
+				System.out.println("CONNECTION(in xa transaction) HOLDABILITY " + (conn1.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
+			}
 			System.out.println("Autocommit on Connection inside global transaction has been set correctly to " + conn1.getAutoCommit());
 			xr.end(xid, XAResource.TMSUCCESS);
 			conn1.rollback();
@@ -230,6 +242,7 @@
 			System.out.println("CALLABLESTATEMENT(this one was created with default holdability inside this global transaction. Check it's holdability) HOLDABILITY " + (callablestmtInsideGlobalTransaction.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
 
 			ResultSet rsx = s.executeQuery("select id from hold_30 for update");
+			 
 			rsx.next(); System.out.println("X@1 id " + rsx.getInt(1));
 			rsx.next(); System.out.println("X@2 id " + rsx.getInt(1));
 			xr.end(xid, XAResource.TMSUCCESS);
@@ -265,7 +278,11 @@
 			System.out.println("STATEMENT(this one was created with default holdability after the global transaction was resumed. Check it's holdability) HOLDABILITY " + (stmtAfterGlobalTransactionResume.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
 			System.out.println("PREPAREDSTATEMENT(this one was created with default holdability after the global transaction was resumed. Check it's holdability) HOLDABILITY " + (prepstmtAfterGlobalTransactionResume.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
 			System.out.println("CALLABLESTATEMENT(this one was created with default holdability after the global transaction was resumed. Check it's holdability) HOLDABILITY " + (callablestmtAfterGlobalTransactionResume.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
-			rsx.next(); System.out.println("X@3 id " + rsx.getInt(1));
+			if (TestUtil.isEmbeddedFramework())
+			{
+				// Network XA BUG gives result set closed
+				rsx.next(); System.out.println("X@3 id " + rsx.getInt(1));
+			}
 			xr.end(xid, XAResource.TMSUCCESS);
 
 
@@ -278,7 +295,6 @@
 			} catch (SQLException sqle) {
 				System.out.println("Expected SQLException " + sqle.getMessage());
 			}
-
 			try {
 				rsh.next(); System.out.println("FAIL - rsh's should be closed (B) " + rsx.getInt(1));
 			} catch (SQLException sqle) {
@@ -289,6 +305,17 @@
 			conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
 			System.out.println("CONNECTION(held) HOLDABILITY " + (conn.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
 
+			
+			if (!TestUtil.isEmbeddedFramework())
+			{
+				// Don't run the rest of the test for client
+				// Network XA BUG: Client allows set HOLD_CURSORS_OVER_COMMIT 
+				// to be set in a a global transaction on the connection and 
+				// statements
+				conn.close();
+				return;
+			}
+				
 			xid = getXid(24, (byte) 21, (byte) 01);
 			xr.start(xid, XAResource.TMNOFLAGS);
 			System.out.println("CONNECTION(xa) HOLDABILITY " + (conn.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
@@ -298,8 +325,7 @@
 			} catch (SQLException sqle) {
 				System.out.println("Expected SQLException(setHoldability) " + sqle.getMessage());
 			}
-
-			// try to create a statement with held attributes
+			
 			try {
 				Statement shxa = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
 				System.out.println("FAIL opened statement with hold cursor attribute in global transaction");



Re: svn commit: r378532 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/DerbyNetClient/checkDataSource30.out suites/DerbyNetClient.exclude tests/jdbcapi/checkDataSource.java tests/jdbcapi/checkDataSource30.java

Posted by Kathey Marsden <km...@sbcglobal.net>.
Daniel John Debrunner wrote:

>>  - Changed to only test SimpleDataSource for embedded
>>    
>>
>
>Can you expand on this last item. The purpose of the test is to check
>all data sources for embedded, the comment implies to me that we are now
>not testing EmbeddedDataSource. Or did I misunderstand?
>
>  
>
This  was poorly worded.  Maybe move the only to the end.

- Changed to test SimpleDataSource for embedded only.


patch 1 changed the test to  use the TestUtil.getXXXDataSource methods
so that it could run with both client and embedded.
So, for example when run with -Dframework=DerbyNetClient  it will  test
ClientXADataSource instead of  EmbeddedXADataSource. SimpleDataSource is
relevant only to embedded so is not run for client.

Here are the three booleans and comments from the patch.  Dan mentioned
to me offline that  for
needRollbackBeforePCGetConnection the embedded behaviour is correct. So
that one need to have the comment changed and a Jira filed.  I will take
care of that in continuing work on DERBY-435 and also move the "only" to
the end of most sentences.


// 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 static boolean testConnectionToString =
TestUtil.isEmbeddedFramework();
   
    // Only embedded supports SimpleDataSource (JSR169). 
    // These tests are exempted from other frameworks
    private static 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
    // I think client is right here (kmarsden), the user should have to
rollback
    private static boolean needRollbackBeforePCGetConnection =
        TestUtil.isDerbyNetClientFramework();
       





Re: svn commit: r378532 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/DerbyNetClient/checkDataSource30.out suites/DerbyNetClient.exclude tests/jdbcapi/checkDataSource.java tests/jdbcapi/checkDataSource30.java

Posted by Daniel John Debrunner <dj...@apache.org>.
Daniel John Debrunner wrote:

> kmarsden@apache.org wrote:

>> - Changed to perform an explicit rollback of active transactions for client before performing a PooledConnection.getConnection()
>>  I think this is an issue with embedded that it allows a PooledConnection.getConnection() with an active transaction, instead of throwing an error if the transaction is active.
> 
> 
> I'm not sure this is a correct change, I thought it was defined that
> PooledConnection.getConnection() closed the existing connection. I need
> to find that reference.

Found the reference through comments in the Derby code for a method
called from EmbedPooledConnection.getConnection(), that was nice!

JDBC 3.0 section 11.4

A single physical PooledConnection object may generate many logical
Connection objects during its lifetime. For a given PooledConnection object,
only the most recently produced logical Connection object will be valid. Any
previously existing Connection object is automatically closed when the
associated
PooledConnection.getConnection method is called. Listeners (connection
pool managers) are not notified in this case.
This gives the application server a way to take a connection away from a
client.
This is an unlikely scenario but may be useful if the application server
is trying to
force an orderly shutdown.

So embedded is correct, I think this part of the test change should be
reverted.

Dan.


Re: svn commit: r378532 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/DerbyNetClient/checkDataSource30.out suites/DerbyNetClient.exclude tests/jdbcapi/checkDataSource.java tests/jdbcapi/checkDataSource30.java

Posted by Daniel John Debrunner <dj...@apache.org>.
kmarsden@apache.org wrote:


> URL: http://svn.apache.org/viewcvs?rev=378532&view=rev
> Log:
> DERBY-435 jdbapi/checkDataSource30.java test should be changed or extended to test client DataSources
>  patch 2 - checkDataSource30 holdability testing for client
>  
> - Enables the checkDataSource30 test for holdability tests that are currently passing.
>   There appear to be several holdability bugs associated with network XA in additon to DERBY-966.
> 
> - Makes some progress toward getting checkDataSource.java to run with client, but it is not enabled yet.
>   - Changed to only run connection toString tests for embedded.
>   - Changed to only test SimpleDataSource for embedded

Can you expand on this last item. The purpose of the test is to check
all data sources for embedded, the comment implies to me that we are now
not testing EmbeddedDataSource. Or did I misunderstand?

>  - Changed to perform an explicit rollback of active transactions for client before performing a PooledConnection.getConnection()
>   I think this is an issue with embedded that it allows a PooledConnection.getConnection() with an active transaction, instead of throwing an error if the transaction is active.

I'm not sure this is a correct change, I thought it was defined that
PooledConnection.getConnection() closed the existing connection. I need
to find that reference.

Dan.