Search in sources :

Example 36 with Uid

use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.

the class SubordinateTestCase method testOnePhaseCommitSyncWithRollbackOnlyViaXATerminatorWithSeparateSync.

@Test
public void testOnePhaseCommitSyncWithRollbackOnlyViaXATerminatorWithSeparateSync() throws Exception {
    final Xid xid = new XidImple(new Uid());
    final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
    final TestSynchronization sync = new TestSynchronization();
    t.registerSynchronization(sync);
    t.setRollbackOnly();
    final XATerminator xaTerminator = SubordinationManager.getXATerminator();
    final XATerminatorExtensions xaTerminatorExtensions = (XATerminatorExtensions) xaTerminator;
    xaTerminatorExtensions.beforeCompletion(xid);
    try {
        xaTerminator.commit(xid, true);
        ((TransactionImple) t).doOnePhaseCommit();
        fail("did not get expected rollback exception");
    } catch (XAException e) {
        assertEquals("javax.transaction.RollbackException", e.getCause().getClass().getName());
        assertEquals(XAException.XA_RBROLLBACK, e.errorCode);
    // expected - we tried to commit a rollbackonly tx.
    }
    assertTrue(sync.isBeforeCompletionDone());
    assertTrue(sync.isAfterCompletionDone());
    assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, 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) XAException(javax.transaction.xa.XAException) Transaction(javax.transaction.Transaction) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple) Test(org.junit.Test)

Example 37 with Uid

use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.

the class SubordinateTestCase method testRollbackSyncViaXATerminatorWithSeparateSync.

@Test
public void testRollbackSyncViaXATerminatorWithSeparateSync() 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 XATerminator xaTerminator = SubordinationManager.getXATerminator();
    final XATerminatorExtensions xaTerminatorExtensions = (XATerminatorExtensions) xaTerminator;
    xaTerminatorExtensions.beforeCompletion(xid);
    xaTerminator.rollback(xid);
    assertTrue(sync.isBeforeCompletionDone());
    assertTrue(sync.isAfterCompletionDone());
    assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, 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)

Example 38 with Uid

use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.

the class SubordinateTestCase method testFailOnCommitOnePhase.

@Test
public void testFailOnCommitOnePhase() throws Exception {
    final Xid xid = new XidImple(new Uid());
    final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
    final TestXAResource xaResource = new TestXAResource();
    // provoke commit into failing with TwoPhaseOutcome.FINISH_ERROR
    // warning: this is sensitive to the impl exception handling in
    // XAResourceRecord.topLevelCommit
    // should cause an exception!
    xaResource.setCommitException(new XAException(XAException.XA_HEURRB));
    t.enlistResource(xaResource);
    final XATerminator xaTerminator = SubordinationManager.getXATerminator();
    try {
        xaTerminator.commit(xid, true);
    } catch (final XAException ex) {
        return;
    }
    assertTrue("commit should throw an exception and not get to here", false);
}
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) XAException(javax.transaction.xa.XAException) Transaction(javax.transaction.Transaction) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 39 with Uid

use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.

the class SubordinateTestCase method testOnePhaseCommitSyncWithRollbackOnlyViaXATerminator.

@Test
public void testOnePhaseCommitSyncWithRollbackOnlyViaXATerminator() throws Exception {
    final Xid xid = new XidImple(new Uid());
    final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
    final TestSynchronization sync = new TestSynchronization();
    t.registerSynchronization(sync);
    t.setRollbackOnly();
    final XATerminator xaTerminator = SubordinationManager.getXATerminator();
    try {
        xaTerminator.commit(xid, true);
        ((TransactionImple) t).doOnePhaseCommit();
        fail("did not get expected rollback exception");
    } catch (XAException e) {
        assertEquals("javax.transaction.RollbackException", e.getCause().getClass().getName());
        assertEquals(XAException.XA_RBROLLBACK, e.errorCode);
    // expected - we tried to commit a rollbackonly tx.
    }
    assertFalse(sync.isBeforeCompletionDone());
    assertTrue(sync.isAfterCompletionDone());
    assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, 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) XAException(javax.transaction.xa.XAException) Transaction(javax.transaction.Transaction) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple) Test(org.junit.Test)

Example 40 with Uid

use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.

the class SubordinateTxUnitTest method testTransactionImple.

@Test
public void testTransactionImple() throws Exception {
    TransactionImple tx = new TransactionImple(new Uid());
    TransactionImple dummy = new TransactionImple(new Uid());
    tx.recordTransaction();
    assertFalse(tx.equals(dummy));
    assertTrue(tx.toString() != null);
    tx.recover();
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple) Test(org.junit.Test)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)402 Test (org.junit.Test)185 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)83 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)74 XidImple (com.arjuna.ats.jta.xa.XidImple)71 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)57 IOException (java.io.IOException)48 Xid (javax.transaction.xa.Xid)44 XAException (javax.transaction.xa.XAException)40 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)32 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)31 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)27 SoapFault11 (com.arjuna.webservices11.SoapFault11)22 Transaction (javax.transaction.Transaction)18 ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)17 Vector (java.util.Vector)17 XATerminator (javax.resource.spi.XATerminator)15 TransactionImporter (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TransactionImporter)14 Enumeration (java.util.Enumeration)13 SystemException (org.omg.CORBA.SystemException)13