Search in sources :

Example 41 with Uid

use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.

the class TransactionImporterUnitTest method testDifferentInstanceFromRecovery.

@Test
public void testDifferentInstanceFromRecovery() throws XAException, RollbackException, SystemException, HeuristicRollbackException, HeuristicMixedException, HeuristicCommitException {
    Uid uid = new Uid();
    XidImple xid = new XidImple(uid);
    SubordinateTransaction subordinateTransaction = SubordinationManager.getTransactionImporter().importTransaction(xid);
    Uid subordinateTransactionUid = subordinateTransaction.get_uid();
    Xid subordinateTransactionXid = subordinateTransaction.baseXid();
    SubordinateTransaction importedTransaction = SubordinationManager.getTransactionImporter().getImportedTransaction(subordinateTransactionXid);
    assertTrue(subordinateTransaction == importedTransaction);
    subordinateTransaction.enlistResource(new XAResource() {

        @Override
        public void commit(Xid xid, boolean b) throws XAException {
        }

        @Override
        public void end(Xid xid, int i) throws XAException {
        }

        @Override
        public void forget(Xid xid) throws XAException {
        }

        @Override
        public int getTransactionTimeout() throws XAException {
            return 0;
        }

        @Override
        public boolean isSameRM(XAResource xaResource) throws XAException {
            return false;
        }

        @Override
        public int prepare(Xid xid) throws XAException {
            return 0;
        }

        @Override
        public Xid[] recover(int i) throws XAException {
            return new Xid[0];
        }

        @Override
        public void rollback(Xid xid) throws XAException {
        }

        @Override
        public boolean setTransactionTimeout(int i) throws XAException {
            return false;
        }

        @Override
        public void start(Xid xid, int i) throws XAException {
        }
    });
    subordinateTransaction.doPrepare();
    Implementations.initialise();
    SubordinateTransaction subordinateTransaction1 = SubordinationManager.getTransactionImporter().recoverTransaction(subordinateTransactionUid);
    assertTrue(subordinateTransaction != subordinateTransaction1);
    SubordinateTransaction importedTransaction1 = SubordinationManager.getTransactionImporter().getImportedTransaction(subordinateTransactionXid);
    assertTrue(importedTransaction != importedTransaction1);
    SubordinateTransaction importedTransaction2 = SubordinationManager.getTransactionImporter().getImportedTransaction(subordinateTransactionXid);
    assertTrue(importedTransaction1 == importedTransaction2);
    importedTransaction2.doCommit();
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XAException(javax.transaction.xa.XAException) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 42 with Uid

use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.

the class XATerminatorUnitTest method test.

@Test
public void test() throws Exception {
    XATerminatorImple term = new XATerminatorImple();
    XidImple xid = new XidImple(new Uid());
    SubordinationManager.getTransactionImporter().importTransaction(xid);
    assertTrue(term.beforeCompletion(xid));
    assertEquals(term.prepare(xid), XAResource.XA_RDONLY);
    SubordinationManager.getTransactionImporter().importTransaction(xid);
    term.commit(xid, true);
    SubordinationManager.getTransactionImporter().importTransaction(xid);
    term.rollback(xid);
    SubordinationManager.getTransactionImporter().importTransaction(xid);
    term.recover(XAResource.TMSTARTRSCAN);
    try {
        term.recover(XAResource.TMSTARTRSCAN);
        fail();
    } catch (final XAException ex) {
    }
    term.recover(XAResource.TMENDRSCAN);
    term.forget(xid);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XAException(javax.transaction.xa.XAException) XATerminatorImple(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple) Test(org.junit.Test)

Example 43 with Uid

use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.

the class XATerminatorUnitTest method testUnknownTransaction.

@Test
public void testUnknownTransaction() throws Exception {
    XATerminatorImple term = new XATerminatorImple();
    XidImple xid = new XidImple(new Uid());
    try {
        term.beforeCompletion(xid);
        fail();
    } catch (final UnexpectedConditionException ex) {
    }
    try {
        term.prepare(xid);
        fail();
    } catch (final XAException ex) {
    }
    try {
        term.commit(xid, false);
        fail();
    } catch (final XAException ex) {
    }
    try {
        term.rollback(xid);
        fail();
    } catch (final XAException ex) {
    }
    try {
        term.forget(xid);
        fail();
    } catch (final XAException ex) {
    }
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XAException(javax.transaction.xa.XAException) UnexpectedConditionException(com.arjuna.ats.jta.exceptions.UnexpectedConditionException) XATerminatorImple(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple) Test(org.junit.Test)

Example 44 with Uid

use of com.arjuna.ats.arjuna.common.Uid 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 45 with Uid

use of com.arjuna.ats.arjuna.common.Uid 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)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)402 Test (org.junit.Test)185 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)83 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)74 XidImple (com.arjuna.ats.jta.xa.XidImple)71 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)57 IOException (java.io.IOException)48 Xid (javax.transaction.xa.Xid)44 XAException (javax.transaction.xa.XAException)40 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)32 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)31 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)27 SoapFault11 (com.arjuna.webservices11.SoapFault11)22 Transaction (javax.transaction.Transaction)18 ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)17 Vector (java.util.Vector)17 XATerminator (javax.resource.spi.XATerminator)15 TransactionImporter (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TransactionImporter)14 Enumeration (java.util.Enumeration)13 SystemException (org.omg.CORBA.SystemException)13