Ejemplo n.º 1
0
  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();
  }
Ejemplo n.º 2
0
  public void testMultipleStartsAreIgnored() {
    mockTaskProcessor_.executeTaskPeriodically(0, null, false);
    controlTaskProcessor_.setMatcher(MockControl.ALWAYS_MATCHER);
    controlTaskProcessor_.setReturnValue(mockScheduledFuture_);
    replayAll();

    objectUnderTest_.startTask(2000);
    objectUnderTest_.startTask(2000);

    verifyAll();
  }
Ejemplo n.º 3
0
  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();
  }