Search in sources :

Example 66 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class VertxUnitTest method value.

public static int value() {
    AtomicAction A = new AtomicAction();
    int result = -1;
    A.begin();
    transactionalObject.increment();
    result = transactionalObject.value();
    A.commit();
    return result;
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 67 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class OptimisticUnitTest method testNestedCommit.

public void testNestedCommit() throws Exception {
    init();
    AtomicObject obj = new AtomicObject();
    AtomicAction a = new AtomicAction();
    AtomicAction b = new AtomicAction();
    a.begin();
    obj.set(1234);
    b.begin();
    obj.set(345);
    b.commit();
    a.commit();
    assertEquals(obj.get(), 345);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 68 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class OptimisticUnitTest method testShared.

public void testShared() throws Exception {
    init();
    AtomicObject obj1 = new AtomicObject();
    AtomicObject obj2 = new AtomicObject(obj1.get_uid(), ObjectModel.MULTIPLE);
    AtomicAction A = new AtomicAction();
    A.begin();
    obj1.set(10);
    A.commit();
    A = new AtomicAction();
    A.begin();
    assertEquals(obj2.get(), obj1.get());
    A.commit();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 69 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class BasicIntUnitTest method testExampleSTM.

public void testExampleSTM() throws Exception {
    RecoverableContainer<Atomic> theContainer = new RecoverableContainer<Atomic>();
    ExampleSTM basic = new ExampleSTM();
    boolean success = true;
    Atomic obj = null;
    try {
        obj = theContainer.enlist(basic);
    } catch (final Throwable ex) {
        ex.printStackTrace();
        success = false;
    }
    assertTrue(success);
    AtomicAction a = new AtomicAction();
    a.begin();
    obj.set(1234);
    a.commit();
    assertEquals(obj.get(), 1234);
    a = new AtomicAction();
    a.begin();
    obj.change(1);
    a.abort();
    assertEquals(obj.get(), 1234);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) RecoverableContainer(org.jboss.stm.internal.RecoverableContainer)

Example 70 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class ContainerRecreateOptimisticUnitTest method testOptimisticRecreate.

public void testOptimisticRecreate() {
    Container<Sample1> theContainer = new Container<Sample1>(Container.TYPE.RECOVERABLE, Container.MODEL.EXCLUSIVE);
    Sample1 obj1 = theContainer.create(new Sample1Imple(10));
    assertTrue(obj1 != null);
    /*
         * Do some basic checks and ensure state is in store prior to sharing.
         */
    AtomicAction A = new AtomicAction();
    A.begin();
    obj1.increment();
    obj1.decrement();
    A.commit();
    assertEquals(obj1.value(), 10);
    assertTrue(theContainer.getIdentifier(obj1).notEquals(Uid.nullUid()));
    Sample1 obj2 = theContainer.clone(new Sample1Imple(), theContainer.getIdentifier(obj1));
    assertTrue(obj2 != null);
    A = new AtomicAction();
    A.begin();
    obj2.increment();
    A.commit();
    assertEquals(obj2.value(), 11);
    A = new AtomicAction();
    A.begin();
    assertEquals(obj1.value(), obj2.value());
    A.commit();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Aggregations

AtomicAction (com.arjuna.ats.arjuna.AtomicAction)179 Test (org.junit.Test)73 Uid (com.arjuna.ats.arjuna.common.Uid)31 TestException (com.hp.mwtests.ts.txoj.common.exceptions.TestException)30 AtomicObject (com.hp.mwtests.ts.txoj.common.resources.AtomicObject)18 Lock (com.arjuna.ats.txoj.Lock)17 RecoverableContainer (org.jboss.stm.internal.RecoverableContainer)8 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)7 PrintWriter (java.io.PrintWriter)7 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)5 ExtendedObject (com.hp.mwtests.ts.arjuna.resources.ExtendedObject)5 Container (org.jboss.stm.Container)5 RecoverAtomicAction (com.arjuna.ats.arjuna.recovery.RecoverAtomicAction)4 BasicRecord (com.hp.mwtests.ts.arjuna.resources.BasicRecord)4 TopLevelAction (com.arjuna.ats.arjuna.TopLevelAction)3 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)3 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)3 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)3 LogStore (com.arjuna.ats.internal.arjuna.objectstore.LogStore)3 EditableAtomicAction (com.arjuna.ats.internal.arjuna.tools.log.EditableAtomicAction)3