assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName());
assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName());
}
public void testIncorrectSuspendResume() throws Exception {
BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
tm.begin();
Connection connection1 = poolingDataSource1.getConnection();
connection1.createStatement();
Connection connection2 = poolingDataSource2.getConnection();
connection2.createStatement();
Transaction tx = tm.suspend();
assertNull(tm.suspend());
try {
tm.resume(null);
fail("TM has allowed resuming a null TX context");
} catch (InvalidTransactionException ex) {
assertEquals("resumed transaction cannot be null", ex.getMessage());
}
tm.resume(tx);
try {
tm.resume(tx);
fail("TM has allowed resuming a TX context when another one is still running");
} catch (IllegalStateException ex) {
assertEquals("a transaction is already running on this thread", ex.getMessage());
}
connection1.close();
connection2.close();
tm.commit();
}