Search in sources :

Example 6 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class JTSObjStoreBrowserTest method jtsReplayTest.

/**
 * Similar to aaReplayTest but uses a JTS transaction instead of an AtomicAction
 * @throws Exception if test fails unexpectedly
 */
// TODO for replay to work on JTS participants ExtendedCrashReocrd needs to extend XAResourceRecord
// TODO @Test
public void jtsReplayTest() throws Exception {
    ArjunaTransactionImple A = new ArjunaTransactionImple(null);
    ExtendedCrashRecord[] recs = startTest(A);
    int outcome = ActionStatus.COMMITTED;
    try {
        A.commit(true);
    } catch (HeuristicHazard e) {
        outcome = ActionStatus.H_HAZARD;
    }
    assertEquals(ActionStatus.H_HAZARD, outcome);
    finishTest(A, true, recs);
}
Also used : ExtendedCrashRecord(com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard)

Example 7 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ServerTopLevelRestrictedUnitTest method testCommit.

@Test
public void testCommit() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    ServerRestrictedTopLevelAction act = new ServerRestrictedTopLevelAction(sc);
    assertTrue(act.type() != null);
    assertTrue(act.child() == null);
    assertTrue(act.deepestControl() != null);
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ServerRestrictedTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.restricted.ServerRestrictedTopLevelAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 8 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ServerTopLevelStrictUnitTest method test.

@Test
public void test() throws Exception {
    ControlImple cont = new ControlImple(null, null);
    Control theControl = cont.getControl();
    ArjunaTransactionImple tx = cont.getImplHandle();
    ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
    ServerStrictTopLevelAction act = new ServerStrictTopLevelAction(sc, true);
    assertTrue(act.interposeResource());
    assertTrue(act.type() != null);
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ServerStrictTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictTopLevelAction) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 9 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ExtendedResourceUnitTest method test.

@Test
public void test() throws Exception {
    DemoArjunaResource ares = new DemoArjunaResource();
    ArjunaTransactionImple tx = new ArjunaTransactionImple(null);
    ExtendedResourceRecord res1 = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), null, new Uid(), tx);
    ExtendedResourceRecord res2 = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), null, new Uid(), tx);
    assertTrue(res1.resourceHandle() != null);
    assertTrue(res1.value() != null);
    assertFalse(res1.propagateOnAbort());
    assertFalse(res1.propagateOnCommit());
    assertTrue(res1.order().notEquals(Uid.nullUid()));
    assertEquals(res1.typeIs(), 101);
    assertTrue(res1.order() != null);
    res1.setValue(null);
    res1.print(new PrintWriter(new ByteArrayOutputStream()));
    OutputObjectState os = new OutputObjectState();
    assertTrue(res1.save_state(os, ObjectType.ANDPERSISTENT));
    InputObjectState is = new InputObjectState(os);
    assertTrue(res1.restore_state(is, ObjectType.ANDPERSISTENT));
    assertFalse(res2.doSave());
    assertFalse(res1.shouldAdd(res2));
    assertFalse(res1.shouldAlter(res2));
    assertFalse(res1.shouldMerge(res2));
    assertFalse(res1.shouldReplace(res2));
    res1 = new ExtendedResourceRecord();
    assertTrue(res1.getRCUid().notEquals(res2.getRCUid()));
    res1.alter(res2);
    res1.merge(res2);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ExtendedResourceRecord(com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord) DemoArjunaResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoArjunaResource) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 10 with ArjunaTransactionImple

use of com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple in project narayana by jbosstm.

the class ExtendedResourceUnitTest method testTopLevelCommit.

@Test
public void testTopLevelCommit() throws Exception {
    DemoArjunaResource ares = new DemoArjunaResource();
    OTSImpleManager.current().begin();
    ArjunaTransactionImple tx = OTSImpleManager.current().getControlWrapper().getImple().getImplHandle();
    ExtendedResourceRecord res = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), tx.getControlHandle().get_coordinator(), new Uid(), OTSImpleManager.current().getControlWrapper().getImple().getImplHandle());
    assertEquals(res.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(res.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
    OTSImpleManager.current().rollback();
    // no heuristic but we can still call method
    assertTrue(res.forgetHeuristic());
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ExtendedResourceRecord(com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord) DemoArjunaResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoArjunaResource) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) Test(org.junit.Test)

Aggregations

ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)33 Test (org.junit.Test)30 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)20 Control (org.omg.CosTransactions.Control)20 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)19 Uid (com.arjuna.ats.arjuna.common.Uid)9 ExtendedResourceRecord (com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord)7 DemoArjunaResource (com.hp.mwtests.ts.jts.orbspecific.resources.DemoArjunaResource)7 ServerTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction)4 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)4 HeuristicHazard (org.omg.CosTransactions.HeuristicHazard)4 ServerNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction)3 ServerOSITopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction)3 ServerOSINestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction)2 ServerStrictNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.strict.ServerStrictNestedAction)2 ExtendedCrashRecord (com.hp.mwtests.ts.jta.jts.common.ExtendedCrashRecord)2 RecoveryCoordinator (org.omg.CosTransactions.RecoveryCoordinator)2 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)1 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)1 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)1