use of org.asynchttpclient.request.body.generator.InputStreamBodyGenerator in project async-http-client by AsyncHttpClient.
the class SimpleAsyncHttpClientTest method byteArrayOutputStreamBodyConsumerTest.
@Test(groups = "standalone")
public void byteArrayOutputStreamBodyConsumerTest() throws Exception {
try (SimpleAsyncHttpClient client = //
new SimpleAsyncHttpClient.Builder().setPooledConnectionIdleTimeout(100).setMaxConnections(//
50).setRequestTimeout(//
5 * 60 * 1000).setUrl(//
getTargetUrl()).setHeader("Content-Type", "text/html").build()) {
ByteArrayOutputStream o = new ByteArrayOutputStream(10);
Future<Response> future = client.post(new InputStreamBodyGenerator(new ByteArrayInputStream(MY_MESSAGE.getBytes())), new OutputStreamBodyConsumer(o));
Response response = future.get();
assertEquals(response.getStatusCode(), 200);
assertEquals(o.toString(), MY_MESSAGE);
}
}
Aggregations