Search in sources :

Example 6 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testValid2PC.

@Test
public void testValid2PC() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    DummyXA res = new DummyXA(false);
    XAResourceRecord xares = new XAResourceRecord(tx, res, tx.getTxId(), null);
    assertEquals(xares.prepare(), Vote.VoteCommit);
    xares.commit();
}
Also used : DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Example 7 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testNested.

@Test
public void testNested() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    XAResourceRecord xares = new XAResourceRecord();
    assertEquals(xares.prepare_subtransaction(), Vote.VoteRollback);
    try {
        xares.commit_subtransaction(null);
        fail();
    } catch (final UNKNOWN ex) {
    }
    try {
        xares.rollback_subtransaction();
        fail();
    } catch (final UNKNOWN ex) {
    }
    assertFalse(xares.propagateOnAbort());
    assertFalse(xares.propagateOnCommit());
}
Also used : XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) UNKNOWN(org.omg.CORBA.UNKNOWN) Test(org.junit.Test)

Example 8 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testReadonly.

@Test
public void testReadonly() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    XAResourceRecord xares;
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(), new TestResource(true), new XidImple(new Uid()), params);
    try {
        xares.commit();
        fail();
    } catch (final NotPrepared ex) {
    }
    assertEquals(xares.prepare(), Vote.VoteReadOnly);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) TestResource(com.hp.mwtests.ts.jta.common.TestResource) NotPrepared(org.omg.CosTransactions.NotPrepared) Test(org.junit.Test)

Example 9 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testValid1PC.

@Test
public void testValid1PC() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    DummyXA res = new DummyXA(false);
    XAResourceRecord xares = new XAResourceRecord(tx, res, tx.getTxId(), null);
    xares.commit_one_phase();
}
Also used : DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Example 10 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testCommitFailure.

@Test
public void testCommitFailure() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    FailureXAResource fxa = new FailureXAResource(FailureXAResource.FailLocation.commit);
    TransactionImple tx = new TransactionImple();
    XAResourceRecord xares = new XAResourceRecord(tx, fxa, tx.getTxId(), null);
    assertEquals(xares.prepare(), Vote.VoteCommit);
    try {
        xares.commit();
        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)

Aggregations

XAResourceRecord (com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord)10 Test (org.junit.Test)9 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)7 DummyXA (com.hp.mwtests.ts.jta.jts.common.DummyXA)4 Uid (com.arjuna.ats.arjuna.common.Uid)3 XidImple (com.arjuna.ats.jta.xa.XidImple)3 DummyRecoverableXAConnection (com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection)3 FailureXAResource (com.hp.mwtests.ts.jta.common.FailureXAResource)2 UNKNOWN (org.omg.CORBA.UNKNOWN)2 HeuristicMixed (org.omg.CosTransactions.HeuristicMixed)2 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1 TxInfo (com.arjuna.ats.internal.jta.xa.TxInfo)1 InactiveTransactionException (com.arjuna.ats.jta.exceptions.InactiveTransactionException)1 InvalidTerminationStateException (com.arjuna.ats.jta.exceptions.InvalidTerminationStateException)1 XAModifier (com.arjuna.ats.jta.xa.XAModifier)1 TestResource (com.hp.mwtests.ts.jta.common.TestResource)1 HeuristicMixedException (javax.transaction.HeuristicMixedException)1 RollbackException (javax.transaction.RollbackException)1 XAException (javax.transaction.xa.XAException)1