use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class RecoverableTest method test.
@Test
public void test() {
RecoverableObject foo = new RecoverableObject();
AtomicAction A = new AtomicAction();
A.begin();
foo.set(2);
assertEquals(2, foo.get());
A.abort();
assertEquals(0, foo.get());
AtomicAction B = new AtomicAction();
B.begin();
foo.set(4);
assertEquals(4, foo.get());
B.commit();
assertEquals(4, foo.get());
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class BasicThreadedObject method run.
public void run() {
if (startAction) {
BasicThreadedObject.A = new AtomicAction();
System.out.println("BasicThreadedObject " + uid + " created action " + BasicThreadedObject.A.get_uid());
BasicThreadedObject.A.begin();
Thread.yield();
} else {
System.out.println("BasicThreadedObject " + uid + " adding to existing action");
if (A != null)
BasicThreadedObject.A.addThread();
Thread.yield();
}
BasicAction act = BasicAction.Current();
if (act != null)
System.out.println("BasicThreadedObject " + uid + " current action " + act.get_uid());
else
System.out.println("BasicThreadedObject " + uid + " current action null");
try {
BasicThreadedObject.O.incr(4);
Thread.yield();
} catch (Exception e) {
}
if (startAction) {
System.out.println("\nBasicThreadedObject " + uid + " committing action " + act.get_uid());
BasicThreadedObject.A.commit();
System.out.println("BasicThreadedObject " + uid + " action " + act.get_uid() + " committed\n");
} else {
System.out.println("\nBasicThreadedObject " + uid + " aborting action " + act.get_uid());
BasicThreadedObject.A.abort();
System.out.println("BasicThreadedObject " + uid + " action " + act.get_uid() + " aborted\n");
}
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class BasicTest method test.
@Test
public void test() throws Exception {
AtomicAction A = new AtomicAction();
BasicObject bo = new BasicObject();
A.begin();
bo.set(2);
A.commit();
assertTrue(bo.getStore() != null);
assertTrue(bo.getStoreRoot() != null);
assertEquals(bo.getObjectModel(), ObjectModel.SINGLE);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class TxLogStateManagerUnitTest method test.
@Test
public void test() throws Exception {
AtomicAction A = new AtomicAction();
TxStateManager tm = new TxStateManager();
arjPropertyManager.getCoordinatorEnvironmentBean().setClassicPrepare(true);
A.begin();
assertTrue(tm.modified());
assertTrue(tm.writeOptimisation());
A.commit();
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class CadaverUnitTest method testAbort.
@Test
public void testAbort() throws Exception {
AtomicAction A = new AtomicAction();
AtomicObject B = new AtomicObject(ObjectModel.MULTIPLE);
Uid u = B.get_uid();
A.begin();
B.set(1234);
A.commit();
A = new AtomicAction();
B = new AtomicObject(u, ObjectModel.MULTIPLE);
A.begin();
AtomicAction C = new AtomicAction();
C.begin();
assertEquals(B.get(), 1234);
B.set(5678);
B.terminate();
C.commit();
assertEquals(A.abort(), ActionStatus.ABORTED);
}
Aggregations