Code example for Future

Methods: cancel

0
 
        final Future<Object> future = this.requester.execute(
                this.requestProducer,
                this.responseConsumer,
                this.connPool, this.exchangeContext, this.callback);
        Assert.assertNotNull(future);
        final ArgumentCaptor<FutureCallback> argCaptor = ArgumentCaptor.forClass(FutureCallback.class);
        Mockito.verify(this.connPool).lease(
                Mockito.eq(host), Mockito.isNull(), argCaptor.capture());
        final ConnRequestCallback connRequestCallback = (ConnRequestCallback) argCaptor.getValue();
 
        future.cancel(true);
        final BasicNIOPoolEntry entry = new BasicNIOPoolEntry("id", host, this.conn);
        connRequestCallback.completed(entry);
        Mockito.verify(this.connPool).release(entry, true);
        Mockito.verify(this.conn, Mockito.never()).requestOutput();
    } 
 
 
    @SuppressWarnings({ "rawtypes", "unchecked" }) 
    @Test