connectionA.close();
connectionB.close();
}
public void testSharedTransactionConversion() throws Exception {
DelegatingConnection connectionA = (DelegatingConnection) newConnection();
DelegatingConnection connectionB = (DelegatingConnection) newConnection();
// in a transaciton the connections should be equal
assertTrue(connectionA.equals(connectionB));
assertTrue(connectionB.equals(connectionA));
assertTrue(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
assertTrue(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));
transactionManager.commit();
// use the connection so it adjusts to the completed transaction
connectionA.getAutoCommit();
connectionB.getAutoCommit();
// no there is no transaction so connections should not be equal
assertFalse(connectionA.equals(connectionB));
assertFalse(connectionB.equals(connectionA));
assertFalse(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
assertFalse(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));
transactionManager.begin();
// use the connection so it adjusts to the new transaction
connectionA.getAutoCommit();
connectionB.getAutoCommit();
// back in a transaction so should be equal again
assertTrue(connectionA.equals(connectionB));
assertTrue(connectionB.equals(connectionA));
assertTrue(connectionA.innermostDelegateEquals(connectionB.getInnermostDelegate()));
assertTrue(connectionB.innermostDelegateEquals(connectionA.getInnermostDelegate()));
connectionA.close();
connectionB.close();
}