Assert.assertNotNull(entry2);
Assert.assertFalse(future3.isDone());
Assert.assertFalse(future4.isDone());
PoolStats totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
Assert.assertEquals(2, totals.getLeased());
Assert.assertEquals(0, totals.getPending());
pool.release(entry1, true);
pool.release(entry2, true);
Mockito.verify(ioreactor, Mockito.times(2)).connect(
Mockito.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Mockito.any(SocketAddress.class),
Mockito.any(), Mockito.any(SessionRequestCallback.class));
Mockito.verify(ioreactor, Mockito.times(2)).connect(
Mockito.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Mockito.any(SocketAddress.class),
Mockito.any(), Mockito.any(SessionRequestCallback.class));
pool.requestCompleted(sessionRequest3);
pool.requestCompleted(sessionRequest4);
Assert.assertTrue(future3.isDone());
final LocalPoolEntry entry3 = future3.get();
Assert.assertNotNull(entry3);
Assert.assertTrue(future4.isDone());
final LocalPoolEntry entry4 = future4.get();
Assert.assertNotNull(entry4);
totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
Assert.assertEquals(2, totals.getLeased());
Assert.assertEquals(0, totals.getPending());
final Future<LocalPoolEntry> future5 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future6 = pool.lease("otherhost", null);
Mockito.verify(ioreactor, Mockito.times(2)).connect(
Mockito.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Mockito.any(SocketAddress.class),
Mockito.any(), Mockito.any(SessionRequestCallback.class));
Mockito.verify(ioreactor, Mockito.times(2)).connect(
Mockito.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Mockito.any(SocketAddress.class),
Mockito.any(), Mockito.any(SessionRequestCallback.class));
pool.release(entry3, true);
pool.release(entry4, true);
Mockito.verify(ioreactor, Mockito.times(3)).connect(
Mockito.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Mockito.any(SocketAddress.class),
Mockito.any(), Mockito.any(SessionRequestCallback.class));
Mockito.verify(ioreactor, Mockito.times(2)).connect(
Mockito.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Mockito.any(SocketAddress.class),
Mockito.any(), Mockito.any(SessionRequestCallback.class));
pool.requestCompleted(sessionRequest1);
Assert.assertTrue(future5.isDone());
final LocalPoolEntry entry5 = future5.get();
Assert.assertNotNull(entry5);
Assert.assertTrue(future6.isDone());
final LocalPoolEntry entry6 = future6.get();
Assert.assertNotNull(entry6);
totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
Assert.assertEquals(2, totals.getLeased());
Assert.assertEquals(0, totals.getPending());
pool.release(entry5, true);
pool.release(entry6, true);
Mockito.verify(ioreactor, Mockito.times(3)).connect(
Mockito.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Mockito.any(SocketAddress.class),
Mockito.any(), Mockito.any(SessionRequestCallback.class));
Mockito.verify(ioreactor, Mockito.times(2)).connect(
Mockito.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Mockito.any(SocketAddress.class),
Mockito.any(), Mockito.any(SessionRequestCallback.class));
totals = pool.getTotalStats();
Assert.assertEquals(2, totals.getAvailable());
Assert.assertEquals(0, totals.getLeased());
Assert.assertEquals(0, totals.getPending());
}