transactionContextManager = null;
transactionCachingInterceptor = null;
}
public void testGetConnectionInTransaction() throws Exception {
TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
ConnectionInfo connectionInfo1 = makeConnectionInfo();
transactionCachingInterceptor.getConnection(connectionInfo1);
assertTrue("Expected to get an initial connection", obtainedConnectionInfo != null);
assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
assertTrue("Expected the same ManagedConnectionInfo in the TransactionContext as was returned",
connectionInfo1.getManagedConnectionInfo()
== getSharedManagedConnectionInfo(transactionContext));
obtainedConnectionInfo = null;
ConnectionInfo connectionInfo2 = new ConnectionInfo();
transactionCachingInterceptor.getConnection(connectionInfo2);
assertTrue("Expected to not get a second connection", obtainedConnectionInfo == null);
assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
assertTrue("Expected the same ManagedConnectionInfo in both ConnectionInfos",
connectionInfo1.getManagedConnectionInfo() == connectionInfo2.getManagedConnectionInfo());
assertTrue("Expected the same ManagedConnectionInfo in the TransactionContext as was returned",
connectionInfo1.getManagedConnectionInfo() == getSharedManagedConnectionInfo(transactionContext));
//commit, see if connection returned.
//we didn't create any handles, so the "ManagedConnection" should be returned.
assertTrue("Expected TransactionContext to report active", transactionContext.isActive());
transactionContext.commit();
assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
assertTrue("Expected TransactionContext to report inactive", !transactionContext.isActive());
}