use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class LockRecordUnitTest method test.
@Test
public void test() {
LockRecord lr = new LockRecord();
assertEquals(lr.lockType(), null);
assertTrue(lr.save_state(new OutputObjectState(), ObjectType.ANDPERSISTENT));
assertFalse(lr.restore_state(new InputObjectState(), ObjectType.ANDPERSISTENT));
assertEquals(lr.value(), null);
lr.setValue(null);
assertEquals(lr.nestedAbort(), TwoPhaseOutcome.FINISH_ERROR);
assertEquals(lr.nestedCommit(), TwoPhaseOutcome.FINISH_ERROR);
assertEquals(lr.topLevelAbort(), TwoPhaseOutcome.FINISH_ERROR);
assertEquals(lr.topLevelCommit(), TwoPhaseOutcome.FINISH_ERROR);
lr = new LockRecord(new AtomicObject(), new AtomicAction());
assertTrue(lr.toString() != null);
lr.print(new PrintWriter(new ByteArrayOutputStream()));
assertTrue(lr.type() != null);
lr.merge(null);
lr.alter(null);
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class AtomicObjectTest1 method test.
@Test
public void test() throws TestException {
txojPropertyManager.getTxojEnvironmentBean().setLockStoreType(BasicPersistentLockStore.class.getName());
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());
atomicObject1.set(START_VALUE_1);
atomicObject2.set(START_VALUE_2);
get12('m', 0);
get21('m', 0);
for (int i = 0; i < 100; i++) randomOperation('1', 0);
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 AtomicObjectTest3 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());
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 thr1 = new ThreadObject2(1);
ThreadObject2 thr2 = new ThreadObject2(2);
thr1.start();
thr2.start();
try {
thr1.join();
thr2.join();
} catch (InterruptedException e) {
}
get12(0, 0);
get21(0, 0);
assertEquals(EXPECTED_RESULT, (getValue1() + getValue2()));
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class BasicActionTest method run.
@Test
public void run() throws TestException {
AtomicObject foo = null;
Uid u = null;
if (u == null)
foo = new AtomicObject();
else
foo = new AtomicObject(u);
AtomicAction A = new AtomicAction();
int value = foo.get();
try {
A.begin();
foo.set(foo.get() + 2);
A.commit();
assertEquals(value + 2, foo.get());
} catch (Exception e) {
A.abort();
fail("AtomicObject exception raised.");
}
System.out.println("\nWill now try some erroneous conditions.\n");
AtomicAction B = new AtomicAction();
u = new Uid();
foo = new AtomicObject(u);
B.begin();
try {
System.out.println("attempting to get value from non-existent object: " + foo.get());
} catch (Exception e) {
}
System.out.println("trying to set value to 5");
try {
foo.set(5);
} catch (Exception e) {
}
try {
System.out.println("attempting to get value again: " + foo.get());
} catch (Exception e) {
}
B.commit();
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class CadaverUnitTest method testCommit.
@Test
public void testCommit() 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.commit(), ActionStatus.COMMITTED);
}
Aggregations