Search in sources :

Example 16 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testPackUnpack.

@Test
public void testPackUnpack() throws Exception {
    XAResourceRecord xares;
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
    OutputObjectState os = new OutputObjectState();
    assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
    InputObjectState is = new InputObjectState(os);
    assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
    xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), null);
    os = new OutputObjectState();
    assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
    is = new InputObjectState(os);
    assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
}
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) DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 17 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method test.

@Test
public void test() throws Exception {
    XAResourceRecord xares = new XAResourceRecord();
    Object obj = new Object();
    xares.setValue(obj);
    assertTrue(xares.value() != obj);
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
    assertTrue(xares.type() != null);
    xares.merge(xares);
    xares.replace(xares);
    assertTrue(xares.toString() != null);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) Test(org.junit.Test)

Example 18 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testReadonly.

@Test
public void testReadonly() throws Exception {
    XAResourceRecord xares;
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(0), new TestResource(true), new XidImple(new Uid()), params);
    assertEquals(xares.topLevelCommit(), TwoPhaseOutcome.NOT_PREPARED);
    assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) TestResource(com.hp.mwtests.ts.jta.common.TestResource) Test(org.junit.Test)

Example 19 with XidImple

use of com.arjuna.ats.jta.xa.XidImple 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 20 with XidImple

use of com.arjuna.ats.jta.xa.XidImple 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)

Aggregations

XidImple (com.arjuna.ats.jta.xa.XidImple)90 Uid (com.arjuna.ats.arjuna.common.Uid)71 Test (org.junit.Test)71 Xid (javax.transaction.xa.Xid)35 XAException (javax.transaction.xa.XAException)28 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)27 Transaction (javax.transaction.Transaction)16 XATerminator (javax.resource.spi.XATerminator)15 TransactionImporter (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TransactionImporter)12 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.jts.jca.XATerminatorImple)10 IOException (java.io.IOException)10 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)9 XAOnePhaseResource (com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource)9 XAResourceRecord (com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord)9 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)8 SampleOnePhaseResource (com.hp.mwtests.ts.jta.common.SampleOnePhaseResource)8 RollbackException (javax.transaction.RollbackException)8 SystemException (javax.transaction.SystemException)8 XAResource (javax.transaction.xa.XAResource)8 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)7