hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject [1/2] httpcomponents-core git commit: Access static methods with the class that defines them, not a subclass.
Date Sat, 02 Sep 2017 20:05:12 GMT
Repository: httpcomponents-core
Updated Branches:
  refs/heads/4.4.x 442d26066 -> 4e99c599b


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/4e99c599/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
index da91c87..235915b 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
@@ -46,7 +46,7 @@ import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.message.BasicHttpResponse;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.ContentEncoder;
-import org.apache.http.nio.NHttpClientConnection;
+import org.apache.http.nio.NHttpConnection;
 import org.apache.http.nio.NHttpServerConnection;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.nio.protocol.HttpAsyncService.Incoming;
@@ -65,6 +65,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.ArgumentMatcher;
+import org.mockito.Matchers;
 import org.mockito.Mockito;
 
 public class TestHttpAsyncService {
@@ -212,7 +213,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         Mockito.doThrow(new RuntimeException()).when(this.httpProcessor).process(
-                Mockito.any(HttpResponse.class), Mockito.any(HttpContext.class));
+                Matchers.any(HttpResponse.class), Matchers.any(HttpContext.class));
         final HttpException httpex = new HttpException();
         try {
             this.protocolHandler.exception(this.conn, httpex);
@@ -245,7 +246,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         Mockito.doThrow(new IOException()).when(this.httpProcessor).process(
-                Mockito.any(HttpResponse.class), Mockito.any(HttpContext.class));
+                Matchers.any(HttpResponse.class), Matchers.any(HttpContext.class));
         final HttpException httpex = new HttpException();
 
         this.protocolHandler.exception(this.conn, httpex);
