use of com.tvd12.ezyhttp.client.HttpClientProxy in project ezyhttp by youngmonkeys.
the class HttpClientProxyTest method executeExceptionTest.
@Test
public void executeExceptionTest() throws Exception {
// given
HttpClientProxy sut = newClientProxy();
GetRequest request = new GetRequest().setConnectTimeout(15000).setResponseType(TestResponse.class).setResponseType(StatusCodes.OK, TestResponse.class).setURL("http://127.0.0.1.0:18081/greet");
// when
CountDownLatch countDownLatch = new CountDownLatch(1);
EzyWrap<Exception> wrap = new EzyWrap<>();
sut.execute(request, new RequestCallback<ResponseEntity>() {
@Override
public void onResponse(ResponseEntity response) {
System.out.println(response);
}
@Override
public void onException(Exception e) {
wrap.setValue(e);
countDownLatch.countDown();
}
});
countDownLatch.await();
// then
Asserts.assertEquals(UnknownHostException.class, wrap.getValue().getClass());
sut.close();
sut.stop();
}
use of com.tvd12.ezyhttp.client.HttpClientProxy in project ezyhttp by youngmonkeys.
the class HttpClientProxyTest method postJsonTest.
@Test
public void postJsonTest() throws Exception {
// given
HttpClientProxy sut = newClientProxy();
PostRequest request = new PostRequest().setConnectTimeout(15000).setEntity(new TestRequest("Monkey")).setResponseType(TestResponse.class).setResponseType(StatusCodes.OK, TestResponse.class).setURL("http://127.0.0.1:18081/greet").setURL(new URL("http://127.0.0.1:18081/greet")).setURL(URI.create("http://127.0.0.1:18081/greet"));
// when
TestResponse actual = sut.call(request, 15000);
// then
TestResponse expectation = new TestResponse("Greet Monkey!");
Asserts.assertEquals(expectation, actual);
sut.close();
sut.stop();
}
use of com.tvd12.ezyhttp.client.HttpClientProxy in project ezyhttp by youngmonkeys.
the class HttpClientProxyTest method startTest.
@Test
public void startTest() {
// given
HttpClientProxy proxy = HttpClientProxy.builder().build();
// when
proxy.start();
// then
proxy.stop();
}
Aggregations