@Test
public void testPlainBodyData() throws Exception {
System.out.println("testPlainBodyData");
IHttpClientEndpoint httpClient = new HttpClient();
IServer server = new HttpServer(new EchoHandler());
ConnectionUtils.start(server);
File file = QAUtil.createTestfile_40k();
RandomAccessFile raf = new RandomAccessFile(file, "r");
FileChannel fc = raf.getChannel();
System.out.println("call");
FutureResponseHandler respHdl = new FutureResponseHandler();
BodyDataSink bodyDataSink = httpClient.send(new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/", "text/plain"), (int) fc.size(), respHdl);
bodyDataSink.transferFrom(fc);
bodyDataSink.close();
fc.close();
raf.close();
IHttpResponse response = respHdl.getResponse();
BlockingBodyDataSource bodyChannel = response.getBlockingBody();
String body = bodyChannel.readString();
System.out.println("closing erver & httpClient");
server.close();
httpClient.close();
if (body.indexOf("Architecture of a Highly Scalable NIO-Based Server") == -1) {
System.out.println("error got:\r\n" + body);
Assert.fail();
}