use of io.vertx.core.net.SocketAddress in project vert.x by eclipse.
the class Http2ClientTest method testReuseConnection.
@Test
public void testReuseConnection() throws Exception {
List<SocketAddress> ports = new ArrayList<>();
server.requestHandler(req -> {
SocketAddress address = req.remoteAddress();
assertNotNull(address);
ports.add(address);
req.response().end();
});
startServer();
CountDownLatch doReq = new CountDownLatch(1);
client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> {
resp.endHandler(v -> {
doReq.countDown();
});
}).exceptionHandler(err -> {
fail();
}).end();
awaitLatch(doReq);
client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> {
resp.endHandler(v -> {
assertEquals(2, ports.size());
assertEquals(ports.get(0), ports.get(1));
testComplete();
});
}).exceptionHandler(err -> {
fail();
}).end();
await();
}
use of io.vertx.core.net.SocketAddress in project java-chassis by ServiceComb.
the class TestVertxToServletMockRequest method testGetLocalAddr.
@Test
public void testGetLocalAddr() {
try {
init();
HttpServerRequest httpServerRequest = Mockito.mock(HttpServerRequest.class);
Deencapsulation.setField(instance, "vertxRequest", httpServerRequest);
SocketAddress socketAddress = Mockito.mock(SocketAddress.class);
Mockito.when(httpServerRequest.localAddress()).thenReturn(socketAddress);
Mockito.when(socketAddress.host()).thenReturn("localhost");
Assert.assertEquals("localhost", instance.getLocalAddr());
} catch (Exception e) {
Assert.assertNotNull(e);
} catch (Error e) {
Assert.assertNotNull(e);
}
}
use of io.vertx.core.net.SocketAddress in project java-chassis by ServiceComb.
the class TestVertxToServletMockRequest method testGetRemoteHost.
@Test
public void testGetRemoteHost() {
try {
init();
HttpServerRequest httpServerRequest = Mockito.mock(HttpServerRequest.class);
Deencapsulation.setField(instance, "vertxRequest", httpServerRequest);
SocketAddress socketAddress = Mockito.mock(SocketAddress.class);
Mockito.when(httpServerRequest.remoteAddress()).thenReturn(socketAddress);
Mockito.when(socketAddress.host()).thenReturn("localhost");
Assert.assertEquals("localhost", instance.getRemoteHost());
} catch (Exception e) {
Assert.assertNotNull(e);
} catch (Error e) {
Assert.assertNotNull(e);
}
}
use of io.vertx.core.net.SocketAddress in project java-chassis by ServiceComb.
the class TestVertxToServletMockRequest method testGetLocalPort.
@Test
public void testGetLocalPort() {
try {
init();
HttpServerRequest httpServerRequest = Mockito.mock(HttpServerRequest.class);
Deencapsulation.setField(instance, "vertxRequest", httpServerRequest);
SocketAddress socketAddress = Mockito.mock(SocketAddress.class);
Mockito.when(httpServerRequest.localAddress()).thenReturn(socketAddress);
Mockito.when(socketAddress.port()).thenReturn(8080);
instance.getLocalPort();
} catch (Exception e) {
Assert.assertNotNull(e);
} catch (Error e) {
Assert.assertNotNull(e);
}
}
use of io.vertx.core.net.SocketAddress in project java-chassis by ServiceComb.
the class TestVertxToServletMockRequest method testGetRemotePort.
@Test
public void testGetRemotePort() {
try {
init();
HttpServerRequest httpServerRequest = Mockito.mock(HttpServerRequest.class);
Deencapsulation.setField(instance, "vertxRequest", httpServerRequest);
SocketAddress socketAddress = Mockito.mock(SocketAddress.class);
Mockito.when(httpServerRequest.remoteAddress()).thenReturn(socketAddress);
Mockito.when(socketAddress.port()).thenReturn(8080);
Assert.assertEquals(8080, instance.getRemotePort());
} catch (Exception e) {
Assert.assertNotNull(e);
} catch (Error e) {
Assert.assertNotNull(e);
}
}
Aggregations