Search in sources :

Example 6 with SubordinateTransaction

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

the class SubordinateTestCase method testOnePhaseCommitSyncWithSeparateSync.

// ///////////
@Test
public void testOnePhaseCommitSyncWithSeparateSync() throws Exception {
    final SubordinateTransaction tm = createTransaction();
    final TestSynchronization sync = new TestSynchronization();
    tm.registerSynchronization(sync);
    tm.doBeforeCompletion();
    tm.doOnePhaseCommit();
    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 7 with SubordinateTransaction

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

the class SubordinateTestCase method testRollbackSyncWithSeparateSync.

@Test
public void testRollbackSyncWithSeparateSync() throws Exception {
    final SubordinateTransaction tm = createTransaction();
    final TestSynchronization sync = new TestSynchronization();
    tm.registerSynchronization(sync);
    tm.doBeforeCompletion();
    tm.doRollback();
    assertTrue(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)

Example 8 with SubordinateTransaction

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

the class SubordinateTestCase method testCleanupOnePhaseCommit.

@Test
public void testCleanupOnePhaseCommit() throws Exception {
    for (int i = 0; i < 1000; i++) {
        final SubordinateTransaction tm = createTransaction();
        tm.doOnePhaseCommit();
    }
    assertEquals(ActionManager.manager().getNumberOfInflightTransactions(), 0);
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 9 with SubordinateTransaction

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

the class SubordinateTestCase method testOnePhaseCommitSyncWithRollbackOnlyWithSeparateSync.

@Test
public void testOnePhaseCommitSyncWithRollbackOnlyWithSeparateSync() throws Exception {
    final SubordinateTransaction tm = createTransaction();
    final TestSynchronization sync = new TestSynchronization();
    tm.registerSynchronization(sync);
    tm.setRollbackOnly();
    tm.doBeforeCompletion();
    try {
        tm.doOnePhaseCommit();
        fail("did not get expected rollback exception");
    } catch (RollbackException e) {
    // expected - we tried to commit a rollbackonly tx.
    }
    assertTrue(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) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Example 10 with SubordinateTransaction

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

the class SubordinateTestCase method testOnePhaseCommitSyncWithRollbackOnly.

@Test
public void testOnePhaseCommitSyncWithRollbackOnly() throws Exception {
    final SubordinateTransaction tm = createTransaction();
    final TestSynchronization sync = new TestSynchronization();
    tm.registerSynchronization(sync);
    tm.setRollbackOnly();
    try {
        tm.doOnePhaseCommit();
        fail("did not get expected rollback exception");
    } catch (RollbackException e) {
    // expected - we tried to commit a rollbackonly tx.
    }
    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) RollbackException(javax.transaction.RollbackException) 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