hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1784138 [4/5] - in /httpcomponents/httpclient/trunk: httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/ httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/ httpclient5/src/examples/org/apache/hc/client5/h...
Date Thu, 23 Feb 2017 14:32:24 GMT
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=1784138&r1=1784137&r2=1784138&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 Thu Feb 23 14:32:24 2017
@@ -36,10 +36,10 @@ import org.apache.hc.client5.http.protoc
 import org.apache.hc.client5.http.protocol.UserTokenHandler;
 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.HttpException;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.io.HttpClientConnection;
 import org.apache.hc.core5.http.io.HttpRequestHandler;
 import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.apache.hc.core5.http.io.entity.StringEntity;
@@ -119,12 +119,10 @@ public class TestStatefulConnManagement
         }
 
         for (final HttpContext context : contexts) {
-            final String uid = (String) context.getAttribute("user");
-
-            for (int r = 0; r < requestCount; r++) {
-                final String state = (String) context.getAttribute("r" + r);
-                Assert.assertNotNull(state);
-                Assert.assertEquals(uid, state);
+            final String state0 = (String) context.getAttribute("r0");
+            Assert.assertNotNull(state0);
+            for (int r = 1; r < requestCount; r++) {
+                Assert.assertEquals(state0, (String) context.getAttribute("r" + r));
             }
         }
 
@@ -176,13 +174,8 @@ public class TestStatefulConnManagement
                             this.context);
                     this.count++;
 
-                    final HttpClientConnection conn = this.context.getConnection(HttpClientConnection.class);
-                    final HttpContext connContext = (HttpContext) conn;
-                    String connuid = (String) connContext.getAttribute("user");
-                    if (connuid == null) {
-                        connContext.setAttribute("user", this.uid);
-                        connuid = this.uid;
-                    }
+                    final HttpConnection conn = this.context.getConnection();
+                    final String connuid = Integer.toHexString(System.identityHashCode(conn));
                     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=1784138&r1=1784137&r2=1784138&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 Thu Feb 23 14:32:24 2017
@@ -33,19 +33,18 @@ import java.net.Socket;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.client5.http.DnsResolver;
-import org.apache.hc.client5.http.HttpConnectionFactory;
 import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.client5.http.SchemePortResolver;
-import org.apache.hc.client5.http.io.ConnectionRequest;
+import org.apache.hc.client5.http.io.ConnectionEndpoint;
+import org.apache.hc.client5.http.io.LeaseRequest;
 import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
 import org.apache.hc.client5.http.protocol.HttpClientContext;
 import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
 import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.config.ConnectionConfig;
 import org.apache.hc.core5.http.config.Lookup;
 import org.apache.hc.core5.http.config.SocketConfig;
-import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.io.HttpConnectionFactory;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.Assert;
 import org.junit.Before;
@@ -60,7 +59,7 @@ public class TestBasicHttpClientConnecti
     @Mock
     private ManagedHttpClientConnection conn;
     @Mock
-    private HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory;
+    private HttpConnectionFactory<ManagedHttpClientConnection> connFactory;
     @Mock
     private Lookup<ConnectionSocketFactory> socketFactoryRegistry;
     @Mock
@@ -88,26 +87,24 @@ public class TestBasicHttpClientConnecti
         final HttpHost target = new HttpHost("localhost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
-        Assert.assertFalse(conn1.isOpen());
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
+        Assert.assertFalse(endpoint1.isConnected());
 
-        mgr.releaseConnection(conn1, null, 100, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 100, TimeUnit.MILLISECONDS);
 
         Assert.assertNull(mgr.getRoute());
         Assert.assertNull(mgr.getState());
 
-        final ConnectionRequest connRequest2 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
+        final LeaseRequest connRequest2 = mgr.lease(route, null);
+        final ConnectionEndpoint conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
         Assert.assertNotNull(conn2);
-        Assert.assertFalse(conn2.isOpen());
+        Assert.assertFalse(conn2.isConnected());
 
-        Mockito.verify(connFactory, Mockito.times(2)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
     }
 
     @Test
@@ -115,29 +112,27 @@ public class TestBasicHttpClientConnecti
         final HttpHost target = new HttpHost("somehost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        Mockito.when(connFactory.create(Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
 
-        mgr.releaseConnection(conn1, null, 10000, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 10000, TimeUnit.MILLISECONDS);
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
 
-        final ConnectionRequest connRequest2 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
+        final LeaseRequest connRequest2 = mgr.lease(route, null);
+        final ConnectionEndpoint conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
         Assert.assertNotNull(conn2);
-        Assert.assertTrue(conn2.isOpen());
+        Assert.assertTrue(conn2.isConnected());
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
     }
 
     @Test
@@ -145,30 +140,27 @@ public class TestBasicHttpClientConnecti
         final HttpHost target = new HttpHost("somehost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, "some state");
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, "some state");
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
 
-        mgr.releaseConnection(conn1, "some other state", 10000, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, "some other state", 10000, TimeUnit.MILLISECONDS);
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals("some other state", mgr.getState());
 
-        final ConnectionRequest connRequest2 = mgr.requestConnection(route, "some other state");
-        final HttpClientConnection conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
+        final LeaseRequest connRequest2 = mgr.lease(route, "some other state");
+        final ConnectionEndpoint conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
         Assert.assertNotNull(conn2);
-        Assert.assertTrue(conn2.isOpen());
+        Assert.assertTrue(conn2.isConnected());
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
     }
 
     @Test
