Search in sources :

Example 26 with AtomicObject

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

the class RecoveryTest method testAbort.

@Test
public void testAbort() 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());
    A.abort();
    rto.replay();
}
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 27 with AtomicObject

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

the class AtomicTest method run.

@Test
public void run() {
    AtomicObject foo = new AtomicObject();
    Uid u = foo.get_uid();
    AtomicAction A = new AtomicAction();
    try {
        A.begin();
        foo.set(2);
        A.commit();
        int finalVal = foo.get();
        assertEquals(2, finalVal);
        foo = new AtomicObject(u);
        A = new AtomicAction();
        A.begin();
        foo.set(4);
        A.commit();
        finalVal = foo.get();
        assertEquals(4, finalVal);
    } catch (TestException e) {
        A.abort();
        fail("AtomicObject exception raised.");
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) AtomicAction(com.arjuna.ats.arjuna.AtomicAction) 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