case "defaultPort": if (member.getValue() instanceof Number) { obj.setDefaultPort(((Number)member.getValue()).intValue());
@Test public void testIdleTimeout() throws Exception { testIdleTimeout(serverOptions, clientOptions.setDefaultPort(DEFAULT_HTTPS_PORT)); }
@Test public void testMultipleRecursiveCallsAndPipelining() throws Exception { int sendRequests = 100; AtomicInteger receivedRequests = new AtomicInteger(); server.requestHandler(x -> { x.response().end("hello"); }) .listen(8080, r -> { if (r.succeeded()) { HttpClient client = vertx.createHttpClient(new HttpClientOptions() .setKeepAlive(true) .setPipelining(true) .setDefaultPort(8080) ); IntStream.range(0, 5).forEach(i -> recursiveCall(client, receivedRequests, sendRequests)); } }); await(); }
@Test public void testDumpManyRequestsOnQueue() throws Exception { int sendRequests = 10000; AtomicInteger receivedRequests = new AtomicInteger(); vertx.createHttpServer(createBaseServerOptions()).requestHandler(r-> { r.response().end(); if (receivedRequests.incrementAndGet() == sendRequests) { testComplete(); } }).listen(onSuccess(s -> { HttpClientOptions ops = createBaseClientOptions() .setDefaultPort(DEFAULT_HTTP_PORT) .setPipelining(true) .setKeepAlive(true); HttpClient client = vertx.createHttpClient(ops); IntStream.range(0, sendRequests).forEach(x -> client.getNow("/", r -> {})); })); await(); }
})); awaitLatch(latch1); HttpClient client = vertx.createHttpClient(new HttpClientOptions().setKeepAlive(false).setDefaultPort(8080));
@Test public void testIdleTimeoutClearTextUpgrade() throws Exception { testIdleTimeout(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTPS_HOST), clientOptions.setDefaultPort(DEFAULT_HTTP_PORT).setUseAlpn(false).setSsl(false).setHttp2ClearTextUpgrade(true)); }
@Test public void testIdleTimeoutClearTextDirect() throws Exception { testIdleTimeout(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTPS_HOST), clientOptions.setDefaultPort(DEFAULT_HTTP_PORT).setUseAlpn(false).setSsl(false).setHttp2ClearTextUpgrade(false)); }
@Test public void testMaxWaitQueueSizeIsRespected() throws Exception { client.close(); client = vertx.createHttpClient(new HttpClientOptions().setDefaultHost(DEFAULT_HTTP_HOST).setDefaultPort(DEFAULT_HTTP_PORT) .setPipelining(false).setMaxWaitQueueSize(0).setMaxPoolSize(2)); waitFor(3); Set<String> expected = new HashSet<>(Arrays.asList("/1", "/2")); server.requestHandler(req -> { assertTrue(expected.contains(req.path())); complete(); }); startServer(); HttpClientRequest req1 = client.get("/1", onFailure(err -> { })); HttpClientRequest req2 = client.get("/2", onFailure(resp -> { })); HttpClientRequest req3 = client.get("/3", onFailure(t -> { assertTrue("Incorrect exception: " + t.getClass().getName(), t instanceof ConnectionPoolTooBusyException); complete(); })); req1.end(); req2.end(); req3.end(); await(); }
.setDefaultPort(8080) .setKeepAlive(true) .setPipelining(false);
.setIdleTimeout(2) .setProtocolVersion(HttpVersion.HTTP_2) .setDefaultPort(8080) .setDefaultHost("localhost")); client.get("/somepath", onSuccess(resp1 -> {
protected HttpClientOptions getHttpClientOptions() { return new HttpClientOptions().setDefaultPort(8080); }
@Test public void testIdleTimeout() throws Exception { testIdleTimeout(serverOptions, clientOptions.setDefaultPort(DEFAULT_HTTPS_PORT)); }
@Test public void testMultipleRecursiveCallsAndPipelining() throws Exception { int sendRequests = 100; AtomicInteger receivedRequests = new AtomicInteger(); server.requestHandler(x -> { x.response().end("hello"); }) .listen(8080, r -> { if (r.succeeded()) { HttpClient client = vertx.createHttpClient(new HttpClientOptions() .setKeepAlive(true) .setPipelining(true) .setDefaultPort(8080) ); IntStream.range(0, 5).forEach(i -> recursiveCall(client, receivedRequests, sendRequests)); } }); await(); }
@Test public void testDumpManyRequestsOnQueue() throws Exception { int sendRequests = 10000; AtomicInteger receivedRequests = new AtomicInteger(); vertx.createHttpServer(createBaseServerOptions()).requestHandler(r-> { r.response().end(); if (receivedRequests.incrementAndGet() == sendRequests) { testComplete(); } }).listen(onSuccess(s -> { HttpClientOptions ops = createBaseClientOptions() .setDefaultPort(DEFAULT_HTTP_PORT) .setPipelining(true) .setKeepAlive(true); HttpClient client = vertx.createHttpClient(ops); IntStream.range(0, sendRequests).forEach(x -> client.getNow("/", r -> {})); })); await(); }
@Override public void setUp() throws Exception { super.setUp(); client = vertx.createHttpClient(new HttpClientOptions().setDefaultPort(8080).setKeepAlive(false)); }
private void connect(final Runnable runnable) { final HttpClientOptions httpClientOptions = new HttpClientOptions(); final JksOptions jksOptions = new JksOptions(); jksOptions.setPath(trustStorePath).setPassword(trustStorePassword); httpClientOptions.setDefaultHost(host).setDefaultPort(port) .setConnectTimeout(timeOutInMilliseconds) .setMaxPoolSize(poolSize) .setKeepAlive(keepAlive) .setPipelining(pipeline) .setSoLinger(soLinger) .setTcpNoDelay(tcpNoDelay) .setTryUseCompression(tryUseCompression) .setSsl(ssl) .setTrustAll(trustAll) .setVerifyHost(verifyHost) .setMaxWebsocketFrameSize(maxWebSocketFrameSize) .setUsePooledBuffers(true); httpClient = vertx.createHttpClient(httpClientOptions); if (debug) logger.debug("HTTP CLIENT: connect:: \nhost {} \nport {}\n", host, port); closed.set(false); Sys.sleep(100); if (runnable != null) runnable.run(); }
@Test public void testIdleTimeoutClearTextUpgrade() throws Exception { testIdleTimeout(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTPS_HOST), clientOptions.setDefaultPort(DEFAULT_HTTP_PORT).setUseAlpn(false).setSsl(false).setHttp2ClearTextUpgrade(true)); }
@Test public void testIdleTimeoutClearTextDirect() throws Exception { testIdleTimeout(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTPS_HOST), clientOptions.setDefaultPort(DEFAULT_HTTP_PORT).setUseAlpn(false).setSsl(false).setHttp2ClearTextUpgrade(false)); }
@Test public void testMaxWaitQueueSizeIsRespected() throws Exception { client.close(); client = vertx.createHttpClient(new HttpClientOptions().setDefaultHost(DEFAULT_HTTP_HOST).setDefaultPort(DEFAULT_HTTP_PORT) .setPipelining(false).setMaxWaitQueueSize(0).setMaxPoolSize(2)); waitFor(3); Set<String> expected = new HashSet<>(Arrays.asList("/1", "/2")); server.requestHandler(req -> { assertTrue(expected.contains(req.path())); complete(); }); startServer(); HttpClientRequest req1 = client.get("/1", resp -> { fail("Should not be called."); }); HttpClientRequest req2 = client.get("/2", resp -> { fail("Should not be called."); }); HttpClientRequest req3 = client.get("/3", resp -> { fail("Should not be called."); }); req3.exceptionHandler(t -> { assertTrue("Incorrect exception: " + t.getClass().getName(), t instanceof ConnectionPoolTooBusyException); complete(); }); req1.end(); req2.end(); req3.end(); await(); }
.setIdleTimeout(2) .setProtocolVersion(HttpVersion.HTTP_2) .setDefaultPort(8080) .setDefaultHost("localhost")); client.get("/somepath", resp1 -> {