} catch (IllegalArgumentException e) { /* expected */ }
}
public void testParseSuccess() throws Exception {
//typical status line
StatusLine statusLine = BasicStatusLine.parse("HTTP/1.1 200 OK");
assertEquals("HTTP/1.1 200 OK", statusLine.toString());
assertEquals(HttpVersion.HTTP_1_1, statusLine.getHttpVersion());
assertEquals(200, statusLine.getStatusCode());
assertEquals("OK", statusLine.getReasonPhrase());
//status line with multi word reason phrase
statusLine = BasicStatusLine.parse("HTTP/1.1 404 Not Found");
assertEquals(404, statusLine.getStatusCode());
assertEquals("Not Found", statusLine.getReasonPhrase());
//reason phrase can be anyting
statusLine = BasicStatusLine.parse("HTTP/1.1 404 Non Trouve");
assertEquals("Non Trouve", statusLine.getReasonPhrase());
//its ok to end with a \n\r
statusLine = BasicStatusLine.parse("HTTP/1.1 404 Not Found\r\n");
assertEquals("Not Found", statusLine.getReasonPhrase());
//this is valid according to the Status-Line BNF
statusLine = BasicStatusLine.parse("HTTP/1.1 200 ");
assertEquals(200, statusLine.getStatusCode());
assertEquals("", statusLine.getReasonPhrase());
//this is not strictly valid, but is lienent
statusLine = BasicStatusLine.parse("HTTP/1.1 200");
assertEquals(200, statusLine.getStatusCode());
assertEquals("", statusLine.getReasonPhrase());
//this is not strictly valid, but is lienent
statusLine = BasicStatusLine.parse("HTTP/1.1 200 OK");
assertEquals(200, statusLine.getStatusCode());
assertEquals("OK", statusLine.getReasonPhrase());
//this is not strictly valid, but is lienent
statusLine = BasicStatusLine.parse("\rHTTP/1.1 200 OK");
assertEquals(200, statusLine.getStatusCode());
assertEquals("OK", statusLine.getReasonPhrase());
assertEquals(HttpVersion.HTTP_1_1, statusLine.getHttpVersion());
//this is not strictly valid, but is lienent
statusLine = BasicStatusLine.parse(" HTTP/1.1 200 OK");
assertEquals(200, statusLine.getStatusCode());
assertEquals("OK", statusLine.getReasonPhrase());
assertEquals(HttpVersion.HTTP_1_1, statusLine.getHttpVersion());
}