Fix some obvious boxing in test classes

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1406884 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2012-11-08 01:32:46 +00:00
parent 5a436e52c3
commit b28ec1bf3d
4 changed files with 20 additions and 20 deletions

View File

@ -56,7 +56,7 @@ public class TestHttpClientUtils {
HttpResponse response = Mockito.mock(HttpResponse.class); HttpResponse response = Mockito.mock(HttpResponse.class);
HttpEntity entity = Mockito.mock(HttpEntity.class); HttpEntity entity = Mockito.mock(HttpEntity.class);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(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();
} }
@ -67,7 +67,7 @@ public class TestHttpClientUtils {
HttpEntity entity = Mockito.mock(HttpEntity.class); HttpEntity entity = Mockito.mock(HttpEntity.class);
InputStream instream = Mockito.mock(InputStream.class); InputStream instream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(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();
@ -103,7 +103,7 @@ public class TestHttpClientUtils {
CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class); CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
HttpEntity entity = Mockito.mock(HttpEntity.class); HttpEntity entity = Mockito.mock(HttpEntity.class);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(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();
@ -115,7 +115,7 @@ public class TestHttpClientUtils {
HttpEntity entity = Mockito.mock(HttpEntity.class); HttpEntity entity = Mockito.mock(HttpEntity.class);
InputStream instream = Mockito.mock(InputStream.class); InputStream instream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity); Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(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();

View File

@ -49,7 +49,7 @@ public class TestEofSensorInputStream {
@Test @Test
public void testClose() throws Exception { public void testClose() throws Exception {
Mockito.when(eofwatcher.streamClosed(Mockito.<InputStream>any())).thenReturn(true); Mockito.when(eofwatcher.streamClosed(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
eofstream.close(); eofstream.close();
@ -79,7 +79,7 @@ public class TestEofSensorInputStream {
@Test @Test
public void testReleaseConnection() throws Exception { public void testReleaseConnection() throws Exception {
Mockito.when(eofwatcher.streamClosed(Mockito.<InputStream>any())).thenReturn(true); Mockito.when(eofwatcher.streamClosed(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
eofstream.releaseConnection(); eofstream.releaseConnection();
@ -94,7 +94,7 @@ public class TestEofSensorInputStream {
@Test @Test
public void testAbortConnection() throws Exception { public void testAbortConnection() throws Exception {
Mockito.when(eofwatcher.streamAbort(Mockito.<InputStream>any())).thenReturn(true); Mockito.when(eofwatcher.streamAbort(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
eofstream.abortConnection(); eofstream.abortConnection();
@ -124,7 +124,7 @@ public class TestEofSensorInputStream {
@Test @Test
public void testRead() throws Exception { public void testRead() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(true); Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
Mockito.when(instream.read()).thenReturn(0, -1); Mockito.when(instream.read()).thenReturn(0, -1);
Assert.assertEquals(0, eofstream.read()); Assert.assertEquals(0, eofstream.read());
@ -147,7 +147,7 @@ public class TestEofSensorInputStream {
@Test @Test
public void testReadIOError() throws Exception { public void testReadIOError() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(true); Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
Mockito.when(instream.read()).thenThrow(new IOException()); Mockito.when(instream.read()).thenThrow(new IOException());
try { try {
@ -163,7 +163,7 @@ public class TestEofSensorInputStream {
@Test @Test
public void testReadByteArray() throws Exception { public void testReadByteArray() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(true); Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt())) Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
.thenReturn(1, -1); .thenReturn(1, -1);
@ -189,7 +189,7 @@ public class TestEofSensorInputStream {
@Test @Test
public void testReadByteArrayIOError() throws Exception { public void testReadByteArrayIOError() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(true); Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt())) Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
.thenThrow(new IOException()); .thenThrow(new IOException());
@ -207,7 +207,7 @@ public class TestEofSensorInputStream {
@Test @Test
public void testReadAfterAbort() throws Exception { public void testReadAfterAbort() throws Exception {
Mockito.when(eofwatcher.streamAbort(Mockito.<InputStream>any())).thenReturn(true); Mockito.when(eofwatcher.streamAbort(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
eofstream.abortConnection(); eofstream.abortConnection();

View File

@ -84,7 +84,7 @@ public class TestHttpAuthenticator {
this.authState = new AuthState(); this.authState = new AuthState();
this.authScheme = Mockito.mock(ContextAwareAuthScheme.class); this.authScheme = Mockito.mock(ContextAwareAuthScheme.class);
Mockito.when(this.authScheme.getSchemeName()).thenReturn("Basic"); Mockito.when(this.authScheme.getSchemeName()).thenReturn("Basic");
Mockito.when(this.authScheme.isComplete()).thenReturn(true); Mockito.when(this.authScheme.isComplete()).thenReturn(Boolean.TRUE);
this.context = new BasicHttpContext(); this.context = new BasicHttpContext();
this.host = new HttpHost("localhost", 80); this.host = new HttpHost("localhost", 80);
this.proxy = new HttpHost("localhost", 8888); this.proxy = new HttpHost("localhost", 8888);

View File

@ -97,7 +97,7 @@ public class TestHttpClientConnectionManagerBase {
CPoolEntry entry = new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn, CPoolEntry entry = new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
-1, TimeUnit.MILLISECONDS); -1, TimeUnit.MILLISECONDS);
Mockito.when(future.isCancelled()).thenReturn(false); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry); Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
Mockito.when(pool.lease(route, null, null)).thenReturn(future); Mockito.when(pool.lease(route, null, null)).thenReturn(future);
@ -120,7 +120,7 @@ public class TestHttpClientConnectionManagerBase {
CPoolEntry entry = new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn, CPoolEntry entry = new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
-1, TimeUnit.MILLISECONDS); -1, TimeUnit.MILLISECONDS);
Mockito.when(future.isCancelled()).thenReturn(true); Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE);
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry); Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
Mockito.when(pool.lease(route, null, null)).thenReturn(future); Mockito.when(pool.lease(route, null, null)).thenReturn(future);
@ -133,7 +133,7 @@ public class TestHttpClientConnectionManagerBase {
HttpHost target = new HttpHost("localhost"); HttpHost target = new HttpHost("localhost");
HttpRoute route = new HttpRoute(target); HttpRoute route = new HttpRoute(target);
Mockito.when(future.isCancelled()).thenReturn(true); Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE);
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenThrow(new TimeoutException()); Mockito.when(future.get(1, TimeUnit.SECONDS)).thenThrow(new TimeoutException());
Mockito.when(pool.lease(route, null, null)).thenReturn(future); Mockito.when(pool.lease(route, null, null)).thenReturn(future);
@ -149,10 +149,10 @@ public class TestHttpClientConnectionManagerBase {
CPoolEntry entry = Mockito.spy(new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn, CPoolEntry entry = Mockito.spy(new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
-1, TimeUnit.MILLISECONDS)); -1, TimeUnit.MILLISECONDS));
Mockito.when(future.isCancelled()).thenReturn(false); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry); Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
Mockito.when(pool.lease(route, null, null)).thenReturn(future); Mockito.when(pool.lease(route, null, null)).thenReturn(future);
Mockito.when(conn.isOpen()).thenReturn(true); Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
ConnectionRequest connRequest1 = mgr.requestConnection(route, null); ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS); HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
@ -174,10 +174,10 @@ public class TestHttpClientConnectionManagerBase {
CPoolEntry entry = Mockito.spy(new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn, CPoolEntry entry = Mockito.spy(new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
-1, TimeUnit.MILLISECONDS)); -1, TimeUnit.MILLISECONDS));
Mockito.when(future.isCancelled()).thenReturn(false); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry); Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
Mockito.when(pool.lease(route, null, null)).thenReturn(future); Mockito.when(pool.lease(route, null, null)).thenReturn(future);
Mockito.when(conn.isOpen()).thenReturn(false); Mockito.when(conn.isOpen()).thenReturn(Boolean.FALSE);
ConnectionRequest connRequest1 = mgr.requestConnection(route, null); ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS); HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);