public void run() {
try {
running.incrementAndGet();
IHttpClientEndpoint httpClient = new HttpClient();
for (int i = 0; i < 50; i++) {
FutureResponseHandler hdl = new FutureResponseHandler();
HttpRequestHeader header = new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/");
header.setContentType("text/plain; charset=UTF-8");
BodyDataSink bodyDataSink = httpClient.send(header, hdl);
if (bodyDataSink.getFlushmode() != FlushMode.SYNC) {
System.out.println("flushmode should be sync");
Assert.fail();
}
for (int k = 0; k < 10; k++) {
try {
byte[] data = QAUtil.generateByteArray(128);
bodyDataSink.write(data);
bodyDataSink.flush();
} catch (Exception e) {
System.out.println("error occured by writing chunk " + e.toString());
Assert.fail();
}
}
bodyDataSink.close();
IHttpResponse response = hdl.getResponse();
if (!response.hasBody()) {
System.out.println("response should have a body");
Assert.fail();
}
response.getBlockingBody().readString();
}
httpClient.close();
} catch (Exception e) {
errors.add(e.toString());
}