@Test
  public void testExchangeConnection() {
    manager = new ConnectionManagerImpl("pool", factory, endpointManager, 2, 0, -1, -1, logger,
        60 * 1000, cancelCriterion, poolStats);
    manager.start(background);

    Connection connection1 = manager.borrowConnection(10);
    Connection connection2 = manager.borrowConnection(10);

    Throwable thrown = catchThrowable(() -> {
      manager.borrowConnection(10);
    });
    assertThat(thrown).isInstanceOf(AllConnectionsInUseException.class);

    assertThat(factory.creates.get()).isEqualTo(2);
    assertThat(factory.destroys.get()).isEqualTo(0);
    assertThat(manager.getConnectionCount()).isEqualTo(2);

    Connection connection3 = manager.exchangeConnection(connection1, emptySet());

    assertThat(factory.creates.get()).isEqualTo(3);
    assertThat(factory.destroys.get()).isEqualTo(1);
    assertThat(manager.getConnectionCount()).isEqualTo(2);

    manager.returnConnection(connection2);

    assertThat(factory.creates.get()).isEqualTo(3);
    assertThat(factory.destroys.get()).isEqualTo(1);
    assertThat(manager.getConnectionCount()).isEqualTo(2);

    Connection connection4 =
        manager.exchangeConnection(connection3, singleton(connection3.getServer()));

    assertThat(factory.creates.get()).isEqualTo(4);
    assertThat(factory.destroys.get()).isEqualTo(2);
    assertThat(manager.getConnectionCount()).isEqualTo(2);

    manager.returnConnection(connection4);
  }
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