Search in sources :

Example 6 with ExtendedObject

use of com.hp.mwtests.ts.arjuna.resources.ExtendedObject in project narayana by jbosstm.

the class CadaverRecordUnitTest method test.

@Test
public void test() {
    ParticipantStore store = StoreManager.setupStore(null, StateType.OS_UNSHARED);
    CadaverRecord cr = new CadaverRecord(new OutputObjectState(), store, new ExtendedObject());
    assertTrue(cr.propagateOnAbort());
    assertTrue(cr.propagateOnCommit());
    assertEquals(cr.typeIs(), RecordType.PERSISTENCE);
    assertTrue(cr.type() != null);
    assertEquals(cr.doSave(), false);
    cr.merge(new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject()));
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new CadaverRecord(new OutputObjectState(), store, new ExtendedObject());
    cr.merge(new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject()));
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new CadaverRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject());
    cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject()));
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new CadaverRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject());
    cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject()));
    cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject()));
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new CadaverRecord();
    cr.print(new PrintWriter(new ByteArrayOutputStream()));
    assertFalse(cr.shouldMerge(new DisposeRecord()));
    assertFalse(cr.shouldReplace(new DisposeRecord()));
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) PersistenceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) DisposeRecord(com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord) CadaverRecord(com.arjuna.ats.internal.arjuna.abstractrecords.CadaverRecord) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 7 with ExtendedObject

use of com.hp.mwtests.ts.arjuna.resources.ExtendedObject in project narayana by jbosstm.

the class DisposeRecordUnitTest method test.

@Test
public void test() {
    ParticipantStore store = StoreManager.setupStore(null, StateType.OS_UNSHARED);
    DisposeRecord cr = new DisposeRecord(store, new ExtendedObject());
    assertFalse(cr.propagateOnAbort());
    assertTrue(cr.propagateOnCommit());
    assertEquals(cr.typeIs(), RecordType.DISPOSE);
    assertTrue(cr.type() != null);
    assertEquals(cr.doSave(), true);
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new DisposeRecord(store, new ExtendedObject());
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new DisposeRecord(store, new ExtendedObject());
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new DisposeRecord(store, new ExtendedObject());
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new DisposeRecord();
    assertFalse(cr.shouldAdd(new PersistenceRecord()));
    assertFalse(cr.shouldAlter(new PersistenceRecord()));
    assertFalse(cr.shouldMerge(new PersistenceRecord()));
    assertFalse(cr.shouldReplace(new PersistenceRecord()));
    assertFalse(cr.save_state(new OutputObjectState(), ObjectType.ANDPERSISTENT));
    assertFalse(cr.restore_state(new InputObjectState(), ObjectType.ANDPERSISTENT));
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) PersistenceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) DisposeRecord(com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord) Test(org.junit.Test)

Example 8 with ExtendedObject

use of com.hp.mwtests.ts.arjuna.resources.ExtendedObject in project narayana by jbosstm.

the class ExtendedUnitTest method testRememberAction.

@Test
public void testRememberAction() throws Exception {
    ExtendedObject bo = new ExtendedObject();
    final Uid u = bo.get_uid();
    bo.activate();
    bo.deactivate();
    bo = new ExtendedObject(u);
    AtomicAction A = new AtomicAction();
    A.begin();
    assertTrue(bo.remember(A));
    A.commit();
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) AtomicAction(com.arjuna.ats.arjuna.AtomicAction) ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) Test(org.junit.Test)

Example 9 with ExtendedObject

use of com.hp.mwtests.ts.arjuna.resources.ExtendedObject in project narayana by jbosstm.

the class ExtendedUnitTest method test.

@Test
public void test() throws Exception {
    AtomicAction A = new AtomicAction();
    ExtendedObject bo = new ExtendedObject();
    Uid u = bo.get_uid();
    A.begin();
    bo.set(2);
    bo.toggle();
    A.commit();
    bo.terminate();
    bo = new ExtendedObject(u);
    assertEquals(bo.status(), ObjectStatus.PASSIVE);
    assertTrue(bo.getStore() != null);
    assertTrue(bo.getStoreRoot() != null);
    assertEquals(bo.objectType(), ObjectType.ANDPERSISTENT);
    PrintWriter pw = new PrintWriter(new StringWriter());
    bo.print(pw);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) StringWriter(java.io.StringWriter) ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 10 with ExtendedObject

use of com.hp.mwtests.ts.arjuna.resources.ExtendedObject in project narayana by jbosstm.

the class ExtendedUnitTest method testFail.

@Test
public void testFail() throws Exception {
    ExtendedObject bo = new ExtendedObject();
    AtomicAction A = new AtomicAction();
    A.begin();
    A.commit();
    // put it back on this thread.
    ThreadActionData.pushAction(A);
    bo.deactivate();
    bo.set_status();
    assertEquals(bo.activate(), false);
    assertEquals(bo.destroy(), false);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) Test(org.junit.Test)

Aggregations

ExtendedObject (com.hp.mwtests.ts.arjuna.resources.ExtendedObject)11 Test (org.junit.Test)11 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)6 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)5 Uid (com.arjuna.ats.arjuna.common.Uid)4 ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)4 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)4 PersistenceRecord (com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord)4 PrintWriter (java.io.PrintWriter)3 DisposeRecord (com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ActivationRecord (com.arjuna.ats.internal.arjuna.abstractrecords.ActivationRecord)1 CadaverActivationRecord (com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord)1 CadaverRecord (com.arjuna.ats.internal.arjuna.abstractrecords.CadaverRecord)1 RecoveryRecord (com.arjuna.ats.internal.arjuna.abstractrecords.RecoveryRecord)1 StringWriter (java.io.StringWriter)1