Search in sources :

Example 31 with TestException

use of com.hp.mwtests.ts.txoj.common.exceptions.TestException in project narayana by jbosstm.

the class PerformanceTest1 method persistentTest.

@Test
public void persistentTest() {
    long iters = 4;
    AtomicObject foo = new AtomicObject();
    AtomicAction A = new AtomicAction();
    long t1 = System.currentTimeMillis();
    A.begin();
    try {
        for (int c = 0; c < iters; c++) {
            foo.set(2);
        }
    } catch (TestException e) {
        fail("AtomicObject exception raised.");
    }
    A.commit();
    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 32 with TestException

use of com.hp.mwtests.ts.txoj.common.exceptions.TestException 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

TestException (com.hp.mwtests.ts.txoj.common.exceptions.TestException)32 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)30 AtomicObject (com.hp.mwtests.ts.txoj.common.resources.AtomicObject)8 Test (org.junit.Test)8 Lock (com.arjuna.ats.txoj.Lock)6 Uid (com.arjuna.ats.arjuna.common.Uid)3 Random (java.util.Random)2 TopLevelAction (com.arjuna.ats.arjuna.TopLevelAction)1 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)1