use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class VertxUnitTest method value.
public static int value() {
AtomicAction A = new AtomicAction();
int result = -1;
A.begin();
transactionalObject.increment();
result = transactionalObject.value();
A.commit();
return result;
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class OptimisticUnitTest method testNestedCommit.
public void testNestedCommit() throws Exception {
init();
AtomicObject obj = new AtomicObject();
AtomicAction a = new AtomicAction();
AtomicAction b = new AtomicAction();
a.begin();
obj.set(1234);
b.begin();
obj.set(345);
b.commit();
a.commit();
assertEquals(obj.get(), 345);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class OptimisticUnitTest method testShared.
public void testShared() throws Exception {
init();
AtomicObject obj1 = new AtomicObject();
AtomicObject obj2 = new AtomicObject(obj1.get_uid(), ObjectModel.MULTIPLE);
AtomicAction A = new AtomicAction();
A.begin();
obj1.set(10);
A.commit();
A = new AtomicAction();
A.begin();
assertEquals(obj2.get(), obj1.get());
A.commit();
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class BasicIntUnitTest method testExampleSTM.
public void testExampleSTM() throws Exception {
RecoverableContainer<Atomic> theContainer = new RecoverableContainer<Atomic>();
ExampleSTM basic = new ExampleSTM();
boolean success = true;
Atomic obj = null;
try {
obj = theContainer.enlist(basic);
} catch (final Throwable ex) {
ex.printStackTrace();
success = false;
}
assertTrue(success);
AtomicAction a = new AtomicAction();
a.begin();
obj.set(1234);
a.commit();
assertEquals(obj.get(), 1234);
a = new AtomicAction();
a.begin();
obj.change(1);
a.abort();
assertEquals(obj.get(), 1234);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class ContainerRecreateOptimisticUnitTest method testOptimisticRecreate.
public void testOptimisticRecreate() {
Container<Sample1> theContainer = new Container<Sample1>(Container.TYPE.RECOVERABLE, Container.MODEL.EXCLUSIVE);
Sample1 obj1 = theContainer.create(new Sample1Imple(10));
assertTrue(obj1 != null);
/*
* Do some basic checks and ensure state is in store prior to sharing.
*/
AtomicAction A = new AtomicAction();
A.begin();
obj1.increment();
obj1.decrement();
A.commit();
assertEquals(obj1.value(), 10);
assertTrue(theContainer.getIdentifier(obj1).notEquals(Uid.nullUid()));
Sample1 obj2 = theContainer.clone(new Sample1Imple(), theContainer.getIdentifier(obj1));
assertTrue(obj2 != null);
A = new AtomicAction();
A.begin();
obj2.increment();
A.commit();
assertEquals(obj2.value(), 11);
A = new AtomicAction();
A.begin();
assertEquals(obj1.value(), obj2.value());
A.commit();
}
Aggregations