assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName());
}
public void testInterleavedGlobalGlobalTransactionsWithDifferentConnectionsLateSuspend() throws Exception {
if (log.isDebugEnabled()) { log.debug("*** getting TM"); }
BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
if (log.isDebugEnabled()) { log.debug("*** before begin"); }
tm.begin();
if (log.isDebugEnabled()) { log.debug("*** after begin"); }
if (log.isDebugEnabled()) { log.debug("*** getting connection from DS1"); }
Connection connection1 = poolingDataSource1.getConnection();
connection1.createStatement();
if (log.isDebugEnabled()) { log.debug("*** closing connection 1"); }
connection1.close();
if (log.isDebugEnabled()) { log.debug(" *** suspending transaction"); }
Transaction t1 = tm.suspend();
assertNull(tm.getTransaction());
if (log.isDebugEnabled()) { log.debug(" *** begin interleaved transaction"); }
tm.begin();
Connection connection2 = poolingDataSource1.getConnection();
assertEquals(POOL_SIZE -2, getPool(poolingDataSource1).inPoolSize());
connection2.createStatement();
connection2.close();
if (log.isDebugEnabled()) { log.debug(" *** commit interleaved transaction"); }
tm.commit();
assertEquals(POOL_SIZE -1, getPool(poolingDataSource1).inPoolSize());
if (log.isDebugEnabled()) { log.debug(" *** resuming transaction"); }
tm.resume(t1);
if (log.isDebugEnabled()) { log.debug("*** committing"); }
tm.commit();
if (log.isDebugEnabled()) { log.debug("*** TX is done"); }
assertEquals(POOL_SIZE, getPool(poolingDataSource1).inPoolSize());
// check flow
List orderedEvents = EventRecorder.getOrderedEvents();