public void testFailedEndTx() throws Exception
{
TestManagedConnection.setFailInStart(false, XAException.XAER_RMFAIL);
TestManagedConnection.setFailInEnd(false, XAException.XAER_RMFAIL);
tm.begin();
TestConnection conn = null;
TestConnection conn2 = null;
try
{
assertTrue("Connection in pool!", cm.getPoolingStrategy().getConnectionCount() == 0);
conn = (TestConnection)cm.allocateConnection(mcf, cri);
//One should have been created
assertTrue(cm.getPoolingStrategy().getConnectionCount() == 1);
conn.close();
TestManagedConnection.setFailInEnd(true, XAException.XAER_RMFAIL);
conn2 = (TestConnection)cm.allocateConnection(mcf, cri);
conn2.close();
tm.commit();
fail("Should not be here.");
}
catch (Throwable e)
{
}
TestManagedConnection.setFailInEnd(false, 0);
TestManagedConnection.setFailInStart(false, 0);
assertTrue(conn2.getMCIsNull());
assertTrue("Connection count" + cm.getPoolingStrategy().getConnectionCount(), cm.getPoolingStrategy().getConnectionCount() == 0);
assertTrue("Failed endTx should destroy Connection", cm.getPoolingStrategy().getConnectionDestroyedCount() > 0);
}