+
+ ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
+ executorServiceSpy = Mockito.spy(executorService);
+ doAnswer(new Answer<ScheduledFuture>() {
+ @Override
+ public ScheduledFuture answer(InvocationOnMock invocationOnMock)
+ throws Throwable {
+ invocationOnMock.callRealMethod();
+ return currentKeepalive;
+ }
+ }).when(executorServiceSpy).schedule(Mockito.<Runnable> any(),
+ Mockito.anyLong(), Matchers.<TimeUnit> any());
+
+ Mockito.when(currentKeepalive.isDone()).thenReturn(true);