use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class SubordinateTestCase method testTwoPhaseCommitSyncWithXAOKViaXATerminatorWithSeparateSync.
@Test
public void testTwoPhaseCommitSyncWithXAOKViaXATerminatorWithSeparateSync() 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 TestXAResource xaResource = new TestXAResource();
xaResource.setPrepareReturnValue(XAResource.XA_OK);
t.enlistResource(xaResource);
final XATerminator xaTerminator = SubordinationManager.getXATerminator();
final XATerminatorExtensions xaTerminatorExtensions = (XATerminatorExtensions) xaTerminator;
xaTerminatorExtensions.beforeCompletion(xid);
assertEquals(XAResource.XA_OK, xaTerminator.prepare(xid));
xaTerminator.commit(xid, false);
assertTrue(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_COMMITTED, t.getStatus());
}
use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class SubordinateTestCase method testRollbackSyncViaXATerminator.
@Test
public void testRollbackSyncViaXATerminator() 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();
xaTerminator.rollback(xid);
assertFalse(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, t.getStatus());
}
use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class SubordinateTestCase method testOnePhaseCommitSyncViaXATerminator.
@Test
public void testOnePhaseCommitSyncViaXATerminator() 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();
xaTerminator.commit(xid, true);
assertTrue(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_COMMITTED, t.getStatus());
}
use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class XAUtilsUnitTest method test.
@Test
public void test() {
DummyXA xa = new DummyXA(false);
assertFalse(XAUtils.mustEndSuspendedRMs(xa));
assertTrue(XAUtils.canOptimizeDelist(xa));
assertEquals(XAUtils.getXANodeName(new XidImple(new Uid())), TxControl.getXANodeName());
}
use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.
the class XAResourceOrphanFilterTest method testSubordinateJTAXAResourceOrphanFilter.
@Test
public void testSubordinateJTAXAResourceOrphanFilter() throws HeuristicRollbackException, HeuristicMixedException, HeuristicCommitException, SystemException, RollbackException, XAException {
XAResourceOrphanFilter orphanFilter = new SubordinateJTAXAResourceOrphanFilter();
XidImple xid = (XidImple) XATxConverter.getXid(Uid.nullUid(), false, XATxConverter.FORMAT_ID);
XATxConverter.setSubordinateNodeName(xid.getXID(), TxControl.getXANodeName());
List<String> xaRecoveryNodes = jtaPropertyManager.getJTAEnvironmentBean().getXaRecoveryNodes();
try {
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList("2"));
assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(xid));
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList("1"));
assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(xid));
} finally {
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(xaRecoveryNodes);
}
}
Aggregations