use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class TransactionImporterUnitTest method testDifferentInstanceFromRecovery.
@Test
public void testDifferentInstanceFromRecovery() throws XAException, RollbackException, SystemException, HeuristicRollbackException, HeuristicMixedException, HeuristicCommitException {
Uid uid = new Uid();
XidImple xid = new XidImple(uid);
SubordinateTransaction subordinateTransaction = SubordinationManager.getTransactionImporter().importTransaction(xid);
Uid subordinateTransactionUid = subordinateTransaction.get_uid();
Xid subordinateTransactionXid = subordinateTransaction.baseXid();
SubordinateTransaction importedTransaction = SubordinationManager.getTransactionImporter().getImportedTransaction(subordinateTransactionXid);
assertTrue(subordinateTransaction == importedTransaction);
subordinateTransaction.enlistResource(new XAResource() {
@Override
public void commit(Xid xid, boolean b) throws XAException {
}
@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 {
}
});
subordinateTransaction.doPrepare();
Implementations.initialise();
SubordinateTransaction subordinateTransaction1 = SubordinationManager.getTransactionImporter().recoverTransaction(subordinateTransactionUid);
assertTrue(subordinateTransaction != subordinateTransaction1);
SubordinateTransaction importedTransaction1 = SubordinationManager.getTransactionImporter().getImportedTransaction(subordinateTransactionXid);
assertTrue(importedTransaction != importedTransaction1);
SubordinateTransaction importedTransaction2 = SubordinationManager.getTransactionImporter().getImportedTransaction(subordinateTransactionXid);
assertTrue(importedTransaction1 == importedTransaction2);
importedTransaction2.doCommit();
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class XATerminatorUnitTest method test.
@Test
public void test() throws Exception {
XATerminatorImple term = new XATerminatorImple();
XidImple xid = new XidImple(new Uid());
SubordinationManager.getTransactionImporter().importTransaction(xid);
assertTrue(term.beforeCompletion(xid));
assertEquals(term.prepare(xid), XAResource.XA_RDONLY);
SubordinationManager.getTransactionImporter().importTransaction(xid);
term.commit(xid, true);
SubordinationManager.getTransactionImporter().importTransaction(xid);
term.rollback(xid);
SubordinationManager.getTransactionImporter().importTransaction(xid);
term.recover(XAResource.TMSTARTRSCAN);
try {
term.recover(XAResource.TMSTARTRSCAN);
fail();
} catch (final XAException ex) {
}
term.recover(XAResource.TMENDRSCAN);
term.forget(xid);
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class XATerminatorUnitTest method testUnknownTransaction.
@Test
public void testUnknownTransaction() throws Exception {
XATerminatorImple term = new XATerminatorImple();
XidImple xid = new XidImple(new Uid());
try {
term.beforeCompletion(xid);
fail();
} catch (final UnexpectedConditionException ex) {
}
try {
term.prepare(xid);
fail();
} catch (final XAException ex) {
}
try {
term.commit(xid, false);
fail();
} catch (final XAException ex) {
}
try {
term.rollback(xid);
fail();
} catch (final XAException ex) {
}
try {
term.forget(xid);
fail();
} catch (final XAException ex) {
}
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class ForgetTest method testRollbackHeuristic.
@Test
public void testRollbackHeuristic() {
SampleOnePhaseResource res = new SampleOnePhaseResource(SampleOnePhaseResource.ErrorType.heurrb);
XidImple xid = new XidImple(new Uid());
XAOnePhaseResource xares = new XAOnePhaseResource(res, xid, null);
assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
assertTrue(res.forgetCalled());
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testPackUnpack.
@Test
public void testPackUnpack() throws Exception {
XAResourceRecord xares;
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
OutputObjectState os = new OutputObjectState();
assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
InputObjectState is = new InputObjectState(os);
assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), null);
os = new OutputObjectState();
assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
is = new InputObjectState(os);
assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
}
Aggregations