RequestBuilder request = client.newRequestBuilder()
.method(Request.METHOD.GET)
.uri(targetUrl + "/suspend")
.transport(transport());
final Socket socket = client.create();
socket.on(new Function<Integer>() {
@Override
public void on(Integer statusCode) {
status.set(statusCode);
socket.close();
latch.countDown();
}
}).on(new Function<IOException>() {
@Override
public void on(IOException t) {
response2.set(t);
ioLatch.countDown();
}
}).open(request.build());
latch.await(5, TimeUnit.SECONDS);
socket.fire("Yo");
ioLatch.await(5, TimeUnit.SECONDS);
assertNotNull(response2.get());
assertEquals(response2.get().getClass(), IOException.class);