@Test
  public void testLifetimeExpiration() throws Exception {
    int lifetimeTimeout = 500;
    manager = new ConnectionManagerImpl("pool", factory, endpointManager, 2, 2, -1, lifetimeTimeout,
        logger, 60 * 1000, cancelCriterion, poolStats);
    manager.start(background);

    await().untilAsserted(() -> {
      assertThat(factory.creates.get()).isEqualTo(2);
      assertThat(factory.destroys.get()).isEqualTo(0);
      assertThat(factory.finds.get()).isEqualTo(0);
    });

    // need to start a thread that keeps the connections busy
    // so that their last access time keeps changing

    Collection<Future<Void>> updaters = new ArrayList<>();
    for (int i = 0; i < 2; i++) {
      updaters
          .add(executorServiceRule.submit(new UpdaterThread(i, lifetimeTimeout / 10 * 2, false)));
    }

    long elapsedMillis = Timer.measure(() -> {
      await().untilAsserted(() -> {
        assertThat(factory.finds.get()).isEqualTo(2);
        // server shouldn't have changed so no increase in creates or destroys
        assertThat(factory.creates.get()).isEqualTo(2);
        assertThat(factory.destroys.get()).isEqualTo(0);
        assertThat(factory.closes.get()).isEqualTo(0);
      });
    });
    assertThat(elapsedMillis)
        .withFailMessage("took too long to expire lifetime; expected=" + lifetimeTimeout
            + " but took=" + elapsedMillis)
        .isLessThan(lifetimeTimeout * 5);

    for (Future<Void> updater : updaters) {
      updater.get(getTimeout().toMillis(), MILLISECONDS);
    }
  }
Test borrow connection toward specific server (use). Max connection is 5, and there is no free
connections in pool.
We are waiting for returnConnection for connection toward this specific server.
After it is returned, we will reuse it.
geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/pooling/ConnectionManagerJUnitTest.java