"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java" between
httpcomponents-client-4.5.6-src.tar.gz and httpcomponents-client-4.5.7-src.tar.gz

About: HttpComponents is an Apache project responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. Java sources.

TestDefaultHttpResponseParser.java  (httpcomponents-client-4.5.6-src):TestDefaultHttpResponseParser.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 58 skipping to change at line 58
public void testResponseParsingWithSomeGarbage() throws Exception { public void testResponseParsingWithSomeGarbage() throws Exception {
final String s = final String s =
"garbage\r\n" + "garbage\r\n" +
"garbage\r\n" + "garbage\r\n" +
"more garbage\r\n" + "more garbage\r\n" +
"HTTP/1.1 200 OK\r\n" + "HTTP/1.1 200 OK\r\n" +
"header1: value1\r\n" + "header1: value1\r\n" +
"header2: value2\r\n" + "header2: value2\r\n" +
"\r\n"; "\r\n";
final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts final SessionInputBuffer inBuffer = new SessionInputBufferMock(s, Consts
.ASCII); .ASCII);
final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponsePa final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponsePa
rser(inbuffer); rser(inBuffer);
final HttpResponse response = parser.parse(); final HttpResponse response = parser.parse();
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion()) ; Assert.assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion()) ;
Assert.assertEquals(200, response.getStatusLine().getStatusCode()); Assert.assertEquals(200, response.getStatusLine().getStatusCode());
final Header[] headers = response.getAllHeaders(); final Header[] headers = response.getAllHeaders();
Assert.assertNotNull(headers); Assert.assertNotNull(headers);
Assert.assertEquals(2, headers.length); Assert.assertEquals(2, headers.length);
Assert.assertEquals("header1", headers[0].getName()); Assert.assertEquals("header1", headers[0].getName());
skipping to change at line 84 skipping to change at line 84
public void testResponseParsingWithTooMuchGarbage() throws Exception { public void testResponseParsingWithTooMuchGarbage() throws Exception {
final String s = final String s =
"garbage\r\n" + "garbage\r\n" +
"garbage\r\n" + "garbage\r\n" +
"more garbage\r\n" + "more garbage\r\n" +
"HTTP/1.1 200 OK\r\n" + "HTTP/1.1 200 OK\r\n" +
"header1: value1\r\n" + "header1: value1\r\n" +
"header2: value2\r\n" + "header2: value2\r\n" +
"\r\n"; "\r\n";
final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts final SessionInputBuffer inBuffer = new SessionInputBufferMock(s, Consts
.ASCII); .ASCII);
final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponsePa final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponsePa
rser(inbuffer) { rser(inBuffer) {
@Override @Override
protected boolean reject(final CharArrayBuffer line, final int count ) { protected boolean reject(final CharArrayBuffer line, final int count ) {
return count >= 2; return count >= 2;
} }
}; };
parser.parse(); parser.parse();
} }
@Test(expected=NoHttpResponseException.class) @Test(expected=NoHttpResponseException.class)
public void testResponseParsingNoResponse() throws Exception { public void testResponseParsingNoResponse() throws Exception {
final SessionInputBuffer inbuffer = new SessionInputBufferMock("", Const final SessionInputBuffer inBuffer = new SessionInputBufferMock("", Const
s.ASCII); s.ASCII);
final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponsePa final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponsePa
rser(inbuffer); rser(inBuffer);
parser.parse(); parser.parse();
} }
@Test(expected=ProtocolException.class) @Test(expected=ProtocolException.class)
public void testResponseParsingOnlyGarbage() throws Exception { public void testResponseParsingOnlyGarbage() throws Exception {
final String s = final String s =
"garbage\r\n" + "garbage\r\n" +
"garbage\r\n" + "garbage\r\n" +
"more garbage\r\n" + "more garbage\r\n" +
"a lot more garbage\r\n"; "a lot more garbage\r\n";
final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts final SessionInputBuffer inBuffer = new SessionInputBufferMock(s, Consts
.ASCII); .ASCII);
final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponsePa final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponsePa
rser(inbuffer); rser(inBuffer);
parser.parse(); parser.parse();
} }
} }
 End of changes. 4 change blocks. 
16 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)