@Test
public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
LocalConnFactory connFactory = Mockito.mock(LocalConnFactory.class);
HttpConnection conn1 = Mockito.mock(HttpConnection.class);
Mockito.when(conn1.isOpen()).thenReturn(true);
HttpConnection conn2 = Mockito.mock(HttpConnection.class);
Mockito.when(conn2.isOpen()).thenReturn(true);
HttpConnection conn3 = Mockito.mock(HttpConnection.class);
Mockito.when(conn3.isOpen()).thenReturn(true);
Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1, conn2, conn3);
HttpConnection conn4 = Mockito.mock(HttpConnection.class);
Mockito.when(conn4.isOpen()).thenReturn(true);
HttpConnection conn5 = Mockito.mock(HttpConnection.class);
Mockito.when(conn5.isOpen()).thenReturn(true);
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);