Search in sources :

Example 6 with AtomicObject

use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.

the class RecoveryTest method testCommit.

@Test
public void testCommit() throws Exception {
    AtomicAction A = new AtomicAction();
    A.begin();
    AtomicObject obj = new AtomicObject();
    OutputObjectState os = new OutputObjectState();
    Uid u = new Uid();
    assertTrue(obj.save_state(os, ObjectType.ANDPERSISTENT));
    assertTrue(StoreManager.getParticipantStore().write_uncommitted(u, obj.type(), os));
    MyRecoveredTO rto = new MyRecoveredTO(u, obj.type(), StoreManager.getParticipantStore());
    rto.replay();
    A.abort();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) Test(org.junit.Test)

Example 7 with AtomicObject

use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.

the class PersistenceTest method testAtomicObject.

@Test
public void testAtomicObject() throws Throwable {
    // StoreManager sm = new StoreManager(null, new TwoPhaseVolatileStore(new ObjectStoreEnvironmentBean()), null);
    AtomicObject obj1 = new AtomicObject(ObjectModel.MULTIPLE);
    obj1.set(50);
    AtomicObject obj2 = new AtomicObject(obj1.get_uid(), ObjectModel.MULTIPLE);
    // assertTrue(obj1.getStore().getClass().getName().equals(TwoPhaseVolatileStore.class.getName()));
    obj1.set(101);
    assertTrue(obj2.get() == 101);
}
Also used : AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) Test(org.junit.Test)

Example 8 with AtomicObject

use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.

the class CadaverUnitTest method testAbort.

@Test
public void testAbort() 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.abort(), ActionStatus.ABORTED);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) Test(org.junit.Test)

Example 9 with AtomicObject

use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.

the class AtomicObjectTest2 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());
    atomicObject1.set(START_VALUE_1);
    atomicObject2.set(START_VALUE_2);
    ThreadObject2 thr1 = new ThreadObject2('1');
    ThreadObject2 thr2 = new ThreadObject2('2');
    thr1.start();
    thr2.start();
    try {
        thr1.join();
        thr2.join();
    } catch (InterruptedException e) {
    }
    get12('m', 0);
    get21('m', 0);
    assertEquals(EXPECTED_RESULT, (getValue1() + getValue2()));
}
Also used : Random(java.util.Random) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) Test(org.junit.Test)

Example 10 with AtomicObject

use of com.hp.mwtests.ts.txoj.common.resources.AtomicObject in project narayana by jbosstm.

the class AtomicObjectTest4 method test.

@Test
public void test() throws TestException {
    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());
    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[] thrs = new ThreadObject2[NUMBER_THREADS];
    for (int i = 0; i < NUMBER_THREADS; i++) thrs[i] = new ThreadObject2(i + 1);
    for (int j = 0; j < NUMBER_THREADS; j++) thrs[j].start();
    try {
        for (int k = 0; k < NUMBER_THREADS; k++) thrs[k].join();
    } catch (InterruptedException e) {
    }
    get12(0, 0);
    get21(0, 0);
    assertEquals(EXPECTED_RESULT, (getValue1() + getValue2()));
}
Also used : Random(java.util.Random) TestException(com.hp.mwtests.ts.txoj.common.exceptions.TestException) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) Test(org.junit.Test)

Aggregations

AtomicObject (com.hp.mwtests.ts.txoj.common.resources.AtomicObject)27 Test (org.junit.Test)26 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)18 Uid (com.arjuna.ats.arjuna.common.Uid)13 TestException (com.hp.mwtests.ts.txoj.common.exceptions.TestException)8 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)4 Random (java.util.Random)4 HammerThreadedObject (com.hp.mwtests.ts.txoj.common.resources.HammerThreadedObject)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintWriter (java.io.PrintWriter)3 LockRecord (com.arjuna.ats.internal.txoj.abstractrecords.LockRecord)2 TopLevelAction (com.arjuna.ats.arjuna.TopLevelAction)1 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 CadaverLockRecord (com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord)1 BasicPersistentLockStore (com.arjuna.ats.internal.txoj.lockstore.BasicPersistentLockStore)1