use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.
the class ExceptionDeferrerTest method testCheckDeferredRollbackException.
@Test
public void testCheckDeferredRollbackException() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
try {
tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.rollback));
} catch (final RollbackException ex) {
fail();
}
try {
tx.commit();
fail();
} catch (final RollbackException ex) {
assertEquals(XAException.XA_HEURRB, ((XAException) ex.getSuppressed()[0]).errorCode);
}
}
use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.
the class ExceptionDeferrerTest method testCheckDeferredHeuristicRollbackSecondOfThreeFails.
@Test
public void testCheckDeferredHeuristicRollbackSecondOfThreeFails() throws Exception {
ThreadActionData.purgeActions();
TxControl.setXANodeName("test");
TransactionImple tx = new TransactionImple(500);
try {
tx.enlistResource(new TestResource());
tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.nota));
tx.enlistResource(new TestResource());
} catch (final RollbackException ex) {
fail();
}
try {
tx.commit();
fail();
} catch (final HeuristicMixedException ex) {
assertEquals(XAException.XAER_NOTA, ((XAException) ex.getSuppressed()[0]).errorCode);
}
}
use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.
the class XATerminatorUnitTest method testFail.
@Test
public void testFail() throws Exception {
XATerminatorImple term = new XATerminatorImple();
XidImple xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.rollback));
try {
term.commit(xid, false);
fail();
} catch (final XAException ex) {
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.heurcom));
try {
term.commit(xid, false);
fail();
} catch (final XAException ex) {
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.heurcom));
term.prepare(xid);
try {
term.commit(xid, false);
} catch (final XAException ex) {
fail();
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.normal));
try {
term.commit(xid, false);
fail();
} catch (final XAException ex) {
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.rollback, FailType.rollback));
try {
term.rollback(xid);
} catch (final XAException ex) {
fail();
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.rollback, FailType.heurcom));
term.prepare(xid);
try {
term.rollback(xid);
fail();
} catch (final XAException ex) {
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.rollback, FailType.normal));
term.prepare(xid);
try {
term.rollback(xid);
fail();
} catch (final XAException ex) {
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.prepare_and_rollback, FailType.normal));
try {
term.prepare(xid);
fail();
} catch (final XAException ex) {
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.prepare_and_rollback, FailType.heurcom));
try {
term.prepare(xid);
fail();
} catch (final XAException ex) {
}
xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
tx.enlistResource(new FailureXAResource(FailLocation.prepare_and_rollback, FailType.rollback));
try {
term.prepare(xid);
fail();
} catch (final XAException ex) {
}
}
use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testRollbackFailure.
@Test
public void testRollbackFailure() throws Exception {
FailureXAResource fxa = new FailureXAResource(FailureXAResource.FailLocation.rollback);
TransactionImple tx = new TransactionImple(0);
XAResourceRecord xares = new XAResourceRecord(tx, fxa, tx.getTxId(), null);
assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(xares.topLevelAbort(), TwoPhaseOutcome.HEURISTIC_MIXED);
assertTrue(xares.forgetHeuristic());
}
use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.
the class TransactionImpleUnitTest method testFailure.
@Test
public void testFailure() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
assertFalse(tx.equals(null));
assertTrue(tx.equals(tx));
tx.enlistResource(new FailureXAResource(FailLocation.commit));
try {
tx.commit();
fail();
} catch (final HeuristicMixedException ex) {
}
assertEquals(tx.getStatus(), Status.STATUS_COMMITTED);
try {
tx.registerSynchronization(null);
fail();
} catch (final SystemException ex) {
}
try {
tx.commit();
fail();
} catch (final IllegalStateException ex) {
}
}
Aggregations