Search in sources :

Example 1 with PersistentContainer

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);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) PersistentContainer(org.jboss.stm.internal.PersistentContainer)

Example 2 with PersistentContainer

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);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) PersistentContainer(org.jboss.stm.internal.PersistentContainer)

Example 3 with PersistentContainer

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);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) PersistentContainer(org.jboss.stm.internal.PersistentContainer)

Example 4 with PersistentContainer

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);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) PersistentContainer(org.jboss.stm.internal.PersistentContainer)

Aggregations

PersistentContainer (org.jboss.stm.internal.PersistentContainer)4 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)3 Uid (com.arjuna.ats.arjuna.common.Uid)1