### Question:
ImmediateFuture { public static <T> Future<T> errorInstance(final Throwable error) { return new Future<T>() { public boolean cancel(boolean mayInterruptIfRunning) { return false; } public boolean isCancelled() { return false; } public boolean isDone() { return true; } public T get() throws ExecutionException { throw new ExecutionException(error); } public T get(long timeout, TimeUnit unit) throws ExecutionException { throw new ExecutionException(error); } }; } private  ImmediateFuture(); static Future<T> newInstance(final T value); static Future<T> errorInstance(final Throwable error);  }### Answer:
@Test public void testErrorInstance() throws Exception { RuntimeException re = new RuntimeException(); Future<String> errorFuture = ImmediateFuture.errorInstance(re); try { errorFuture.get(); fail(); } catch (ExecutionException ee) { assertSame(re, ee.getCause()); } }