Search in sources :

Example 16 with XATerminator

use of javax.resource.spi.XATerminator in project narayana by jbosstm.

the class SubordinateTestCase method testRollbackSyncViaXATerminator.

@Test
public void testRollbackSyncViaXATerminator() throws Exception {
    final Xid xid = new XidImple(new Uid());
    final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
    final TestSynchronization sync = new TestSynchronization();
    t.registerSynchronization(sync);
    final XATerminator xaTerminator = SubordinationManager.getXATerminator();
    xaTerminator.rollback(xid);
    assertFalse(sync.isBeforeCompletionDone());
    assertTrue(sync.isAfterCompletionDone());
    assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, t.getStatus());
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XATerminator(javax.resource.spi.XATerminator) Xid(javax.transaction.xa.Xid) Transaction(javax.transaction.Transaction) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 17 with XATerminator

use of javax.resource.spi.XATerminator in project narayana by jbosstm.

the class SubordinateTestCase method testOnePhaseCommitSyncViaXATerminator.

@Test
public void testOnePhaseCommitSyncViaXATerminator() throws Exception {
    final Xid xid = new XidImple(new Uid());
    final Transaction t = SubordinationManager.getTransactionImporter().importTransaction(xid);
    final TestSynchronization sync = new TestSynchronization();
    t.registerSynchronization(sync);
    final XATerminator xaTerminator = SubordinationManager.getXATerminator();
    xaTerminator.commit(xid, true);
    assertTrue(sync.isBeforeCompletionDone());
    assertTrue(sync.isAfterCompletionDone());
    assertEquals(javax.transaction.Status.STATUS_COMMITTED, t.getStatus());
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XATerminator(javax.resource.spi.XATerminator) Xid(javax.transaction.xa.Xid) Transaction(javax.transaction.Transaction) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 18 with XATerminator

use of javax.resource.spi.XATerminator in project narayana by jbosstm.

the class JCAServerTransactionRecoveryModuleTest method testReloadStateAcceptable.

@Test
public void testReloadStateAcceptable() throws XAException, RollbackException, SystemException {
    JCAServerTransactionRecoveryModule module = new JCAServerTransactionRecoveryModule();
    XATerminator terminator = new XATerminatorImple();
    Xid xid = new Xid() {

        @Override
        public int getFormatId() {
            return 0;
        }

        @Override
        public byte[] getGlobalTransactionId() {
            return new byte[0];
        }

        @Override
        public byte[] getBranchQualifier() {
            return new byte[0];
        }
    };
    SubordinationManager.getTransactionImporter().importTransaction(xid);
    SubordinateTransaction importedTransaction = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
    importedTransaction.enlistResource(new XAResource() {

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

        @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 {
        }
    });
    terminator.prepare(xid);
    module.periodicWorkFirstPass();
    module.periodicWorkSecondPass();
    module.periodicWorkFirstPass();
    module.periodicWorkSecondPass();
    assertFalse(commitCalled);
    terminator.commit(xid, false);
    assertTrue(commitCalled);
}
Also used : XATerminator(javax.resource.spi.XATerminator) Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XAException(javax.transaction.xa.XAException) XATerminatorImple(com.arjuna.ats.internal.jta.transaction.jts.jca.XATerminatorImple) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Aggregations

XATerminator (javax.resource.spi.XATerminator)18 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)16 Xid (javax.transaction.xa.Xid)16 Test (org.junit.Test)16 Uid (com.arjuna.ats.arjuna.common.Uid)15 XidImple (com.arjuna.ats.jta.xa.XidImple)15 Transaction (javax.transaction.Transaction)15 XAException (javax.transaction.xa.XAException)8 XATerminatorExtensions (com.arjuna.ats.internal.jta.resources.spi.XATerminatorExtensions)6 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple)2 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.jts.jca.XATerminatorImple)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvalidObjectException (java.io.InvalidObjectException)1 ObjectStreamException (java.io.ObjectStreamException)1 Serializable (java.io.Serializable)1 Type (java.lang.reflect.Type)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1