@Test
  public void test022ClientRegisterUnregisterRequests() throws CacheException {
    final String regionName1 = getName() + "-1";

    VM server1 = vm0;
    VM client = vm2;

    // Create server1.
    server1.invoke("Create Cache Server", () -> {
      RegionFactory<Object, Object> factory = getCache().createRegionFactory();
      factory.setScope(Scope.DISTRIBUTED_ACK);
      factory.setDataPolicy(DataPolicy.REPLICATE);
      factory.setConcurrencyChecksEnabled(false);
      createRegion(regionName1, factory);

      startBridgeServer(0);
    });

    final int port = server1.invoke(ConnectionPoolDUnitTest::getCacheServerPort);
    final String host0 = NetworkUtils.getServerHostName();

    // Create client.
    client.invoke("Create region", () -> {
      getLonerSystem();
      getCache();

      RegionFactory<Object, Object> factory = getCache().createRegionFactory();
      factory.setScope(Scope.LOCAL);
      factory.setConcurrencyChecksEnabled(false);

      configureConnectionPool(factory, host0, new int[] {port}, true, -1, -1,
          null);

      Region<Object, Object> region11 = createRegion(regionName1, factory);
      region11.getAttributesMutator().addCacheListener(new CertifiableTestCacheListener<>());
    });

    // Init values at server.
    server1.invoke("Create values", () -> {
      Region<Object, Object> region1 = getRootRegion().getSubregion(regionName1);
      for (int i = 0; i < 20; i++) {
        region1.put("key-string-" + i, "value-" + i);
      }
    });

    // Put some values on the client.
    client.invoke("Put values client and close pool", () -> {
      Region<Object, Object> region1 = getRootRegion().getSubregion(regionName1);

      for (int i = 0; i < 10; i++) {
        region1.put("key-string-" + i, "client-value-" + i);
      }

      String pName = region1.getAttributes().getPoolName();
      region1.localDestroyRegion();
      PoolImpl p = (PoolImpl) PoolManager.find(pName);
      p.destroy();
    });

    server1.invoke("validate Client Register UnRegister", () -> {
      for (CacheServer cacheServer : getCache().getCacheServers()) {
        InternalCacheServer bsi = (InternalCacheServer) cacheServer;
        final CacheClientNotifierStats ccnStats =
            bsi.getAcceptor().getCacheClientNotifier().getStats();

        await().until(() -> ccnStats.getClientRegisterRequests() == ccnStats
            .getClientUnRegisterRequests());
        assertThat(ccnStats.getClientRegisterRequests())
            .describedAs("HealthMonitor Client Register/UnRegister mismatch.")
            .isEqualTo(ccnStats.getClientUnRegisterRequests());
      }
    });
  }
A handy method to poll for arrival of non-null/non-invalid entries

@param r the Region to poll
@param key the key of the Entry to poll for
geode-core/src/distributedTest/java/org/apache/geode/cache/ConnectionPoolDUnitTest.java