Search in sources :

Example 6 with XATerminatorExtensions

use of com.arjuna.ats.internal.jta.resources.spi.XATerminatorExtensions in project narayana by jbosstm.

the class SubordinateTestCase method testTwoPhaseCommitSyncWithXAOKViaXATerminatorWithSeparateSync.

@Test
public void testTwoPhaseCommitSyncWithXAOKViaXATerminatorWithSeparateSync() throws Exception {
    final Xid xid = new XidImple(new Uid());
    final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
    final TestSynchronization sync = new TestSynchronization();
    t.registerSynchronization(sync);
    final TestXAResource xaResource = new TestXAResource();
    xaResource.setPrepareReturnValue(XAResource.XA_OK);
    t.enlistResource(xaResource);
    final XATerminator xaTerminator = SubordinationManager.getXATerminator();
    final XATerminatorExtensions xaTerminatorExtensions = (XATerminatorExtensions) xaTerminator;
    xaTerminatorExtensions.beforeCompletion(xid);
    assertEquals(XAResource.XA_OK, xaTerminator.prepare(xid));
    xaTerminator.commit(xid, false);
    assertTrue(sync.isBeforeCompletionDone());
    assertTrue(sync.isAfterCompletionDone());
    assertEquals(javax.transaction.Status.STATUS_COMMITTED, t.getStatus());
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XATerminator(javax.resource.spi.XATerminator) Xid(javax.transaction.xa.Xid) XATerminatorExtensions(com.arjuna.ats.internal.jta.resources.spi.XATerminatorExtensions) Transaction(javax.transaction.Transaction) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)6 XATerminatorExtensions (com.arjuna.ats.internal.jta.resources.spi.XATerminatorExtensions)6 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)6 XidImple (com.arjuna.ats.jta.xa.XidImple)6 XATerminator (javax.resource.spi.XATerminator)6 Transaction (javax.transaction.Transaction)6 Xid (javax.transaction.xa.Xid)6 Test (org.junit.Test)6 XAException (javax.transaction.xa.XAException)2 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple)1