Search in sources :

Example 1 with RecoveryXAResource

use of com.hp.mwtests.ts.jta.common.RecoveryXAResource in project narayana by jbosstm.

the class TransactionImpleUnitTest method testThreadIsActive.

@Test
public void testThreadIsActive() throws Exception {
    ThreadActionData.purgeActions();
    Class[] parameterTypes = new Class[1];
    TransactionImple tx = new TransactionImple(0);
    tx.enlistResource(new RecoveryXAResource());
    parameterTypes[0] = XAResource.class;
    Method m = tx.getClass().getDeclaredMethod("threadIsActive", parameterTypes);
    m.setAccessible(true);
    Object[] parameters = new Object[1];
    parameters[0] = new RecoveryXAResource();
    Boolean res = (Boolean) m.invoke(tx, parameters);
    assertFalse(res.booleanValue());
    tx.rollback();
    ThreadActionData.purgeActions();
}
Also used : TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) Method(java.lang.reflect.Method) RecoveryXAResource(com.hp.mwtests.ts.jta.common.RecoveryXAResource) Test(org.junit.Test)

Example 2 with RecoveryXAResource

use of com.hp.mwtests.ts.jta.common.RecoveryXAResource in project narayana by jbosstm.

the class XARecoveryModuleUnitTest method testXAResourceOrphanFilter.

@Test
public void testXAResourceOrphanFilter() throws Exception {
    XAResourceOrphanFilter xaResourceOrphanFilter = new DummyXAResourceOrphanFilter(XAResourceOrphanFilter.Vote.ROLLBACK);
    XARecoveryModule xarm = new XARecoveryModule();
    xarm.addXAResourceOrphanFilter(xaResourceOrphanFilter);
    Class[] parameterTypes = new Class[2];
    parameterTypes[0] = XAResource.class;
    parameterTypes[1] = Xid.class;
    Method m = xarm.getClass().getDeclaredMethod("handleOrphan", parameterTypes);
    m.setAccessible(true);
    Object[] parameters = new Object[2];
    parameters[0] = new RecoveryXAResource();
    parameters[1] = new XidImple();
    m.invoke(xarm, parameters);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Method(java.lang.reflect.Method) RecoveryXAResource(com.hp.mwtests.ts.jta.common.RecoveryXAResource) JTANodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter) XAResourceOrphanFilter(com.arjuna.ats.jta.recovery.XAResourceOrphanFilter) NodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.NodeNameXAResourceOrphanFilter) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Example 3 with RecoveryXAResource

use of com.hp.mwtests.ts.jta.common.RecoveryXAResource in project narayana by jbosstm.

the class XARecoveryModuleUnitTest method testRecover.

@Test
public void testRecover() throws Exception {
    ArrayList<String> r = new ArrayList<String>();
    TransactionImple tx = new TransactionImple(0);
    assertTrue(tx.enlistResource(new RecoveryXAResource()));
    assertEquals(tx.doPrepare(), TwoPhaseOutcome.PREPARE_OK);
    r.add("com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource");
    jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(r);
    XARecoveryModule xarm = new XARecoveryModule();
    assertNull(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(), null)));
    for (int i = 0; i < 11; i++) {
        xarm.periodicWorkFirstPass();
        xarm.periodicWorkSecondPass();
    }
    assertTrue(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(new Uid()), null)) == null);
    assertNull(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(), null)));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple) ArrayList(java.util.ArrayList) RecoveryXAResource(com.hp.mwtests.ts.jta.common.RecoveryXAResource) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Example 4 with RecoveryXAResource

use of com.hp.mwtests.ts.jta.common.RecoveryXAResource in project narayana by jbosstm.

the class XARecoveryModuleUnitTest method testRecover.

@Test
public void testRecover() throws Exception {
    ArrayList<String> r = new ArrayList<String>();
    TransactionImple tx = new TransactionImple();
    assertTrue(tx.enlistResource(new RecoveryXAResource()));
    SubordinateAtomicTransaction sat = new SubordinateAtomicTransaction(tx.get_uid(), tx.getTxId(), 0);
    assertEquals(sat.doPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
    r.add("com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource");
    jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(r);
    XARecoveryModule xarm = new XARecoveryModule();
    for (int i = 0; i < 11; i++) {
        xarm.periodicWorkFirstPass();
        xarm.periodicWorkSecondPass();
    }
}
Also used : SubordinateAtomicTransaction(com.arjuna.ats.internal.jta.transaction.jts.subordinate.jca.SubordinateAtomicTransaction) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) ArrayList(java.util.ArrayList) RecoveryXAResource(com.hp.mwtests.ts.jta.common.RecoveryXAResource) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule) Test(org.junit.Test)

Aggregations

RecoveryXAResource (com.hp.mwtests.ts.jta.common.RecoveryXAResource)4 Test (org.junit.Test)4 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)2 XidImple (com.arjuna.ats.jta.xa.XidImple)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 JTANodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter)1 NodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.NodeNameXAResourceOrphanFilter)1 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule)1 XAResourceRecord (com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord)1 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)1 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple)1 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)1 SubordinateAtomicTransaction (com.arjuna.ats.internal.jta.transaction.jts.subordinate.jca.SubordinateAtomicTransaction)1 XAResourceOrphanFilter (com.arjuna.ats.jta.recovery.XAResourceOrphanFilter)1