@Test public void testFailures () throws Exception XARecoveryModule xarm = new XARecoveryModule(); Class[] parameterTypes = new Class[2]; Uid u = new Uid();
@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); }
@Test public void testTimelyXAResourceRecoveryHelperRemoval3() throws Exception { final XARecoveryModule xaRecoveryModule = new XARecoveryModule(); ExecutorService pool = Executors.newFixedThreadPool(1);
@Test public void testXAResourceRecoveryHelperRegistration() { XARecoveryModule xaRecoveryModule = new XARecoveryModule(); XAResourceRecoveryHelper xaResourceRecoveryHelper = new DummyXAResourceRecoveryHelper(); xaRecoveryModule.addXAResourceRecoveryHelper(xaResourceRecoveryHelper); xaRecoveryModule.removeXAResourceRecoveryHelper(xaResourceRecoveryHelper); }
@Test public void testXAResourceOrphanFilterRegistration() { XARecoveryModule xaRecoveryModule = new XARecoveryModule(); XAResourceOrphanFilter xaResourceOrphanFilter = new DummyXAResourceOrphanFilter(); xaRecoveryModule.addXAResourceOrphanFilter(xaResourceOrphanFilter); xaRecoveryModule.removeXAResourceOrphanFilter(xaResourceOrphanFilter); }
@BeforeClass public static void beforeClass() throws Exception { RecoveryEnvironmentBean recoveryEnvironmentBean = recoveryPropertyManager.getRecoveryEnvironmentBean(); // Ensure that test XAR is recoverable by adding the test XAResourceRecovery ArrayList<String> rcvClassNames = new ArrayList<>(); rcvClassNames.add(XATestResourceXARecovery.class.getName()); jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(rcvClassNames); recoveryEnvironmentBean.setRecoveryBackoffPeriod(1); // use a short interval between passes recoveryEnvironmentBean.setRecoveryListener(true); // configure the RecoveryMonitor manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT); manager.addModule(new XARecoveryModule()); // we only need to test the XARecoveryModule manager.startRecoveryManagerThread(); // start periodic recovery }
@Test public void testNull () { XARecoveryModule xarm = new XARecoveryModule(); xarm.periodicWorkFirstPass(); xarm.periodicWorkSecondPass(); assertNotNull(xarm.id()); }
private void testTimelyXAResourceRecoveryHelperRemoval(final boolean somethingToRecover) throws Exception { final XARecoveryModule xaRecoveryModule = new XARecoveryModule(); final long xAResourcesSleepMillis = 500; final long millis = System.currentTimeMillis();
@Test public void test() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, SecurityException, HeuristicMixedException, HeuristicRollbackException, NamingException { arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(JDBCStore.class.getName()); arjPropertyManager.getObjectStoreEnvironmentBean().setJdbcAccess(TestJDBCAccess.class.getName()); javax.transaction.TransactionManager tm = TransactionManager.transactionManager(); tm.begin(); tm.getTransaction().enlistResource(new DummyXAResource()); tm.getTransaction().enlistResource(new DummyXAResource()); tm.commit(); assertTrue(commitCount == 1); FAULT_JDBC = true; jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList(new String[] { "1" })); jtaPropertyManager.getJTAEnvironmentBean().setXaResourceOrphanFilters(Arrays.asList(new XAResourceOrphanFilter[] { new com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter(), new com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter() })); jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveries(Arrays.asList(new XAResourceRecovery[] { new DummyXAResourceRecovery() })); jtaPropertyManager.getJTAEnvironmentBean().setOrphanSafetyInterval(1); recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(2); recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModules(Arrays.asList(new RecoveryModule[] { new XARecoveryModule() })); RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT); manager.scan(); assertFalse(rollbackCalled); }
XARecoveryModule recoveryModule = new XARecoveryModule(); recoveryModule.addXAResourceRecoveryHelper(xaResourceRecoveryHelper);
XARecoveryModule xaRecoveryModule = new XARecoveryModule(); Field safetyIntervalMillis = RecoveryXids.class.getDeclaredField("safetyIntervalMillis"); safetyIntervalMillis.setAccessible(true);
XARecoveryModule xarm = new XARecoveryModule();
XARecoveryModule xarm = new XARecoveryModule();
manager.addModule(new XARecoveryModule()); // we only need to test the XARecoveryModule
@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) )); }
XARecoveryModule xarm = new XARecoveryModule();
jtaPropertyManager.getJTAEnvironmentBean().setOrphanSafetyInterval(0); jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList(new String[]{NodeNameXAResourceOrphanFilter.RECOVER_ALL_NODES})); XARecoveryModule xarm = new XARecoveryModule(); xarm.addXAResourceOrphanFilter(new JTANodeNameXAResourceOrphanFilter()); xarm.addXAResourceRecoveryHelper(new XAResourceRecoveryHelper() {
XARecoveryModule xarm = new XARecoveryModule(); xarm.addXAResourceRecoveryHelper(new XAResourceRecoveryHelper() { @Override
manager.addModule(new XARecoveryModule()); // we only need to test the XARecoveryModule
XARecoveryModule xaRecoveryModule = new XARecoveryModule(); xaRecoveryModule.addXAResourceRecoveryHelper(new XAResourceRecoveryHelper() { @Override