DefaultResponseFuture implements ResponseFuture, Traceable { @Override public boolean cancel() { Exception e = new MotanServiceException(this.getClass().getName() + " task cancel: serverPort=" + serverUrl.getServerPortStr() + " " + MotanFrameworkUtil.toString(request) + " cost=" + (System.currentTimeMillis() - createTime)); return cancel(e); } DefaultResponseFuture(Request requestObj, int timeout, URL serverUrl); @Override void onSuccess(Response response); @Override void onFailure(Response response); @Override Object getValue(); @Override Exception getException(); @Override boolean cancel(); @Override boolean isCancelled(); @Override boolean isDone(); @Override boolean isSuccess(); @Override void addListener(FutureListener listener); @Override long getCreateTime(); @Override void setReturnType(Class<?> clazz); Object getRequestObj(); FutureState getState(); @Override long getRequestId(); @Override long getProcessTime(); @Override void setProcessTime(long time); @Override int getTimeout(); @Override Map<String, String> getAttachments(); @Override void setAttachment(String key, String value); @Override byte getRpcProtocolVersion(); @Override void setRpcProtocolVersion(byte rpcProtocolVersion); @Override TraceableContext getTraceableContext(); @Override void setSerializeNumber(int number); @Override int getSerializeNumber();  }
@Test public void testCancel() { DefaultRequest request = new DefaultRequest(); DefaultResponseFuture response = new DefaultResponseFuture(request, 10, url); response.cancel(); try { response.getValue(); Assert.assertTrue(false); } catch (Exception e) { Assert.assertTrue(true); } Assert.assertTrue(response.isCancelled()); }