use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class OnePhaseCommitUnitTest method testBasic.
@Test
public void testBasic() throws Exception {
AtomicAction A = new AtomicAction();
OnePhaseAbstractRecord rec = new OnePhaseAbstractRecord();
A.begin();
A.add(rec);
A.commit();
assertTrue(rec.onePhaseCalled());
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class OnePhaseCommitUnitTest method testFailed.
@Test
public void testFailed() throws Exception {
AtomicAction A = new AtomicAction();
OnePhaseAbstractRecord rec1 = new OnePhaseAbstractRecord();
BasicRecord rec2 = new BasicRecord();
A.begin();
A.add(rec1);
A.add(rec2);
A.commit();
assertTrue(!rec1.onePhaseCalled());
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class OnePhaseCommitUnitTest method testDynamic.
@Test
public void testDynamic() throws Exception {
AtomicAction A = new AtomicAction();
OnePhaseAbstractRecord rec1 = new OnePhaseAbstractRecord();
OnePhaseAbstractRecord rec2 = new OnePhaseAbstractRecord();
A.begin();
/*
* Because these are the same record type, we know that they will
* be called in the order in which they were registered.
*
* There are two records, so 1PC will not be triggered initially. But
* the first record will return read-only from prepare, which will
* then trigger 1PC to happen dynamically.
*/
A.add(rec1);
A.add(rec2);
A.commit();
assertTrue(!rec1.onePhaseCalled());
assertTrue(rec2.onePhaseCalled());
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicActionUnitTest method testPreventCommit.
@Test
public void testPreventCommit() throws Exception {
AtomicAction A = new AtomicAction();
A.begin();
A.preventCommit();
A.commit();
assertEquals(A.status(), ActionStatus.ABORTED);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicActionUnitTest method testActivateDeactivate.
@Test
public void testActivateDeactivate() throws Exception {
AtomicAction A = new AtomicAction();
A.begin();
assertEquals(A.activate(), false);
A.abort();
assertEquals(A.deactivate(), true);
}
Aggregations