use of org.webpieces.httpclient.mocks.MockResponseListener in project webpieces by deanhiller.
the class TestCancelStream method testServerCloseSocket.
@Test
public void testServerCloseSocket() throws InterruptedException, ExecutionException, TimeoutException {
XFuture<Void> connect = httpSocket.connect(new InetSocketAddress(8555));
MockResponseListener mockListener = new MockResponseListener();
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/home", false);
mockChannel.addWriteResponse(XFuture.completedFuture(null));
httpSocket.send(req, mockListener);
mockChannel.simulateClose();
Assert.assertTrue(mockListener.isClosed());
}
use of org.webpieces.httpclient.mocks.MockResponseListener in project webpieces by deanhiller.
the class TestCancelStream method testClientCancelNoKeepAlive.
@Test
public void testClientCancelNoKeepAlive() {
XFuture<Void> connect = httpSocket.connect(new InetSocketAddress(8555));
MockResponseListener mockListener = new MockResponseListener();
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/home", false);
mockChannel.addWriteResponse(XFuture.completedFuture(null));
HttpStreamRef ref = httpSocket.send(req, mockListener);
XFuture<Void> cancelDone = ref.cancel("some reason");
Assert.assertTrue(cancelDone.isDone());
// Assert the socket is NOT closed
Assert.assertTrue(mockChannel.isClosed());
}
use of org.webpieces.httpclient.mocks.MockResponseListener in project webpieces by deanhiller.
the class TestCancelStream method testClientCancelWithKeepAlive.
// @Test
// public void testRequestResponseXFutureCancelNoKeepAlive() {
// throw new UnsupportedOperationException("not done yet");
// }
//
// @Test
// public void testRequestResponseXFutureCancelWithKeepAlive() {
// throw new UnsupportedOperationException("not done yet");
// }
@Test
public void testClientCancelWithKeepAlive() {
XFuture<Void> connect = httpSocket.connect(new InetSocketAddress(8555));
MockResponseListener mockListener = new MockResponseListener();
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/home", false);
req.addHeader(new Header(KnownHeaderName.CONNECTION, "keep-alive"));
mockChannel.addWriteResponse(XFuture.completedFuture(null));
HttpStreamRef ref = httpSocket.send(req, mockListener);
XFuture<Void> cancelDone = ref.cancel("some reason");
Assert.assertTrue(cancelDone.isDone());
// Assert the socket is NOT closed
Assert.assertFalse(mockChannel.isClosed());
}
Aggregations