@@ -176,35 +168,30 @@ public class TestBasicHttpClientConnecti
         final HttpHost target1 = new HttpHost("somehost", 80);
         final HttpRoute route1 = new HttpRoute(target1);
 
-        Mockito.when(connFactory.create(
-                Mockito.<HttpRoute>any(), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route1, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route1, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route1), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
 
-        mgr.releaseConnection(conn1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
 
         Assert.assertEquals(route1, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
 
         final HttpHost target2 = new HttpHost("otherhost", 80);
         final HttpRoute route2 = new HttpRoute(target2);
-        final ConnectionRequest connRequest2 = mgr.requestConnection(route2, null);
-        final HttpClientConnection conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
+        final LeaseRequest connRequest2 = mgr.lease(route2, null);
+        final ConnectionEndpoint conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
         Assert.assertNotNull(conn2);
-        Assert.assertFalse(conn2.isOpen());
+        Assert.assertFalse(conn2.isConnected());
 
         Mockito.verify(conn).close();
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route1), Mockito.<ConnectionConfig>any());
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route2), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
     }
 
     @Test
@@ -212,49 +199,41 @@ public class TestBasicHttpClientConnecti
         final HttpHost target = new HttpHost("somehost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
 
-        mgr.releaseConnection(conn1, null, 10, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 10, TimeUnit.MILLISECONDS);
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
 
         Thread.sleep(50);
 
-        final ConnectionRequest connRequest2 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
+        final LeaseRequest connRequest2 = mgr.lease(route, null);
+        final ConnectionEndpoint conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
         Assert.assertNotNull(conn2);
-        Assert.assertFalse(conn2.isOpen());
+        Assert.assertFalse(conn2.isConnected());
 
         Mockito.verify(conn).close();
-        Mockito.verify(connFactory, Mockito.times(2)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void testLeaseInvalidArg() throws Exception {
-        mgr.requestConnection(null, null);
+        Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
     }
 
     @Test(expected=IllegalArgumentException.class)
     public void testReleaseInvalidArg() throws Exception {
-        mgr.releaseConnection(null, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(null, null, 0, TimeUnit.MILLISECONDS);
     }
 
     @Test(expected=IllegalStateException.class)
     public void testReleaseAnotherConnection() throws Exception {
-        final HttpClientConnection wrongCon = Mockito.mock(HttpClientConnection.class);
-        mgr.releaseConnection(wrongCon, null, 0, TimeUnit.MILLISECONDS);
+        final ConnectionEndpoint wrongCon = Mockito.mock(ConnectionEndpoint.class);
+        mgr.release(wrongCon, null, 0, TimeUnit.MILLISECONDS);
     }
 
     @Test
@@ -262,26 +241,24 @@ public class TestBasicHttpClientConnecti
         final HttpHost target = new HttpHost("somehost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
 
-        mgr.releaseConnection(conn1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
 
-        mgr.shutdown();
+        mgr.close();
 
         Mockito.verify(conn, Mockito.times(1)).shutdown();
 
         try {
-            final ConnectionRequest connRequest2 = mgr.requestConnection(route, null);
+            final LeaseRequest connRequest2 = mgr.lease(route, null);
             connRequest2.get(0, TimeUnit.MILLISECONDS);
             Assert.fail("IllegalStateException expected");
         } catch (final IllegalStateException ex) {
@@ -290,7 +267,7 @@ public class TestBasicHttpClientConnecti
         // Should have no effect
         mgr.closeExpired();
         mgr.closeIdle(0L, TimeUnit.MILLISECONDS);
-        mgr.shutdown();
+        mgr.close();
 
         Mockito.verify(conn, Mockito.times(1)).shutdown();
     }
@@ -300,19 +277,17 @@ public class TestBasicHttpClientConnecti
         final HttpHost target = new HttpHost("somehost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
 
-        mgr.releaseConnection(conn1, null, 10, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 10, TimeUnit.MILLISECONDS);
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
@@ -329,19 +304,17 @@ public class TestBasicHttpClientConnecti
         final HttpHost target = new HttpHost("somehost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
-        Mockito.verify(connFactory, Mockito.times(1)).create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any());
+        Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
 
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
 
-        mgr.releaseConnection(conn1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
 
         Assert.assertEquals(route, mgr.getRoute());
         Assert.assertEquals(null, mgr.getState());
@@ -358,13 +331,12 @@ public class TestBasicHttpClientConnecti
         final HttpHost target = new HttpHost("somehost", 80);
         final HttpRoute route = new HttpRoute(target);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
-        mgr.releaseConnection(conn1, null, 100, TimeUnit.MILLISECONDS);
+        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.getConnection(route, null);
         mgr.getConnection(route, null);
@@ -377,12 +349,11 @@ public class TestBasicHttpClientConnecti
         final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
         final HttpRoute route = new HttpRoute(target, local, true);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
         final HttpClientContext context = HttpClientContext.create();
         final SocketConfig sconfig = SocketConfig.custom().build();
@@ -401,7 +372,7 @@ public class TestBasicHttpClientConnecti
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenReturn(socket);
 
-        mgr.connect(conn1, route, 123, context);
+        mgr.connect(endpoint1, 123, TimeUnit.MILLISECONDS, context);
 
         Mockito.verify(dnsResolver, Mockito.times(1)).resolve("somehost");
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(target);
@@ -409,8 +380,6 @@ public class TestBasicHttpClientConnecti
         Mockito.verify(plainSocketFactory, Mockito.times(1)).connectSocket(123, socket, target,
                 new InetSocketAddress(remote, 8443),
                 new InetSocketAddress(local, 0), context);
-
-        mgr.routeComplete(conn1, route, context);
     }
 
     @Test
@@ -421,12 +390,11 @@ public class TestBasicHttpClientConnecti
         final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
         final HttpRoute route = new HttpRoute(target, local, proxy, true);
 
-        Mockito.when(connFactory.create(
-                Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
+        Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
+        Assert.assertNotNull(endpoint1);
 
         final HttpClientContext context = HttpClientContext.create();
         final SocketConfig sconfig = SocketConfig.custom().build();
@@ -447,7 +415,7 @@ public class TestBasicHttpClientConnecti
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenReturn(socket);
 
-        mgr.connect(conn1, route, 123, context);
+        mgr.connect(endpoint1, 123, TimeUnit.MILLISECONDS, context);
 
         Mockito.verify(dnsResolver, Mockito.times(1)).resolve("someproxy");
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(proxy);
@@ -458,13 +426,11 @@ public class TestBasicHttpClientConnecti
 
         Mockito.when(conn.getSocket()).thenReturn(socket);
 
-        mgr.upgrade(conn1, route, context);
+        mgr.upgrade(endpoint1, context);
 
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(target);
         Mockito.verify(sslSocketFactory, Mockito.times(1)).createLayeredSocket(
                 socket, "somehost", 8443, context);
-
-        mgr.routeComplete(conn1, route, 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=1784138&r1=1784137&r2=1784138&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 Thu Feb 23 14:32:24 2017
@@ -243,6 +243,8 @@ public class TestHttpClientConnectionOpe
         final HttpContext context = new BasicHttpContext();
         final HttpHost host = new HttpHost("somehost", -1, "https");
 
+        Mockito.when(conn.isOpen()).thenReturn(true);
+        Mockito.when(conn.getSocket()).thenReturn(socket);
         Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(sslSocketFactory);
         Mockito.when(schemePortResolver.resolve(host)).thenReturn(443);
         Mockito.when(sslSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);

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=1784138&r1=1784137&r2=1784138&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 Thu Feb 23 14:32:24 2017
@@ -34,20 +34,18 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.hc.client5.http.ConnectionPoolTimeoutException;
 import org.apache.hc.client5.http.DnsResolver;
 import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.client5.http.SchemePortResolver;
-import org.apache.hc.client5.http.io.ConnectionRequest;
+import org.apache.hc.client5.http.io.ConnectionEndpoint;
+import org.apache.hc.client5.http.io.LeaseRequest;
 import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
 import org.apache.hc.client5.http.protocol.HttpClientContext;
 import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
 import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.config.ConnectionConfig;
 import org.apache.hc.core5.http.config.Lookup;
 import org.apache.hc.core5.http.config.SocketConfig;
-import org.apache.hc.core5.http.io.HttpClientConnection;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.pool.PoolEntry;
 import org.apache.hc.core5.pool.StrictConnPool;
@@ -109,14 +107,12 @@ public class TestPoolingHttpClientConnec
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
-        Assert.assertNotNull(conn1);
-        Assert.assertNotSame(conn, conn1);
-        final CPoolProxy poolProxy = CPoolProxy.getProxy(conn1);
-        poolProxy.markRouteComplete();
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(1, TimeUnit.SECONDS);
+        Assert.assertNotNull(endpoint1);
+        Assert.assertNotSame(conn, endpoint1);
 
-        mgr.releaseConnection(conn1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
 
         Mockito.verify(pool).release(entry, true);
     }
@@ -138,12 +134,12 @@ public class TestPoolingHttpClientConnec
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
-        Assert.assertNotNull(conn1);
-        Assert.assertNotSame(conn, conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(1, TimeUnit.SECONDS);
+        Assert.assertNotNull(endpoint1);
+        Assert.assertNotSame(conn, endpoint1);
 
-        mgr.releaseConnection(conn1, null, 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, null, 0, TimeUnit.MILLISECONDS);
 
         Mockito.verify(pool).release(entry, false);
     }
@@ -160,11 +156,11 @@ public class TestPoolingHttpClientConnec
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
         connRequest1.get(1, TimeUnit.SECONDS);
     }
 
-    @Test(expected=ConnectionPoolTimeoutException.class)
+    @Test(expected=TimeoutException.class)
     public void testLeaseFutureTimeout() throws Exception {
         final HttpHost target = new HttpHost("localhost", 80);
         final HttpRoute route = new HttpRoute(target);
@@ -173,7 +169,7 @@ public class TestPoolingHttpClientConnec
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenThrow(new TimeoutException());
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
         connRequest1.get(1, TimeUnit.SECONDS);
     }
 
@@ -190,14 +186,12 @@ public class TestPoolingHttpClientConnec
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
         Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
-        Assert.assertNotNull(conn1);
-        Assert.assertTrue(conn1.isOpen());
-        final CPoolProxy poolProxy = CPoolProxy.getProxy(conn1);
-        poolProxy.markRouteComplete();
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(1, TimeUnit.SECONDS);
+        Assert.assertNotNull(endpoint1);
+        Assert.assertTrue(endpoint1.isConnected());
 
-        mgr.releaseConnection(conn1, "some state", 10, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, "some state", 10, TimeUnit.MILLISECONDS);
 
         Mockito.verify(pool).release(entry, true);
         Assert.assertEquals("some state", entry.getState());
@@ -216,14 +210,12 @@ public class TestPoolingHttpClientConnec
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
         Mockito.when(conn.isOpen()).thenReturn(Boolean.FALSE);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
-        Assert.assertNotNull(conn1);
-        Assert.assertFalse(conn1.isOpen());
-        final CPoolProxy poolProxy = CPoolProxy.getProxy(conn1);
-        poolProxy.markRouteComplete();
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(1, TimeUnit.SECONDS);
+        Assert.assertNotNull(endpoint1);
+        Assert.assertFalse(endpoint1.isConnected());
 
-        mgr.releaseConnection(conn1, "some state", 0, TimeUnit.MILLISECONDS);
+        mgr.release(endpoint1, "some state", 0, TimeUnit.MILLISECONDS);
 
         Mockito.verify(pool).release(entry, false);
         Assert.assertEquals(null, entry.getState());
@@ -240,16 +232,14 @@ public class TestPoolingHttpClientConnec
         entry.assignConnection(conn);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
-        Mockito.when(conn.isOpen()).thenReturn(true);
+        Mockito.when(conn.isOpen()).thenReturn(false);
         Mockito.when(future.isCancelled()).thenReturn(false);
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
-        Assert.assertNotNull(conn1);
-        final CPoolProxy poolProxy = CPoolProxy.getProxy(conn1);
-        poolProxy.markRouteComplete();
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(1, TimeUnit.SECONDS);
+        Assert.assertNotNull(endpoint1);
 
         final HttpClientContext context = HttpClientContext.create();
         final SocketConfig sconfig = SocketConfig.custom().build();
@@ -268,7 +258,7 @@ public class TestPoolingHttpClientConnec
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenReturn(socket);
 
-        mgr.connect(conn1, route, 123, context);
+        mgr.connect(endpoint1, 123, TimeUnit.MILLISECONDS, context);
 
         Mockito.verify(dnsResolver, Mockito.times(1)).resolve("somehost");
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(target);
@@ -276,8 +266,6 @@ public class TestPoolingHttpClientConnec
         Mockito.verify(plainSocketFactory, Mockito.times(1)).connectSocket(123, socket, target,
                 new InetSocketAddress(remote, 8443),
                 new InetSocketAddress(local, 0), context);
-
-        mgr.routeComplete(conn1, route, context);
     }
 
     @Test
@@ -292,24 +280,22 @@ public class TestPoolingHttpClientConnec
         entry.assignConnection(conn);
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
-        Mockito.when(conn.isOpen()).thenReturn(true);
+        Mockito.when(conn.isOpen()).thenReturn(false);
         Mockito.when(future.isCancelled()).thenReturn(false);
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
 
-        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
-        final HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
-        Assert.assertNotNull(conn1);
+        final LeaseRequest connRequest1 = mgr.lease(route, null);
+        final ConnectionEndpoint endpoint1 = connRequest1.get(1, TimeUnit.SECONDS);
+        Assert.assertNotNull(endpoint1);
 
         final ConnectionSocketFactory plainsf = Mockito.mock(ConnectionSocketFactory.class);
         final LayeredConnectionSocketFactory sslsf = Mockito.mock(LayeredConnectionSocketFactory.class);
         final Socket mockSock = Mockito.mock(Socket.class);
         final HttpClientContext context = HttpClientContext.create();
         final SocketConfig sconfig = SocketConfig.custom().build();
-        final ConnectionConfig cconfig = ConnectionConfig.custom().build();
 
         mgr.setDefaultSocketConfig(sconfig);
-        mgr.setDefaultConnectionConfig(cconfig);
 
         Mockito.when(dnsResolver.resolve("someproxy")).thenReturn(new InetAddress[] {remote});
         Mockito.when(schemePortResolver.resolve(proxy)).thenReturn(8080);
@@ -325,7 +311,7 @@ public class TestPoolingHttpClientConnec
                 Mockito.<InetSocketAddress>any(),
                 Mockito.<HttpContext>any())).thenReturn(mockSock);
 
-        mgr.connect(conn1, route, 123, context);
+        mgr.connect(endpoint1, 123, TimeUnit.MILLISECONDS, context);
 
         Mockito.verify(dnsResolver, Mockito.times(1)).resolve("someproxy");
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(proxy);
@@ -334,15 +320,14 @@ public class TestPoolingHttpClientConnec
                 new InetSocketAddress(remote, 8080),
                 new InetSocketAddress(local, 0), context);
 
+        Mockito.when(conn.isOpen()).thenReturn(true);
         Mockito.when(conn.getSocket()).thenReturn(mockSock);
 
-        mgr.upgrade(conn1, route, context);
+        mgr.upgrade(endpoint1, context);
 
         Mockito.verify(schemePortResolver, Mockito.times(1)).resolve(target);
         Mockito.verify(sslsf, Mockito.times(1)).createLayeredSocket(
                 mockSock, "somehost", 8443, context);
-
-        mgr.routeComplete(conn1, route, context);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultProxyRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultProxyRoutePlanner.java?rev=1784138&r1=1784137&r2=1784138&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultProxyRoutePlanner.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultProxyRoutePlanner.java Thu Feb 23 14:32:24 2017
@@ -61,10 +61,9 @@ public class TestDefaultProxyRoutePlanne
     @Test
     public void testDefaultProxyDirect() throws Exception {
         final HttpHost target = new HttpHost("somehost", 80, "http");
-        final HttpRequest request = new BasicHttpRequest("GET", "/");
 
         final HttpContext context = new BasicHttpContext();
-        final HttpRoute route = routePlanner.determineRoute(target, request, context);
+        final HttpRoute route = routePlanner.determineRoute(target, context);
 
         Assert.assertEquals(target, route.getTargetHost());
         Assert.assertEquals(defaultProxy, route.getProxyHost());
@@ -80,7 +79,7 @@ public class TestDefaultProxyRoutePlanne
 
         final HttpClientContext context = HttpClientContext.create();
         context.setRequestConfig(RequestConfig.custom().setProxy(proxy).build());
-        final HttpRoute route = routePlanner.determineRoute(target, request, context);
+        final HttpRoute route = routePlanner.determineRoute(target, context);
 
         Assert.assertEquals(target, route.getTargetHost());
         Assert.assertEquals(proxy, route.getProxyHost());

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultRoutePlanner.java?rev=1784138&r1=1784137&r2=1784138&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultRoutePlanner.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultRoutePlanner.java Thu Feb 23 14:32:24 2017
@@ -27,6 +27,8 @@
 
 package org.apache.hc.client5.http.impl.routing;
 
+import java.net.URI;
+
 import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.client5.http.SchemePortResolver;
 import org.apache.hc.client5.http.config.RequestConfig;
@@ -37,6 +39,8 @@ import org.apache.hc.core5.http.Protocol
 import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.apache.hc.core5.http.protocol.BasicHttpContext;
 import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.net.URIAuthority;
+import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,10 +64,9 @@ public class TestDefaultRoutePlanner {
     @Test
     public void testDirect() throws Exception {
         final HttpHost target = new HttpHost("somehost", 80, "http");
-        final HttpRequest request = new BasicHttpRequest("GET", "/");
 
         final HttpContext context = new BasicHttpContext();
-        final HttpRoute route = routePlanner.determineRoute(target, request, context);
+        final HttpRoute route = routePlanner.determineRoute(target, context);
 
         Assert.assertEquals(target, route.getTargetHost());
         Assert.assertEquals(1, route.getHopCount());
@@ -75,10 +78,9 @@ public class TestDefaultRoutePlanner {
     public void testDirectDefaultPort() throws Exception {
         final HttpHost target = new HttpHost("somehost", -1, "https");
         Mockito.when(schemePortResolver.resolve(target)).thenReturn(443);
-        final HttpRequest request = new BasicHttpRequest("GET", "/");
 
         final HttpContext context = new BasicHttpContext();
-        final HttpRoute route = routePlanner.determineRoute(target, request, context);
+        final HttpRoute route = routePlanner.determineRoute(target, context);
 
         Assert.assertEquals(new HttpHost("somehost", 443, "https"), route.getTargetHost());
         Assert.assertEquals(1, route.getHopCount());
@@ -89,11 +91,10 @@ public class TestDefaultRoutePlanner {
     public void testViaProxy() throws Exception {
         final HttpHost target = new HttpHost("somehost", 80, "http");
         final HttpHost proxy = new HttpHost("proxy", 8080);
-        final HttpRequest request = new BasicHttpRequest("GET", "/");
 
         final HttpClientContext context = HttpClientContext.create();
         context.setRequestConfig(RequestConfig.custom().setProxy(proxy).build());
-        final HttpRoute route = routePlanner.determineRoute(target, request, context);
+        final HttpRoute route = routePlanner.determineRoute(target, context);
 
         Assert.assertEquals(target, route.getTargetHost());
         Assert.assertEquals(proxy, route.getProxyHost());
@@ -104,10 +105,28 @@ public class TestDefaultRoutePlanner {
 
     @Test(expected= ProtocolException.class)
     public void testNullTarget() throws Exception {
-        final HttpRequest request = new BasicHttpRequest("GET", "/");
+        final HttpContext context = new BasicHttpContext();
+        routePlanner.determineRoute(null, context);
+    }
+
+    @Test
+    public void testDetermineHost() throws Exception {
+        final HttpContext context = new BasicHttpContext();
+        final HttpRequest request1 = new BasicHttpRequest("GET", "/");
+        final HttpHost host1 = routePlanner.determineTargetHost(request1, context);
+        Assert.assertThat(host1, CoreMatchers.nullValue());
+
+        final HttpRequest request2 = new BasicHttpRequest("GET", new URI("https://somehost:8443/"));
+        final HttpHost host2 = routePlanner.determineTargetHost(request2, context);
+        Assert.assertThat(host2, CoreMatchers.equalTo(new HttpHost("somehost", 8443, "https")));
+    }
 
+    @Test(expected = ProtocolException.class)
+    public void testDetermineHostMissingScheme() throws Exception {
         final HttpContext context = new BasicHttpContext();
-        routePlanner.determineRoute(null, request, context);
+        final HttpRequest request1 = new BasicHttpRequest("GET", "/");
+        request1.setAuthority(new URIAuthority("host"));
+        routePlanner.determineTargetHost(request1, context);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestSystemDefaultRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestSystemDefaultRoutePlanner.java?rev=1784138&r1=1784137&r2=1784138&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestSystemDefaultRoutePlanner.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestSystemDefaultRoutePlanner.java Thu Feb 23 14:32:24 2017
@@ -38,8 +38,6 @@ import java.util.List;
 import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.client5.http.SchemePortResolver;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.apache.hc.core5.http.protocol.BasicHttpContext;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.Assert;
@@ -68,10 +66,9 @@ public class TestSystemDefaultRoutePlann
     @Test
     public void testDirect() throws Exception {
         final HttpHost target = new HttpHost("somehost", 80, "http");
-        final HttpRequest request = new BasicHttpRequest("GET", "/");
 
         final HttpContext context = new BasicHttpContext();
-        final HttpRoute route = routePlanner.determineRoute(target, request, context);
+        final HttpRoute route = routePlanner.determineRoute(target, context);
 
         Assert.assertEquals(target, route.getTargetHost());
         Assert.assertEquals(1, route.getHopCount());
@@ -83,10 +80,9 @@ public class TestSystemDefaultRoutePlann
     public void testDirectDefaultPort() throws Exception {
         final HttpHost target = new HttpHost("somehost", -1, "https");
         Mockito.when(schemePortResolver.resolve(target)).thenReturn(443);
-        final HttpRequest request = new BasicHttpRequest("GET", "/");
 
         final HttpContext context = new BasicHttpContext();
-        final HttpRoute route = routePlanner.determineRoute(target, request, context);
+        final HttpRoute route = routePlanner.determineRoute(target, context);
 
         Assert.assertEquals(new HttpHost("somehost", 443, "https"), route.getTargetHost());
         Assert.assertEquals(1, route.getHopCount());
@@ -109,11 +105,9 @@ public class TestSystemDefaultRoutePlann
         Mockito.when(proxySelector.select(new URI("http://somehost:80"))).thenReturn(proxies);
 
         final HttpHost target = new HttpHost("somehost", 80, "http");
-        final HttpRequest request =
-            new BasicHttpRequest("GET", "/");
 
         final HttpContext context = new BasicHttpContext();
-        final HttpRoute route = routePlanner.determineRoute(target, request, context);
+        final HttpRoute route = routePlanner.determineRoute(target, context);
 
         Assert.assertEquals(target, route.getTargetHost());
         Assert.assertEquals(2, route.getHopCount());

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestDefaultBackoffStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestDefaultBackoffStrategy.java?rev=1784138&r1=1784137&r2=1784138&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestDefaultBackoffStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestDefaultBackoffStrategy.java Thu Feb 23 14:32:24 2017
@@ -32,8 +32,7 @@ import static org.junit.Assert.assertTru
 import java.net.ConnectException;
 import java.net.SocketTimeoutException;
 
-import org.apache.hc.client5.http.ConnectionPoolTimeoutException;
-import org.apache.hc.client5.http.sync.ConnectionBackoffStrategy;
+import org.apache.hc.core5.http.ConnectionRequestTimeoutException;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.message.BasicHttpResponse;
@@ -51,11 +50,6 @@ public class TestDefaultBackoffStrategy
     }
 
     @Test
-    public void isABackoffStrategy() {
-        assertTrue(impl instanceof ConnectionBackoffStrategy);
-    }
-
-    @Test
     public void backsOffForSocketTimeouts() {
         assertTrue(impl.shouldBackoff(new SocketTimeoutException()));
     }
@@ -67,7 +61,7 @@ public class TestDefaultBackoffStrategy
 
     @Test
     public void doesNotBackOffForConnectionManagerTimeout() {
-        assertFalse(impl.shouldBackoff(new ConnectionPoolTimeoutException()));
+        assertFalse(impl.shouldBackoff(new ConnectionRequestTimeoutException()));
     }
 
     @Test

Copied: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java (from r1784071, httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestConnectionHolder.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java?p2=httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java&p1=httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestConnectionHolder.java&r1=1784071&r2=1784138&rev=1784138&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestConnectionHolder.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java Thu Feb 23 14:32:24 2017
@@ -29,28 +29,32 @@ package org.apache.hc.client5.http.impl.
 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.http.io.HttpClientConnection;
 import org.apache.logging.log4j.Logger;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
 
 @SuppressWarnings({"static-access"}) // test code
-public class TestConnectionHolder {
+public class TestEndpointHolder {
 
+    @Mock
     private Logger log;
+    @Mock
     private HttpClientConnectionManager mgr;
-    private HttpClientConnection conn;
-    private ConnectionHolder connHolder;
+    @Mock
+    private ConnectionEndpoint endpoint;
+
+    private EndpointHolder connHolder;
 
     @Before
     public void setup() {
-        log = Mockito.mock(Logger.class);
-        mgr = Mockito.mock(HttpClientConnectionManager.class);
-        conn = Mockito.mock(HttpClientConnection.class);
-        connHolder = new ConnectionHolder(log, mgr, conn);
+        MockitoAnnotations.initMocks(this);
+        connHolder = new EndpointHolder(log, mgr, endpoint);
     }
 
     @Test
@@ -59,14 +63,14 @@ public class TestConnectionHolder {
 
         Assert.assertTrue(connHolder.isReleased());
 
-        Mockito.verify(conn).shutdown();
-        Mockito.verify(mgr).releaseConnection(conn, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(endpoint).shutdown();
+        Mockito.verify(mgr).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
 
         connHolder.abortConnection();
 
-        Mockito.verify(conn, Mockito.times(1)).shutdown();
-        Mockito.verify(mgr, Mockito.times(1)).releaseConnection(
-                Mockito.<HttpClientConnection>any(),
+        Mockito.verify(endpoint, Mockito.times(1)).shutdown();
+        Mockito.verify(mgr, Mockito.times(1)).release(
+                Mockito.<ConnectionEndpoint>any(),
                 Mockito.anyObject(),
                 Mockito.anyLong(),
                 Mockito.<TimeUnit>any());
@@ -74,14 +78,14 @@ public class TestConnectionHolder {
 
     @Test
     public void testAbortConnectionIOError() throws Exception {
-        Mockito.doThrow(new IOException()).when(conn).shutdown();
+        Mockito.doThrow(new IOException()).when(endpoint).shutdown();
 
         connHolder.abortConnection();
 
         Assert.assertTrue(connHolder.isReleased());
 
-        Mockito.verify(conn).shutdown();
-        Mockito.verify(mgr).releaseConnection(conn, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(endpoint).shutdown();
+        Mockito.verify(mgr).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
     }
 
     @Test
@@ -90,14 +94,14 @@ public class TestConnectionHolder {
 
         Assert.assertTrue(connHolder.isReleased());
 
-        Mockito.verify(conn).shutdown();
-        Mockito.verify(mgr).releaseConnection(conn, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(endpoint).shutdown();
+        Mockito.verify(mgr).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
 
         Assert.assertFalse(connHolder.cancel());
 
-        Mockito.verify(conn, Mockito.times(1)).shutdown();
-        Mockito.verify(mgr, Mockito.times(1)).releaseConnection(
-                Mockito.<HttpClientConnection>any(),
+        Mockito.verify(endpoint, Mockito.times(1)).shutdown();
+        Mockito.verify(mgr, Mockito.times(1)).release(
+                Mockito.<ConnectionEndpoint>any(),
                 Mockito.anyObject(),
                 Mockito.anyLong(),
                 Mockito.<TimeUnit>any());
@@ -113,13 +117,13 @@ public class TestConnectionHolder {
 
         Assert.assertTrue(connHolder.isReleased());
 
-        Mockito.verify(conn, Mockito.never()).close();
-        Mockito.verify(mgr).releaseConnection(conn, "some state", 100, TimeUnit.SECONDS);
+        Mockito.verify(endpoint, Mockito.never()).close();
+        Mockito.verify(mgr).release(endpoint, "some state", 100000, TimeUnit.MILLISECONDS);
 
         connHolder.releaseConnection();
 
-        Mockito.verify(mgr, Mockito.times(1)).releaseConnection(
-                Mockito.<HttpClientConnection>any(),
+        Mockito.verify(mgr, Mockito.times(1)).release(
+                Mockito.<ConnectionEndpoint>any(),
                 Mockito.anyObject(),
                 Mockito.anyLong(),
                 Mockito.<TimeUnit>any());
@@ -135,13 +139,13 @@ public class TestConnectionHolder {
 
         Assert.assertTrue(connHolder.isReleased());
 
-        Mockito.verify(conn, Mockito.times(1)).close();
-        Mockito.verify(mgr).releaseConnection(conn, null, 0, TimeUnit.MILLISECONDS);
+        Mockito.verify(endpoint, Mockito.times(1)).close();
+        Mockito.verify(mgr).release(endpoint, null, 0, TimeUnit.MILLISECONDS);
 
         connHolder.releaseConnection();
 
-        Mockito.verify(mgr, Mockito.times(1)).releaseConnection(
-                Mockito.<HttpClientConnection>any(),
+        Mockito.verify(mgr, Mockito.times(1)).release(
+                Mockito.<ConnectionEndpoint>any(),
                 Mockito.anyObject(),
                 Mockito.anyLong(),
                 Mockito.<TimeUnit>any());

Propchange: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestIdleConnectionEvictor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestIdleConnectionEvictor.java?rev=1784138&r1=1784137&r2=1784138&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestIdleConnectionEvictor.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestIdleConnectionEvictor.java Thu Feb 23 14:32:24 2017
@@ -29,7 +29,7 @@ package org.apache.hc.client5.http.impl.
 
 import java.util.concurrent.TimeUnit;
 
-import org.apache.hc.client5.http.io.HttpClientConnectionManager;
+import org.apache.hc.core5.pool.ConnPoolControl;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -41,7 +41,7 @@ public class TestIdleConnectionEvictor {
 
     @Test
     public void testEvictExpiredAndIdle() throws Exception {
-        final HttpClientConnectionManager cm = Mockito.mock(HttpClientConnectionManager.class);
+        final ConnPoolControl<?> cm = Mockito.mock(ConnPoolControl.class);
         final IdleConnectionEvictor connectionEvictor = new IdleConnectionEvictor(cm,
                 500, TimeUnit.MILLISECONDS, 3, TimeUnit.SECONDS);
         connectionEvictor.start();
@@ -60,7 +60,7 @@ public class TestIdleConnectionEvictor {
 
     @Test
     public void testEvictExpiredOnly() throws Exception {
-        final HttpClientConnectionManager cm = Mockito.mock(HttpClientConnectionManager.class);
+        final ConnPoolControl<?> cm = Mockito.mock(ConnPoolControl.class);
         final IdleConnectionEvictor connectionEvictor = new IdleConnectionEvictor(cm,
                 500, TimeUnit.MILLISECONDS, 0, TimeUnit.SECONDS);
         connectionEvictor.start();

Modified: httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestInternalHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestInternalHttpClient.java?rev=1784138&r1=1784137&r2=1784138&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestInternalHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestInternalHttpClient.java Thu Feb 23 14:32:24 2017
@@ -36,7 +36,6 @@ import org.apache.hc.client5.http.auth.C
 import org.apache.hc.client5.http.config.RequestConfig;
 import org.apache.hc.client5.http.cookie.CookieSpecProvider;
 import org.apache.hc.client5.http.cookie.CookieStore;
-import org.apache.hc.client5.http.io.HttpClientConnectionManager;
 import org.apache.hc.client5.http.methods.HttpGet;
 import org.apache.hc.client5.http.methods.RoutedHttpRequest;
 import org.apache.hc.client5.http.protocol.ClientProtocolException;
@@ -44,12 +43,10 @@ import org.apache.hc.client5.http.protoc
 import org.apache.hc.client5.http.routing.HttpRoutePlanner;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.config.Lookup;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 
 /**
@@ -59,7 +56,6 @@ import org.mockito.Mockito;
 public class TestInternalHttpClient {
 
     private ClientExecChain execChain;
-    private HttpClientConnectionManager connManager;
     private HttpRoutePlanner routePlanner;
     private Lookup<CookieSpecProvider> cookieSpecRegistry;
     private Lookup<AuthSchemeProvider> authSchemeRegistry;
@@ -75,7 +71,6 @@ public class TestInternalHttpClient {
     @Before
     public void setup() throws Exception {
         execChain = Mockito.mock(ClientExecChain.class);
-        connManager = Mockito.mock(HttpClientConnectionManager.class);
         routePlanner = Mockito.mock(HttpRoutePlanner.class);
         cookieSpecRegistry = Mockito.mock(Lookup.class);
         authSchemeRegistry = Mockito.mock(Lookup.class);
@@ -85,7 +80,7 @@ public class TestInternalHttpClient {
         closeable1 = Mockito.mock(Closeable.class);
         closeable2 = Mockito.mock(Closeable.class);
 
-        client = new InternalHttpClient(execChain, connManager, routePlanner,
+        client = new InternalHttpClient(execChain, routePlanner,
                 cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider,
                 defaultConfig, Arrays.asList(closeable1, closeable2));
 
@@ -96,17 +91,12 @@ public class TestInternalHttpClient {
         final HttpGet httpget = new HttpGet("http://somehost/stuff");
         final HttpRoute route = new HttpRoute(new HttpHost("somehost", 80));
 
-        final ArgumentCaptor<HttpRequest> argcap = ArgumentCaptor.forClass(HttpRequest.class);
         Mockito.when(routePlanner.determineRoute(
                 Mockito.eq(new HttpHost("somehost")),
-                argcap.capture(),
                 Mockito.<HttpClientContext>any())).thenReturn(route);
 
         client.execute(httpget);
 
-        Assert.assertNotNull(argcap.getValue());
-        Assert.assertSame(httpget, argcap.getValue());
-
         Mockito.verify(execChain).execute(
                 Mockito.<RoutedHttpRequest>any(),
                 Mockito.<HttpClientContext>any(),
@@ -120,7 +110,6 @@ public class TestInternalHttpClient {
 
         Mockito.when(routePlanner.determineRoute(
                 Mockito.eq(new HttpHost("somehost")),
-                Mockito.<RoutedHttpRequest>any(),
                 Mockito.<HttpClientContext>any())).thenReturn(route);
         Mockito.when(execChain.execute(
                 Mockito.<RoutedHttpRequest>any(),
@@ -137,7 +126,6 @@ public class TestInternalHttpClient {
 
         Mockito.when(routePlanner.determineRoute(
                 Mockito.eq(new HttpHost("somehost")),
-                Mockito.<RoutedHttpRequest>any(),
                 Mockito.<HttpClientContext>any())).thenReturn(route);
 
         final HttpClientContext context = HttpClientContext.create();
@@ -157,7 +145,6 @@ public class TestInternalHttpClient {
 
         Mockito.when(routePlanner.determineRoute(
                 Mockito.eq(new HttpHost("somehost")),
-                Mockito.<RoutedHttpRequest>any(),
                 Mockito.<HttpClientContext>any())).thenReturn(route);
 
         final RequestConfig config = RequestConfig.custom().build();
@@ -176,7 +163,6 @@ public class TestInternalHttpClient {
 
         Mockito.when(routePlanner.determineRoute(
                 Mockito.eq(new HttpHost("somehost")),
-                Mockito.<RoutedHttpRequest>any(),
                 Mockito.<HttpClientContext>any())).thenReturn(route);
 
         final HttpClientContext context = HttpClientContext.create();



Mime
View raw message