public void testRestartStarted() { mockTaskProcessor_.executeTaskPeriodically(1000, null, true); controlTaskProcessor_.setMatcher( new AbstractMatcher() { public boolean matches(Object[] expected, Object[] actual) { return expected[0].equals(actual[0]); } }); controlTaskProcessor_.setReturnValue(mockScheduledFuture_); mockScheduledFuture_.cancel(true); controlScheduledFuture_.setReturnValue(true); mockTaskProcessor_.executeTaskPeriodically(2000, null, true); controlTaskProcessor_.setReturnValue(mockScheduledFuture_); replayAll(); objectUnderTest_.startTask(1000); objectUnderTest_.restartTask(2000); verifyAll(); }
public void testMultipleStartsAreIgnored() { mockTaskProcessor_.executeTaskPeriodically(0, null, false); controlTaskProcessor_.setMatcher(MockControl.ALWAYS_MATCHER); controlTaskProcessor_.setReturnValue(mockScheduledFuture_); replayAll(); objectUnderTest_.startTask(2000); objectUnderTest_.startTask(2000); verifyAll(); }
public void testStopTask() { mockTaskProcessor_.executeTaskPeriodically(0, null, false); controlTaskProcessor_.setMatcher(MockControl.ALWAYS_MATCHER); controlTaskProcessor_.setReturnValue(mockScheduledFuture_); controlScheduledFuture_.expectAndReturn(mockScheduledFuture_.cancel(true), true); replayAll(); objectUnderTest_.startTask(2000); objectUnderTest_.stopTask(); verifyAll(); }