Search in sources :

Example 1 with LastResourceRecord

use of com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord in project narayana by jbosstm.

the class AtomicActionTestBase method testPrepareWithLRRFailOn2PCAwareResourcePrepare.

protected void testPrepareWithLRRFailOn2PCAwareResourcePrepare() {
    OnePhase onePhase = new OnePhase();
    AbstractRecord lastResourceRecord = new LastResourceRecord(onePhase);
    AbstractRecord shutdownRecord = new ShutdownRecord(ShutdownRecord.FAIL_IN_PREPARE);
    executeTest(true, ActionStatus.ABORTED, null, shutdownRecord, lastResourceRecord);
    Assert.assertEquals(OnePhase.ROLLEDBACK, onePhase.status());
}
Also used : LastResourceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Example 2 with LastResourceRecord

use of com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord in project narayana by jbosstm.

the class AtomicActionTestBase method testPrepareWithLRRFailOn2PCAwareResourceCommit.

protected void testPrepareWithLRRFailOn2PCAwareResourceCommit() {
    OnePhase onePhase = new OnePhase();
    AbstractRecord lastResourceRecord = new LastResourceRecord(onePhase);
    AbstractRecord shutdownRecord = new ShutdownRecord(ShutdownRecord.FAIL_IN_COMMIT);
    executeTest(true, ActionStatus.COMMITTED, null, lastResourceRecord, shutdownRecord);
    Assert.assertEquals(OnePhase.COMMITTED, onePhase.status());
}
Also used : LastResourceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Example 3 with LastResourceRecord

use of com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord in project narayana by jbosstm.

the class LastResource method run.

@Test
public void run() {
    AtomicAction A = new AtomicAction();
    OnePhase opRes = new OnePhase();
    A.begin();
    A.add(new LastResourceRecord(opRes));
    A.add(new ShutdownRecord(ShutdownRecord.FAIL_IN_PREPARE));
    A.commit();
    assertEquals(OnePhase.ROLLEDBACK, opRes.status());
    A = new AtomicAction();
    opRes = new OnePhase();
    A.begin();
    A.add(new LastResourceRecord(opRes));
    A.add(new ShutdownRecord(ShutdownRecord.FAIL_IN_COMMIT));
    A.commit();
    assertEquals(OnePhase.COMMITTED, opRes.status());
    A = new AtomicAction();
    A.begin();
    A.add(new LastResourceRecord(new OnePhase()));
    assertEquals(AddOutcome.AR_DUPLICATE, A.add(new LastResourceRecord(new OnePhase())));
    A.abort();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) ShutdownRecord(com.hp.mwtests.ts.arjuna.resources.ShutdownRecord) LastResourceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord) OnePhase(com.hp.mwtests.ts.arjuna.resources.OnePhase) Test(org.junit.Test)

Example 4 with LastResourceRecord

use of com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord in project narayana by jbosstm.

the class LastResourceUnitTest method test.

@Test
public void test() {
    // force errors!
    LastResourceRecord cr = new LastResourceRecord(null);
    assertFalse(cr.propagateOnAbort());
    assertFalse(cr.propagateOnCommit());
    assertEquals(cr.typeIs(), RecordType.LASTRESOURCE);
    assertTrue(cr.type() != null);
    assertFalse(cr.doSave());
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
    assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new LastResourceRecord(null);
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
    assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_ERROR);
    cr = new LastResourceRecord(null);
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
    assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new LastResourceRecord(null);
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
    assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new LastResourceRecord(null);
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
    assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
    cr.print(new PrintWriter(new ByteArrayOutputStream()));
    assertEquals(cr.value(), null);
    cr.setValue(null);
    assertFalse(cr.shouldAdd(new PersistenceRecord()));
    assertFalse(cr.shouldAlter(new PersistenceRecord()));
    assertFalse(cr.shouldMerge(new PersistenceRecord()));
    assertFalse(cr.shouldReplace(new PersistenceRecord()));
    cr = new LastResourceRecord();
    cr.merge(new PersistenceRecord());
    cr.alter(new PersistenceRecord());
}
Also used : LastResourceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PersistenceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 5 with LastResourceRecord

use of com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord in project narayana by jbosstm.

the class AtomicActionTestBase method testPrepareWithLRRSuccess.

protected void testPrepareWithLRRSuccess() {
    OnePhase onePhase = new OnePhase();
    AbstractRecord lastResourceRecord = new LastResourceRecord(onePhase);
    AbstractRecord basicRecord = new BasicRecord();
    executeTest(true, ActionStatus.COMMITTED, null, basicRecord, lastResourceRecord);
    Assert.assertEquals(OnePhase.COMMITTED, onePhase.status());
}
Also used : LastResourceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Aggregations

LastResourceRecord (com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord)5 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)3 Test (org.junit.Test)2 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)1 PersistenceRecord (com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord)1 OnePhase (com.hp.mwtests.ts.arjuna.resources.OnePhase)1 ShutdownRecord (com.hp.mwtests.ts.arjuna.resources.ShutdownRecord)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1