final FutureResponseHandler respHdl = new FutureResponseHandler();
final BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + container.getLocalPort() + "/test"), respHdl);
dataSink.setFlushmode(FlushMode.ASYNC);
IWriteCompletionHandler completionHandler1 = new IWriteCompletionHandler() {
public void onWritten(int written) throws IOException {
try {
IHttpResponse response = respHdl.getResponse();
Assert.assertEquals(200, response.getStatus());
final BodyDataSource dataSource = response.getBody();
Assert.assertEquals("test", dataSource.readStringByLength(4));
IWriteCompletionHandler completionHandler2 = new IWriteCompletionHandler() {
public void onWritten(int written) throws IOException {
Assert.assertEquals("12345", dataSource.readStringByLength(5));
IWriteCompletionHandler completionHandler3 = new IWriteCompletionHandler() {
public void onWritten(int written) throws IOException {
Assert.assertEquals("789", dataSource.readStringByLength(3));
dataSink.close();
}