use of io.vertx.core.http.HttpClient in project java-chassis by ServiceComb.
the class HttpClientVerticle method createClientPool.
@Override
public HttpClientWithContext createClientPool() {
HttpClientOptions httpClientOptions = (HttpClientOptions) config().getValue(CLIENT_OPTIONS);
HttpClient httpClient = vertx.createHttpClient(httpClientOptions);
return new HttpClientWithContext(httpClient, context);
}
use of io.vertx.core.http.HttpClient in project java-chassis by ServiceComb.
the class TestVertxGetMethod method testVertxGetMethod.
@Test
public void testVertxGetMethod() {
HttpClient client = Mockito.mock(HttpClient.class);
Invocation invocation = Mockito.mock(Invocation.class);
IpPort ipPort = Mockito.mock(IpPort.class);
Mockito.when(ipPort.getPort()).thenReturn(10);
assertEquals(10, ipPort.getPort());
Mockito.when(ipPort.getHostOrIp()).thenReturn("ever");
assertEquals("ever", ipPort.getHostOrIp());
RestOperationMeta operation = Mockito.mock(RestOperationMeta.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
HttpClientRequest obj = VertxGetMethod.INSTANCE.createRequest(client, invocation, ipPort, "good", operation, asyncResp);
Assert.assertNull(obj);
}
use of io.vertx.core.http.HttpClient in project java-chassis by ServiceComb.
the class TestVertxPostMethod method testVertxPostMethod.
@Test
public void testVertxPostMethod() {
Invocation invocation = Mockito.mock(Invocation.class);
HttpClient client = Mockito.mock(HttpClient.class);
IpPort ipPort = Mockito.mock(IpPort.class);
RestOperationMeta operation = Mockito.mock(RestOperationMeta.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
Mockito.when(ipPort.getPort()).thenReturn(23);
assertEquals(23, ipPort.getPort());
Mockito.when(ipPort.getHostOrIp()).thenReturn("testCall");
assertNotNull("testCall", ipPort.getHostOrIp());
HttpClientRequest obj = VertxPostMethod.INSTANCE.createRequest(client, invocation, ipPort, "test", operation, asyncResp);
Assert.assertNull(obj);
}
use of io.vertx.core.http.HttpClient in project vertx-examples by vert-x3.
the class VertxHttpClientVerticle method start.
@Override
public void start() throws Exception {
HttpClient client = vertx.createHttpClient();
client.getNow("perdu.com", "/", response -> {
response.bodyHandler(buffer -> LOGGER.info(buffer.toString("UTF-8")));
});
}
use of io.vertx.core.http.HttpClient in project vertx-examples by vert-x3.
the class JUnitVerticleTest method canGetHello.
@Test
public void canGetHello(TestContext context) {
Async async = context.async();
HttpClient client = vertx.createHttpClient();
client.getNow(port, "localhost", "/", response -> {
response.bodyHandler(body -> {
context.assertEquals("Hello!", body.toString());
client.close();
async.complete();
});
});
}
Aggregations