Search in sources :

Example 1 with AtomicObject

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

the class ReactivateUnitTest method test.

@Test
public void test() {
    try {
        AtomicObject obj = new AtomicObject();
        Uid objRef = obj.get_uid();
        AtomicAction A = new AtomicAction();
        A.begin();
        obj.set(1234);
        A.commit();
        AtomicObject recObj = new AtomicObject(objRef);
        AtomicAction B = new AtomicAction();
        B.begin();
        assertEquals(1234, recObj.get());
        B.abort();
    } catch (Exception ex) {
        fail(ex.toString());
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) AtomicAction(com.arjuna.ats.arjuna.AtomicAction) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) Test(org.junit.Test)

Example 2 with AtomicObject

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

the class LockConflictUnitTest method testAtomicObject.

@Test
public void testAtomicObject() throws Exception {
    HammerThreadedObject.object = new AtomicObject();
    HammerThreadedObject object1 = new HammerThreadedObject(2);
    HammerThreadedObject object2 = new HammerThreadedObject(-2);
    HammerThreadedObject.object.setRetry(2);
    object1.start();
    object2.start();
    try {
        object1.join();
        object2.join();
    } catch (InterruptedException e) {
    }
}
Also used : HammerThreadedObject(com.hp.mwtests.ts.txoj.common.resources.HammerThreadedObject) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) Test(org.junit.Test)

Example 3 with AtomicObject

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

the class ObjectModelTest method testMULTIPLE.

@Test
public void testMULTIPLE() throws IOException, TestException {
    AtomicObject obj1 = new AtomicObject(ObjectModel.MULTIPLE);
    AtomicObject obj2 = new AtomicObject(obj1.get_uid(), ObjectModel.MULTIPLE);
    AtomicAction A = new AtomicAction();
    A.begin();
    obj1.set(1234);
    A.commit();
    assertEquals(1234, obj2.get());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) Test(org.junit.Test)

Example 4 with AtomicObject

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

the class PerformanceTest2 method persistentTest.

@Test
public void persistentTest() {
    long iters = 1000;
    AtomicObject foo = new AtomicObject();
    AtomicAction A = null;
    long t1 = System.currentTimeMillis();
    try {
        for (int c = 0; c < iters; c++) {
            A = new AtomicAction();
            A.begin();
            foo.set(2);
            A.commit();
        }
    } catch (TestException e) {
        if (A != null)
            A.abort();
        fail("AtomicObject exception raised.");
    }
    reportThroughput("persistentTest", iters, t1);
}
Also used : 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)

Example 5 with AtomicObject

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

the class Hammer method test.

@Test
public void test() {
    HammerThreadedObject.object = new AtomicObject();
    HammerThreadedObject object1 = new HammerThreadedObject(2);
    HammerThreadedObject object2 = new HammerThreadedObject(-2);
    object1.start();
    object2.start();
    try {
        object1.join();
        object2.join();
    } catch (InterruptedException e) {
    }
}
Also used : HammerThreadedObject(com.hp.mwtests.ts.txoj.common.resources.HammerThreadedObject) 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