@Test @UseDataProvider("provideRedirect") public void redirect(final Method method, final URI uri, final Operation operation, final Body requestBody, final String requestData, final Body responseBody, final boolean chunkedEncoding) throws InterruptedException, ExecutionException { final Client client = new ApacheClient.Builder().usingChunkedEncoding(chunkedEncoding).build(); final HttpRequest.Builder builder = new HttpRequest.Builder(method, uri, operation); builder.withBody(requestBody); builder.withContext(Context.X_OG_OBJECT_SIZE, String.valueOf(requestBody.getSize())); final Request request = builder.build(); final Response response = client.execute(request).get(); assertThat(response.getStatusCode(), is(200)); assertThat(response.getBody().getDataType(), is(responseBody.getDataType())); assertThat(response.getBody().getSize(), is(responseBody.getSize())); verify(requestedFor(method, uri.getPath()).withRequestBody(equalTo(requestData))); verify(requestedFor(method, "/container/").withRequestBody(equalTo(requestData))); }
@Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; }
ApacheClient implements Client { @Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; } }
ApacheClient implements Client { @Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; } private  ApacheClient(final Builder builder); }
ApacheClient implements Client { @Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; } private  ApacheClient(final Builder builder); @Override ListenableFuture<Response> execute(final Request request); @Override ListenableFuture<Integer> shutdown(final boolean immediate, final int timeout); @Override String toString(); }
ApacheClient implements Client { @Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; } private  ApacheClient(final Builder builder); @Override ListenableFuture<Response> execute(final Request request); @Override ListenableFuture<Integer> shutdown(final boolean immediate, final int timeout); @Override String toString();  }