Search in sources :

Example 6 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testRecovery.

@Test
public void testRecovery() throws Exception {
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    DummyXAResourceRecord xares = new DummyXAResourceRecord(new TransactionImple(), new DummyXA(false), new XidImple(new Uid()), params);
    assertEquals(xares.getRecoveryCoordinator(), null);
    assertEquals(xares.recover(), XARecoveryResource.FAILED_TO_RECOVER);
    xares.setXAResource(null);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Example 7 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple 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 8 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testPackUnpack.

@Test
public void testPackUnpack() 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 DummyXA(false), new XidImple(new Uid()), params);
    OutputObjectState os = new OutputObjectState();
    assertTrue(xares.saveState(os));
    xares = new XAResourceRecord();
    InputObjectState is = new InputObjectState(os);
    assertTrue(xares.restoreState(is));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) 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) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 9 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method test.

@Test
public void test() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    XAResourceRecord xares = new XAResourceRecord();
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(), new DummyXA(false), new XidImple(new Uid()), params);
    xares.merge(null);
    xares.alter(null);
    assertTrue(xares.type() != null);
    assertTrue(xares.toString() != null);
    assertTrue(xares.get_uid().notEquals(Uid.nullUid()));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) 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 TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple 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)

Aggregations

TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)28 Test (org.junit.Test)23 DummyXA (com.hp.mwtests.ts.jta.jts.common.DummyXA)9 Uid (com.arjuna.ats.arjuna.common.Uid)7 XAResourceRecord (com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord)7 Transaction (javax.transaction.Transaction)5 XidImple (com.arjuna.ats.jta.xa.XidImple)4 DummyRecoverableXAConnection (com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection)4 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)3 FailureXAResource (com.hp.mwtests.ts.jta.common.FailureXAResource)3 Synchronization (javax.transaction.Synchronization)3 SystemException (javax.transaction.SystemException)3 WorkSynchronization (com.arjuna.ats.internal.jta.transaction.jts.jca.WorkSynchronization)2 FailureXAResource (com.hp.mwtests.ts.jta.tools.FailureXAResource)2 RollbackException (javax.transaction.RollbackException)2 XAException (javax.transaction.xa.XAException)2 Xid (javax.transaction.xa.Xid)2 Control (org.omg.CosTransactions.Control)2 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1