hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1793305 [4/5] - in /httpcomponents/httpclient/trunk: ./ httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/ httpclient5-fluent/src/main/java/org...
Date Mon, 01 May 2017 10:47:11 GMT
Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionAutoRelease.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionAutoRelease.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionAutoRelease.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionAutoRelease.java Mon May  1 10:47:09 2017
@@ -30,6 +30,8 @@ package org.apache.hc.client5.http.impl.
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.net.Socket;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
@@ -38,18 +40,18 @@ import org.apache.hc.client5.http.io.Con
 import org.apache.hc.client5.http.io.LeaseRequest;
 import org.apache.hc.client5.http.localserver.LocalServerTestBase;
 import org.apache.hc.client5.http.sync.methods.HttpGet;
-import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.MalformedChunkCodingException;
+import org.apache.hc.core5.http.config.CharCodingConfig;
+import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.impl.io.DefaultBHttpServerConnection;
-import org.apache.hc.core5.http.io.HttpRequestHandler;
-import org.apache.hc.core5.http.io.entity.BasicHttpEntity;
+import org.apache.hc.core5.http.impl.io.DefaultBHttpServerConnectionFactory;
+import org.apache.hc.core5.http.io.SessionOutputBuffer;
 import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.apache.hc.core5.http.protocol.HttpContext;
-import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -86,7 +88,7 @@ public class TestConnectionAutoRelease e
         final LeaseRequest connreq2 = this.connManager.lease(new HttpRoute(target), null);
         final ConnectionEndpoint endpoint = connreq2.get(250, TimeUnit.MILLISECONDS);
 
-        this.connManager.release(endpoint, null, -1, null);
+        this.connManager.release(endpoint, null, TimeValue.NEG_ONE_MILLISECONDS);
     }
 
     @Test
@@ -121,7 +123,7 @@ public class TestConnectionAutoRelease e
         final LeaseRequest connreq2 = this.connManager.lease(new HttpRoute(target), null);
         final ConnectionEndpoint endpoint = connreq2.get(250, TimeUnit.MILLISECONDS);
 
-        this.connManager.release(endpoint, null, -1, null);
+        this.connManager.release(endpoint, null, TimeValue.NEG_ONE_MILLISECONDS);
     }
 
     @Test
@@ -156,42 +158,34 @@ public class TestConnectionAutoRelease e
         final LeaseRequest connreq2 = this.connManager.lease(new HttpRoute(target), null);
         final ConnectionEndpoint endpoint = connreq2.get(250, TimeUnit.MILLISECONDS);
 
-        this.connManager.release(endpoint, null, -1, null);
+        this.connManager.release(endpoint, null, TimeValue.NEG_ONE_MILLISECONDS);
     }
 
     @Test
     public void testReleaseOnIOException() throws Exception {
-        this.serverBootstrap.registerHandler("/dropdead", new HttpRequestHandler() {
+        serverBootstrap.setConnectionFactory(new DefaultBHttpServerConnectionFactory(null, H1Config.DEFAULT, CharCodingConfig.DEFAULT) {
 
             @Override
-            public void handle(
-                    final ClassicHttpRequest request,
-                    final ClassicHttpResponse response,
-                    final HttpContext context) throws HttpException, IOException {
-                final BasicHttpEntity entity = new BasicHttpEntity() {
+            public DefaultBHttpServerConnection createConnection(final Socket socket) throws IOException {
+                final DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(null, H1Config.DEFAULT) {
 
                     @Override
-                    public void writeTo(
-                            final OutputStream outstream) throws IOException {
-                        final byte[] tmp = new byte[5];
-                        outstream.write(tmp);
-                        outstream.flush();
-
-                        // do something comletely ugly in order to trigger
-                        // MalformedChunkCodingException
-                        final DefaultBHttpServerConnection conn = (DefaultBHttpServerConnection)
-                                context.getAttribute(HttpCoreContext.HTTP_CONNECTION);
+                    protected OutputStream createContentOutputStream(
+                            final long len,
+                            final SessionOutputBuffer buffer,
+                            final OutputStream outputStream,
+                            final Supplier<List<? extends Header>> trailers) {
                         try {
-                            conn.sendResponseHeader(response);
-                        } catch (final HttpException ignore) {
+                            buffer.flush(outputStream);
+                            outputStream.close();
+                        } catch (final IOException ignore) {
                         }
+                        return super.createContentOutputStream(len, buffer, outputStream, trailers);
                     }
-
                 };
-                entity.setChunked(true);
-                response.setEntity(entity);
+                conn.bind(socket);
+                return conn;
             }
-
         });
 
         this.connManager.setDefaultMaxPerRoute(1);
@@ -203,7 +197,7 @@ public class TestConnectionAutoRelease e
         final HttpHost target = start();
 
         // Get some random data
-        final HttpGet httpget = new HttpGet("/dropdead");
+        final HttpGet httpget = new HttpGet("/random/1024");
         final ClassicHttpResponse response = this.httpclient.execute(target, httpget);
 
         final LeaseRequest connreq1 = this.connManager.lease(new HttpRoute(target), null);
@@ -218,8 +212,8 @@ public class TestConnectionAutoRelease e
         // Read the content
         try {
             EntityUtils.toByteArray(e);
-            Assert.fail("MalformedChunkCodingException should have been thrown");
-        } catch (final MalformedChunkCodingException expected) {
+            Assert.fail("IOException should have been thrown");
+        } catch (final IOException expected) {
 
         }
 
@@ -230,7 +224,7 @@ public class TestConnectionAutoRelease e
         final LeaseRequest connreq2 = this.connManager.lease(new HttpRoute(target), null);
         final ConnectionEndpoint endpoint = connreq2.get(250, TimeUnit.MILLISECONDS);
 
-        this.connManager.release(endpoint, null, -1, null);
+        this.connManager.release(endpoint, null, TimeValue.NEG_ONE_MILLISECONDS);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionManagement.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionManagement.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionManagement.java Mon May  1 10:47:09 2017
@@ -49,6 +49,7 @@ import org.apache.hc.core5.http.protocol
 import org.apache.hc.core5.http.protocol.RequestConnControl;
 import org.apache.hc.core5.http.protocol.RequestContent;
 import org.apache.hc.core5.http.protocol.RequestTargetHost;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -77,7 +78,7 @@ public class TestConnectionManagement ex
         final LeaseRequest leaseRequest1 = this.connManager.lease(route, null);
         final ConnectionEndpoint endpoint1 = leaseRequest1.get(0, TimeUnit.MILLISECONDS);
 
-        this.connManager.connect(endpoint1, 0, TimeUnit.MILLISECONDS, context);
+        this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context);
 
         final HttpProcessor httpProcessor = new DefaultHttpProcessor(
                 new RequestTargetHost(), new RequestContent(), new RequestConnControl());
@@ -99,12 +100,12 @@ public class TestConnectionManagement ex
         }
 
         endpoint1.close();
-        this.connManager.release(endpoint1, null, -1, null);
+        this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS);
         final LeaseRequest leaseRequest2 = this.connManager.lease(route, null);
         final ConnectionEndpoint endpoint2 = leaseRequest2.get(0, TimeUnit.MILLISECONDS);
         Assert.assertFalse(endpoint2.isConnected());
 
-        this.connManager.connect(endpoint2, 0, TimeUnit.MILLISECONDS, context);
+        this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECONDS, context);
 
         try (final ClassicHttpResponse response2 = endpoint2.execute(request, exec, context)) {
             Assert.assertEquals(HttpStatus.SC_OK, response2.getCode());
@@ -112,7 +113,7 @@ public class TestConnectionManagement ex
 
         // release connection after marking it for re-use
         // expect the next connection obtained to be open
-        this.connManager.release(endpoint2, null, -1, null);
+        this.connManager.release(endpoint2, null, TimeValue.NEG_ONE_MILLISECONDS);
 
         final LeaseRequest leaseRequest3 = this.connManager.lease(route, null);
         final ConnectionEndpoint endpoint3 = leaseRequest3.get(0, TimeUnit.MILLISECONDS);
@@ -123,7 +124,7 @@ public class TestConnectionManagement ex
             Assert.assertEquals(HttpStatus.SC_OK, response3.getCode());
         }
 
-        this.connManager.release(endpoint3, null, -1, null);
+        this.connManager.release(endpoint3, null, TimeValue.NEG_ONE_MILLISECONDS);
         this.connManager.close();
     }
 
@@ -145,7 +146,7 @@ public class TestConnectionManagement ex
 
         final LeaseRequest leaseRequest1 = this.connManager.lease(route, null);
         final ConnectionEndpoint endpoint1 = leaseRequest1.get(0, TimeUnit.MILLISECONDS);
-        this.connManager.connect(endpoint1, 0, TimeUnit.MILLISECONDS, context);
+        this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context);
 
         final HttpProcessor httpProcessor = new DefaultHttpProcessor(
                 new RequestTargetHost(), new RequestContent(), new RequestConnControl());
