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());
}
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());
}
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();
}
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());
}
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());
}
Aggregations