Search in sources :

Example 1 with BasicObject

use of com.hp.mwtests.ts.arjuna.resources.BasicObject in project narayana by jbosstm.

the class DestroyRecoverTest method test.

@Test
public void test() {
    arjPropertyManager.getCoordinatorEnvironmentBean().setAlternativeRecordOrdering(true);
    AtomicAction A = new AtomicAction();
    BasicObject bo = null;
    Uid txId = null;
    Uid objId = null;
    boolean passed = true;
    try {
        A.begin();
        bo = new BasicObject();
        objId = bo.get_uid();
        A.removeThread();
        A.commit();
    } catch (Exception ex) {
        ex.printStackTrace();
        passed = false;
    }
    if (passed) {
        try {
            A = new AtomicAction();
            txId = A.get_uid();
            A.begin();
            bo.activate();
            bo.destroy();
            A.add(new BasicCrashRecord());
            A.removeThread();
            A.commit();
        } catch (com.arjuna.ats.arjuna.exceptions.FatalError ex) {
        // ignore
        } catch (Exception ex) {
            ex.printStackTrace();
            passed = false;
        }
    }
    if (passed) {
        try {
            passed = false;
            RecoveryTransaction tx = new RecoveryTransaction(txId);
            tx.doCommit();
            /*
                 * Committing the recovered transaction should have disposed of the
                 * user object, meaning activation will fail. Which for this test
                 * is a successful outcome!
                 */
            BasicObject recoveredObject = new BasicObject(objId);
            if (recoveredObject.get() == -1)
                passed = true;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    assertTrue(passed);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) BasicObject(com.hp.mwtests.ts.arjuna.resources.BasicObject) Test(org.junit.Test)

Example 2 with BasicObject

use of com.hp.mwtests.ts.arjuna.resources.BasicObject in project narayana by jbosstm.

the class DestroyTest method test.

@Test
public void test() {
    for (int i = 0; i < 100; i++) {
        AtomicAction A = new AtomicAction();
        A.begin();
        BasicObject bo = new BasicObject();
        bo.set(2);
        A.commit();
        AtomicAction B = new AtomicAction();
        AtomicAction C = new AtomicAction();
        B.begin();
        C.begin();
        bo.destroy();
        C.commit();
        B.abort();
        C = new AtomicAction();
        C.begin();
        bo.destroy();
        C.commit();
    }
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) BasicObject(com.hp.mwtests.ts.arjuna.resources.BasicObject) Test(org.junit.Test)

Example 3 with BasicObject

use of com.hp.mwtests.ts.arjuna.resources.BasicObject in project narayana by jbosstm.

the class PersistenceUnitTest method testSaveRestore.

@Test
public void testSaveRestore() {
    final BasicObject obj = new BasicObject();
    final Uid objUid = obj.get_uid();
    obj.set(1234);
    obj.deactivate();
    final BasicObject rec = new BasicObject(objUid);
    int res = rec.get();
    assertEquals(1234, res);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) BasicObject(com.hp.mwtests.ts.arjuna.resources.BasicObject) Test(org.junit.Test)

Example 4 with BasicObject

use of com.hp.mwtests.ts.arjuna.resources.BasicObject in project narayana by jbosstm.

the class BasicTest method test.

@Test
public void test() throws Exception {
    AtomicAction A = new AtomicAction();
    BasicObject bo = new BasicObject();
    A.begin();
    bo.set(2);
    A.commit();
    assertTrue(bo.getStore() != null);
    assertTrue(bo.getStoreRoot() != null);
    assertEquals(bo.getObjectModel(), ObjectModel.SINGLE);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) BasicObject(com.hp.mwtests.ts.arjuna.resources.BasicObject) Test(org.junit.Test)

Example 5 with BasicObject

use of com.hp.mwtests.ts.arjuna.resources.BasicObject in project narayana by jbosstm.

the class BasicTest method testNested.

@Test
public void testNested() throws Exception {
    AtomicAction A = new AtomicAction();
    AtomicAction B = new AtomicAction();
    BasicObject bo = new BasicObject();
    Uid u = bo.get_uid();
    A.begin();
    B.begin();
    bo.set(2);
    B.commit();
    A.commit();
    bo = new BasicObject(u);
    A = new AtomicAction();
    A.begin();
    assertEquals(bo.get(), 2);
    A.commit();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) BasicObject(com.hp.mwtests.ts.arjuna.resources.BasicObject) Test(org.junit.Test)

Aggregations

BasicObject (com.hp.mwtests.ts.arjuna.resources.BasicObject)5 Test (org.junit.Test)5 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)4 Uid (com.arjuna.ats.arjuna.common.Uid)3