@Test
public void earlyCloseOfAvailableConnections() throws ConnectionException, InterruptedException, IOException {

  initPool(Integer.MAX_VALUE, //
      1, // Only 1 connection simultaneously
      Integer.MAX_VALUE, //
      .95);
  TestConnection<ClusterManagementService.Iface> conn = (TestConnection<ClusterManagementService.Iface>) pool
      .reserveConnection(ClusterManagementService.Iface.class, ADDR1, null);
  int connId = conn.getId();
  Assert.assertEquals(conn.getServiceInfo().getServiceInterface(), ClusterManagementService.Iface.class,
      "Correct service expected");
  conn.close(); // release connection
  // request a connection to another host (so it won't get re-used), which in our case should NOT be blocked, as the
  // pool should reach the "early close" level and close the first connection right away without waiting for it to
  // timeout.
  TestConnection<ClusterManagementService.Iface> conn2 = (TestConnection<ClusterManagementService.Iface>) pool
      .reserveConnection(ClusterManagementService.Iface.class, ADDR2, null);
  conn2.close();
  // ensure that the "close" method on the first connection was called
  Mockito.verify(conn.getTransport()).close();
  Assert.assertNotEquals(conn2.getId(), connId, "Expected that connection was not re-used, as first "
      + "connection should have been closed before the second was opened");
  Assert.assertEquals(conn2.getServiceInfo().getServiceInterface(), ClusterManagementService.Iface.class,
      "Correct service expected");
}