WebClientFactoryImpl implements HttpClientFactory, WebSocketFactory { @Override public HttpClient createHttpClient(String consumerName) { logger.debug("http client for consumer {} requested", consumerName); checkConsumerName(consumerName); return createHttpClientInternal(consumerName, false, null); } @Activate  WebClientFactoryImpl(final @Reference ExtensibleTrustManager extensibleTrustManager); @Override HttpClient createHttpClient(String consumerName); @Override WebSocketClient createWebSocketClient(String consumerName); @Override HttpClient getCommonHttpClient(); @Override WebSocketClient getCommonWebSocketClient();  }
@Disabled("only for manual test") @Test public void testMultiThreadedCustom() throws Exception { ThreadPoolExecutor workers = new ThreadPoolExecutor(20, 80, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(50 * 50)); final List<HttpClient> clients = new ArrayList<>(); final int maxClients = 2; final int maxRequests = 2; for (int i = 0; i < maxClients; i++) { HttpClient httpClient = webClientFactory.createHttpClient("consumer" + i); clients.add(httpClient); } final List<String> failures = new ArrayList<>(); for (int i = 0; i < maxRequests; i++) { for (final HttpClient client : clients) { workers.execute(new Runnable() { @Override public void run() { try { ContentResponse response = client.GET(TEST_URL); if (response.getStatus() != 200) { failures.add("Statuscode != 200"); } } catch (InterruptedException | ExecutionException | TimeoutException e) { failures.add("Unexpected exception:" + e.getMessage()); } } }); } } workers.shutdown(); workers.awaitTermination(120, TimeUnit.SECONDS); if (!failures.isEmpty()) { fail(failures.toString()); } for (HttpClient client : clients) { client.stop(); } }