private void basicTestBridgeServerFailover(final int cnxCount) throws CacheException {
    final String name = getName();

    // Create two cache servers
    Stream.of(vm0, vm1).forEach(vm -> vm.invoke("Create Cache Server", () -> {
      RegionFactory<Object, Object> factory = getBridgeServerRegionAttributes(null, null);
      createRegion(name, factory);
      startBridgeServer(0);
    }));

    final int port0 = vm0.invoke(ConnectionPoolDUnitTest::getCacheServerPort);
    final String host0 = NetworkUtils.getServerHostName();

    final int port1 = vm1.invoke(ConnectionPoolDUnitTest::getCacheServerPort);

    // Create one bridge client in this VM

    vm2.invoke("Create region", () -> {
      getLonerSystem();
      getCache();
      RegionFactory<Object, Object> factory = getCache().createRegionFactory();
      factory.setScope(Scope.LOCAL);
      factory.setConcurrencyChecksEnabled(false);
      String ServerGroup = null;
      configureConnectionPoolWithNameAndFactory(factory, host0, new int[] {port0, port1}, true,
          -1, cnxCount, ServerGroup, TEST_POOL_NAME, PoolManager.createFactory(), 100, -1, -2,
          -1);
      Region<Object, Object> region = createRegion(name, factory);

      // force connections to form
      region.put("keyInit", 0);
      region.put("keyInit2", 0);
    });

    vm2.invoke("verify2Servers", () -> {
      Region<Object, Object> region = getRootRegion().getSubregion(name);
      PoolImpl pool = getPool(region);
      verifyServerCount(pool, 2);
    });

    final String expected = "java.io.IOException";
    final String addExpected =
        "<ExpectedException action=add>" + expected + "</ExpectedException>";
    final String removeExpected =
        "<ExpectedException action=remove>" + expected + "</ExpectedException>";

    vm2.invoke(() -> {
      LogWriter bgexecLogger = new LocalLogWriter(ALL.intLevel(), System.out);
      bgexecLogger.info(addExpected);
    });

    try { // make sure we removeExpected

      // Bounce the non-current server (I know that VM1 contains the non-current server
      // because ...
      vm1.invoke(() -> stopBridgeServer(getCache()));

      vm2.invoke("verify1Server", () -> {
        Region<Object, Object> region = getRootRegion().getSubregion(name);
        PoolImpl pool = getPool(region);
        verifyServerCount(pool, 1);
      });

      vm1.invoke("Restart CacheServer", () -> {
        Region<Object, Object> region = getRootRegion().getSubregion(name);
        assertThat(region).isNotNull();
        startBridgeServer(port1);
      });

      // Pause long enough for the monitor to realize the server has been bounced
      // and reconnect to it.
      vm2.invoke("verify2Servers", () -> {
        Region<Object, Object> region = getRootRegion().getSubregion(name);
        PoolImpl pool = getPool(region);
        verifyServerCount(pool, 2);
      });

    } finally {
      vm2.invoke(() -> {
        LogWriter bgexecLogger = new LocalLogWriter(ALL.intLevel(), System.out);
        bgexecLogger.info(removeExpected);
      });
    }

    // Stop the other cache server
    vm0.invoke(() -> stopBridgeServer(getCache()));

    // Run awhile
    vm2.invoke("verify1Server", () -> {
      Region<Object, Object> region = getRootRegion().getSubregion(name);
      PoolImpl pool = getPool(region);
      verifyServerCount(pool, 1);
    });

    // Close Pool
    vm2.invoke("Close Pool", () -> {
      Region<Object, Object> region = getRootRegion().getSubregion(name);
      region.localDestroyRegion();
    });
  }
Test BridgeServer failover with connectionsPerServer set to 0
geode-core/src/distributedTest/java/org/apache/geode/cache/ConnectionPoolDUnitTest.java