use of com.hp.mwtests.ts.jta.common.TestResource in project narayana by jbosstm.
the class AsyncCommit method test.
@Test
public void test() throws Exception {
UserTransactionImple ut = new UserTransactionImple();
ut.begin();
TransactionImple current = TransactionImple.getTransaction();
TestResource res1, res2;
current.enlistResource(res1 = new TestResource());
current.enlistResource(res2 = new TestResource());
current.delistResource(res2, XAResource.TMSUCCESS);
current.delistResource(res1, XAResource.TMSUCCESS);
Future<Void> commitAsync = ut.commitAsync();
commitAsync.get();
}
use of com.hp.mwtests.ts.jta.common.TestResource in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testReadonly.
@Test
public void testReadonly() throws Exception {
XAResourceRecord xares;
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
xares = new XAResourceRecord(new TransactionImple(0), new TestResource(true), new XidImple(new Uid()), params);
assertEquals(xares.topLevelCommit(), TwoPhaseOutcome.NOT_PREPARED);
assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
}
use of com.hp.mwtests.ts.jta.common.TestResource in project narayana by jbosstm.
the class ExceptionDeferrerTest method testCheckDeferredHeuristicRollbackSecondResourceFails.
@Test
public void testCheckDeferredHeuristicRollbackSecondResourceFails() 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));
} 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.TestResource 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.TestResource 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);
}
}
Aggregations