Search in sources :

Example 1 with PeriodicRecovery

use of com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery in project narayana by jbosstm.

the class ImportNonUniqueBranchTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    RecoveryEnvironmentBean environmentBean = BeanPopulator.getDefaultInstance(RecoveryEnvironmentBean.class);
    List<String> moduleNames = new ArrayList<>();
    moduleNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateAtomicActionRecoveryModule");
    moduleNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule");
    environmentBean.setRecoveryModuleClassNames(moduleNames);
    environmentBean.setRecoveryBackoffPeriod(1);
    BeanPopulator.getDefaultInstance(JTAEnvironmentBean.class).setXAResourceRecordWrappingPlugin(new XAResourceRecordWrappingPluginImpl());
    periodicRecovery = new PeriodicRecovery(false, false);
    for (RecoveryModule recoveryModule : periodicRecovery.getModules()) {
        if (recoveryModule instanceof XARecoveryModule) {
            xaRecoveryModule = (XARecoveryModule) recoveryModule;
            break;
        }
    }
}
Also used : RecoveryEnvironmentBean(com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean) PeriodicRecovery(com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery) ArrayList(java.util.ArrayList) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) JTAEnvironmentBean(com.arjuna.ats.jta.common.JTAEnvironmentBean) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) BeforeClass(org.junit.BeforeClass)

Example 2 with PeriodicRecovery

use of com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery in project narayana by jbosstm.

the class PeriodicRecoveryTest method testInitialDelay.

@Test
public void testInitialDelay() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    RecoveryEnvironmentBean bean = recoveryPropertyManager.getRecoveryEnvironmentBean().setPeriodicRecoveryInitilizationOffset(1);
    PeriodicRecovery periodicRecovery = new PeriodicRecovery(false, false);
    Method doInitialWait = periodicRecovery.getClass().getDeclaredMethod("doInitialWait");
    doInitialWait.setAccessible(true);
    long l = System.currentTimeMillis();
    try {
        doInitialWait.invoke(periodicRecovery, null);
    } finally {
        doInitialWait.setAccessible(false);
    }
    assertTrue(System.currentTimeMillis() - l > 500);
}
Also used : RecoveryEnvironmentBean(com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean) PeriodicRecovery(com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

RecoveryEnvironmentBean (com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean)2 PeriodicRecovery (com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery)2 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)1 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)1 JTAEnvironmentBean (com.arjuna.ats.jta.common.JTAEnvironmentBean)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1