Search in sources :

Example 1 with TwoPhaseCoordinator

use of com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator in project narayana by jbosstm.

the class XAResourceOrphanFilterTest method testJTAActionStatusServiceXAResourceOrphanFilter.

@Test
public void testJTAActionStatusServiceXAResourceOrphanFilter() {
    XAResourceOrphanFilter orphanFilter = new JTAActionStatusServiceXAResourceOrphanFilter();
    List<String> xaRecoveryNodes = jtaPropertyManager.getJTAEnvironmentBean().getXaRecoveryNodes();
    List<String> recoveryNodes = new LinkedList<String>();
    recoveryNodes.add("1");
    jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(recoveryNodes);
    try {
        Uid uid = new Uid();
        Xid xid = XATxConverter.getXid(uid, false, XATxConverter.FORMAT_ID);
        assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(xid));
        TwoPhaseCoordinator tpc = new TwoPhaseCoordinator(uid);
        try {
            tpc.start();
            assertEquals(XAResourceOrphanFilter.Vote.LEAVE_ALONE, orphanFilter.checkXid(xid));
        } finally {
            tpc.cancel();
        }
        assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(xid));
        jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(null);
        TwoPhaseCoordinator tpc2 = new TwoPhaseCoordinator(uid);
        tpc2.start();
        assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(xid));
        tpc2.cancel();
    } finally {
        jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(xaRecoveryNodes);
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) TwoPhaseCoordinator(com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator) Xid(javax.transaction.xa.Xid) JTAActionStatusServiceXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTAActionStatusServiceXAResourceOrphanFilter) JTANodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter) SubordinateJTAXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter) SubordinationManagerXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinationManagerXAResourceOrphanFilter) JTAActionStatusServiceXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTAActionStatusServiceXAResourceOrphanFilter) XAResourceOrphanFilter(com.arjuna.ats.jta.recovery.XAResourceOrphanFilter) NodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.NodeNameXAResourceOrphanFilter) JTATransactionLogXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)1 TwoPhaseCoordinator (com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator)1 JTAActionStatusServiceXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTAActionStatusServiceXAResourceOrphanFilter)1 JTANodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter)1 JTATransactionLogXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter)1 NodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.NodeNameXAResourceOrphanFilter)1 SubordinateJTAXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter)1 SubordinationManagerXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinationManagerXAResourceOrphanFilter)1 XAResourceOrphanFilter (com.arjuna.ats.jta.recovery.XAResourceOrphanFilter)1 LinkedList (java.util.LinkedList)1 Xid (javax.transaction.xa.Xid)1 Test (org.junit.Test)1