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;
}
use of com.hp.mwtests.ts.jta.common.DummyXA in project narayana by jbosstm.
the class TransactionImpleUnitTest method test.
@Test
public void test() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
TxImpleOverride.put(tx);
assertEquals(tx, TransactionImple.getTransaction(tx.get_uid()));
DummyXA res = new DummyXA(false);
tx.enlistResource(res);
tx.delistResource(res, XAResource.TMSUSPEND);
assertTrue(tx.isAlive());
tx.commit();
assertTrue(tx.getRemainingTimeoutMills() != -1);
assertTrue(tx.getTimeout() != -1);
assertEquals(tx.getSynchronizations().size(), 0);
assertEquals(tx.getResources().size(), 1);
TxImpleOverride.remove(tx);
assertTrue(TransactionImple.getTransactions() != null);
assertEquals(TransactionImple.getTransaction(tx.get_uid()), null);
try {
tx = (TransactionImple) TransactionManager.transactionManager(new InitialContext());
fail();
} catch (final Throwable ex) {
}
assertNull(TransactionImple.getTransaction(null));
}
use of com.hp.mwtests.ts.jta.common.DummyXA in project narayana by jbosstm.
the class TransactionImpleUnitTest method testDelist.
@Test
public void testDelist() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
try {
tx.delistResource(null, XAResource.TMSUCCESS);
fail();
} catch (final SystemException ex) {
}
DummyXA xares = new DummyXA(false);
try {
assertFalse(tx.delistResource(xares, XAResource.TMSUCCESS));
} catch (final Throwable ex) {
fail();
}
tx.enlistResource(xares);
assertTrue(tx.delistResource(xares, XAResource.TMSUCCESS));
tx.commit();
try {
tx.delistResource(xares, XAResource.TMSUCCESS);
fail();
} catch (final IllegalStateException ex) {
}
}
use of com.hp.mwtests.ts.jta.common.DummyXA in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testPackUnpack.
@Test
public void testPackUnpack() throws Exception {
XAResourceRecord xares;
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
OutputObjectState os = new OutputObjectState();
assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
InputObjectState is = new InputObjectState(os);
assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), null);
os = new OutputObjectState();
assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
is = new InputObjectState(os);
assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
}
use of com.hp.mwtests.ts.jta.common.DummyXA in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testValid1PC.
@Test
public void testValid1PC() throws Exception {
TransactionImple tx = new TransactionImple(0);
DummyXA res = new DummyXA(false);
XAResourceRecord xares = new XAResourceRecord(tx, res, tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.FINISH_OK);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.end, FailType.normal), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.end, FailType.timeout), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.end, FailType.XA_RBCOMMFAIL), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.heurcom), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.FINISH_OK);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.timeout), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.nota), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.inval), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.proto), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.rmfail), tx.getTxId(), null);
assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
}
Aggregations