Search in sources :

Example 11 with DummyXA

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

the class XAUtilsUnitTest method test.

@Test
public void test() {
    DummyXA xa = new DummyXA(false);
    assertFalse(XAUtils.mustEndSuspendedRMs(xa));
    assertTrue(XAUtils.canOptimizeDelist(xa));
    assertEquals(XAUtils.getXANodeName(new XidImple(new Uid())), TxControl.getXANodeName());
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) Test(org.junit.Test)

Example 12 with DummyXA

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

the class XAResourceRecordUnitTest method testValid2PC.

@Test
public void testValid2PC() throws Exception {
    TransactionImple tx = new TransactionImple(0);
    DummyXA res = new DummyXA(false);
    XAResourceRecord xares = new XAResourceRecord(tx, res, tx.getTxId(), null);
    assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(xares.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
}
Also used : DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) Test(org.junit.Test)

Example 13 with DummyXA

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

the class OnePhaseUnitTest method testPackUnpack.

@Test
public void testPackUnpack() throws Exception {
    DummyXA res = new DummyXA(false);
    XidImple xid = new XidImple(new Uid());
    XAOnePhaseResource xares = new XAOnePhaseResource(res, xid, null);
    OutputObjectState os = new OutputObjectState();
    xares.pack(os);
    InputObjectState is = new InputObjectState(os);
    xares.unpack(is);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) XAOnePhaseResource(com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 14 with DummyXA

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

the class RecoveryXidsUnitTest method test.

@Test
public void test() {
    TestResource tr = new TestResource();
    RecoveryXids rxids = new RecoveryXids(tr);
    Xid[] xids = new XidImple[2];
    xids[0] = new XidImple(new Uid());
    xids[1] = new XidImple(new Uid());
    RecoveryXids dup1 = new RecoveryXids(new DummyXA(false));
    RecoveryXids dup2 = new RecoveryXids(tr);
    assertFalse(rxids.equals(dup1));
    assertTrue(rxids.equals(dup2));
    rxids.nextScan(xids);
    rxids.nextScan(xids);
    xids[1] = new XidImple(new Uid());
    rxids.nextScan(xids);
    Object[] trans = rxids.toRecover();
    assertEquals(0, trans.length);
    try {
        Thread.sleep(20010);
    } catch (InterruptedException e) {
    }
    // force cleanup.
    rxids.nextScan(xids);
    trans = rxids.toRecover();
    assertEquals(2, trans.length);
    assertTrue(trans[0].equals(xids[0]) || trans[1].equals(xids[0]));
    assertTrue(trans[0].equals(xids[1]) || trans[1].equals(xids[1]));
    assertTrue(rxids.contains(xids[0]));
    assertFalse(rxids.updateIfEquivalentRM(new TestResource(), null));
    assertTrue(rxids.updateIfEquivalentRM(new TestResource(), xids));
    assertFalse(rxids.isSameRM(new TestResource()));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) Xid(javax.transaction.xa.Xid) DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) RecoveryXids(com.arjuna.ats.internal.jta.recovery.arjunacore.RecoveryXids) TestResource(com.hp.mwtests.ts.jta.common.TestResource) Test(org.junit.Test)

Example 15 with DummyXA

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

the class ObjStoreBrowserTest method generateHeuristic.

private TransactionImple generateHeuristic(TransactionImple tx, FailureXAResource failureXAResource) throws Exception {
    ThreadActionData.purgeActions();
    XAResource[] resources = { new DummyXA(false), failureXAResource };
    // enlist the XA resources into the transaction
    for (XAResource resource : resources) tx.enlistResource(resource);
    try {
        tx.commit();
        fail("Expected a mixed heuristic");
    } catch (final HeuristicMixedException expected) {
    }
    return tx;
}
Also used : FailureXAResource(com.hp.mwtests.ts.jta.tools.FailureXAResource) XAResource(javax.transaction.xa.XAResource) DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) HeuristicMixedException(javax.transaction.HeuristicMixedException)

Aggregations

DummyXA (com.hp.mwtests.ts.jta.common.DummyXA)15 Test (org.junit.Test)13 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)9 Uid (com.arjuna.ats.arjuna.common.Uid)6 XidImple (com.arjuna.ats.jta.xa.XidImple)5 XAResourceRecord (com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord)4 Xid (javax.transaction.xa.Xid)3 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)2 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)2 DummyRecoverableXAConnection (com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection)2 HeuristicMixedException (javax.transaction.HeuristicMixedException)2 SystemException (javax.transaction.SystemException)2 XAResource (javax.transaction.xa.XAResource)2 RecoveryXids (com.arjuna.ats.internal.jta.recovery.arjunacore.RecoveryXids)1 XARecoveryResourceImple (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryResourceImple)1 XAOnePhaseResource (com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource)1 FailureXAResource (com.hp.mwtests.ts.jta.common.FailureXAResource)1 TestResource (com.hp.mwtests.ts.jta.common.TestResource)1 FailureXAResource (com.hp.mwtests.ts.jta.tools.FailureXAResource)1 Method (java.lang.reflect.Method)1