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