Search in sources :

Example 91 with AtomicAction

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

the class OnePhaseCommitUnitTest method testBasic.

@Test
public void testBasic() throws Exception {
    AtomicAction A = new AtomicAction();
    OnePhaseAbstractRecord rec = new OnePhaseAbstractRecord();
    A.begin();
    A.add(rec);
    A.commit();
    assertTrue(rec.onePhaseCalled());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) OnePhaseAbstractRecord(com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord) Test(org.junit.Test)

Example 92 with AtomicAction

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

the class OnePhaseCommitUnitTest method testFailed.

@Test
public void testFailed() throws Exception {
    AtomicAction A = new AtomicAction();
    OnePhaseAbstractRecord rec1 = new OnePhaseAbstractRecord();
    BasicRecord rec2 = new BasicRecord();
    A.begin();
    A.add(rec1);
    A.add(rec2);
    A.commit();
    assertTrue(!rec1.onePhaseCalled());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) OnePhaseAbstractRecord(com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord) BasicRecord(com.hp.mwtests.ts.arjuna.resources.BasicRecord) Test(org.junit.Test)

Example 93 with AtomicAction

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

the class OnePhaseCommitUnitTest method testDynamic.

@Test
public void testDynamic() throws Exception {
    AtomicAction A = new AtomicAction();
    OnePhaseAbstractRecord rec1 = new OnePhaseAbstractRecord();
    OnePhaseAbstractRecord rec2 = new OnePhaseAbstractRecord();
    A.begin();
    /*
         * Because these are the same record type, we know that they will
         * be called in the order in which they were registered.
         * 
         * There are two records, so 1PC will not be triggered initially. But
         * the first record will return read-only from prepare, which will
         * then trigger 1PC to happen dynamically.
         */
    A.add(rec1);
    A.add(rec2);
    A.commit();
    assertTrue(!rec1.onePhaseCalled());
    assertTrue(rec2.onePhaseCalled());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) OnePhaseAbstractRecord(com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord) Test(org.junit.Test)

Example 94 with AtomicAction

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

the class AtomicActionUnitTest method testPreventCommit.

@Test
public void testPreventCommit() throws Exception {
    AtomicAction A = new AtomicAction();
    A.begin();
    A.preventCommit();
    A.commit();
    assertEquals(A.status(), ActionStatus.ABORTED);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Test(org.junit.Test)

Example 95 with AtomicAction

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

the class AtomicActionUnitTest method testActivateDeactivate.

@Test
public void testActivateDeactivate() throws Exception {
    AtomicAction A = new AtomicAction();
    A.begin();
    assertEquals(A.activate(), false);
    A.abort();
    assertEquals(A.deactivate(), true);
}
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