@@ -167,19 +168,19 @@ public class TestConnectionManagement ex
         }
 
         endpoint1.close();
-        this.connManager.release(endpoint1, null, 100, TimeUnit.MILLISECONDS);
+        this.connManager.release(endpoint1, null, TimeValue.ofMillis(100));
 
         final LeaseRequest leaseRequest2 = this.connManager.lease(route, null);
         final ConnectionEndpoint endpoint2 = leaseRequest2.get(0, TimeUnit.MILLISECONDS);
         Assert.assertFalse(endpoint2.isConnected());
 
-        this.connManager.connect(endpoint2, 0, TimeUnit.MILLISECONDS, context);
+        this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECONDS, context);
 
         try (final ClassicHttpResponse response2 = endpoint2.execute(request, exec, context)) {
             Assert.assertEquals(HttpStatus.SC_OK, response2.getCode());
         }
 
-        this.connManager.release(endpoint2, null, 100, TimeUnit.MILLISECONDS);
+        this.connManager.release(endpoint2, null, TimeValue.ofMillis(100));
 
         final LeaseRequest leaseRequest3 = this.connManager.lease(route, null);
         final ConnectionEndpoint endpoint3 = leaseRequest3.get(0, TimeUnit.MILLISECONDS);
@@ -190,7 +191,7 @@ public class TestConnectionManagement ex
             Assert.assertEquals(HttpStatus.SC_OK, response3.getCode());
         }
 
-        this.connManager.release(endpoint3, null, 100, TimeUnit.MILLISECONDS);
+        this.connManager.release(endpoint3, null, TimeValue.ofMillis(100));
         Thread.sleep(150);
 
         final LeaseRequest leaseRequest4 = this.connManager.lease(route, null);
@@ -198,7 +199,7 @@ public class TestConnectionManagement ex
         Assert.assertFalse(endpoint4.isConnected());
 
         // repeat the communication, no need to prepare the request again
-        this.connManager.connect(endpoint4, 0, TimeUnit.MILLISECONDS, context);
+        this.connManager.connect(endpoint4, TimeValue.NEG_ONE_MILLISECONDS, context);
 
         try (final ClassicHttpResponse response4 = endpoint4.execute(request, exec, context)) {
             Assert.assertEquals(HttpStatus.SC_OK, response4.getCode());
@@ -218,13 +219,13 @@ public class TestConnectionManagement ex
 
         final LeaseRequest leaseRequest1 = this.connManager.lease(route, null);
         final ConnectionEndpoint endpoint1 = leaseRequest1.get(0, TimeUnit.MILLISECONDS);
-        this.connManager.connect(endpoint1, 0, TimeUnit.MILLISECONDS, context);
+        this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context);
 
         Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
         Assert.assertEquals(1, this.connManager.getTotalStats().getLeased());
         Assert.assertEquals(1, this.connManager.getStats(route).getLeased());
 
-        this.connManager.release(endpoint1, null, 100, TimeUnit.MILLISECONDS);
+        this.connManager.release(endpoint1, null, TimeValue.ofMillis(100));
 
         // Released, still active.
         Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
@@ -253,8 +254,7 @@ public class TestConnectionManagement ex
     @Test
     public void testCloseExpiredTTLConnections() throws Exception {
 
-        this.connManager = new PoolingHttpClientConnectionManager(
-                100, TimeUnit.MILLISECONDS);
+        this.connManager = new PoolingHttpClientConnectionManager(TimeValue.ofMillis(100));
         this.clientBuilder.setConnectionManager(this.connManager);
 
         this.connManager.setMaxTotal(1);
@@ -265,13 +265,13 @@ public class TestConnectionManagement ex
 
         final LeaseRequest leaseRequest1 = this.connManager.lease(route, null);
         final ConnectionEndpoint endpoint1 = leaseRequest1.get(0, TimeUnit.MILLISECONDS);
-        this.connManager.connect(endpoint1, 0, TimeUnit.MILLISECONDS, context);
+        this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context);
 
         Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());
         Assert.assertEquals(1, this.connManager.getTotalStats().getLeased());
         Assert.assertEquals(1, this.connManager.getStats(route).getLeased());
         // Release, let remain idle for forever
-        this.connManager.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
+        this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS);
 
         // Released, still active.
         Assert.assertEquals(Collections.singleton(route), this.connManager.getRoutes());

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestIdleConnectionEviction.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestIdleConnectionEviction.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestIdleConnectionEviction.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestIdleConnectionEviction.java Mon May  1 10:47:09 2017
@@ -27,8 +27,6 @@
 
 package org.apache.hc.client5.http.impl.integration;
 
-import java.util.concurrent.TimeUnit;
-
 import org.apache.hc.client5.http.impl.IdleConnectionEvictor;
 import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
 import org.apache.hc.client5.http.localserver.LocalServerTestBase;
