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());
}
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);
}
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);
}
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()));
}
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;
}
Aggregations