Code example for Future

Methods: get, isCancelled, isDone

0
        } catch (ExecutionException ex) {
            assertSame(error, ex.getCause());
        } 
 
        Future<Object> future = holder.asFuture();
        assertFalse(future.isCancelled());
        assertTrue(future.isDone());
 
        try { 
            future.get();
            fail("Exception expected"); 
        } catch (ExecutionException ex) {
            assertSame(error, ex.getCause());
        } 
        try { 
            future.get(0, TimeUnit.NANOSECONDS);
            fail("Exception expected"); 
        } catch (ExecutionException ex) {
            assertSame(error, ex.getCause());
        } 
        try { 
            future.get(Long.MAX_VALUE, TimeUnit.DAYS);
            fail("Exception expected"); 
        } catch (ExecutionException ex) {
            assertSame(error, ex.getCause());
        } 
    }