Search in sources :

Example 1 with XAOnePhaseResource

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource 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 XAOnePhaseResource

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource 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 XAOnePhaseResource

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource in project narayana by jbosstm.

the class OnePhaseUnitTest method testInvalid.

@Test
public void testInvalid() {
    XAOnePhaseResource xares = new XAOnePhaseResource();
    assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
    assertEquals(xares.rollback(), TwoPhaseOutcome.FINISH_ERROR);
}
Also used : XAOnePhaseResource(com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource) Test(org.junit.Test)

Example 4 with XAOnePhaseResource

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource 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 5 with XAOnePhaseResource

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource 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)

Aggregations

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