use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class CadaverUnitTest method testBasic.
@Test
public void testBasic() throws Exception {
AtomicAction A = new AtomicAction();
AtomicObject B = new AtomicObject();
A.begin();
CadaverLockRecord clr = new CadaverLockRecord(null, B, A);
LockRecord lr = new LockRecord(B, A);
assertTrue(clr.type() != null);
clr.print(new PrintWriter(new ByteArrayOutputStream()));
clr.replace(lr);
A.abort();
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class CadaverUnitTest method testMultipleNestedAbort.
@Test
public void testMultipleNestedAbort() 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.abort();
assertEquals(A.commit(), ActionStatus.COMMITTED);
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class CadaverUnitTest method testMultipleNestedCommit.
@Test
public void testMultipleNestedCommit() 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);
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class NestedTopLevelAction method test.
@Test
public void test() {
AtomicAction A = new AtomicAction();
TopLevelAction B = new TopLevelAction();
AtomicAction C = new AtomicAction();
AtomicObject foo1 = new AtomicObject();
AtomicObject foo2 = new AtomicObject();
try {
A.begin();
foo1.set(5);
System.out.println("Current atomic object 1 state: " + foo1.get());
System.out.println("\nStarting nested top-level action.");
B.begin();
System.out.println(B);
foo2.set(7);
System.out.println("Current atomic object 2 state: " + foo2.get());
System.out.println("\nCommitting nested top-level action.");
B.commit();
System.out.println("\nAborting top-level action.");
A.abort();
C.begin();
int val1 = foo1.get();
int val2 = foo2.get();
System.out.println("\nFinal atomic object 1 state: " + val1);
assertEquals(0, val1);
System.out.println("\nFinal atomic object 2 state: " + val2);
assertEquals(7, val2);
C.commit();
} catch (TestException e) {
A.abort();
B.abort();
C.abort();
fail("AtomicObject exception raised.");
}
}
use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.
the class PerformanceTest1 method persistentTest.
@Test
public void persistentTest() {
long iters = 4;
AtomicObject foo = new AtomicObject();
AtomicAction A = new AtomicAction();
long t1 = System.currentTimeMillis();
A.begin();
try {
for (int c = 0; c < iters; c++) {
foo.set(2);
}
} catch (TestException e) {
fail("AtomicObject exception raised.");
}
A.commit();
reportThroughput("persistentTest", iters, t1);
}
Aggregations