Search in sources :

Example 11 with AtomicObject

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

the class LockManagerUnitTest method test.

@Test
public void test() throws Throwable {
    AtomicObject obj = new AtomicObject();
    obj = new AtomicObject();
    assertTrue(obj.releaselock(new Uid()));
    assertEquals(obj.setlock(null), LockResult.REFUSED);
    obj.print(new PrintWriter(new ByteArrayOutputStream()));
    obj.printState(new PrintWriter(new ByteArrayOutputStream()));
    assertEquals(new DummyLockManager().type(), "StateManager/LockManager");
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 12 with AtomicObject

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

the class DestroyTest method test.

@Test
public void test() throws TestException {
    AtomicObject atomicObject = new AtomicObject();
    Uid u = atomicObject.get_uid();
    AtomicAction a = new AtomicAction();
    a.begin();
    atomicObject.set(10);
    assertTrue(atomicObject.destroy());
    a.commit();
    atomicObject = new AtomicObject(u);
    int val;
    try {
        val = atomicObject.get();
    } catch (final TestException ex) {
        // activate should fail so setlock should fail
        // differentiate between -1
        val = -2;
    }
    assertEquals(-2, val);
}
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)

Example 13 with AtomicObject

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

the class SharedHammer method main.

public static void main(String[] args) {
    boolean creator = true;
    Uid id = null;
    for (int i = 0; i < args.length; i++) {
        if ("-object".equals(args[i])) {
            creator = false;
            id = new Uid(args[i + 1]);
        }
    }
    if (creator) {
        HammerThreadedObject.object = new AtomicObject();
        System.out.println("Object created with id: " + HammerThreadedObject.object);
    } else
        HammerThreadedObject.object = new AtomicObject(id);
    HammerThreadedObject object1 = new HammerThreadedObject(1);
    object1.start();
    try {
        object1.join();
    } catch (InterruptedException e) {
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) HammerThreadedObject(com.hp.mwtests.ts.txoj.common.resources.HammerThreadedObject) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject)

Example 14 with AtomicObject

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

the class ObjectModelTest method testSINGLE.

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

Example 15 with AtomicObject

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

the class RecoveryModuleUnitTest method test.

@Test
public void test() throws Exception {
    DummyTOModule trm = new DummyTOModule();
    AtomicAction A = new AtomicAction();
    trm.intialise();
    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));
    A.abort();
    trm.periodicWorkFirstPass();
    trm.periodicWorkSecondPass();
}
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)

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