Search in sources :

Example 1 with ExtendedObject

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

the class PersistenceRecordUnitTest method test.

@Test
public void test() {
    ParticipantStore store = StoreManager.setupStore(null, StateType.OS_UNSHARED);
    PersistenceRecord cr = new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject());
    arjPropertyManager.getCoordinatorEnvironmentBean().setClassicPrepare(true);
    assertFalse(cr.propagateOnAbort());
    assertTrue(cr.propagateOnCommit());
    assertEquals(cr.typeIs(), RecordType.PERSISTENCE);
    assertTrue(cr.type() != null);
    assertEquals(cr.doSave(), true);
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_ERROR);
    cr = new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject());
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
    cr.print(new PrintWriter(new ByteArrayOutputStream()));
    OutputObjectState os = new OutputObjectState();
    assertTrue(cr.save_state(os, ObjectType.ANDPERSISTENT));
    assertTrue(cr.restore_state(new InputObjectState(os), ObjectType.ANDPERSISTENT));
    assertEquals(cr.topLevelCleanup(), TwoPhaseOutcome.FINISH_OK);
}
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) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 2 with ExtendedObject

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

the class RecoveryRecordUnitTest method test.

@Test
public void test() {
    RecoveryRecord cr = new RecoveryRecord(new OutputObjectState(), new ExtendedObject());
    assertFalse(cr.propagateOnAbort());
    assertTrue(cr.propagateOnCommit());
    assertEquals(cr.typeIs(), RecordType.RECOVERY);
    assertTrue(cr.type() != null);
    assertEquals(cr.doSave(), false);
    assertTrue(cr.value() != null);
    cr.setValue(new OutputObjectState());
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_ERROR);
    cr = new RecoveryRecord(new OutputObjectState(), new ExtendedObject());
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new RecoveryRecord(new OutputObjectState(), new ExtendedObject());
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_ERROR);
    cr = new RecoveryRecord(new OutputObjectState(), new ExtendedObject());
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new RecoveryRecord();
    cr.merge(new RecoveryRecord());
    cr.alter(new RecoveryRecord());
    assertTrue(cr.save_state(new OutputObjectState(), ObjectType.ANDPERSISTENT));
    assertFalse(cr.restore_state(new InputObjectState(), ObjectType.ANDPERSISTENT));
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) RecoveryRecord(com.arjuna.ats.internal.arjuna.abstractrecords.RecoveryRecord) ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 3 with ExtendedObject

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

the class ExtendedUnitTest method testTryLock.

@Test
public void testTryLock() throws Exception {
    ExtendedObject bo = new ExtendedObject();
    assertTrue(bo.lock());
    assertTrue(bo.unlock());
}
Also used : ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) Test(org.junit.Test)

Example 4 with ExtendedObject

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

the class CadaverActivationUnitTest method test.

@Test
public void test() {
    ParticipantStore store = StoreManager.setupStore(null, StateType.OS_UNSHARED);
    CadaverActivationRecord cr = new CadaverActivationRecord(new ExtendedObject());
    assertTrue(cr.propagateOnAbort());
    assertTrue(cr.propagateOnCommit());
    assertEquals(cr.typeIs(), RecordType.ACTIVATION);
    assertTrue(cr.type() != null);
    assertEquals(cr.doSave(), false);
    assertFalse(cr.shouldReplace(new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject())));
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new CadaverActivationRecord(new ExtendedObject());
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new CadaverActivationRecord(new ExtendedObject());
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new CadaverActivationRecord(new ExtendedObject());
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
}
Also used : 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) CadaverActivationRecord(com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord) Test(org.junit.Test)

Example 5 with ExtendedObject

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

the class ActivationRecordUnitTest method test.

@Test
public void test() {
    AtomicAction A = new AtomicAction();
    AtomicAction B = new AtomicAction();
    A.begin();
    B.begin();
    ActivationRecord cr = new ActivationRecord(ObjectType.ANDPERSISTENT, new ExtendedObject(), B);
    assertFalse(cr.propagateOnAbort());
    assertTrue(cr.propagateOnCommit());
    assertEquals(cr.typeIs(), RecordType.ACTIVATION);
    assertTrue(cr.type() != null);
    assertEquals(cr.doSave(), false);
    assertEquals((Integer) cr.value(), new Integer(ObjectType.ANDPERSISTENT));
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new ActivationRecord(ObjectType.ANDPERSISTENT, new ExtendedObject(), B);
    assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
    B.abort();
    cr = new ActivationRecord(ObjectType.ANDPERSISTENT, new ExtendedObject(), A);
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
    cr = new ActivationRecord(ObjectType.ANDPERSISTENT, new ExtendedObject(), A);
    assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
    cr = new ActivationRecord();
    cr.merge(new ActivationRecord());
    cr.alter(new ActivationRecord());
    assertTrue(cr.save_state(new OutputObjectState(), ObjectType.ANDPERSISTENT));
    assertFalse(cr.restore_state(new InputObjectState(), ObjectType.ANDPERSISTENT));
    A.abort();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ActivationRecord(com.arjuna.ats.internal.arjuna.abstractrecords.ActivationRecord) ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) 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