"Fossies" - the Fresh Open Source Software Archive  

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

TestHttpClientUtils.java  (httpcomponents-client-4.5.6-src):TestHttpClientUtils.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 69 skipping to change at line 69
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(Boolean.FALSE); Mockito.when(entity.isStreaming()).thenReturn(Boolean.FALSE);
HttpClientUtils.closeQuietly(response); HttpClientUtils.closeQuietly(response);
Mockito.verify(entity, Mockito.never()).getContent(); Mockito.verify(entity, Mockito.never()).getContent();
} }
@Test @Test
public void testCloseQuietlyResponseEntity() throws Exception { public void testCloseQuietlyResponseEntity() throws Exception {
final HttpResponse response = Mockito.mock(HttpResponse.class); final HttpResponse response = Mockito.mock(HttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class); final HttpEntity entity = Mockito.mock(HttpEntity.class);
final InputStream instream = Mockito.mock(InputStream.class); final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE); Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
Mockito.when(entity.getContent()).thenReturn(instream); Mockito.when(entity.getContent()).thenReturn(inStream);
HttpClientUtils.closeQuietly(response); HttpClientUtils.closeQuietly(response);
Mockito.verify(instream).close(); Mockito.verify(inStream).close();
} }
@Test @Test
public void testCloseQuietlyResponseIgnoreIOError() throws Exception { public void testCloseQuietlyResponseIgnoreIOError() throws Exception {
final HttpResponse response = Mockito.mock(HttpResponse.class); final HttpResponse response = Mockito.mock(HttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class); final HttpEntity entity = Mockito.mock(HttpEntity.class);
final InputStream instream = Mockito.mock(InputStream.class); final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.getContent()).thenReturn(instream); Mockito.when(entity.getContent()).thenReturn(inStream);
Mockito.doThrow(new IOException()).when(instream).close(); Mockito.doThrow(new IOException()).when(inStream).close();
HttpClientUtils.closeQuietly(response); HttpClientUtils.closeQuietly(response);
} }
@Test @Test
public void testCloseQuietlyCloseableResponseNull() throws Exception { public void testCloseQuietlyCloseableResponseNull() throws Exception {
final CloseableHttpResponse response = null; final CloseableHttpResponse response = null;
HttpClientUtils.closeQuietly(response); HttpClientUtils.closeQuietly(response);
} }
@Test @Test
skipping to change at line 117 skipping to change at line 117
Mockito.when(entity.isStreaming()).thenReturn(Boolean.FALSE); Mockito.when(entity.isStreaming()).thenReturn(Boolean.FALSE);
HttpClientUtils.closeQuietly(response); HttpClientUtils.closeQuietly(response);
Mockito.verify(entity, Mockito.never()).getContent(); Mockito.verify(entity, Mockito.never()).getContent();
Mockito.verify(response).close(); Mockito.verify(response).close();
} }
@Test @Test
public void testCloseQuietlyCloseableResponseEntity() throws Exception { public void testCloseQuietlyCloseableResponseEntity() throws Exception {
final CloseableHttpResponse response = Mockito.mock(CloseableHttpRespons e.class); final CloseableHttpResponse response = Mockito.mock(CloseableHttpRespons e.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class); final HttpEntity entity = Mockito.mock(HttpEntity.class);
final InputStream instream = Mockito.mock(InputStream.class); final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE); Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
Mockito.when(entity.getContent()).thenReturn(instream); Mockito.when(entity.getContent()).thenReturn(inStream);
HttpClientUtils.closeQuietly(response); HttpClientUtils.closeQuietly(response);
Mockito.verify(instream).close(); Mockito.verify(inStream).close();
Mockito.verify(response).close(); Mockito.verify(response).close();
} }
@Test @Test
public void testCloseQuietlyCloseableResponseIgnoreIOError() throws Exceptio n { public void testCloseQuietlyCloseableResponseIgnoreIOError() throws Exceptio n {
final CloseableHttpResponse response = Mockito.mock(CloseableHttpRespons e.class); final CloseableHttpResponse response = Mockito.mock(CloseableHttpRespons e.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class); final HttpEntity entity = Mockito.mock(HttpEntity.class);
final InputStream instream = Mockito.mock(InputStream.class); final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.getContent()).thenReturn(instream); Mockito.when(entity.getContent()).thenReturn(inStream);
Mockito.doThrow(new IOException()).when(instream).close(); Mockito.doThrow(new IOException()).when(inStream).close();
HttpClientUtils.closeQuietly(response); HttpClientUtils.closeQuietly(response);
} }
@Test @Test
public void testCloseQuietlyHttpClientNull() throws Exception { public void testCloseQuietlyHttpClientNull() throws Exception {
final CloseableHttpClient httpclient = null; final CloseableHttpClient httpclient = null;
HttpClientUtils.closeQuietly(httpclient); HttpClientUtils.closeQuietly(httpclient);
} }
@Test @Test
 End of changes. 10 change blocks. 
12 lines changed or deleted 12 lines changed or added

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