@Test public void testConcurrency(){ int n = 1000; final CountDownLatch latch = new CountDownLatch(n); StringHttpClient http = new StringHttpClient(new RandomResponseAndLatencyHttpEngine(1, 30)); for(int i=0;i<n;i++){ http.request(Requests .get("SOME_URL") ).consume(r -> { latch.countDown(); }); } try { latch.await(10, TimeUnit.SECONDS); } catch (InterruptedException e) { } assertEquals(0, latch.getCount()); }
public Future<HttpResponse<T>> request(final HttpRequest.Builder request) { return this.request(request.build()); }
BaseHttpClient { public Future<HttpResponse<T>> request(final HttpRequest.Builder request) { return this.request(request.build()); } }
BaseHttpClient { public Future<HttpResponse<T>> request(final HttpRequest.Builder request) { return this.request(request.build()); } BaseHttpClient(HttpAsyncEngine engine); }
BaseHttpClient { public Future<HttpResponse<T>> request(final HttpRequest.Builder request) { return this.request(request.build()); } BaseHttpClient(HttpAsyncEngine engine); void addDefaultHeader(String key, String value); Future<HttpResponse<T>> request(final HttpRequest.Builder request); Future<HttpResponse<T>> request(final HttpRequest request); }
BaseHttpClient { public Future<HttpResponse<T>> request(final HttpRequest.Builder request) { return this.request(request.build()); } BaseHttpClient(HttpAsyncEngine engine); void addDefaultHeader(String key, String value); Future<HttpResponse<T>> request(final HttpRequest.Builder request); Future<HttpResponse<T>> request(final HttpRequest request);  }