use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class SubordinateTestCase method testOnePhaseCommitSyncWithRollbackOnlyViaXATerminatorWithSeparateSync.
@Test
public void testOnePhaseCommitSyncWithRollbackOnlyViaXATerminatorWithSeparateSync() throws Exception {
final Xid xid = new XidImple(new Uid());
final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
final TestSynchronization sync = new TestSynchronization();
t.registerSynchronization(sync);
t.setRollbackOnly();
final XATerminator xaTerminator = SubordinationManager.getXATerminator();
final XATerminatorExtensions xaTerminatorExtensions = (XATerminatorExtensions) xaTerminator;
xaTerminatorExtensions.beforeCompletion(xid);
try {
xaTerminator.commit(xid, true);
((TransactionImple) t).doOnePhaseCommit();
fail("did not get expected rollback exception");
} catch (XAException e) {
assertEquals("javax.transaction.RollbackException", e.getCause().getClass().getName());
assertEquals(XAException.XA_RBROLLBACK, e.errorCode);
// expected - we tried to commit a rollbackonly tx.
}
assertTrue(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, t.getStatus());
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class SubordinateTestCase method testRollbackSyncViaXATerminatorWithSeparateSync.
@Test
public void testRollbackSyncViaXATerminatorWithSeparateSync() throws Exception {
final Xid xid = new XidImple(new Uid());
final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
final TestSynchronization sync = new TestSynchronization();
t.registerSynchronization(sync);
final XATerminator xaTerminator = SubordinationManager.getXATerminator();
final XATerminatorExtensions xaTerminatorExtensions = (XATerminatorExtensions) xaTerminator;
xaTerminatorExtensions.beforeCompletion(xid);
xaTerminator.rollback(xid);
assertTrue(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, t.getStatus());
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class SubordinateTestCase method testFailOnCommitOnePhase.
@Test
public void testFailOnCommitOnePhase() throws Exception {
final Xid xid = new XidImple(new Uid());
final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
final TestXAResource xaResource = new TestXAResource();
// provoke commit into failing with TwoPhaseOutcome.FINISH_ERROR
// warning: this is sensitive to the impl exception handling in
// XAResourceRecord.topLevelCommit
// should cause an exception!
xaResource.setCommitException(new XAException(XAException.XA_HEURRB));
t.enlistResource(xaResource);
final XATerminator xaTerminator = SubordinationManager.getXATerminator();
try {
xaTerminator.commit(xid, true);
} catch (final XAException ex) {
return;
}
assertTrue("commit should throw an exception and not get to here", false);
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class SubordinateTestCase method testOnePhaseCommitSyncWithRollbackOnlyViaXATerminator.
@Test
public void testOnePhaseCommitSyncWithRollbackOnlyViaXATerminator() throws Exception {
final Xid xid = new XidImple(new Uid());
final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
final TestSynchronization sync = new TestSynchronization();
t.registerSynchronization(sync);
t.setRollbackOnly();
final XATerminator xaTerminator = SubordinationManager.getXATerminator();
try {
xaTerminator.commit(xid, true);
((TransactionImple) t).doOnePhaseCommit();
fail("did not get expected rollback exception");
} catch (XAException e) {
assertEquals("javax.transaction.RollbackException", e.getCause().getClass().getName());
assertEquals(XAException.XA_RBROLLBACK, e.errorCode);
// expected - we tried to commit a rollbackonly tx.
}
assertFalse(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, t.getStatus());
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class SubordinateTxUnitTest method testTransactionImple.
@Test
public void testTransactionImple() throws Exception {
TransactionImple tx = new TransactionImple(new Uid());
TransactionImple dummy = new TransactionImple(new Uid());
tx.recordTransaction();
assertFalse(tx.equals(dummy));
assertTrue(tx.toString() != null);
tx.recover();
}
Aggregations