### Question:
DefaultPromise extends AbstractFuture<V> implements Promise<V> { @Override public boolean cancel(boolean mayInterruptIfRunning) { if (RESULT_UPDATER.compareAndSet(this, null, CANCELLATION_CAUSE_HOLDER)) { checkNotifyWaiters(); notifyListeners(); return true; } return false; } DefaultPromise(EventExecutor executor); protected  DefaultPromise(); @Override Promise<V> setSuccess(V result); @Override // 设置promise 的result值 boolean trySuccess(V result); @Override Promise<V> setFailure(Throwable cause); @Override boolean tryFailure(Throwable cause); @Override boolean setUncancellable(); @Override boolean isSuccess(); @Override boolean isCancellable(); @Override Throwable cause(); @Override Promise<V> addListener(GenericFutureListener<? extends Future<? super V>> listener); @Override Promise<V> addListeners(GenericFutureListener<? extends Future<? super V>>... listeners); @Override Promise<V> removeListener(final GenericFutureListener<? extends Future<? super V>> listener); @Override Promise<V> removeListeners(final GenericFutureListener<? extends Future<? super V>>... listeners); @Override Promise<V> await(); @Override Promise<V> awaitUninterruptibly(); @Override boolean await(long timeout, TimeUnit unit); @Override boolean await(long timeoutMillis); @Override boolean awaitUninterruptibly(long timeout, TimeUnit unit); @Override boolean awaitUninterruptibly(long timeoutMillis); @SuppressWarnings("unchecked") @Override V getNow(); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override Promise<V> sync(); @Override Promise<V> syncUninterruptibly(); @Override String toString();  }### Answer:
@Test(expected = CancellationException.class) public void testCancellationExceptionIsThrownWhenBlockingGet() throws InterruptedException, ExecutionException { final Promise<Void> promise = new DefaultPromise<Void>(ImmediateEventExecutor.INSTANCE); promise.cancel(false); promise.get(); }
@Test(expected = CancellationException.class) public void testCancellationExceptionIsThrownWhenBlockingGetWithTimeout() throws InterruptedException, ExecutionException, TimeoutException { final Promise<Void> promise = new DefaultPromise<Void>(ImmediateEventExecutor.INSTANCE); promise.cancel(false); promise.get(1, TimeUnit.SECONDS); }