baseRequest.setHandled(true);
response.getOutputStream().write(data);
}
});
InputStreamResponseListener listener = new InputStreamResponseListener();
client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
.send(listener);
Response response = listener.get(5, TimeUnit.SECONDS);
Assert.assertNotNull(response);
Assert.assertEquals(200, response.getStatus());
InputStream input = listener.getInputStream();
Assert.assertNotNull(input);
for (byte b : data)
{
int read = input.read();
assertTrue(read >= 0);
Assert.assertEquals(b & 0xFF, read);
}
Assert.assertEquals(-1, input.read());
Result result = listener.await(5, TimeUnit.SECONDS);
Assert.assertNotNull(result);
Assert.assertFalse(result.isFailed());
Assert.assertSame(response, result.getResponse());
}