@Test
public void testMirror()
        throws Exception
{

    // Test return value
    ExtendedSettableFuture<String> fromFuture = ExtendedSettableFuture.create();
    SettableFuture<String> toFuture = SettableFuture.create();
    mirror(fromFuture, toFuture, true);
    fromFuture.set("abc");
    assertEquals(toFuture.get(), "abc");
    // Test exception
    fromFuture = ExtendedSettableFuture.create();
    toFuture = SettableFuture.create();
    mirror(fromFuture, toFuture, true);
    fromFuture.setException(new RuntimeException());
    assertThrows(ExecutionException.class, toFuture::get);
    // Test cancellation without interrupt
    fromFuture = ExtendedSettableFuture.create();
    toFuture = SettableFuture.create();
    mirror(fromFuture, toFuture, false);
    toFuture.cancel(true);
    // Parent Future should receive the cancellation
    assertTrue(fromFuture.isCancelled());
    assertFalse(fromFuture.checkWasInterrupted());
    // Test cancellation with interrupt
    fromFuture = ExtendedSettableFuture.create();
    toFuture = SettableFuture.create();
    mirror(fromFuture, toFuture, true);
    toFuture.cancel(false);
    // Parent Future should receive the cancellation
    assertTrue(fromFuture.isCancelled());
    assertTrue(fromFuture.checkWasInterrupted());
}