...
| Code Block |
|---|
String requests=
"GET /context/servlet/info?query=foo HTTP/1.1\r\n"+
"Host: tester\r\n"+
"\r\n"+
"GET /context/hello HTTP/1.1\r\n"+
"Host: tester\r\n"+
"\r\n";
String responses = tester.getResponses(requests);
String expected=
"HTTP/1.1 200 OK\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Content-Length: 21\r\n"+
"\r\n"+
"<h1>Test Servlet</h1>" +
"HTTP/1.1 200 OK\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Content-Length: 22\r\n"+
"\r\n"+
"<h1>Hello Servlet</h1>";
assertEquals(expected,responses);
|
Generated Requests and Parsed Responses
Dealing with raw HTTP can be a bit verbose and difficult to test non protocol aspects. The HttpTester class allows for simple generation of requests and parsing of response (it can also parse requests and generate responses).
| Code Block |
|---|