final HttpHost target = new HttpHost("somehost");
final HttpRoute route = new HttpRoute(target);
Mockito.when(connFactory.create(Mockito.eq(route), Mockito.<ConnectionConfig>any())).thenReturn(conn);
final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
Assert.assertNotNull(conn1);
Mockito.verify(connFactory, Mockito.times(1)).create(
Mockito.eq(route), Mockito.<ConnectionConfig>any());
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
mgr.releaseConnection(conn1, 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);
Assert.assertNotNull(conn2);
Assert.assertTrue(conn2.isOpen());
Mockito.verify(connFactory, Mockito.times(1)).create(
Mockito.eq(route), Mockito.<ConnectionConfig>any());