use of javax.resource.spi.XATerminator 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 javax.resource.spi.XATerminator 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 javax.resource.spi.XATerminator in project narayana by jbosstm.
the class JCAServerTransactionRecoveryModuleTest method testReloadStateAcceptable.
@Test
public void testReloadStateAcceptable() throws XAException, RollbackException, SystemException {
JCAServerTransactionRecoveryModule module = new JCAServerTransactionRecoveryModule();
XATerminator terminator = new XATerminatorImple();
Xid xid = new Xid() {
@Override
public int getFormatId() {
return 0;
}
@Override
public byte[] getGlobalTransactionId() {
return new byte[0];
}
@Override
public byte[] getBranchQualifier() {
return new byte[0];
}
};
SubordinationManager.getTransactionImporter().importTransaction(xid);
SubordinateTransaction importedTransaction = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
importedTransaction.enlistResource(new XAResource() {
@Override
public void commit(Xid xid, boolean b) throws XAException {
commitCalled = true;
}
@Override
public void end(Xid xid, int i) throws XAException {
}
@Override
public void forget(Xid xid) throws XAException {
}
@Override
public int getTransactionTimeout() throws XAException {
return 0;
}
@Override
public boolean isSameRM(XAResource xaResource) throws XAException {
return false;
}
@Override
public int prepare(Xid xid) throws XAException {
return 0;
}
@Override
public Xid[] recover(int i) throws XAException {
return new Xid[0];
}
@Override
public void rollback(Xid xid) throws XAException {
}
@Override
public boolean setTransactionTimeout(int i) throws XAException {
return false;
}
@Override
public void start(Xid xid, int i) throws XAException {
}
});
terminator.prepare(xid);
module.periodicWorkFirstPass();
module.periodicWorkSecondPass();
module.periodicWorkFirstPass();
module.periodicWorkSecondPass();
assertFalse(commitCalled);
terminator.commit(xid, false);
assertTrue(commitCalled);
}
Aggregations