Search in sources :

Example 51 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class HeuristicNotificationUnitTest method test.

@Test
public void test() throws Exception {
    AtomicAction A = new AtomicAction();
    DummyHeuristic dh = new DummyHeuristic();
    A.begin();
    A.add(new BasicRecord());
    A.add(new BasicRecord());
    A.add(new HeuristicRecord());
    A.addSynchronization(dh);
    A.commit(false);
    assertEquals(TwoPhaseOutcome.HEURISTIC_MIXED, dh.getStatus());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) DummyHeuristic(com.hp.mwtests.ts.arjuna.resources.DummyHeuristic) BasicRecord(com.hp.mwtests.ts.arjuna.resources.BasicRecord) HeuristicRecord(com.hp.mwtests.ts.arjuna.resources.HeuristicRecord) Test(org.junit.Test)

Example 52 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class AtomicActionUnitTest method testNested.

@Test
public void testNested() throws Exception {
    AtomicAction A = new AtomicAction();
    AtomicAction B = new AtomicAction();
    A.begin();
    B.begin();
    assertTrue(A.childTransactions().length == 1);
    B.commit();
    A.abort();
    assertEquals(A.deactivate(), true);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Test(org.junit.Test)

Example 53 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class AtomicActionUnitTest method testBasic.

@Test
public void testBasic() throws Exception {
    AtomicAction A = new AtomicAction();
    A.begin();
    assertEquals(A.hierarchyDepth(), 1);
    assertEquals(A.topLevelActionUid(), A.get_uid());
    A.end(true);
    assertEquals(A.status(), ActionStatus.COMMITTED);
    assertEquals(A.getTimeout(), AtomicAction.NO_TIMEOUT);
    assertTrue(BasicAction.Current() != null);
    ThreadActionData.purgeActions();
    assertEquals(BasicAction.Current(), null);
    assertTrue(A.type() != null);
    assertTrue(BasicAction.maintainHeuristics());
    assertTrue(A.destroy());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Test(org.junit.Test)

Example 54 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class AtomicActionUnitTest method testCanCommitSuspendedTransaction.

@Test
public void testCanCommitSuspendedTransaction() throws Exception {
    AtomicAction aa = new AtomicAction();
    aa.begin();
    assertTrue(aa.Current() != null);
    aa.suspend();
    assertTrue(aa.Current() == null);
    SimpleAbstractRecord simpleAbstractRecord = new SimpleAbstractRecord();
    aa.add(simpleAbstractRecord);
    aa.commit();
    assertTrue(simpleAbstractRecord.wasCommitted());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Test(org.junit.Test)

Example 55 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class AtomicActionUnitTest method testThreading.

@Test
public void testThreading() throws Exception {
    AtomicAction A = new AtomicAction();
    A.begin();
    assertEquals(A.status(), ActionStatus.RUNNING);
    assertTrue(A.addChildThread());
    A.addThread();
    A.addThread(new Thread());
    assertEquals(A.activeThreads(), 1);
    A.removeChildThread();
    assertEquals(A.activeThreads(), 0);
    A.commit(true);
    assertEquals(A.status(), ActionStatus.COMMITTED);
    ThreadActionData.purgeActions();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Test(org.junit.Test)

Aggregations

AtomicAction (com.arjuna.ats.arjuna.AtomicAction)179 Test (org.junit.Test)73 Uid (com.arjuna.ats.arjuna.common.Uid)31 TestException (com.hp.mwtests.ts.txoj.common.exceptions.TestException)30 AtomicObject (com.hp.mwtests.ts.txoj.common.resources.AtomicObject)18 Lock (com.arjuna.ats.txoj.Lock)17 RecoverableContainer (org.jboss.stm.internal.RecoverableContainer)8 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)7 PrintWriter (java.io.PrintWriter)7 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)5 ExtendedObject (com.hp.mwtests.ts.arjuna.resources.ExtendedObject)5 Container (org.jboss.stm.Container)5 RecoverAtomicAction (com.arjuna.ats.arjuna.recovery.RecoverAtomicAction)4 BasicRecord (com.hp.mwtests.ts.arjuna.resources.BasicRecord)4 TopLevelAction (com.arjuna.ats.arjuna.TopLevelAction)3 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)3 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)3 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)3 LogStore (com.arjuna.ats.internal.arjuna.objectstore.LogStore)3 EditableAtomicAction (com.arjuna.ats.internal.arjuna.tools.log.EditableAtomicAction)3