@Test
  public void test_borrow_connection_toward_specific_server_no_freeConnection_wait_for_timeout()
      throws Exception {
    long idleTimeoutMillis = 300;
    manager =
        new ConnectionManagerImpl("pool", factory, endpointManager, 5, 1, idleTimeoutMillis, -1,
            logger, 60 * 1000, cancelCriterion, poolStats);
    manager.start(background);

    await().untilAsserted(() -> assertThat(manager.getConnectionCount()).isOne());

    long borrowTimeoutMillis = 500;

    // seize connection toward any server
    Connection connection1 = manager.borrowConnection(borrowTimeoutMillis);
    Connection connection2 = manager.borrowConnection(borrowTimeoutMillis);

    // Seize connection toward this specific server
    manager.borrowConnection(new ServerLocation("localhost", 5), borrowTimeoutMillis, false);
    manager.borrowConnection(new ServerLocation("localhost", 5), borrowTimeoutMillis, false);
    manager.borrowConnection(new ServerLocation("localhost", 5), borrowTimeoutMillis, false);

    // Return some connections, let them idle expire
    manager.returnConnection(connection1);
    manager.returnConnection(connection2);

    long elapsedMillis = Timer.measure(() -> {
      Throwable thrown = catchThrowable(() -> {
        manager.borrowConnection(new ServerLocation("localhost", 5), borrowTimeoutMillis, true);
      });
      assertThat(thrown).isInstanceOf(AllConnectionsInUseException.class);
    });
    assertThat(elapsedMillis)
        .isGreaterThanOrEqualTo(borrowTimeoutMillis - ALLOWABLE_ERROR_IN_MILLIS);
  }
Test borrow connection toward specific server. Max connection is 5, and there is no free
connections in pool.
After connection is returned to pool, since is not toward this specific server, wait for
idleTimeoutMillis,
so after expire (and pool size is reduced to 4) it can be seized.
geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/pooling/ConnectionManagerJUnitTest.java