Source:
public void testRecoveryMonitorWithSuccess() throws Exception { XAResource dummy = new XAResource() { @Override public void commit(Xid xid, boolean b) throws XAException { } @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 { } }; RecoveryEnvironmentBean recoveryEnvironmentBean = recoveryPropertyManager.getRecoveryEnvironmentBean(); XATestResourceXARecovery.setUseFaultyResources(false); TransactionImple tx = new TransactionImple(0); assertTrue(tx.enlistResource(dummy)); assertTrue(tx.enlistResource(dummy)); tx.commit(); recoveryEnvironmentBean.setRecoveryBackoffPeriod(1); recoveryEnvironmentBean.setRecoveryListener(true); RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT); XARecoveryModule xaRecoveryModule = new XARecoveryModule(); manager.addModule(xaRecoveryModule); try { manager.startRecoveryManagerThread(); String host = recoveryEnvironmentBean.getRecoveryAddress(); String rcPort = String.valueOf(recoveryEnvironmentBean.getRecoveryPort()); RecoveryMonitor.main(new String[] {"-verbose", "-port", rcPort, "-host", host}); assertEquals("DONE", RecoveryMonitor.getResponse()); assertEquals("DONE", RecoveryMonitor.getSystemOutput()); assertFalse(!xaRecoveryModule.isPeriodicWorkSuccessful()); } finally { manager.terminate(); } }

Target:
public void testRecoveryMonitorWithSuccess() throws Exception { XAResource dummy = new XAResource() { @Override public void commit(Xid xid, boolean b) throws XAException { } @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 { } }; RecoveryEnvironmentBean recoveryEnvironmentBean = recoveryPropertyManager.getRecoveryEnvironmentBean(); XATestResourceXARecovery.setUseFaultyResources(false); TransactionImple tx = new TransactionImple(0); assertTrue(tx.enlistResource(dummy)); assertTrue(tx.enlistResource(dummy)); tx.commit(); recoveryEnvironmentBean.setRecoveryBackoffPeriod(1); recoveryEnvironmentBean.setRecoveryListener(true); RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT); XARecoveryModule xaRecoveryModule = new XARecoveryModule(); manager.addModule(xaRecoveryModule); try { manager.startRecoveryManagerThread(); String host = recoveryEnvironmentBean.getRecoveryAddress(); String rcPort = String.valueOf(recoveryEnvironmentBean.getRecoveryPort()); RecoveryMonitor.main(new String[] {"-verbose", "-port", rcPort, "-host", host}); assertEquals("DONE", RecoveryMonitor.getResponse()); assertEquals("DONE", RecoveryMonitor.getSystemOutput()); assertTrue(xaRecoveryModule.isPeriodicWorkSuccessful()); } finally { manager.terminate(); } }