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

  initPool(Integer.MAX_VALUE, //
      1, // Only 1 connection simultaneously - we expect to block!
      3_000, // 3s idle time.
      2); // high earlyCloseLevel to force to block
  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");
  long beforeNanos = System.nanoTime();
  conn.close(); // release connection
  // request a connection to another host (so it won't get re-used), which should be blocked - the first connection
  // was released, but it is effectively still open until it is closed automatically by the timeout!
  TestConnection<ClusterManagementService.Iface> conn2 = (TestConnection<ClusterManagementService.Iface>) pool
      .reserveConnection(ClusterManagementService.Iface.class, ADDR2, null);
  long afterNanos = System.nanoTime();
  conn2.close();
  // ensure that the "close" method on the first connection was called
  Mockito.verify(conn.getTransport()).close();
  Assert.assertTrue(afterNanos - beforeNanos >= 3_000_000_000L,
      "Expected to have blocked at least the timeout time until we receive a new connection, but waited only "
          + (afterNanos - beforeNanos) + " nanos");
  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");
}