@@ -38,6 +36,7 @@ import org.apache.hc.client5.http.sync.m
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Test;
 
 public class TestIdleConnectionEviction extends LocalServerTestBase {
@@ -49,8 +48,7 @@ public class TestIdleConnectionEviction
 
         final HttpHost target = start();
 
-        final IdleConnectionEvictor idleConnectionMonitor = new IdleConnectionEvictor(
-                this.connManager, 50, TimeUnit.MILLISECONDS);
+        final IdleConnectionEvictor idleConnectionMonitor = new IdleConnectionEvictor(this.connManager, TimeValue.ofMillis(50));
         idleConnectionMonitor.start();
 
         final HttpGet httpget = new HttpGet("/random/1024");

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestMalformedServerResponse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestMalformedServerResponse.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestMalformedServerResponse.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestMalformedServerResponse.java Mon May  1 10:47:09 2017
@@ -37,6 +37,7 @@ import org.apache.hc.core5.http.ClassicH
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.impl.io.DefaultBHttpServerConnection;
 import org.apache.hc.core5.http.io.HttpConnectionFactory;
 import org.apache.hc.core5.http.io.HttpRequestHandler;
@@ -50,8 +51,8 @@ public class TestMalformedServerResponse
 
     static class BrokenServerConnection extends DefaultBHttpServerConnection {
 
-        public BrokenServerConnection(final int buffersize) {
-            super(buffersize);
+        public BrokenServerConnection(final H1Config h1Config) {
+            super(null, h1Config);
         }
 
         @Override
@@ -77,7 +78,7 @@ public class TestMalformedServerResponse
 
         @Override
         public DefaultBHttpServerConnection createConnection(final Socket socket) throws IOException {
-            final BrokenServerConnection conn = new BrokenServerConnection(4096);
+            final BrokenServerConnection conn = new BrokenServerConnection(H1Config.DEFAULT);
             conn.bind(socket);
             return conn;
         }

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestRedirects.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestRedirects.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestRedirects.java Mon May  1 10:47:09 2017
@@ -46,8 +46,8 @@ import org.apache.hc.client5.http.sync.m
 import org.apache.hc.client5.http.utils.URIUtils;
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.EndpointDetails;
 import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpConnection;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpHost;
@@ -87,8 +87,8 @@ public class TestRedirects extends Local
                 final ClassicHttpRequest request,
                 final ClassicHttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
-            final HttpConnection conn = (HttpConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION);
-            final InetSocketAddress socketAddress = (InetSocketAddress) conn.getLocalAddress();
+            final EndpointDetails endpointDetails = (EndpointDetails) context.getAttribute(HttpCoreContext.CONNECTION_ENDPOINT);
+            final InetSocketAddress socketAddress = (InetSocketAddress) endpointDetails.getLocalAddress();
             String localhost = socketAddress.getHostName();
             if (localhost.equals("127.0.0.1")) {
                 localhost = "localhost";

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestStatefulConnManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestStatefulConnManagement.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestStatefulConnManagement.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestStatefulConnManagement.java Mon May  1 10:47:09 2017
@@ -36,7 +36,7 @@ import org.apache.hc.client5.http.protoc
 import org.apache.hc.client5.http.sync.methods.HttpGet;
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.HttpConnection;
+import org.apache.hc.core5.http.EndpointDetails;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpStatus;
@@ -174,8 +174,8 @@ public class TestStatefulConnManagement
                             this.context);
                     this.count++;
 
-                    final HttpConnection conn = this.context.getConnection();
-                    final String connuid = Integer.toHexString(System.identityHashCode(conn));
+                    final EndpointDetails endpointDetails = this.context.getEndpointDetails();
+                    final String connuid = Integer.toHexString(System.identityHashCode(endpointDetails));
                     this.context.setAttribute("r" + r, connuid);
                     EntityUtils.consume(response.getEntity());
                 }

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java Mon May  1 10:47:09 2017
@@ -46,6 +46,8 @@ import org.apache.hc.core5.http.config.L
 import org.apache.hc.core5.http.config.SocketConfig;
 import org.apache.hc.core5.http.io.HttpConnectionFactory;
 import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.io.ShutdownType;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -94,7 +96,7 @@ public class TestBasicHttpClientConnecti
         Assert.assertNotNull(endpoint1);
         Assert.assertFalse(endpoint1.isConnected());
 
-        mgr.release(endpoint1, null, 100, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.ofMillis(100));
 
         Assert.assertNull(mgr.getRoute());
         Assert.assertNull(mgr.getState());
@@ -122,7 +124,7 @@ public class TestBasicHttpClientConnecti
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
 
-        mgr.release(endpoint1, null, 10000, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.ofMillis(100));
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
@@ -150,7 +152,7 @@ public class TestBasicHttpClientConnecti
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
 
-        mgr.release(endpoint1, "some other state", 10000, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, "some other state", TimeValue.ofMillis(10000));
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals("some other state", mgr.getState());
@@ -178,7 +180,7 @@ public class TestBasicHttpClientConnecti
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
 
-        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS);
 
         Assert.assertEquals(route1, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
@@ -209,7 +211,7 @@ public class TestBasicHttpClientConnecti
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
 
-        mgr.release(endpoint1, null, 10, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.ofMillis(10));
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
@@ -227,13 +229,13 @@ public class TestBasicHttpClientConnecti
 
     @Test(expected=IllegalArgumentException.class)
     public void testReleaseInvalidArg() throws Exception {
-        mgr.release(null, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(null, null, TimeValue.NEG_ONE_MILLISECONDS);
     }
 
     @Test(expected=IllegalStateException.class)
     public void testReleaseAnotherConnection() throws Exception {
         final ConnectionEndpoint wrongCon = Mockito.mock(ConnectionEndpoint.class);
-        mgr.release(wrongCon, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(wrongCon, null, TimeValue.NEG_ONE_MILLISECONDS);
     }
 
     @Test
@@ -251,11 +253,11 @@ public class TestBasicHttpClientConnecti
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
 
-        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS);
 
         mgr.close();
 
-        Mockito.verify(conn, Mockito.times(1)).shutdown();
+        Mockito.verify(conn, Mockito.times(1)).shutdown(ShutdownType.GRACEFUL);
 
         try {
             final LeaseRequest connRequest2 = mgr.lease(route, null);
@@ -269,7 +271,7 @@ public class TestBasicHttpClientConnecti
         mgr.closeIdle(0L, TimeUnit.MILLISECONDS);
         mgr.close();
 
-        Mockito.verify(conn, Mockito.times(1)).shutdown();
+        Mockito.verify(conn, Mockito.times(1)).shutdown(ShutdownType.GRACEFUL);
     }
 
     @Test
@@ -287,7 +289,7 @@ public class TestBasicHttpClientConnecti
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
 
-        mgr.release(endpoint1, null, 10, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.ofMillis(10));
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
@@ -314,7 +316,7 @@ public class TestBasicHttpClientConnecti
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
 
-        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS);
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
@@ -336,7 +338,7 @@ public class TestBasicHttpClientConnecti
         final LeaseRequest connRequest1 = mgr.lease(route, null);
         final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
         Assert.assertNotNull(endpoint1);
-        mgr.release(endpoint1, null, 100, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.ofMillis(100));
 
         mgr.getConnection(route, null);
         mgr.getConnection(route, null);
@@ -365,19 +367,19 @@ public class TestBasicHttpClientConnecti
         Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(plainSocketFactory);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.eq(socket),
                 Mockito.<HttpHost>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenReturn(socket);
 
-        mgr.connect(endpoint1, 123, TimeUnit.MILLISECONDS, context);
+        mgr.connect(endpoint1, TimeValue.ofMillis(123), context);
 
         Mockito.verify(dnsResolver, Mockito.times(1)).resolve("somehost");
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(target);
         Mockito.verify(plainSocketFactory, Mockito.times(1)).createSocket(context);
-        Mockito.verify(plainSocketFactory, Mockito.times(1)).connectSocket(123, socket, target,
+        Mockito.verify(plainSocketFactory, Mockito.times(1)).connectSocket(TimeValue.ofMillis(123), socket, target,
                 new InetSocketAddress(remote, 8443),
                 new InetSocketAddress(local, 0), context);
     }
@@ -408,19 +410,19 @@ public class TestBasicHttpClientConnecti
         Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(sslSocketFactory);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.eq(socket),
                 Mockito.<HttpHost>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenReturn(socket);
 
-        mgr.connect(endpoint1, 123, TimeUnit.MILLISECONDS, context);
+        mgr.connect(endpoint1, TimeValue.ofMillis(123), context);
 
         Mockito.verify(dnsResolver, Mockito.times(1)).resolve("someproxy");
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(proxy);
         Mockito.verify(plainSocketFactory, Mockito.times(1)).createSocket(context);
-        Mockito.verify(plainSocketFactory, Mockito.times(1)).connectSocket(123, socket, proxy,
+        Mockito.verify(plainSocketFactory, Mockito.times(1)).connectSocket(TimeValue.ofMillis(123), socket, proxy,
                 new InetSocketAddress(remote, 8080),
                 new InetSocketAddress(local, 0), context);
 

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java Mon May  1 10:47:09 2017
@@ -32,6 +32,7 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.SocketTimeoutException;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.client5.http.ConnectTimeoutException;
 import org.apache.hc.client5.http.DnsResolver;
@@ -46,6 +47,7 @@ import org.apache.hc.core5.http.config.L
 import org.apache.hc.core5.http.config.SocketConfig;
 import org.apache.hc.core5.http.protocol.BasicHttpContext;
 import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -89,7 +91,7 @@ public class TestHttpClientConnectionOpe
         Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.<Socket>any(),
                 Mockito.<HttpHost>any(),
                 Mockito.<InetSocketAddress>any(),
@@ -99,12 +101,12 @@ public class TestHttpClientConnectionOpe
         final SocketConfig socketConfig = SocketConfig.custom()
             .setSoKeepAlive(true)
             .setSoReuseAddress(true)
-            .setSoTimeout(5000)
+            .setSoTimeout(5000, TimeUnit.MILLISECONDS)
             .setTcpNoDelay(true)
-            .setSoLinger(50)
+            .setSoLinger(50, TimeUnit.MILLISECONDS)
             .build();
         final InetSocketAddress localAddress = new InetSocketAddress(local, 0);
-        connectionOperator.connect(conn, host, localAddress, 1000, socketConfig, context);
+        connectionOperator.connect(conn, host, localAddress, TimeValue.ofMillis(1000), socketConfig, context);
 
         Mockito.verify(socket).setKeepAlive(true);
         Mockito.verify(socket).setReuseAddress(true);
@@ -113,7 +115,7 @@ public class TestHttpClientConnectionOpe
         Mockito.verify(socket).setTcpNoDelay(true);
 
         Mockito.verify(plainSocketFactory).connectSocket(
-                1000,
+                TimeValue.ofMillis(1000),
                 socket,
                 host,
                 new InetSocketAddress(ip1, 80),
@@ -134,14 +136,14 @@ public class TestHttpClientConnectionOpe
         Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.<Socket>any(),
                 Mockito.<HttpHost>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenThrow(new SocketTimeoutException());
 
-        connectionOperator.connect(conn, host, null, 1000, SocketConfig.DEFAULT, context);
+        connectionOperator.connect(conn, host, null, TimeValue.ofMillis(1000), SocketConfig.DEFAULT, context);
     }
 
     @Test(expected=HttpHostConnectException.class)
@@ -156,14 +158,14 @@ public class TestHttpClientConnectionOpe
         Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.<Socket>any(),
                 Mockito.<HttpHost>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenThrow(new ConnectException());
 
-        connectionOperator.connect(conn, host, null, 1000, SocketConfig.DEFAULT, context);
+        connectionOperator.connect(conn, host, null, TimeValue.ofMillis(1000), SocketConfig.DEFAULT, context);
     }
 
     @Test
@@ -179,14 +181,14 @@ public class TestHttpClientConnectionOpe
         Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.<Socket>any(),
                 Mockito.<HttpHost>any(),
                 Mockito.eq(new InetSocketAddress(ip1, 80)),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenThrow(new ConnectException());
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.<Socket>any(),
                 Mockito.<HttpHost>any(),
                 Mockito.eq(new InetSocketAddress(ip2, 80)),
@@ -194,10 +196,10 @@ public class TestHttpClientConnectionOpe
                 Mockito.<HttpContext>any())).thenReturn(socket);
 
         final InetSocketAddress localAddress = new InetSocketAddress(local, 0);
