tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1431366 - in /openejb/trunk/openejb: container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/ container/openejb-core/src/main/java/org/apache/openejb/...
Date Thu, 10 Jan 2013 14:00:24 GMT
Author: rmannibucau
Date: Thu Jan 10 14:00:24 2013
New Revision: 1431366

URL: http://svn.apache.org/viewvc?rev=1431366&view=rev
Log:
TOMEE-720 can't use 2 datasources in a single tx

Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXAConnection.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXADataSource.java
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
    openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceFromPoolTest.java
    openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceTest.java
    openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatDataSourceFromPoolTest.java
    openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatPoolTest.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
Thu Jan 10 14:00:24 2013
@@ -93,6 +93,7 @@ import org.apache.openejb.persistence.Jt
 import org.apache.openejb.persistence.PersistenceClassLoaderHandler;
 import org.apache.openejb.resource.GeronimoConnectionManagerFactory;
 import org.apache.openejb.resource.jdbc.DataSourceFactory;
+import org.apache.openejb.resource.jdbc.managed.local.ManagedDataSource;
 import org.apache.openejb.spi.ApplicationServer;
 import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.spi.SecurityService;
@@ -1223,6 +1224,10 @@ public class Assembler extends Assembler
                 //Ignore
             }
 
+            if (object instanceof ManagedDataSource) {
+                ((ManagedDataSource) object).clean();
+            }
+
         } else if (object instanceof ConnectorReference) {
             final ConnectorReference cr = (ConnectorReference) object;
             try {

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
Thu Jan 10 14:00:24 2013
@@ -216,7 +216,8 @@ public class DataSourceFactory {
 
     public static void destroy(final Object o) throws Throwable {
         final Object instance = realInstance(o);
-        creatorByDataSource.remove(instance).destroy(instance);
+        final DataSourceCreator remove = creatorByDataSource.remove(instance);
+        remove.destroy(instance);
     }
 
     // remove proxy added by us in front of the datasource returned by the creator

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
Thu Jan 10 14:00:24 2013
@@ -18,6 +18,7 @@ package org.apache.openejb.resource.jdbc
 
 import org.apache.openejb.OpenEJB;
 
+import javax.sql.DataSource;
 import javax.transaction.RollbackException;
 import javax.transaction.Status;
 import javax.transaction.Synchronization;
@@ -34,7 +35,7 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class ManagedConnection implements InvocationHandler {
-    private static final Map<Transaction, Connection> CONNECTION_BY_TX = new ConcurrentHashMap<Transaction,
Connection>();
+    private static final Map<DataSource, Map<Transaction, Connection>> CONNECTION_BY_TX_BY_DS
= new ConcurrentHashMap<DataSource, Map<Transaction, Connection>>();
 
     private final TransactionManager transactionManager;
     private final LocalXAResource xaResource;
@@ -42,12 +43,14 @@ public class ManagedConnection implement
     private Transaction currentTransaction;
     private boolean closed;
 
+    private final Map<Transaction, Connection> connectionByTx;
 
-    public ManagedConnection(final Connection connection, final TransactionManager txMgr)
{
+    public ManagedConnection(final DataSource ds, final Connection connection, final TransactionManager
txMgr) {
         delegate = connection;
         transactionManager = txMgr;
         closed = false;
         xaResource = new LocalXAResource(delegate);
+        connectionByTx = CONNECTION_BY_TX_BY_DS.get(ds);
     }
 
     public XAResource getXAResource() throws SQLException {
@@ -92,13 +95,13 @@ public class ManagedConnection implement
             // or enlist this one in the tx
             int status = transaction.getStatus();
             if (isUnderTransaction(status)) {
-                final Connection connection = CONNECTION_BY_TX.get(transaction);
+                final Connection connection = connectionByTx.get(transaction);
                 if (connection != delegate) {
                     if (connection != null) { // use already existing one
                         delegate.close(); // return to pool
                         delegate = connection;
                     } else {
-                        CONNECTION_BY_TX.put(transaction, delegate);
+                        connectionByTx.put(transaction, delegate);
                         currentTransaction = transaction;
                         try {
                             transaction.enlistResource(getXAResource());
@@ -108,7 +111,7 @@ public class ManagedConnection implement
                             throw new SQLException("Unable to enlist connection the transaction",
e);
                         }
 
-                        transaction.registerSynchronization(new ClosingSynchronization(delegate));
+                        transaction.registerSynchronization(new ClosingSynchronization(delegate,
connectionByTx));
 
                         delegate.setAutoCommit(false);
                     }
@@ -121,8 +124,6 @@ public class ManagedConnection implement
         } catch (InvocationTargetException ite) {
             throw ite.getTargetException();
         }
-
-
     }
 
     private static Object invoke(final Method method, final Connection delegate, final Object[]
args) throws Throwable {
@@ -176,11 +177,24 @@ public class ManagedConnection implement
         }
     }
 
+    public static void pushDataSource(final DataSource ds) {
+        CONNECTION_BY_TX_BY_DS.put(ds, new ConcurrentHashMap<Transaction, Connection>());
+    }
+
+    public static void cleanDataSource(final DataSource ds) {
+        final Map<Transaction, Connection> map = CONNECTION_BY_TX_BY_DS.remove(ds);
+        if (map != null) {
+            map.clear();
+        }
+    }
+
     private static class ClosingSynchronization implements Synchronization {
         private final Connection connection;
+        private final Map<Transaction, Connection> mapToCleanup;
 
-        public ClosingSynchronization(final Connection delegate) {
+        public ClosingSynchronization(final Connection delegate, Map<Transaction, Connection>
connByTx) {
             connection = delegate;
+            mapToCleanup = connByTx;
         }
 
         @Override
@@ -193,7 +207,7 @@ public class ManagedConnection implement
             close(connection);
             try {
                 final Transaction tx = OpenEJB.getTransactionManager().getTransaction();
-                CONNECTION_BY_TX.remove(tx);
+                mapToCleanup.remove(tx);
             } catch (SystemException ignored) {
                 // no-op
             }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
Thu Jan 10 14:00:24 2013
@@ -36,6 +36,7 @@ public class ManagedDataSource implement
     public ManagedDataSource(final DataSource ds, final TransactionManager txMgr) {
         delegate = ds;
         transactionManager = txMgr;
+        ManagedConnection.pushDataSource(this);
     }
 
     @Override
@@ -84,10 +85,14 @@ public class ManagedDataSource implement
     }
 
     private Connection managed(final Connection connection) {
-        return (Connection) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
CONNECTION_CLASS, new ManagedConnection(connection, transactionManager));
+        return (Connection) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
CONNECTION_CLASS, new ManagedConnection(this, connection, transactionManager));
     }
 
     public DataSource getDelegate() {
         return delegate;
     }
+
+    public void clean() {
+        ManagedConnection.cleanDataSource(this);
+    }
 }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXAConnection.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXAConnection.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXAConnection.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXAConnection.java
Thu Jan 10 14:00:24 2013
@@ -18,6 +18,7 @@ package org.apache.openejb.resource.jdbc
 
 import org.apache.openejb.resource.jdbc.managed.local.ManagedConnection;
 
+import javax.sql.DataSource;
 import javax.sql.XAConnection;
 import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAResource;
@@ -25,8 +26,8 @@ import java.sql.Connection;
 import java.sql.SQLException;
 
 public class ManagedXAConnection extends ManagedConnection {
-    public ManagedXAConnection(final Connection connection, final TransactionManager txMgr)
throws SQLException {
-        super(connection, txMgr);
+    public ManagedXAConnection(final DataSource ds, final Connection connection, final TransactionManager
txMgr) throws SQLException {
+        super(ds, connection, txMgr);
     }
 
     @Override

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXADataSource.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXADataSource.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXADataSource.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/xa/ManagedXADataSource.java
Thu Jan 10 14:00:24 2013
@@ -47,6 +47,6 @@ public class ManagedXADataSource extends
     }
 
     private Connection managedXA(final Connection connection) throws SQLException {
-        return (Connection) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
CONNECTION_CLASS, new ManagedXAConnection(connection, transactionManager));
+        return (Connection) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
CONNECTION_CLASS, new ManagedXAConnection(delegate, connection, transactionManager));
     }
 }

Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
Thu Jan 10 14:00:24 2013
@@ -35,6 +35,7 @@ import javax.ejb.Singleton;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 import javax.sql.DataSource;
+import javax.transaction.Transaction;
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -58,6 +59,9 @@ public class ManagedDataSourceTest {
     @EJB
     private Persister persistManager;
 
+    @Resource
+    private DataSource ds;
+
     @BeforeClass
     public static void createTable() throws SQLException, ClassNotFoundException {
         Class.forName("org.hsqldb.jdbcDriver");
@@ -162,7 +166,7 @@ public class ManagedDataSourceTest {
 
     @Test
     public void rollback() throws SQLException {
-            persistManager.saveAndRollback();
+        persistManager.saveAndRollback();
         assertFalse(exists(2));
     }
 
@@ -196,10 +200,11 @@ public class ManagedDataSourceTest {
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
-        final Map<?, ?> instance = (Map<?, ?>) map.get(null);
-        assertEquals(0, instance.size());
+        final Map<DataSource, Map<Transaction, Connection>>  instance = (Map<DataSource,
Map<Transaction, Connection>> ) map.get(null);
+        assertEquals(1, instance.size());
+        assertEquals(0, instance.values().iterator().next().size());
     }
 
     private static boolean exists(int id) throws SQLException {

Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
Thu Jan 10 14:00:24 2013
@@ -33,6 +33,7 @@ import javax.ejb.EJBContext;
 import javax.ejb.LocalBean;
 import javax.ejb.Singleton;
 import javax.sql.DataSource;
+import javax.transaction.Transaction;
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -183,12 +184,11 @@ public class MultiThreadedManagedDataSou
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
-        final Map<?, ?> instance = (Map<?, ?>) map.get(null);
-        assertEquals(0, instance.size());
-
-        execute(DriverManager.getConnection(URL, USER, PASSWORD), "DELETE FROM " + TABLE);
+        final Map<DataSource, Map<Transaction, Connection>>  instance = (Map<DataSource,
Map<Transaction, Connection>> ) map.get(null);
+        assertEquals(1, instance.size());
+        assertEquals(0, instance.values().iterator().next().size());
     }
 
     private static boolean exists(int id) throws SQLException {

Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
Thu Jan 10 14:00:24 2013
@@ -34,6 +34,7 @@ import javax.ejb.Singleton;
 import javax.ejb.TransactionManagement;
 import javax.ejb.TransactionManagementType;
 import javax.sql.DataSource;
+import javax.transaction.Transaction;
 import javax.transaction.UserTransaction;
 import java.lang.reflect.Field;
 import java.sql.Connection;
@@ -210,10 +211,11 @@ public class UTManagedDataSourceTest {
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
-        final Map<?, ?> instance = (Map<?, ?>) map.get(null);
-        assertEquals(0, instance.size());
+        final Map<DataSource, Map<Transaction, Connection>>  instance = (Map<DataSource,
Map<Transaction, Connection>> ) map.get(null);
+        assertEquals(1, instance.size());
+        assertEquals(0, instance.values().iterator().next().size());
     }
 
     private static boolean exists(int id) throws Exception {

Modified: openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceFromPoolTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceFromPoolTest.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceFromPoolTest.java
(original)
+++ openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceFromPoolTest.java
Thu Jan 10 14:00:24 2013
@@ -37,6 +37,7 @@ import javax.ejb.Singleton;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 import javax.sql.DataSource;
+import javax.transaction.Transaction;
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -196,10 +197,11 @@ public class BoneCPPooledDataSourceFromP
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
-        final Map<?, ?> instance = (Map<?, ?>) map.get(null);
-        assertEquals(0, instance.size());
+        final Map<DataSource, Map<Transaction, Connection>>  instance = (Map<DataSource,
Map<Transaction, Connection>> ) map.get(null);
+        assertEquals(1, instance.size());
+        assertEquals(0, instance.values().iterator().next().size());
     }
 
     private static boolean exists(int id) throws SQLException {

Modified: openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceTest.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceTest.java
(original)
+++ openejb/trunk/openejb/server/openejb-bonecp/src/test/java/org/apache/openejb/bonecp/BoneCPPooledDataSourceTest.java
Thu Jan 10 14:00:24 2013
@@ -35,6 +35,7 @@ import javax.ejb.Singleton;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 import javax.sql.DataSource;
+import javax.transaction.Transaction;
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -197,10 +198,11 @@ public class BoneCPPooledDataSourceTest 
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
-        final Map<?, ?> instance = (Map<?, ?>) map.get(null);
-        assertEquals(0, instance.size());
+        final Map<DataSource, Map<Transaction, Connection>>  instance = (Map<DataSource,
Map<Transaction, Connection>> ) map.get(null);
+        assertEquals(1, instance.size());
+        assertEquals(0, instance.values().iterator().next().size());
     }
 
     private static boolean exists(int id) throws SQLException {

Modified: openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatDataSourceFromPoolTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatDataSourceFromPoolTest.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatDataSourceFromPoolTest.java
(original)
+++ openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatDataSourceFromPoolTest.java
Thu Jan 10 14:00:24 2013
@@ -36,6 +36,7 @@ import javax.ejb.Singleton;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 import javax.sql.DataSource;
+import javax.transaction.Transaction;
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -195,10 +196,11 @@ public class TomcatDataSourceFromPoolTes
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
-        final Map<?, ?> instance = (Map<?, ?>) map.get(null);
-        assertEquals(0, instance.size());
+        final Map<DataSource, Map<Transaction, Connection>>  instance = (Map<DataSource,
Map<Transaction, Connection>> ) map.get(null);
+        assertEquals(1, instance.size());
+        assertEquals(0, instance.values().iterator().next().size());
     }
 
     private static boolean exists(int id) throws SQLException {

Modified: openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatPoolTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatPoolTest.java?rev=1431366&r1=1431365&r2=1431366&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatPoolTest.java
(original)
+++ openejb/trunk/openejb/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatPoolTest.java
Thu Jan 10 14:00:24 2013
@@ -35,6 +35,7 @@ import javax.ejb.Singleton;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 import javax.sql.DataSource;
+import javax.transaction.Transaction;
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -197,10 +198,11 @@ public class TomcatPoolTest {
 
     @After
     public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
-        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX");
+        final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
         map.setAccessible(true);
-        final Map<?, ?> instance = (Map<?, ?>) map.get(null);
-        assertEquals(0, instance.size());
+        final Map<DataSource, Map<Transaction, Connection>>  instance = (Map<DataSource,
Map<Transaction, Connection>> ) map.get(null);
+        assertEquals(1, instance.size());
+        assertEquals(0, instance.values().iterator().next().size());
     }
 
     private static boolean exists(int id) throws SQLException {



Mime
View raw message