@Test
public void testCancel() throws Exception {

    final MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
    doReturn(true).when(future).cancelOwner(anyBoolean());
    assertFalse(future.isCancelled());
    assertFalse(future.isDone());
    assertTrue(future.cancel(false));
    assertTrue(future.isCancelled());
    assertTrue(future.isDone());
    assertFalse(future.cancel(false));
    assertTrue(future.isCancelled());
    assertTrue(future.isDone());
    try {
        future.get();
        fail("This future was canceled");
    } catch (final CancellationException ignore) {
    }
}