Context ctxSub = new Context(ctxRoot, "/ctx1");
ctxRoot.addHandler("/ctx1/uuu/*", new DoNothingHandler());
ctxSub.addHandler("/test/*", new CompareParametersHandler());
Server server = new HttpServer(ctxRoot);
ConnectionUtils.start(server);
GetRequest reqXSocket = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx0/ctx1/test/test2");
reqXSocket.setHeader("Host", "localhost");
reqXSocket.setHeader("User-Agent", "me");
GetRequest reqJetty = new GetRequest("http://localhost:" + jettyServer.getConnectors()[0].getLocalPort() + "/ctx0/ctx1/test/test2");
reqJetty.setHeader("Host", "localhost");
reqJetty.setHeader("User-Agent", "me");
IBlockingConnection conXSocket = new BlockingConnection("localhost", server.getLocalPort());
IBlockingConnection conJetty = new BlockingConnection("localhost", jettyServer.getConnectors()[0].getLocalPort());
conXSocket.write(reqXSocket.toString());
String header = conXSocket.readStringByDelimiter("\r\n\r\n");
int contentLength = QAUtil.readContentLength(header);
String bodyXSocket = conXSocket.readStringByLength(contentLength);
conJetty.write(reqJetty.toString());
String headerJetty = conJetty.readStringByDelimiter("\r\n\r\n");
int contentLengthJetty = QAUtil.readContentLength(headerJetty);
String bodyJetty = conJetty.readStringByLength(contentLengthJetty);
Assert.assertEquals(bodyXSocket, bodyJetty);
conJetty.close();
conXSocket.close();
jettyServer.stop();
server.close();
}