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 {
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();
}
use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.
the class ExceptionDeferrerTest method testCheckDeferredHeuristicRollbackFirstResourceFails.
@Test
public void testCheckDeferredHeuristicRollbackFirstResourceFails() throws Exception {
ThreadActionData.purgeActions();
TxControl.setXANodeName("test");
TransactionImple tx = new TransactionImple(500);
try {
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 ExceptionDeferrerTest method testCheckDeferredPrepareRollbackException.
@Test
public void testCheckDeferredPrepareRollbackException() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
tx.enlistResource(new FailureXAResource());
try {
tx.enlistResource(new FailureXAResource(FailLocation.prepare, FailType.rollback));
} catch (final RollbackException ex) {
fail();
}
try {
tx.commit();
fail();
} catch (final RollbackException ex) {
assertEquals(XAException.XAER_INVAL, ((XAException) ex.getSuppressed()[0]).errorCode);
}
}
use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.
the class ExceptionDeferrerTest method testCheckDeferredPrepareInitCause.
@Test
public void testCheckDeferredPrepareInitCause() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
tx.enlistResource(new FailureXAResource());
try {
tx.enlistResource(new FailureXAResource(FailLocation.prepare, FailType.message));
} catch (final RollbackException ex) {
fail();
}
try {
tx.commit();
fail();
} catch (final RollbackException ex) {
assertEquals(XAException.XA_RBROLLBACK, ((XAException) ex.getSuppressed()[0]).errorCode);
assertEquals("test message", ((XAException) ex.getSuppressed()[0]).getCause().getMessage());
}
}
use of com.hp.mwtests.ts.jta.common.FailureXAResource in project narayana by jbosstm.
the class ExceptionDeferrerTest method testCheckDeferredPrepareHeuristic.
@Test
public void testCheckDeferredPrepareHeuristic() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
tx.enlistResource(new FailureXAResource());
try {
tx.enlistResource(new FailureXAResource(FailLocation.prepare, FailType.XA_HEURHAZ));
} catch (final RollbackException ex) {
fail();
}
try {
tx.commit();
fail();
} catch (final HeuristicMixedException ex) {
assertEquals(XAException.XA_HEURHAZ, ((XAException) ex.getSuppressed()[0]).errorCode);
}
}
Aggregations