}
}
public void testSLParseSuccess() throws Exception {
//typical status line
StatusLine statusLine = BasicLineParser.parseStatusLine
("HTTP/1.1 200 OK", null);
assertEquals("HTTP/1.1 200 OK", statusLine.toString());
assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
assertEquals(200, statusLine.getStatusCode());
assertEquals("OK", statusLine.getReasonPhrase());
//status line with multi word reason phrase
statusLine = BasicLineParser.parseStatusLine
("HTTP/1.1 404 Not Found", null);
assertEquals(404, statusLine.getStatusCode());
assertEquals("Not Found", statusLine.getReasonPhrase());
//reason phrase can be anyting
statusLine = BasicLineParser.parseStatusLine
("HTTP/1.1 404 Non Trouve", null);
assertEquals("Non Trouve", statusLine.getReasonPhrase());
//its ok to end with a \n\r
statusLine = BasicLineParser.parseStatusLine
("HTTP/1.1 404 Not Found\r\n", null);
assertEquals("Not Found", statusLine.getReasonPhrase());
//this is valid according to the Status-Line BNF
statusLine = BasicLineParser.parseStatusLine
("HTTP/1.1 200 ", null);
assertEquals(200, statusLine.getStatusCode());
assertEquals("", statusLine.getReasonPhrase());
//this is not strictly valid, but is lenient
statusLine = BasicLineParser.parseStatusLine
("HTTP/1.1 200", null);
assertEquals(200, statusLine.getStatusCode());
assertEquals("", statusLine.getReasonPhrase());
//this is not strictly valid, but is lenient
statusLine = BasicLineParser.parseStatusLine
("HTTP/1.1 200 OK", null);
assertEquals(200, statusLine.getStatusCode());
assertEquals("OK", statusLine.getReasonPhrase());
//this is not strictly valid, but is lenient
statusLine = BasicLineParser.parseStatusLine
("\rHTTP/1.1 200 OK", null);
assertEquals(200, statusLine.getStatusCode());
assertEquals("OK", statusLine.getReasonPhrase());
assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
//this is not strictly valid, but is lenient
statusLine = BasicLineParser.parseStatusLine
(" HTTP/1.1 200 OK", null);
assertEquals(200, statusLine.getStatusCode());
assertEquals("OK", statusLine.getReasonPhrase());
assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
}