"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.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.

TestBasicResponseHandler.java  (httpcomponents-client-4.5.6-src):TestBasicResponseHandler.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 64 skipping to change at line 64
Mockito.when(response.getStatusLine()).thenReturn(sl); Mockito.when(response.getStatusLine()).thenReturn(sl);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
final BasicResponseHandler handler = new BasicResponseHandler(); final BasicResponseHandler handler = new BasicResponseHandler();
final String s = handler.handleResponse(response); final String s = handler.handleResponse(response);
Assert.assertEquals("stuff", s); Assert.assertEquals("stuff", s);
} }
@Test @Test
public void testUnsuccessfulResponse() throws Exception { public void testUnsuccessfulResponse() throws Exception {
final InputStream instream = Mockito.mock(InputStream.class); final InputStream inStream = Mockito.mock(InputStream.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class); final HttpEntity entity = Mockito.mock(HttpEntity.class);
Mockito.when(entity.isStreaming()).thenReturn(true); Mockito.when(entity.isStreaming()).thenReturn(true);
Mockito.when(entity.getContent()).thenReturn(instream); Mockito.when(entity.getContent()).thenReturn(inStream);
final StatusLine sl = new BasicStatusLine(HttpVersion.HTTP_1_1, 404, "No t Found"); final StatusLine sl = new BasicStatusLine(HttpVersion.HTTP_1_1, 404, "No t Found");
final HttpResponse response = Mockito.mock(HttpResponse.class); final HttpResponse response = Mockito.mock(HttpResponse.class);
Mockito.when(response.getStatusLine()).thenReturn(sl); Mockito.when(response.getStatusLine()).thenReturn(sl);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
final BasicResponseHandler handler = new BasicResponseHandler(); final BasicResponseHandler handler = new BasicResponseHandler();
try { try {
handler.handleResponse(response); handler.handleResponse(response);
Assert.fail("HttpResponseException expected"); Assert.fail("HttpResponseException expected");
} catch (final HttpResponseException ex) { } catch (final HttpResponseException ex) {
Assert.assertEquals(404, ex.getStatusCode()); Assert.assertEquals(404, ex.getStatusCode());
Assert.assertEquals("Not Found", ex.getMessage()); Assert.assertEquals("status code: 404, reason phrase: Not Found", ex .getMessage());
} }
Mockito.verify(entity).getContent(); Mockito.verify(entity).getContent();
Mockito.verify(instream).close(); Mockito.verify(inStream).close();
} }
} }
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added

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