Search in sources :

Example 21 with SubordinateTransaction

use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.

the class SubordinateTestCase method testCleanupCommit.

@Test
public void testCleanupCommit() throws Exception {
    for (int i = 0; i < 1000; i++) {
        final SubordinateTransaction tm = createTransaction();
        assertEquals(TwoPhaseOutcome.PREPARE_READONLY, tm.doPrepare());
    // don't call commit for read only case.
    }
    assertEquals(ActionManager.manager().getNumberOfInflightTransactions(), 0);
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 22 with SubordinateTransaction

use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.

the class SubordinateTestCase method testCleanupSecondPhaseRollback.

@Test
public void testCleanupSecondPhaseRollback() throws Exception {
    for (int i = 0; i < 1000; i++) {
        final SubordinateTransaction tm = createTransaction();
        assertEquals(TwoPhaseOutcome.PREPARE_READONLY, tm.doPrepare());
    // don't call rollback for read only case
    }
    assertEquals(ActionManager.manager().getNumberOfInflightTransactions(), 0);
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 23 with SubordinateTransaction

use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.

the class SubordinateTestCase method testPrepareRollback.

@Test
public void testPrepareRollback() throws Exception {
    final SubordinateTransaction tm = createTransaction();
    assertEquals(TwoPhaseOutcome.PREPARE_READONLY, tm.doPrepare());
    // Due to the readonly we allow the massage - this matches doPhase2Abort in ServerTransaction
    tm.doRollback();
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 24 with SubordinateTransaction

use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.

the class SubordinateTestCase method testTwoPhaseCommitSyncWithSeparateSync.

@Test
public void testTwoPhaseCommitSyncWithSeparateSync() throws Exception {
    final SubordinateTransaction tm = createTransaction();
    final TestSynchronization sync = new TestSynchronization();
    tm.registerSynchronization(sync);
    tm.doBeforeCompletion();
    assertEquals(TwoPhaseOutcome.PREPARE_READONLY, tm.doPrepare());
    // don't call commit for read only case
    assertTrue(sync.isBeforeCompletionDone());
    assertTrue(sync.isAfterCompletionDone());
    assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 25 with SubordinateTransaction

use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.

the class SubordinateTestCase method testTwoPhaseCommitSyncWithRollbackOnly.

@Test
public void testTwoPhaseCommitSyncWithRollbackOnly() throws Exception {
    final SubordinateTransaction tm = createTransaction();
    final TestSynchronization sync = new TestSynchronization();
    tm.registerSynchronization(sync);
    tm.setRollbackOnly();
    assertEquals(TwoPhaseOutcome.PREPARE_NOTOK, tm.doPrepare());
    tm.doRollback();
    assertFalse(sync.isBeforeCompletionDone());
    assertTrue(sync.isAfterCompletionDone());
    assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Aggregations

SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)42 Test (org.junit.Test)35 XAException (javax.transaction.xa.XAException)18 Uid (com.arjuna.ats.arjuna.common.Uid)16 Xid (javax.transaction.xa.Xid)13 XidImple (com.arjuna.ats.jta.xa.XidImple)12 TransactionImporter (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TransactionImporter)7 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.jts.jca.XATerminatorImple)6 RollbackException (javax.transaction.RollbackException)6 SystemException (javax.transaction.SystemException)6 XAResource (javax.transaction.xa.XAResource)6 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple)4 ArrayList (java.util.ArrayList)4 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)3 SubordinateXidImple (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateXidImple)3 UnexpectedConditionException (com.arjuna.ats.jta.exceptions.UnexpectedConditionException)3 XAResourceRecoveryHelper (com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper)3 TestXAResource (com.hp.mwtests.ts.jta.jts.TestXAResource)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 HeuristicMixedException (javax.transaction.HeuristicMixedException)3