@@ -295,7 +296,7 @@ public class TestHttpAsyncService {
         final HttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
         Mockito.when(this.requestConsumer.getException()).thenReturn(null);
         final Object data = new Object();
         Mockito.when(this.requestConsumer.getResult()).thenReturn(data);
@@ -309,7 +310,7 @@ public class TestHttpAsyncService {
         Assert.assertNull(incoming);
 
         final ArgumentCaptor<HttpContext> argumentCaptor = ArgumentCaptor.forClass(HttpContext.class);
-        Mockito.verify(this.httpProcessor).process(Mockito.eq(request), argumentCaptor.capture());
+        Mockito.verify(this.httpProcessor).process(Matchers.eq(request), argumentCaptor.capture());
         final HttpContext exchangeContext = argumentCaptor.getValue();
         Assert.assertNotNull(exchangeContext);
 
@@ -338,7 +339,7 @@ public class TestHttpAsyncService {
         final HttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
         Mockito.when(this.requestConsumer.getException()).thenReturn(null);
         final Object data = new Object();
         Mockito.when(this.requestConsumer.getResult()).thenReturn(data);
@@ -352,11 +353,11 @@ public class TestHttpAsyncService {
         Assert.assertNull(incoming);
 
         Mockito.verify(this.requestConsumer).requestReceived(request);
-        Mockito.verify(this.requestConsumer).requestCompleted(Mockito.<HttpContext>any());
+        Mockito.verify(this.requestConsumer).requestCompleted(Matchers.<HttpContext>any());
         Mockito.verify(this.requestHandler, Mockito.never()).handle(
-                Mockito.any(),
-                Mockito.any(HttpAsyncExchange.class),
-                Mockito.any(HttpContext.class));
+                Matchers.any(),
+                Matchers.any(HttpAsyncExchange.class),
+                Matchers.any(HttpContext.class));
 
         Assert.assertFalse(state.getPipeline().isEmpty());
         final PipelineEntry entry = state.getPipeline().remove();
@@ -383,7 +384,7 @@ public class TestHttpAsyncService {
         final HttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
         Mockito.when(this.requestConsumer.getException()).thenReturn(null);
         final Object data = new Object();
         Mockito.when(this.requestConsumer.getResult()).thenReturn(data);
@@ -397,11 +398,11 @@ public class TestHttpAsyncService {
         Assert.assertNull(incoming);
 
         Mockito.verify(this.requestConsumer).requestReceived(request);
-        Mockito.verify(this.requestConsumer).requestCompleted(Mockito.<HttpContext>any());
+        Mockito.verify(this.requestConsumer).requestCompleted(Matchers.<HttpContext>any());
         Mockito.verify(this.requestHandler, Mockito.never()).handle(
-                Mockito.any(),
-                Mockito.any(HttpAsyncExchange.class),
-                Mockito.any(HttpContext.class));
+                Matchers.any(),
+                Matchers.any(HttpAsyncExchange.class),
+                Matchers.any(HttpContext.class));
 
         Assert.assertFalse(state.getPipeline().isEmpty());
         final PipelineEntry entry1 = state.getPipeline().remove();
@@ -421,7 +422,7 @@ public class TestHttpAsyncService {
         request.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
 
         this.protocolHandler.requestReceived(this.conn);
 
@@ -443,7 +444,7 @@ public class TestHttpAsyncService {
                 HttpVersion.HTTP_1_1);
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
 
         this.protocolHandler.requestReceived(this.conn);
 
@@ -477,7 +478,7 @@ public class TestHttpAsyncService {
         request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
 
         this.protocolHandler.requestReceived(this.conn);
 
@@ -499,7 +500,7 @@ public class TestHttpAsyncService {
         Mockito.verify(this.httpProcessor).process(request, exchangeContext);
         Mockito.verify(this.requestConsumer).requestReceived(request);
         Mockito.verify(this.conn, Mockito.never()).suspendInput();
-        Mockito.verify(this.conn).submitResponse(Mockito.argThat(new ArgumentMatcher<HttpResponse>()
{
+        Mockito.verify(this.conn).submitResponse(Matchers.argThat(new ArgumentMatcher<HttpResponse>()
{
 
             @Override
             public boolean matches(final Object argument) {
@@ -525,7 +526,7 @@ public class TestHttpAsyncService {
         request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
 
         this.protocolHandler.requestReceived(this.conn);
 
@@ -548,8 +549,8 @@ public class TestHttpAsyncService {
         Mockito.verify(this.requestConsumer).requestReceived(request);
         Mockito.verify(this.conn).suspendInput();
         Mockito.verify(expectationVerifier).verify(
-                Mockito.any(HttpAsyncExchange.class),
-                Mockito.eq(exchangeContext));
+                Matchers.any(HttpAsyncExchange.class),
+                Matchers.eq(exchangeContext));
     }
 
     @Test
@@ -609,7 +610,7 @@ public class TestHttpAsyncService {
 
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
 
         this.protocolHandler.requestReceived(this.conn);
 
@@ -641,7 +642,7 @@ public class TestHttpAsyncService {
 
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
 
         this.protocolHandler.requestReceived(this.conn);
 
@@ -669,7 +670,7 @@ public class TestHttpAsyncService {
         Mockito.when(this.conn.getContext()).thenReturn(this.connContext);
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
-                Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
+                Matchers.eq(request), Matchers.any(HttpContext.class))).thenReturn(this.requestConsumer);
         Mockito.when(((SessionBufferStatus) this.conn).hasBufferedInput()).thenReturn(Boolean.TRUE);
 
         this.protocolHandler.requestReceived(this.conn);
@@ -1016,7 +1017,7 @@ public class TestHttpAsyncService {
         Assert.assertEquals(MessageState.READY, state.getResponseState());
 
         Mockito.verify(this.conn).requestInput();
-        Mockito.verify(this.conn).submitResponse(Mockito.argThat(new ArgumentMatcher<HttpResponse>()
{
+        Mockito.verify(this.conn).submitResponse(Matchers.argThat(new ArgumentMatcher<HttpResponse>()
{
 
             @Override
             public boolean matches(final Object argument) {
@@ -1095,8 +1096,8 @@ public class TestHttpAsyncService {
         Assert.assertNull(state.getOutgoing());
 
         final ArgumentCaptor<HttpAsyncExchange> argCaptor = ArgumentCaptor.forClass(HttpAsyncExchange.class);
-        Mockito.verify(this.requestHandler).handle(Mockito.same(request),
-                argCaptor.capture(), Mockito.same(exchangeContext));
+        Mockito.verify(this.requestHandler).handle(Matchers.same(request),
+                argCaptor.capture(), Matchers.same(exchangeContext));
         final HttpAsyncExchange exchange = argCaptor.getValue();
 
         Assert.assertNotNull(exchange);
@@ -1130,9 +1131,9 @@ public class TestHttpAsyncService {
         Assert.assertNotNull(response);
         Assert.assertEquals(500, response.getStatusLine().getStatusCode());
 
-        Mockito.verify(this.requestHandler, Mockito.never()).handle(Mockito.<HttpRequest>any(),
-                Mockito.<HttpAsyncExchange>any(), Mockito.<HttpContext>any());
-        Mockito.verify(this.conn).submitResponse(Mockito.same(response));
+        Mockito.verify(this.requestHandler, Mockito.never()).handle(Matchers.<HttpRequest>any(),
+                Matchers.<HttpAsyncExchange>any(), Matchers.<HttpContext>any());
+        Mockito.verify(this.conn).submitResponse(Matchers.same(response));
     }
 
     @Test(expected=HttpException.class)
@@ -1311,7 +1312,7 @@ public class TestHttpAsyncService {
 
         this.protocolHandler.endOfInput(this.conn);
 
-        Mockito.verify(this.conn, Mockito.never()).setSocketTimeout(Mockito.anyInt());
+        Mockito.verify(this.conn, Mockito.never()).setSocketTimeout(Matchers.anyInt());
         Mockito.verify(this.conn).close();
     }
 
@@ -1330,19 +1331,19 @@ public class TestHttpAsyncService {
     public void testTimeoutActiveConnection() throws Exception {
         final State state = new State();
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.conn.getStatus()).thenReturn(NHttpClientConnection.ACTIVE, NHttpClientConnection.CLOSED);
+        Mockito.when(this.conn.getStatus()).thenReturn(NHttpConnection.ACTIVE, NHttpConnection.CLOSED);
 
         this.protocolHandler.timeout(this.conn);
 
         Mockito.verify(this.conn).close();
-        Mockito.verify(this.conn, Mockito.never()).setSocketTimeout(Mockito.anyInt());
+        Mockito.verify(this.conn, Mockito.never()).setSocketTimeout(Matchers.anyInt());
     }
 
     @Test
     public void testTimeoutActiveConnectionBufferedData() throws Exception {
         final State state = new State();
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.conn.getStatus()).thenReturn(NHttpClientConnection.ACTIVE, NHttpClientConnection.CLOSING);
+        Mockito.when(this.conn.getStatus()).thenReturn(NHttpConnection.ACTIVE, NHttpConnection.CLOSING);
 
         this.protocolHandler.timeout(this.conn);
 
@@ -1363,14 +1364,14 @@ public class TestHttpAsyncService {
                 request, response, this.responseProducer, exchangeContext);
         state.setOutgoing(outgoing);
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
-        Mockito.when(this.conn.getStatus()).thenReturn(NHttpClientConnection.CLOSING);
+        Mockito.when(this.conn.getStatus()).thenReturn(NHttpConnection.CLOSING);
 
         this.protocolHandler.timeout(this.conn);
 
         Mockito.verify(this.conn).shutdown();
-        Mockito.verify(this.requestConsumer).failed(Mockito.any(SocketTimeoutException.class));
+        Mockito.verify(this.requestConsumer).failed(Matchers.any(SocketTimeoutException.class));
         Mockito.verify(this.requestConsumer).close();
-        Mockito.verify(this.responseProducer).failed(Mockito.any(SocketTimeoutException.class));
+        Mockito.verify(this.responseProducer).failed(Matchers.any(SocketTimeoutException.class));
         Mockito.verify(this.responseProducer).close();
     }
 


Mime
View raw message