use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.
the class JTSObjStoreBrowserTest method jtsReplayTest.
/**
* Similar to aaReplayTest but uses a JTS transaction instead of an AtomicAction
* @throws Exception if test fails unexpectedly
*/
// TODO for replay to work on JTS participants ExtendedCrashReocrd needs to extend XAResourceRecord
// TODO @Test
public void jtsReplayTest() throws Exception {
ArjunaTransactionImple A = new ArjunaTransactionImple(null);
ExtendedCrashRecord[] recs = startTest(A);
int outcome = ActionStatus.COMMITTED;
try {
A.commit(true);
} catch (HeuristicHazard e) {
outcome = ActionStatus.H_HAZARD;
}
assertEquals(ActionStatus.H_HAZARD, outcome);
finishTest(A, true, recs);
}
use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.
the class ServerTopLevelRestrictedUnitTest method testCommit.
@Test
public void testCommit() throws Exception {
ControlImple cont = new ControlImple(null, null);
Control theControl = cont.getControl();
ArjunaTransactionImple tx = cont.getImplHandle();
ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
ServerRestrictedTopLevelAction act = new ServerRestrictedTopLevelAction(sc);
assertTrue(act.type() != null);
assertTrue(act.child() == null);
assertTrue(act.deepestControl() != null);
}
use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.
the class ServerTopLevelStrictUnitTest method test.
@Test
public void test() throws Exception {
ControlImple cont = new ControlImple(null, null);
Control theControl = cont.getControl();
ArjunaTransactionImple tx = cont.getImplHandle();
ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
ServerStrictTopLevelAction act = new ServerStrictTopLevelAction(sc, true);
assertTrue(act.interposeResource());
assertTrue(act.type() != null);
}
use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.
the class ExtendedResourceUnitTest method test.
@Test
public void test() throws Exception {
DemoArjunaResource ares = new DemoArjunaResource();
ArjunaTransactionImple tx = new ArjunaTransactionImple(null);
ExtendedResourceRecord res1 = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), null, new Uid(), tx);
ExtendedResourceRecord res2 = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), null, new Uid(), tx);
assertTrue(res1.resourceHandle() != null);
assertTrue(res1.value() != null);
assertFalse(res1.propagateOnAbort());
assertFalse(res1.propagateOnCommit());
assertTrue(res1.order().notEquals(Uid.nullUid()));
assertEquals(res1.typeIs(), 101);
assertTrue(res1.order() != null);
res1.setValue(null);
res1.print(new PrintWriter(new ByteArrayOutputStream()));
OutputObjectState os = new OutputObjectState();
assertTrue(res1.save_state(os, ObjectType.ANDPERSISTENT));
InputObjectState is = new InputObjectState(os);
assertTrue(res1.restore_state(is, ObjectType.ANDPERSISTENT));
assertFalse(res2.doSave());
assertFalse(res1.shouldAdd(res2));
assertFalse(res1.shouldAlter(res2));
assertFalse(res1.shouldMerge(res2));
assertFalse(res1.shouldReplace(res2));
res1 = new ExtendedResourceRecord();
assertTrue(res1.getRCUid().notEquals(res2.getRCUid()));
res1.alter(res2);
res1.merge(res2);
}
use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.
the class ExtendedResourceUnitTest method testTopLevelCommit.
@Test
public void testTopLevelCommit() throws Exception {
DemoArjunaResource ares = new DemoArjunaResource();
OTSImpleManager.current().begin();
ArjunaTransactionImple tx = OTSImpleManager.current().getControlWrapper().getImple().getImplHandle();
ExtendedResourceRecord res = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), tx.getControlHandle().get_coordinator(), new Uid(), OTSImpleManager.current().getControlWrapper().getImple().getImplHandle());
assertEquals(res.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(res.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
OTSImpleManager.current().rollback();
// no heuristic but we can still call method
assertTrue(res.forgetHeuristic());
}
Aggregations