Code example for Future

Methods: get, isCancelled, isDone

0
        assertSame(expectedResult, holder.waitResult());
        assertSame(expectedResult, holder.waitResult(0, TimeUnit.NANOSECONDS));
        assertSame(expectedResult, holder.waitResult(Long.MAX_VALUE, TimeUnit.DAYS));
 
        Future<Object> future = holder.asFuture();
        assertFalse(future.isCancelled());
        assertTrue(future.isDone());
        assertSame(expectedResult, future.get());
        assertSame(expectedResult, future.get(0, TimeUnit.NANOSECONDS));
        assertSame(expectedResult, future.get(Long.MAX_VALUE, TimeUnit.DAYS));
    } 
 
    private static void checkError(FutureResultHolder<Object> holder, Throwable error) throws Exception {
        assertTrue(holder.hasCompleted());
        assertFalse(holder.hasCompletedWithSuccess());
        assertTrue(holder.hasCompletedWithError());
 
        try { 
            holder.tryGetResult();
            fail("Exception expected"); 
        } catch (ExecutionException ex) {