Search in sources :

Example 1 with SampleOnePhaseResource

use of com.hp.mwtests.ts.jta.common.SampleOnePhaseResource in project narayana by jbosstm.

the class ForgetTest method testRollbackHeuristic.

@Test
public void testRollbackHeuristic() {
    SampleOnePhaseResource res = new SampleOnePhaseResource(SampleOnePhaseResource.ErrorType.heurrb);
    XidImple xid = new XidImple(new Uid());
    XAOnePhaseResource xares = new XAOnePhaseResource(res, xid, null);
    assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
    assertTrue(res.forgetCalled());
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XAOnePhaseResource(com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource) SampleOnePhaseResource(com.hp.mwtests.ts.jta.common.SampleOnePhaseResource) Test(org.junit.Test)

Example 2 with SampleOnePhaseResource

use of com.hp.mwtests.ts.jta.common.SampleOnePhaseResource in project narayana by jbosstm.

the class OnePhaseUnitTest method testPackUnpackError.

@Test
public void testPackUnpackError() throws Exception {
    SampleOnePhaseResource res = new SampleOnePhaseResource();
    XidImple xid = new XidImple(new Uid());
    XAOnePhaseResource xares = new XAOnePhaseResource(res, xid, null);
    OutputObjectState os = new OutputObjectState();
    try {
        xares.pack(os);
        fail();
    } catch (final IOException ex) {
    }
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XAOnePhaseResource(com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource) SampleOnePhaseResource(com.hp.mwtests.ts.jta.common.SampleOnePhaseResource) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with SampleOnePhaseResource

use of com.hp.mwtests.ts.jta.common.SampleOnePhaseResource in project narayana by jbosstm.

the class OnePhaseUnitTest method testFailure.

@Test
public void testFailure() throws Exception {
    SampleOnePhaseResource res = new SampleOnePhaseResource(ErrorType.heurmix);
    XAOnePhaseResource xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
    assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
    res = new SampleOnePhaseResource(ErrorType.rmerr);
    xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
    assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
    res = new SampleOnePhaseResource(ErrorType.nota);
    xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
    assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
    res = new SampleOnePhaseResource(ErrorType.inval);
    xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
    assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
    res = new SampleOnePhaseResource(ErrorType.proto);
    xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
    assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XAOnePhaseResource(com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource) SampleOnePhaseResource(com.hp.mwtests.ts.jta.common.SampleOnePhaseResource) Test(org.junit.Test)

Example 4 with SampleOnePhaseResource

use of com.hp.mwtests.ts.jta.common.SampleOnePhaseResource in project narayana by jbosstm.

the class OnePhaseUnitTest method test.

@Test
public void test() throws Exception {
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] obj = new Object[1];
    SampleOnePhaseResource res = new SampleOnePhaseResource();
    obj[XAResourceRecord.XACONNECTION] = rc;
    XAOnePhaseResource xares = new XAOnePhaseResource(res, new XidImple(new Uid()), obj);
    OutputObjectState os = new OutputObjectState();
    xares.pack(os);
    InputObjectState is = new InputObjectState(os);
    xares.unpack(is);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) XAOnePhaseResource(com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource) SampleOnePhaseResource(com.hp.mwtests.ts.jta.common.SampleOnePhaseResource) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 5 with SampleOnePhaseResource

use of com.hp.mwtests.ts.jta.common.SampleOnePhaseResource in project narayana by jbosstm.

the class OnePhaseUnitTest method testCommit.

@Test
public void testCommit() {
    SampleOnePhaseResource res = new SampleOnePhaseResource();
    XidImple xid = new XidImple(new Uid());
    XAOnePhaseResource xares = new XAOnePhaseResource(res, xid, null);
    assertEquals(xares.commit(), TwoPhaseOutcome.FINISH_OK);
    assertTrue(res.onePhaseCalled());
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XAOnePhaseResource(com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource) SampleOnePhaseResource(com.hp.mwtests.ts.jta.common.SampleOnePhaseResource) Test(org.junit.Test)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)8 XAOnePhaseResource (com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource)8 XidImple (com.arjuna.ats.jta.xa.XidImple)8 SampleOnePhaseResource (com.hp.mwtests.ts.jta.common.SampleOnePhaseResource)8 Test (org.junit.Test)8 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)2 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 DummyRecoverableXAConnection (com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection)1 IOException (java.io.IOException)1