Search in sources :

Example 6 with FailureXAResource

use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testRollbackFailure.

@Test
public void testRollbackFailure() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    FailureXAResource fxa = new FailureXAResource(FailureXAResource.FailLocation.rollback);
    TransactionImple tx = new TransactionImple();
    XAResourceRecord xares = new XAResourceRecord(tx, fxa, tx.getTxId(), null);
    assertEquals(xares.prepare(), Vote.VoteCommit);
    try {
        xares.rollback();
        fail();
    } catch (final HeuristicMixed ex) {
    }
    xares.forget();
}
Also used : XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) FailureXAResource(com.hp.mwtests.ts.jta.common.FailureXAResource) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) Test(org.junit.Test)

Example 7 with FailureXAResource

use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.

the class ExceptionDeferrerTest method testCheckDeferredHeuristicRollbackFirstResourceFails.

@Test
public void testCheckDeferredHeuristicRollbackFirstResourceFails() throws Exception {
    ThreadActionData.purgeActions();
    TxControl.setXANodeName("test");
    TransactionImple tx = new TransactionImple(500);
    try {
        tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.nota));
        tx.enlistResource(new TestResource());
    } catch (final RollbackException ex) {
        fail();
    }
    try {
        tx.commit();
        fail();
    } catch (final HeuristicMixedException ex) {
        assertEquals(XAException.XAER_NOTA, ((XAException) ex.getSuppressed()[0]).errorCode);
    }
}
Also used : XAException(javax.transaction.xa.XAException) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) FailureXAResource(com.hp.mwtests.ts.jta.common.FailureXAResource) HeuristicMixedException(javax.transaction.HeuristicMixedException) TestResource(com.hp.mwtests.ts.jta.common.TestResource) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Example 8 with FailureXAResource

use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.

the class ExceptionDeferrerTest method testCheckDeferredPrepareRollbackException.

@Test
public void testCheckDeferredPrepareRollbackException() throws Exception {
    ThreadActionData.purgeActions();
    TransactionImple tx = new TransactionImple(0);
    tx.enlistResource(new FailureXAResource());
    try {
        tx.enlistResource(new FailureXAResource(FailLocation.prepare, FailType.rollback));
    } catch (final RollbackException ex) {
        fail();
    }
    try {
        tx.commit();
        fail();
    } catch (final RollbackException ex) {
        assertEquals(XAException.XAER_INVAL, ((XAException) ex.getSuppressed()[0]).errorCode);
    }
}
Also used : XAException(javax.transaction.xa.XAException) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) FailureXAResource(com.hp.mwtests.ts.jta.common.FailureXAResource) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Example 9 with FailureXAResource

use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.

the class ExceptionDeferrerTest method testCheckDeferredPrepareInitCause.

@Test
public void testCheckDeferredPrepareInitCause() throws Exception {
    ThreadActionData.purgeActions();
    TransactionImple tx = new TransactionImple(0);
    tx.enlistResource(new FailureXAResource());
    try {
        tx.enlistResource(new FailureXAResource(FailLocation.prepare, FailType.message));
    } catch (final RollbackException ex) {
        fail();
    }
    try {
        tx.commit();
        fail();
    } catch (final RollbackException ex) {
        assertEquals(XAException.XA_RBROLLBACK, ((XAException) ex.getSuppressed()[0]).errorCode);
        assertEquals("test message", ((XAException) ex.getSuppressed()[0]).getCause().getMessage());
    }
}
Also used : XAException(javax.transaction.xa.XAException) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) FailureXAResource(com.hp.mwtests.ts.jta.common.FailureXAResource) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Example 10 with FailureXAResource

use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.

the class ExceptionDeferrerTest method testCheckDeferredPrepareHeuristic.

@Test
public void testCheckDeferredPrepareHeuristic() throws Exception {
    ThreadActionData.purgeActions();
    TransactionImple tx = new TransactionImple(0);
    tx.enlistResource(new FailureXAResource());
    try {
        tx.enlistResource(new FailureXAResource(FailLocation.prepare, FailType.XA_HEURHAZ));
    } catch (final RollbackException ex) {
        fail();
    }
    try {
        tx.commit();
        fail();
    } catch (final HeuristicMixedException ex) {
        assertEquals(XAException.XA_HEURHAZ, ((XAException) ex.getSuppressed()[0]).errorCode);
    }
}
Also used : XAException(javax.transaction.xa.XAException) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) FailureXAResource(com.hp.mwtests.ts.jta.common.FailureXAResource) HeuristicMixedException(javax.transaction.HeuristicMixedException) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Aggregations

FailureXAResource (com.hp.mwtests.ts.jta.common.FailureXAResource)16 Test (org.junit.Test)16 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)12 XAException (javax.transaction.xa.XAException)9 RollbackException (javax.transaction.RollbackException)8 HeuristicMixedException (javax.transaction.HeuristicMixedException)7 XAResourceRecord (com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord)3 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)3 TestResource (com.hp.mwtests.ts.jta.common.TestResource)3 XAResourceRecord (com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord)2 SystemException (javax.transaction.SystemException)2 HeuristicMixed (org.omg.CosTransactions.HeuristicMixed)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)1 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple)1 XidImple (com.arjuna.ats.jta.xa.XidImple)1 DummyXA (com.hp.mwtests.ts.jta.common.DummyXA)1