use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class RecoveryTest method testCommit.
@Test
public void testCommit() throws Exception {
AtomicAction A = new AtomicAction();
A.begin();
AtomicObject obj = new AtomicObject();
OutputObjectState os = new OutputObjectState();
Uid u = new Uid();
assertTrue(obj.save_state(os, ObjectType.ANDPERSISTENT));
assertTrue(StoreManager.getParticipantStore().write_uncommitted(u, obj.type(), os));
MyRecoveredTO rto = new MyRecoveredTO(u, obj.type(), StoreManager.getParticipantStore());
rto.replay();
A.abort();
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class PersistenceTest method testAtomicObject.
@Test
public void testAtomicObject() throws Throwable {
// StoreManager sm = new StoreManager(null, new TwoPhaseVolatileStore(new ObjectStoreEnvironmentBean()), null);
AtomicObject obj1 = new AtomicObject(ObjectModel.MULTIPLE);
obj1.set(50);
AtomicObject obj2 = new AtomicObject(obj1.get_uid(), ObjectModel.MULTIPLE);
// assertTrue(obj1.getStore().getClass().getName().equals(TwoPhaseVolatileStore.class.getName()));
obj1.set(101);
assertTrue(obj2.get() == 101);
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject 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);
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class AtomicObjectTest2 method test.
@Test
public void test() throws TestException {
rand = new Random();
atomicObject1 = new AtomicObject();
atomicObject2 = new AtomicObject();
System.out.println(atomicObject1.get_uid());
System.out.println(atomicObject2.get_uid());
atomicObject1.set(START_VALUE_1);
atomicObject2.set(START_VALUE_2);
ThreadObject2 thr1 = new ThreadObject2('1');
ThreadObject2 thr2 = new ThreadObject2('2');
thr1.start();
thr2.start();
try {
thr1.join();
thr2.join();
} catch (InterruptedException e) {
}
get12('m', 0);
get21('m', 0);
assertEquals(EXPECTED_RESULT, (getValue1() + getValue2()));
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class AtomicObjectTest4 method test.
@Test
public void test() throws TestException {
rand = new Random();
atomicObject1 = new AtomicObject(ObjectModel.MULTIPLE);
atomicObject2 = new AtomicObject(ObjectModel.MULTIPLE);
System.out.println(atomicObject1.get_uid());
System.out.println(atomicObject2.get_uid());
try {
atomicObject1.set(START_VALUE_1);
} catch (TestException e) {
System.out.println("0 set1 : failed");
}
try {
atomicObject2.set(START_VALUE_2);
} catch (TestException e) {
System.out.println("0 set2 : failed");
}
ThreadObject2[] thrs = new ThreadObject2[NUMBER_THREADS];
for (int i = 0; i < NUMBER_THREADS; i++) thrs[i] = new ThreadObject2(i + 1);
for (int j = 0; j < NUMBER_THREADS; j++) thrs[j].start();
try {
for (int k = 0; k < NUMBER_THREADS; k++) thrs[k].join();
} catch (InterruptedException e) {
}
get12(0, 0);
get21(0, 0);
assertEquals(EXPECTED_RESULT, (getValue1() + getValue2()));
}
Aggregations