@Override public boolean hasException() { return monitor.hasException(); }
@Test public void testSingleDispatcherWithTimer() { ForeignExceptionListener listener1 = Mockito.mock(ForeignExceptionListener.class); ForeignExceptionListener listener2 = Mockito.mock(ForeignExceptionListener.class); ForeignExceptionDispatcher monitor = new ForeignExceptionDispatcher(); // add the listeners monitor.addListener(listener1); monitor.addListener(listener2); TimeoutExceptionInjector timer = new TimeoutExceptionInjector(monitor, 1000); timer.start(); timer.trigger(); assertTrue("Monitor didn't get timeout", monitor.hasException()); // verify that that we propagated the error Mockito.verify(listener1).receive(Mockito.any()); Mockito.verify(listener2).receive(Mockito.any()); }
/** * Wait for the coordinator task to complete, and verify all the mocks * @param task to wait on * @throws Exception on unexpected failure */ private void waitAndVerifyProc(Procedure proc, VerificationMode prepare, VerificationMode commit, VerificationMode cleanup, VerificationMode finish, boolean opHasError) throws Exception { boolean caughtError = false; try { proc.waitForCompleted(); } catch (ForeignException fe) { caughtError = true; } // make sure that the task called all the expected phases Mockito.verify(proc, prepare).sendGlobalBarrierStart(); Mockito.verify(proc, commit).sendGlobalBarrierReached(); Mockito.verify(proc, finish).sendGlobalBarrierComplete(); assertEquals("Operation error state was unexpected", opHasError, proc.getErrorMonitor() .hasException()); assertEquals("Operation error state was unexpected", opHasError, caughtError); }
@Override public boolean hasException() { return monitor.hasException(); }
@Override public boolean hasException() { return this.errorMonitor.hasException(); }
@Override public boolean hasException() { return monitor.hasException(); }
@Test public void testSingleDispatcherWithTimer() { ForeignExceptionListener listener1 = Mockito.mock(ForeignExceptionListener.class); ForeignExceptionListener listener2 = Mockito.mock(ForeignExceptionListener.class); ForeignExceptionDispatcher monitor = new ForeignExceptionDispatcher(); // add the listeners monitor.addListener(listener1); monitor.addListener(listener2); TimeoutExceptionInjector timer = new TimeoutExceptionInjector(monitor, 1000); timer.start(); timer.trigger(); assertTrue("Monitor didn't get timeout", monitor.hasException()); // verify that that we propagated the error Mockito.verify(listener1).receive(Mockito.any()); Mockito.verify(listener2).receive(Mockito.any()); }
/** * Wait for the coordinator task to complete, and verify all the mocks * @param task to wait on * @throws Exception on unexpected failure */ private void waitAndVerifyProc(Procedure proc, VerificationMode prepare, VerificationMode commit, VerificationMode cleanup, VerificationMode finish, boolean opHasError) throws Exception { boolean caughtError = false; try { proc.waitForCompleted(); } catch (ForeignException fe) { caughtError = true; } // make sure that the task called all the expected phases Mockito.verify(proc, prepare).sendGlobalBarrierStart(); Mockito.verify(proc, commit).sendGlobalBarrierReached(); Mockito.verify(proc, finish).sendGlobalBarrierComplete(); assertEquals("Operation error state was unexpected", opHasError, proc.getErrorMonitor() .hasException()); assertEquals("Operation error state was unexpected", opHasError, caughtError); }