Search in sources :

Example 1 with OnePhaseAbstractRecord

use of com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord 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 2 with OnePhaseAbstractRecord

use of com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord 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 3 with OnePhaseAbstractRecord

use of com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord 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)

Aggregations

AtomicAction (com.arjuna.ats.arjuna.AtomicAction)3 OnePhaseAbstractRecord (com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord)3 Test (org.junit.Test)3 BasicRecord (com.hp.mwtests.ts.arjuna.resources.BasicRecord)1