-        connectionOperator.connect(conn, host, localAddress, 1000, SocketConfig.DEFAULT, context);
+        connectionOperator.connect(conn, host, localAddress, TimeValue.ofMillis(1000), SocketConfig.DEFAULT, context);
 
         Mockito.verify(plainSocketFactory).connectSocket(
-                1000,
+                TimeValue.ofMillis(1000),
                 socket,
                 host,
                 new InetSocketAddress(ip2, 80),
@@ -217,7 +219,7 @@ public class TestHttpClientConnectionOpe
         Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.<Socket>any(),
                 Mockito.<HttpHost>any(),
                 Mockito.<InetSocketAddress>any(),
@@ -225,10 +227,10 @@ public class TestHttpClientConnectionOpe
                 Mockito.<HttpContext>any())).thenReturn(socket);
 
         final InetSocketAddress localAddress = new InetSocketAddress(local, 0);
-        connectionOperator.connect(conn, host, localAddress, 1000, SocketConfig.DEFAULT, context);
+        connectionOperator.connect(conn, host, localAddress, TimeValue.ofMillis(1000), SocketConfig.DEFAULT, context);
 
         Mockito.verify(plainSocketFactory).connectSocket(
-                1000,
+                TimeValue.ofMillis(1000),
                 socket,
                 host,
                 new InetSocketAddress(ip, 80),

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java Mon May  1 10:47:09 2017
@@ -49,6 +49,7 @@ import org.apache.hc.core5.http.config.S
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.pool.PoolEntry;
 import org.apache.hc.core5.pool.StrictConnPool;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -94,7 +95,7 @@ public class TestPoolingHttpClientConnec
         final HttpHost target = new HttpHost("localhost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, -1, TimeUnit.MILLISECONDS);
+        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS);
         entry.assignConnection(conn);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@@ -112,7 +113,7 @@ public class TestPoolingHttpClientConnec
         Assert.assertNotNull(endpoint1);
         Assert.assertNotSame(conn, endpoint1);
 
-        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS);
 
         Mockito.verify(pool).release(entry, true);
     }
