Code example for ScheduledFuture

Methods: isDone

0
 
	@Test
	public void scheduleAndCancelHeartbeat() throws Exception {
 
		ScheduledFuture<?> task = mock(ScheduledFuture.class);
		willReturn(task).given(this.taskScheduler).schedule(any(Runnable.class), any(Date.class));
 
		this.session.setActive(true);
		this.session.scheduleHeartbeat();
 
		verify(this.taskScheduler).schedule(any(Runnable.class), any(Date.class));
		verifyNoMoreInteractions(this.taskScheduler);
 
		given(task.isDone()).willReturn(false);
 
		this.session.cancelHeartbeat();
 
		verify(task).isDone();
		verify(task).cancel(false);
		verifyNoMoreInteractions(task);
	} 
 
}