root.addLast(h2);
IServer server = new HttpServer(root);
server.start();
IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
con.write("POST / HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"User-Agent: me\r\n" +
"Content-Length: 4\r\n" +
"\r\n");
QAUtil.sleep(500);
Assert.assertEquals(0, h1.countOnRequestCalled());
Assert.assertEquals(0, h2.countOnRequestCalled());
con.write("1234");
String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
int contentLength = QAUtil.readContentLength(header);
con.readByteBufferByLength(contentLength);
QAUtil.sleep(200);
Assert.assertEquals(1, h1.countOnRequestCalled());
Assert.assertTrue(h1.getOnRequestThreadname().startsWith("xWorker"));
Assert.assertEquals(1, h2.countOnRequestCalled());
Assert.assertTrue(h2.getOnRequestThreadname().startsWith("xWorker"));
con.close();
server.close();
}