@@ -122,7 +123,7 @@ public class TestPoolingHttpClientConnec
         final HttpHost target = new HttpHost("localhost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, -1, TimeUnit.MILLISECONDS);
+        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
         Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
@@ -139,7 +140,7 @@ public class TestPoolingHttpClientConnec
         Assert.assertNotNull(endpoint1);
         Assert.assertNotSame(conn, endpoint1);
 
-        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS);
 
         Mockito.verify(pool).release(entry, false);
     }
@@ -149,7 +150,7 @@ public class TestPoolingHttpClientConnec
         final HttpHost target = new HttpHost("localhost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, -1, TimeUnit.MILLISECONDS);
+        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS);
         entry.assignConnection(conn);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE);
@@ -178,7 +179,7 @@ public class TestPoolingHttpClientConnec
         final HttpHost target = new HttpHost("localhost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, -1, TimeUnit.MILLISECONDS);
+        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS);
         entry.assignConnection(conn);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@@ -191,7 +192,7 @@ public class TestPoolingHttpClientConnec
         Assert.assertNotNull(endpoint1);
         Assert.assertTrue(endpoint1.isConnected());
 
-        mgr.release(endpoint1, "some state", 10, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECONDS);
 
         Mockito.verify(pool).release(entry, true);
         Assert.assertEquals("some state", entry.getState());
@@ -202,7 +203,7 @@ public class TestPoolingHttpClientConnec
         final HttpHost target = new HttpHost("localhost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, -1, TimeUnit.MILLISECONDS);
+        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS);
         entry.assignConnection(conn);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@@ -215,7 +216,7 @@ public class TestPoolingHttpClientConnec
         Assert.assertNotNull(endpoint1);
         Assert.assertFalse(endpoint1.isConnected());
 
-        mgr.release(endpoint1, "some state", 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECONDS);
 
         Mockito.verify(pool).release(entry, false);
         Assert.assertEquals(null, entry.getState());
@@ -228,7 +229,7 @@ public class TestPoolingHttpClientConnec
         final InetAddress local = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
         final HttpRoute route = new HttpRoute(target, local, true);
 
