final HttpRoute route1 = new HttpRoute(target1);
Mockito.when(connFactory.create(Mockito.<ConnectionConfig>any())).thenReturn(conn);
final ConnectionRequest connRequest1 = mgr.requestConnection(route1, null);
final HttpClientConnection conn1 = connRequest1.get(0, TimeUnit.MILLISECONDS);
Assert.assertNotNull(conn1);
Mockito.verify(connFactory, Mockito.times(1)).create(Mockito.<ConnectionConfig>any());
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
mgr.releaseConnection(conn1, null, 0, TimeUnit.MILLISECONDS);
Assert.assertEquals(route1, mgr.getRoute());
Assert.assertEquals(null, mgr.getState());
final HttpHost target2 = new HttpHost("otherhost");
final HttpRoute route2 = new HttpRoute(target2);
final ConnectionRequest connRequest2 = mgr.requestConnection(route2, null);
final HttpClientConnection conn2 = connRequest2.get(0, TimeUnit.MILLISECONDS);
Assert.assertNotNull(conn2);
Assert.assertFalse(conn2.isOpen());
Mockito.verify(conn).close();
Mockito.verify(connFactory, Mockito.times(2)).create(Mockito.<ConnectionConfig>any());
}