db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r942908 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Date Mon, 10 May 2010 21:21:18 GMT
Author: kmarsden
Date: Mon May 10 21:21:16 2010
New Revision: 942908

URL: http://svn.apache.org/viewvc?rev=942908&view=rev
Log:
DERBY-4343 ASSERT FAILED calling setTransactionIsolation checking isolation_ == level on pooled
connection

Contributed by Lily Wei lilywei at yahoo dot com

This is just the test case for this issue. The issue itself was actually fixed with DERBY-4314.
Also included is one DERBY-4314 test case to make sure piggybacking works ok after statement
execution.



Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java?rev=942908&r1=942907&r2=942908&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Mon May 10 21:21:16 2010
@@ -145,6 +145,7 @@ public class J2EEDataSourceTest extends 
             new J2EEDataSourceTest("testCloseActiveConnection_XA_global"));
         suite.addTest(new J2EEDataSourceTest("testDescriptionProperty"));
         suite.addTest(new J2EEDataSourceTest("testConnectionErrorEvent"));
+        suite.addTest(new J2EEDataSourceTest("testIsolationWithFourConnections"));
         suite.addTest(new J2EEDataSourceTest(
                               "testConnectionEventListenerIsNull"));
         suite.addTest(new J2EEDataSourceTest("testReadOnlyToWritableTran"));
@@ -1625,6 +1626,10 @@ public class J2EEDataSourceTest extends 
         assertConnectionState(ResultSet.CLOSE_CURSORS_AT_COMMIT, 
             Connection.TRANSACTION_REPEATABLE_READ,
             false, false, conn);
+        //DERBY-4314 create a statement(s2) and execute ddl sql
+        Statement s2 = conn.createStatement();
+        s2.executeUpdate("create table testglobal (i int)");
+        //DERBY-4314 end test
         xar.end(xid2, XAResource.TMSUCCESS);
 
         xar.start(xid, XAResource.TMJOIN);
@@ -2060,7 +2065,46 @@ public class J2EEDataSourceTest extends 
         con.close();
         pc.close();
     }
+    /**
+     * Check setTransactioIsolation and with four connection in connection pool
+     * for DERBY-4343 case
+     * 
+     * @throws SQLException
+     */
+    public void testIsolationWithFourConnections()
+            throws SQLException {
+        ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();
 
+        PooledConnection pc = ds.getPooledConnection();
+        //First connection
+        Connection conn = pc.getConnection();
+        conn.setAutoCommit(false);
+        conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+        Statement s = conn.createStatement();
+        ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM SYS.SYSTABLES");
+        rs.next();
+        int ri = rs.getInt(1);
+        rs.close();
+        conn.rollback();
+        conn.close();
+        
+        //Second connection
+        conn = pc.getConnection();
+        conn.close();
+        
+        //Third connection
+        conn = pc.getConnection();
+        conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+        assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn.getTransactionIsolation());
+        conn.close();
+        
+        //Fourth connetion
+        conn = pc.getConnection();
+        conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
+        assertEquals(Connection.TRANSACTION_READ_UNCOMMITTED, conn.getTransactionIsolation());
+        conn.close();
+    
+    }
     // test that an xastart in auto commit mode commits the existing work.
     // test fix of a bug ('beetle 5178') wherein XAresource.start() when 
     // auto-commit is true did not implictly commit any transaction



Mime
View raw message