RequestHandler rh = new RequestHandler();
IServer server = new HttpServer(rh);
server.start();
IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
con.write("GET /picture/?21,32 HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"User-Agent: me\r\n" +
"\r\n");
String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
int contentLength = QAUtil.readContentLength(header);
String body = con.readStringByLength(contentLength);
Assert.assertTrue(header.indexOf("200") != -1);
Assert.assertEquals("OK", body);
IHttpRequest request = rh.getRequest();
Assert.assertEquals("21,32", request.getQueryString());
Assert.assertEquals("localhost", request.getHost());
Assert.assertEquals("me", request.getUserAgent());
Assert.assertEquals(0, request.getParameterNameSet().size());
request.setParameter("test1", "value1");
Assert.assertEquals("21,32", request.getQueryString());
Assert.assertEquals("value1", request.getParameter("test1"));
con.close();
server.close();
}