use of org.jboss.stm.internal.PersistentContainer in project narayana by jbosstm.
the class NestedHammerUnitTest method testPersistentHammerMULTIPLE.
public void testPersistentHammerMULTIPLE() {
PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>(ObjectModel.MULTIPLE);
Sample obj1 = theContainer.enlist(new SampleLockable(10));
Sample obj2 = theContainer.enlist(new SampleLockable(10));
Worker worker1 = new Worker(obj1, obj2);
Worker worker2 = new Worker(obj1, obj2);
AtomicAction A = new AtomicAction();
/*
* Make sure the state is saved to disk before proceeding. Important
* for the MULTIPLE option.
*/
A.begin();
obj1.increment();
obj1.decrement();
obj2.increment();
obj2.decrement();
A.commit();
worker1.start();
worker2.start();
try {
worker1.join();
worker2.join();
} catch (final Throwable ex) {
}
assertEquals(obj1.value() + obj2.value(), 20);
}
use of org.jboss.stm.internal.PersistentContainer in project narayana by jbosstm.
the class PersistentContainerUnitTest method testGetUid.
public void testGetUid() {
PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
SampleLockable tester = new SampleLockable();
boolean success = true;
try {
Sample proxy = theContainer.enlist(tester);
Uid u = theContainer.getUidForOriginal(proxy);
assertNotNull(u);
} catch (final Throwable ex) {
ex.printStackTrace();
success = false;
}
assertTrue(success);
}
use of org.jboss.stm.internal.PersistentContainer in project narayana by jbosstm.
the class InvocationHandlerUnitTest method testTxWriteLockCommit.
@SuppressWarnings(value = { "unused" })
public void testTxWriteLockCommit() throws Throwable {
PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
SampleLockable tester = new SampleLockable();
boolean success = true;
Sample proxy = theContainer.enlist(tester);
assertNotNull(proxy);
AtomicAction act = new AtomicAction();
act.begin();
proxy.writeValue();
act.commit();
assertEquals(proxy.readValue(), 1);
}
use of org.jboss.stm.internal.PersistentContainer in project narayana by jbosstm.
the class InvocationHandlerUnitTest method testTxWriteLockRollback.
@SuppressWarnings(value = { "unused" })
public void testTxWriteLockRollback() throws Throwable {
PersistentContainer<Sample> theContainer = new PersistentContainer<Sample>();
SampleLockable tester = new SampleLockable();
boolean success = true;
Sample proxy = theContainer.enlist(tester);
assertNotNull(proxy);
AtomicAction act = new AtomicAction();
act.begin();
proxy.writeValue();
act.abort();
assertEquals(proxy.readValue(), 0);
}
Aggregations