@Test
public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
HttpConnectionFactory connFactory = Mockito.mock(HttpConnectionFactory.class);
HttpConnection conn1 = Mockito.mock(HttpConnection.class);
HttpConnection conn2 = Mockito.mock(HttpConnection.class);
HttpConnection conn3 = Mockito.mock(HttpConnection.class);
Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1, conn2, conn3);
HttpConnection conn4 = Mockito.mock(HttpConnection.class);
HttpConnection conn5 = Mockito.mock(HttpConnection.class);
Mockito.when(connFactory.create(Mockito.eq("otherhost"))).thenReturn(conn4, conn5);
LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
pool.setMaxPerRoute("somehost", 2);
pool.setMaxPerRoute("otherhost", 2);