@Test public void testDomainSocketClient() throws Exception { File sock = TestUtils.tmpFile(".sock"); vertx = Vertx.vertx(); NetClient client = vertx.createNetClient(); client.connect(SocketAddress.domainSocketAddress(sock.getAbsolutePath()), onFailure(err -> { assertEquals(err.getClass(), IllegalArgumentException.class); testComplete(); })); await(); } }
@Test public void testDomainSocketServer() throws Exception { File sock = TestUtils.tmpFile(".sock"); vertx = Vertx.vertx(); NetServer server = vertx.createNetServer(); server.connectHandler(so -> {}); server.listen(SocketAddress.domainSocketAddress(sock.getAbsolutePath()), onFailure(err -> { assertEquals(err.getClass(), IllegalArgumentException.class); testComplete(); })); await(); }
public void setUp() throws Exception { super.setUp(); if (USE_DOMAIN_SOCKETS) { assertTrue("Native transport not enabled", USE_NATIVE_TRANSPORT); tmp = TestUtils.tmpFile(".sock"); testAddress = SocketAddress.domainSocketAddress(tmp.getAbsolutePath()); } else { testAddress = SocketAddress.inetSocketAddress(1234, "localhost"); } client = vertx.createNetClient(new NetClientOptions().setConnectTimeout(1000)); server = vertx.createNetServer(); }
@Test public void testListenDomainSocketAddress() throws Exception { Vertx vx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true)); Assume.assumeTrue("Native transport must be enabled", vx.isNativeTransportEnabled()); NetClient netClient = vx.createNetClient(); HttpServer httpserver = vx.createHttpServer().requestHandler(req -> req.response().end()); File sockFile = TestUtils.tmpFile(".sock"); SocketAddress sockAddress = SocketAddress.domainSocketAddress(sockFile.getAbsolutePath()); httpserver.listen(sockAddress, onSuccess(server -> { netClient.connect(sockAddress, onSuccess(sock -> { sock.handler(buf -> { assertTrue("Response is not an http 200", buf.toString("UTF-8").startsWith("HTTP/1.1 200 OK")); testComplete(); }); sock.write("GET / HTTP/1.1\r\n\r\n"); })); })); try { await(); } finally { vx.close(); } }
@Test public void testHttpServerWithIdleTimeoutSendChunkedFile() throws Exception { int expected = 16 * 1024 * 1024; // We estimate this will take more than 200ms to transfer with a 1ms pause in chunks File sent = TestUtils.tmpFile(".dat", expected); server.close(); server = vertx
@Test public void testSendFilePipelined() throws Exception { int n = 4; waitFor(n); File sent = TestUtils.tmpFile(".dat", 16 * 1024); server.requestHandler( req -> { req.response().sendFile(sent.getAbsolutePath()); }); startServer(); client.close(); client = vertx.createHttpClient(createBaseClientOptions().setPipelining(true).setMaxPoolSize(1)); for (int i = 0;i < n;i++) { client.getNow(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, onSuccess(resp -> { resp.exceptionHandler(this::fail); resp.bodyHandler(body -> { complete(); }); })); } await(); } }
private void testdleTimeoutSendChunkedFile(boolean idleOnServer) throws Exception { int expected = 16 * 1024 * 1024; // We estimate this will take more than 200ms to transfer with a 1ms pause in chunks File sent = TestUtils.tmpFile(".dat", expected); server.close(); Consumer<NetSocket> sender = so -> {
@Test public void testDomainSocketClient() throws Exception { File sock = TestUtils.tmpFile(".sock"); vertx = Vertx.vertx(); NetClient client = vertx.createNetClient(); client.connect(SocketAddress.domainSocketAddress(sock.getAbsolutePath()), onFailure(err -> { assertEquals(err.getClass(), IllegalArgumentException.class); testComplete(); })); await(); } }
@Test public void testDomainSocketServer() throws Exception { File sock = TestUtils.tmpFile(".sock"); vertx = Vertx.vertx(); NetServer server = vertx.createNetServer(); server.connectHandler(so -> {}); server.listen(SocketAddress.domainSocketAddress(sock.getAbsolutePath()), onFailure(err -> { assertEquals(err.getClass(), IllegalArgumentException.class); testComplete(); })); await(); }
public void setUp() throws Exception { super.setUp(); if (USE_DOMAIN_SOCKETS) { assertTrue("Native transport not enabled", USE_NATIVE_TRANSPORT); tmp = TestUtils.tmpFile(".sock"); testAddress = SocketAddress.domainSocketAddress(tmp.getAbsolutePath()); } else { testAddress = SocketAddress.inetSocketAddress(1234, "localhost"); } client = vertx.createNetClient(new NetClientOptions().setConnectTimeout(1000)); server = vertx.createNetServer(); }
@Test public void testListenDomainSocketAddress() throws Exception { Vertx vx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true)); Assume.assumeTrue("Native transport must be enabled", vx.isNativeTransportEnabled()); NetClient netClient = vx.createNetClient(); HttpServer httpserver = vx.createHttpServer().requestHandler(req -> req.response().end()); File sockFile = TestUtils.tmpFile(".sock"); SocketAddress sockAddress = SocketAddress.domainSocketAddress(sockFile.getAbsolutePath()); httpserver.listen(sockAddress, onSuccess(server -> { netClient.connect(sockAddress, onSuccess(sock -> { sock.handler(buf -> { assertTrue("Response is not an http 200", buf.toString("UTF-8").startsWith("HTTP/1.1 200 OK")); testComplete(); }); sock.write("GET / HTTP/1.1\r\n\r\n"); })); })); try { await(); } finally { vx.close(); } }
@Test public void testHttpServerWithIdleTimeoutSendChunkedFile() throws Exception { int expected = 16 * 1024 * 1024; // We estimate this will take more than 200ms to transfer with a 1ms pause in chunks File sent = TestUtils.tmpFile(".dat", expected); server.close(); server = vertx
@Test public void testSendFilePipelined() throws Exception { int n = 4; waitFor(n); File sent = TestUtils.tmpFile(".dat", 16 * 1024); server.requestHandler( req -> { req.response().sendFile(sent.getAbsolutePath()); }); startServer(); client.close(); client = vertx.createHttpClient(createBaseClientOptions().setPipelining(true).setMaxPoolSize(1)); for (int i = 0;i < n;i++) { client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> { resp.exceptionHandler(this::fail); resp.bodyHandler(body -> { complete(); }); }).exceptionHandler(this::fail).end(); } await(); } }
private void testdleTimeoutSendChunkedFile(boolean idleOnServer) throws Exception { int expected = 16 * 1024 * 1024; // We estimate this will take more than 200ms to transfer with a 1ms pause in chunks File sent = TestUtils.tmpFile(".dat", expected); server.close(); Consumer<NetSocket> sender = so -> {