@Test
    public void testCallback() throws InterruptedException {
        RequestBody b3 = new RequestBody(3, "Hello world!");
        final CountDownLatch latch = new CountDownLatch(1);
        final List<Class<?>> ret = new ArrayList<Class<?>>();
        try {
            client.invokeWithCallback(addr, b3, new InvokeCallback() {

                @Override
                public void onResponse(Object result) {
                    Assert.fail("Should not reach here!");
                }

                @Override
                public void onException(Throwable e) {
                    //logger.error("Process exception in callback.", e);
                    ret.add(e.getClass());
                    latch.countDown();
                }

                @Override
                public Executor getExecutor() {
                    return null;
                }

            }, timeout);

        } catch (RemotingException e) {
            logger
                .error("Other RemotingException but InvokeTimeoutException occurred in future", e);
            Assert.fail("Should not reach here!");
        }
        latch.await();
        Assert.assertEquals(InvokeTimeoutException.class, ret.get(0));
    }
future try to get result wait a shorter time or just the same with specified timeout in invokeWithFuture
src/test/java/com/alipay/remoting/rpc/timeout/TimeoutTest.java