-        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, -1, TimeUnit.MILLISECONDS);
+        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS);
         entry.assignConnection(conn);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@@ -251,19 +252,19 @@ public class TestPoolingHttpClientConnec
         Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(plainSocketFactory);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
         Mockito.when(plainSocketFactory.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.eq(socket),
                 Mockito.<HttpHost>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenReturn(socket);
 
-        mgr.connect(endpoint1, 123, TimeUnit.MILLISECONDS, context);
+        mgr.connect(endpoint1, TimeValue.ofMillis(123), context);
 
         Mockito.verify(dnsResolver, Mockito.times(1)).resolve("somehost");
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(target);
         Mockito.verify(plainSocketFactory, Mockito.times(1)).createSocket(context);
-        Mockito.verify(plainSocketFactory, Mockito.times(1)).connectSocket(123, socket, target,
+        Mockito.verify(plainSocketFactory, Mockito.times(1)).connectSocket(TimeValue.ofMillis(123), socket, target,
                 new InetSocketAddress(remote, 8443),
                 new InetSocketAddress(local, 0), context);
     }
@@ -276,7 +277,7 @@ public class TestPoolingHttpClientConnec
         final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
         final HttpRoute route = new HttpRoute(target, local, proxy, true);
 
-        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, -1, TimeUnit.MILLISECONDS);
+        final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS);
         entry.assignConnection(conn);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@@ -304,19 +305,19 @@ public class TestPoolingHttpClientConnec
         Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(sslsf);
         Mockito.when(plainsf.createSocket(Mockito.<HttpContext>any())).thenReturn(mockSock);
         Mockito.when(plainsf.connectSocket(
-                Mockito.anyInt(),
+                Mockito.<TimeValue>any(),
                 Mockito.eq(mockSock),
                 Mockito.<HttpHost>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenReturn(mockSock);
 
-        mgr.connect(endpoint1, 123, TimeUnit.MILLISECONDS, context);
+        mgr.connect(endpoint1, TimeValue.ofMillis(123), context);
 
         Mockito.verify(dnsResolver, Mockito.times(1)).resolve("someproxy");
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(proxy);
         Mockito.verify(plainsf, Mockito.times(1)).createSocket(context);
-        Mockito.verify(plainsf, Mockito.times(1)).connectSocket(123, mockSock, proxy,
+        Mockito.verify(plainsf, Mockito.times(1)).connectSocket(TimeValue.ofMillis(123), mockSock, proxy,
                 new InetSocketAddress(remote, 8080),
                 new InetSocketAddress(local, 0), context);
 

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/MockConnPoolControl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/MockConnPoolControl.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/MockConnPoolControl.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/MockConnPoolControl.java Mon May  1 10:47:09 2017
@@ -28,11 +28,11 @@ package org.apache.hc.client5.http.impl.
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.core5.pool.ConnPoolControl;
 import org.apache.hc.core5.pool.PoolStats;
+import org.apache.hc.core5.util.TimeValue;
 
 public final class MockConnPoolControl implements ConnPoolControl<HttpRoute> {
 
@@ -94,7 +94,7 @@ public final class MockConnPoolControl i
     }
 
     @Override
-    public void closeIdle(final long idletime, final TimeUnit tunit) {
+    public void closeIdle(final TimeValue idletime) {
     }
 
     @Override

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java Mon May  1 10:47:09 2017
@@ -26,11 +26,10 @@
  */
 package org.apache.hc.client5.http.impl.sync;
 
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.hc.client5.http.io.ConnectionEndpoint;
 import org.apache.hc.client5.http.io.HttpClientConnectionManager;
+import org.apache.hc.core5.io.ShutdownType;
+import org.apache.hc.core5.util.TimeValue;
 import org.apache.logging.log4j.Logger;
 import org.junit.Assert;
 import org.junit.Before;
@@ -63,29 +62,14 @@ public class TestEndpointHolder {
 
         Assert.assertTrue(connHolder.isReleased());
 
-        Mockito.verify(endpoint).shutdown();
-        Mockito.verify(mgr).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(endpoint).shutdown(ShutdownType.IMMEDIATE);
+        Mockito.verify(mgr).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
 
         connHolder.abortConnection();
 
-        Mockito.verify(endpoint, Mockito.times(1)).shutdown();
+        Mockito.verify(endpoint, Mockito.times(1)).shutdown(ShutdownType.IMMEDIATE);
         Mockito.verify(mgr, Mockito.times(1)).release(
-                Mockito.<ConnectionEndpoint>any(),
-                Mockito.anyObject(),
-                Mockito.anyLong(),
-                Mockito.<TimeUnit>any());
-    }
-
-    @Test
-    public void testAbortConnectionIOError() throws Exception {
-        Mockito.doThrow(new IOException()).when(endpoint).shutdown();
-
-        connHolder.abortConnection();
-
-        Assert.assertTrue(connHolder.isReleased());
-
-        Mockito.verify(endpoint).shutdown();
-        Mockito.verify(mgr).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+                Mockito.<ConnectionEndpoint>any(), Mockito.anyObject(), Mockito.<TimeValue>any());
     }
 
     @Test
@@ -94,23 +78,20 @@ public class TestEndpointHolder {
 
         Assert.assertTrue(connHolder.isReleased());
 
-        Mockito.verify(endpoint).shutdown();
-        Mockito.verify(mgr).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(endpoint).shutdown(ShutdownType.IMMEDIATE);
+        Mockito.verify(mgr).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
 
         Assert.assertFalse(connHolder.cancel());
 
-        Mockito.verify(endpoint, Mockito.times(1)).shutdown();
+        Mockito.verify(endpoint, Mockito.times(1)).shutdown(ShutdownType.IMMEDIATE);
         Mockito.verify(mgr, Mockito.times(1)).release(
-                Mockito.<ConnectionEndpoint>any(),
-                Mockito.anyObject(),
-                Mockito.anyLong(),
-                Mockito.<TimeUnit>any());
+                Mockito.<ConnectionEndpoint>any(), Mockito.anyObject(), Mockito.<TimeValue>any());
     }
 
     @Test
     public void testReleaseConnectionReusable() throws Exception {
         connHolder.setState("some state");
-        connHolder.setValidFor(100, TimeUnit.SECONDS);
+        connHolder.setValidFor(TimeValue.ofSeconds(100));
         connHolder.markReusable();
 
         connHolder.releaseConnection();
@@ -118,21 +99,18 @@ public class TestEndpointHolder {
         Assert.assertTrue(connHolder.isReleased());
 
         Mockito.verify(endpoint, Mockito.never()).close();
-        Mockito.verify(mgr).release(endpoint, "some state", 100000, TimeUnit.MILLISECONDS);
+        Mockito.verify(mgr).release(endpoint, "some state", TimeValue.ofSeconds(100));
 
         connHolder.releaseConnection();
 
         Mockito.verify(mgr, Mockito.times(1)).release(
-                Mockito.<ConnectionEndpoint>any(),
-                Mockito.anyObject(),
-                Mockito.anyLong(),
-                Mockito.<TimeUnit>any());
+                Mockito.<ConnectionEndpoint>any(), Mockito.anyObject(), Mockito.<TimeValue>any());
     }
 
     @Test
     public void testReleaseConnectionNonReusable() throws Exception {
         connHolder.setState("some state");
-        connHolder.setValidFor(100, TimeUnit.SECONDS);
+        connHolder.setValidFor(TimeValue.ofSeconds(100));
         connHolder.markNonReusable();
 
         connHolder.releaseConnection();
@@ -140,15 +118,12 @@ public class TestEndpointHolder {
         Assert.assertTrue(connHolder.isReleased());
 
         Mockito.verify(endpoint, Mockito.times(1)).close();
-        Mockito.verify(mgr).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(mgr).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
 
         connHolder.releaseConnection();
 
         Mockito.verify(mgr, Mockito.times(1)).release(
-                Mockito.<ConnectionEndpoint>any(),
-                Mockito.anyObject(),
-                Mockito.anyLong(),
-                Mockito.<TimeUnit>any());
+                Mockito.<ConnectionEndpoint>any(), Mockito.anyObject(), Mockito.<TimeValue>any());
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestFutureRequestExecutionService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestFutureRequestExecutionService.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestFutureRequestExecutionService.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestFutureRequestExecutionService.java Mon May  1 10:47:09 2017
@@ -47,8 +47,8 @@ import org.apache.hc.core5.concurrent.Fu
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.impl.io.bootstrap.HttpServer;
-import org.apache.hc.core5.http.impl.io.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.apache.hc.core5.http.io.HttpRequestHandler;
 import org.apache.hc.core5.http.io.ResponseHandler;
 import org.apache.hc.core5.http.protocol.HttpContext;

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMainClientExec.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMainClientExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMainClientExec.java Mon May  1 10:47:09 2017
@@ -77,6 +77,7 @@ import org.apache.hc.core5.http.io.entit
 import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -136,9 +137,9 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(123)
-                .setSocketTimeout(234)
-                .setConnectionRequestTimeout(345)
+                .setConnectTimeout(123, TimeUnit.MILLISECONDS)
+                .setSocketTimeout(234, TimeUnit.MILLISECONDS)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -153,11 +154,11 @@ public class TestMainClientExec {
         Mockito.verify(connRequest).get(345, TimeUnit.MILLISECONDS);
         Mockito.verify(execAware, Mockito.times(1)).setCancellable(connRequest);
         Mockito.verify(execAware, Mockito.times(2)).setCancellable(Mockito.<Cancellable>any());
-        Mockito.verify(connManager).connect(endpoint, 123, TimeUnit.MILLISECONDS, context);
+        Mockito.verify(connManager).connect(endpoint, TimeValue.ofMillis(123), context);
         Mockito.verify(endpoint).setSocketTimeout(234);
         Mockito.verify(endpoint, Mockito.times(1)).execute(request, requestExecutor, context);
         Mockito.verify(endpoint, Mockito.times(1)).close();
-        Mockito.verify(connManager).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(connManager).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
 
         Assert.assertNull(context.getUserToken());
         Assert.assertNotNull(finalResponse);
@@ -169,7 +170,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectionRequestTimeout(345)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -186,13 +187,13 @@ public class TestMainClientExec {
                 Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
         Mockito.when(keepAliveStrategy.getKeepAliveDuration(
                 Mockito.same(response),
-                Mockito.<HttpClientContext>any())).thenReturn(678L);
+                Mockito.<HttpClientContext>any())).thenReturn(TimeValue.ofMillis(678L));
 
         final ClassicHttpResponse finalResponse = mainClientExec.execute(request, context, execAware);
         Mockito.verify(connManager).lease(route, null);
         Mockito.verify(connRequest).get(345, TimeUnit.MILLISECONDS);
         Mockito.verify(endpoint, Mockito.times(1)).execute(request, requestExecutor, context);
-        Mockito.verify(connManager).release(endpoint, null, 678L, TimeUnit.MILLISECONDS);
+        Mockito.verify(connManager).release(endpoint, null, TimeValue.ofMillis(678L));
         Mockito.verify(endpoint, Mockito.never()).close();
 
         Assert.assertNotNull(finalResponse);
@@ -204,7 +205,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectionRequestTimeout(345)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -219,6 +220,9 @@ public class TestMainClientExec {
                 Mockito.same(request),
                 Mockito.same(response),
                 Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
+        Mockito.when(keepAliveStrategy.getKeepAliveDuration(
+                Mockito.same(response),
+                Mockito.<HttpClientContext>any())).thenReturn(TimeValue.ofMinutes(1));
         Mockito.when(userTokenHandler.getUserToken(
                 Mockito.same(route),
                 Mockito.<HttpClientContext>any())).thenReturn("this and that");
@@ -227,7 +231,7 @@ public class TestMainClientExec {
         Mockito.verify(connManager).lease(route, null);
         Mockito.verify(connRequest).get(345, TimeUnit.MILLISECONDS);
         Mockito.verify(endpoint, Mockito.times(1)).execute(request, requestExecutor, context);
-        Mockito.verify(connManager).release(endpoint, "this and that", 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(connManager).release(endpoint, "this and that", TimeValue.ofMinutes(1));
         Mockito.verify(endpoint, Mockito.never()).close();
 
         Assert.assertEquals("this and that", context.getUserToken());
@@ -238,7 +242,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectionRequestTimeout(345)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -265,8 +269,7 @@ public class TestMainClientExec {
         Mockito.verify(connManager, Mockito.never()).release(
                 Mockito.same(endpoint),
                 Mockito.any(),
-                Mockito.anyInt(),
-                Mockito.<TimeUnit>any());
+                Mockito.<TimeValue>any());
         Mockito.verify(endpoint, Mockito.never()).close();
 
         Assert.assertNotNull(finalResponse);
@@ -274,7 +277,7 @@ public class TestMainClientExec {
         finalResponse.close();
 
         Mockito.verify(connManager, Mockito.times(1)).release(
-                endpoint, null, 0, TimeUnit.MILLISECONDS);
+                endpoint, null, TimeValue.ZERO_MILLISECONDS);
         Mockito.verify(endpoint, Mockito.times(1)).close();
     }
 
@@ -282,7 +285,7 @@ public class TestMainClientExec {
     public void testSocketTimeoutExistingConnection() throws Exception {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
-        final RequestConfig config = RequestConfig.custom().setSocketTimeout(3000).build();
+        final RequestConfig config = RequestConfig.custom().setSocketTimeout(3000, TimeUnit.MILLISECONDS).build();
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
         context.setRequestConfig(config);
         final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
@@ -333,7 +336,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectionRequestTimeout(345)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -347,8 +350,7 @@ public class TestMainClientExec {
             Mockito.verify(execAware, Mockito.times(2)).setCancellable(Mockito.<Cancellable>any());
             Mockito.verify(connManager, Mockito.never()).connect(
                     Mockito.same(endpoint),
-                    Mockito.anyInt(),
-                    Mockito.<TimeUnit>any(),
+                    Mockito.<TimeValue>any(),
                     Mockito.<HttpContext>any());
             throw ex;
         }
@@ -359,8 +361,8 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(567)
-                .setConnectionRequestTimeout(345)
+                .setConnectTimeout(567, TimeUnit.MILLISECONDS)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -371,7 +373,7 @@ public class TestMainClientExec {
             mainClientExec.execute(request, context, execAware);
         } catch (final IOException ex) {
             Mockito.verify(connRequest, Mockito.times(1)).get(345, TimeUnit.MILLISECONDS);
-            Mockito.verify(connManager, Mockito.times(1)).connect(endpoint, 567, TimeUnit.MILLISECONDS, context);
+            Mockito.verify(connManager, Mockito.times(1)).connect(endpoint, TimeValue.ofMillis(567), context);
             Mockito.verify(requestExecutor, Mockito.never()).execute(
                     Mockito.same(request),
                     Mockito.<HttpClientConnection>any(),
@@ -567,7 +569,7 @@ public class TestMainClientExec {
         try {
             mainClientExec.execute(request, context, execAware);
         } catch (final Exception ex) {
-            Mockito.verify(connManager).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+            Mockito.verify(connManager).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
 
             throw ex;
         }
@@ -587,7 +589,7 @@ public class TestMainClientExec {
         try {
             mainClientExec.execute(request, context, execAware);
         } catch (final Exception ex) {
-            Mockito.verify(connManager).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+            Mockito.verify(connManager).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
 
             throw ex;
         }
@@ -607,7 +609,7 @@ public class TestMainClientExec {
         try {
             mainClientExec.execute(request, context, execAware);
         } catch (final Exception ex) {
-            Mockito.verify(connManager).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+            Mockito.verify(connManager).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
 
             throw ex;
         }
@@ -618,7 +620,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(567)
+                .setConnectTimeout(567, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -627,7 +629,7 @@ public class TestMainClientExec {
 
         mainClientExec.establishRoute(endpoint, route, request, context);
 
-        Mockito.verify(connManager).connect(endpoint, 567, TimeUnit.MILLISECONDS, context);
+        Mockito.verify(connManager).connect(endpoint, TimeValue.ofMillis(567), context);
     }
 
     @Test
@@ -635,7 +637,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target, null, proxy, false);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(567)
+                .setConnectTimeout(567, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -644,7 +646,7 @@ public class TestMainClientExec {
 
         mainClientExec.establishRoute(endpoint, route, request, context);
 
-        Mockito.verify(connManager).connect(endpoint, 567, TimeUnit.MILLISECONDS, context);
+        Mockito.verify(connManager).connect(endpoint, TimeValue.ofMillis(567), context);
     }
 
     @Test
@@ -652,7 +654,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target, null, proxy, true);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(321)
+                .setConnectTimeout(321, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -666,7 +668,7 @@ public class TestMainClientExec {
 
         mainClientExec.establishRoute(endpoint, route, request, context);
 
-        Mockito.verify(connManager).connect(endpoint, 321, TimeUnit.MILLISECONDS, context);
+        Mockito.verify(connManager).connect(endpoint, TimeValue.ofMillis(321), context);
         final ArgumentCaptor<ClassicHttpRequest> reqCaptor = ArgumentCaptor.forClass(ClassicHttpRequest.class);
         Mockito.verify(endpoint).execute(
                 reqCaptor.capture(),
@@ -724,7 +726,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target, null, proxy, true);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(567)
+                .setConnectTimeout(567, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -757,7 +759,7 @@ public class TestMainClientExec {
 
         mainClientExec.establishRoute(endpoint, route, request, context);
 
-        Mockito.verify(connManager).connect(endpoint, 567, TimeUnit.MILLISECONDS, context);
+        Mockito.verify(connManager).connect(endpoint, TimeValue.ofMillis(567), context);
         Mockito.verify(instream1).close();
     }
 
@@ -766,7 +768,7 @@ public class TestMainClientExec {
         final HttpRoute route = new HttpRoute(target, null, proxy, true);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(567)
+                .setConnectTimeout(567, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -799,7 +801,7 @@ public class TestMainClientExec {
 
         mainClientExec.establishRoute(endpoint, route, request, context);
 
-        Mockito.verify(connManager).connect(endpoint, 567, TimeUnit.MILLISECONDS, context);
+        Mockito.verify(connManager).connect(endpoint, TimeValue.ofMillis(567), context);
         Mockito.verify(instream1, Mockito.never()).close();
         Mockito.verify(endpoint).close();
     }

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMinimalClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMinimalClientExec.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMinimalClientExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMinimalClientExec.java Mon May  1 10:47:09 2017
@@ -51,6 +51,7 @@ import org.apache.hc.core5.http.HttpExce
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
 import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -98,9 +99,9 @@ public class TestMinimalClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(123)
-                .setSocketTimeout(234)
-                .setConnectionRequestTimeout(345)
+                .setConnectTimeout(123, TimeUnit.MILLISECONDS)
+                .setSocketTimeout(234, TimeUnit.MILLISECONDS)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -115,11 +116,11 @@ public class TestMinimalClientExec {
         Mockito.verify(connRequest).get(345, TimeUnit.MILLISECONDS);
         Mockito.verify(execAware, Mockito.times(1)).setCancellable(connRequest);
         Mockito.verify(execAware, Mockito.times(2)).setCancellable(Mockito.<Cancellable>any());
-        Mockito.verify(connManager).connect(endpoint, 123, TimeUnit.MILLISECONDS, context);
+        Mockito.verify(connManager).connect(endpoint, TimeValue.ofMillis(123), context);
         Mockito.verify(endpoint).setSocketTimeout(234);
         Mockito.verify(endpoint, Mockito.times(1)).execute(request, requestExecutor, context);
         Mockito.verify(endpoint, Mockito.times(1)).close();
-        Mockito.verify(connManager).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(connManager).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
 
         Assert.assertNotNull(finalResponse);
         Assert.assertTrue(finalResponse instanceof CloseableHttpResponse);
@@ -130,9 +131,9 @@ public class TestMinimalClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(123)
-                .setSocketTimeout(234)
-                .setConnectionRequestTimeout(345)
+                .setConnectTimeout(123, TimeUnit.MILLISECONDS)
+                .setSocketTimeout(234, TimeUnit.MILLISECONDS)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -149,13 +150,13 @@ public class TestMinimalClientExec {
                 Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
         Mockito.when(keepAliveStrategy.getKeepAliveDuration(
                 Mockito.same(response),
-                Mockito.<HttpClientContext>any())).thenReturn(678L);
+                Mockito.<HttpClientContext>any())).thenReturn(TimeValue.ofMillis(678L));
 
         final ClassicHttpResponse finalResponse = minimalClientExec.execute(request, context, execAware);
         Mockito.verify(connManager).lease(route, null);
         Mockito.verify(connRequest).get(345, TimeUnit.MILLISECONDS);
         Mockito.verify(endpoint, Mockito.times(1)).execute(request, requestExecutor, context);
-        Mockito.verify(connManager).release(endpoint, null, 678L, TimeUnit.MILLISECONDS);
+        Mockito.verify(connManager).release(endpoint, null, TimeValue.ofMillis(678L));
         Mockito.verify(endpoint, Mockito.never()).close();
 
         Assert.assertNotNull(finalResponse);
@@ -167,9 +168,9 @@ public class TestMinimalClientExec {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
         final RequestConfig config = RequestConfig.custom()
-                .setConnectTimeout(123)
-                .setSocketTimeout(234)
-                .setConnectionRequestTimeout(345)
+                .setConnectTimeout(123, TimeUnit.MILLISECONDS)
+                .setSocketTimeout(234, TimeUnit.MILLISECONDS)
+                .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
                 .build();
         context.setRequestConfig(config);
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
@@ -196,8 +197,7 @@ public class TestMinimalClientExec {
         Mockito.verify(connManager, Mockito.never()).release(
                 Mockito.same(endpoint),
                 Mockito.any(),
-                Mockito.anyInt(),
-                Mockito.<TimeUnit>any());
+                Mockito.<TimeValue>any());
         Mockito.verify(endpoint, Mockito.never()).close();
 
         Assert.assertNotNull(finalResponse);
@@ -205,7 +205,7 @@ public class TestMinimalClientExec {
         finalResponse.close();
 
         Mockito.verify(connManager, Mockito.times(1)).release(
-                endpoint, null, 0, TimeUnit.MILLISECONDS);
+                endpoint, null, TimeValue.ZERO_MILLISECONDS);
         Mockito.verify(endpoint, Mockito.times(1)).close();
     }
 
@@ -213,7 +213,7 @@ public class TestMinimalClientExec {
     public void testSocketTimeoutExistingConnection() throws Exception {
         final HttpRoute route = new HttpRoute(target);
         final HttpClientContext context = new HttpClientContext();
-        final RequestConfig config = RequestConfig.custom().setSocketTimeout(3000).build();
+        final RequestConfig config = RequestConfig.custom().setSocketTimeout(3000, TimeUnit.MILLISECONDS).build();
         final RoutedHttpRequest request = RoutedHttpRequest.adapt(new HttpGet("http://bar/test"), route);
         context.setRequestConfig(config);
         final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
@@ -298,7 +298,7 @@ public class TestMinimalClientExec {
         try {
             minimalClientExec.execute(request, context, execAware);
         } catch (final Exception ex) {
-            Mockito.verify(connManager).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+            Mockito.verify(connManager).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
             throw ex;
         }
     }
@@ -317,7 +317,7 @@ public class TestMinimalClientExec {
         try {
             minimalClientExec.execute(request, context, execAware);
         } catch (final Exception ex) {
-            Mockito.verify(connManager).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+            Mockito.verify(connManager).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
             throw ex;
         }
     }
@@ -336,7 +336,7 @@ public class TestMinimalClientExec {
         try {
             minimalClientExec.execute(request, context, execAware);
         } catch (final Exception ex) {
-            Mockito.verify(connManager).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
+            Mockito.verify(connManager).release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
             throw ex;
         }
     }

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/localserver/LocalServerTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/localserver/LocalServerTestBase.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/localserver/LocalServerTestBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/localserver/LocalServerTestBase.java Mon May  1 10:47:09 2017
@@ -27,15 +27,15 @@
 
 package org.apache.hc.client5.http.localserver;
 
-import java.util.concurrent.TimeUnit;
-
 import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
 import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
 import org.apache.hc.client5.http.impl.sync.HttpClientBuilder;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.config.SocketConfig;
-import org.apache.hc.core5.http.impl.io.bootstrap.HttpServer;
-import org.apache.hc.core5.http.impl.io.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.io.ShutdownType;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.After;
 import org.junit.Before;
 
@@ -69,7 +69,7 @@ public abstract class LocalServerTestBas
     @Before
     public void setUp() throws Exception {
         final SocketConfig socketConfig = SocketConfig.custom()
-                .setSoTimeout(15000)
+                .setSoTimeout(TimeValue.ofSeconds(15))
                 .build();
         this.serverBootstrap = ServerBootstrap.bootstrap()
                 .setSocketConfig(socketConfig)
@@ -91,7 +91,7 @@ public abstract class LocalServerTestBas
             this.httpclient.close();
         }
         if (this.server != null) {
-            this.server.shutdown(10, TimeUnit.SECONDS);
+            this.server.shutdown(ShutdownType.GRACEFUL);
         }
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java Mon May  1 10:47:09 2017
@@ -189,7 +189,7 @@ public class TestRequestAddCookies {
         final HttpRequest request = new BasicHttpRequest("GET", "/");
 
         final HttpClientContext context = HttpClientContext.create();
-        context.setAttribute(HttpCoreContext.HTTP_CONNECTION, null);
+        context.setAttribute(HttpCoreContext.CONNECTION_ENDPOINT, null);
         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
 



Mime
View raw message