@Test
  public void testCloseDuringRegionOperation() throws Exception {
    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> createReplicateRegion(regionName, getDiskDirs(getVMId())));
    }

    // Try to make sure there are some operations in flight while closing the cache

    AsyncInvocation<Integer> createDataInVM0 = vm0.invokeAsync(() -> {
      Region<Integer, Integer> region = getCache().getRegion(regionName);
      COUNT.set(0);
      while (true) {
        try {
          region.put(0, COUNT.incrementAndGet());
        } catch (CacheClosedException | RegionDestroyedException e) {
          break;
        }
      }
      return COUNT.get();
    });

    AsyncInvocation<Integer> createDataInVM1 = vm1.invokeAsync(() -> {
      Region<Integer, Integer> region = getCache().getRegion(regionName);
      COUNT.set(0);
      while (true) {
        try {
          region.put(1, COUNT.incrementAndGet());
        } catch (CacheClosedException | RegionDestroyedException e) {
          break;
        }
      }
      return COUNT.get();
    });

    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> {
        await().until(() -> COUNT.get() > 1);
      });
    }

    AsyncInvocation<Void> closeCacheInVM0 = vm0.invokeAsync(() -> getCache().close());
    AsyncInvocation<Void> closeCacheInVM1 = vm1.invokeAsync(() -> getCache().close());

    closeCacheInVM0.await();
    closeCacheInVM1.await();

    int expectedValueFor0 = createDataInVM0.get();
    int expectedValueFor1 = createDataInVM1.get();

    AsyncInvocation<Void> createPersistentRegionInVM0 = vm0.invokeAsync(() -> {
      createReplicateRegion(regionName, getDiskDirs(getVMId()));
    });
    AsyncInvocation<Void> createPersistentRegionInVM1 = vm1.invokeAsync(() -> {
      createReplicateRegion(regionName, getDiskDirs(getVMId()));
    });

    createPersistentRegionInVM0.await();
    createPersistentRegionInVM1.await();

    for (int key : asList(0, 1)) {
      int valueInVM0 = vm0.invoke(() -> getValue(key));
      int valueInVM1 = vm1.invoke(() -> getValue(key));

      int expectedValue = key == 0 ? expectedValueFor0 : expectedValueFor1;

      assertThat(valueInVM0)
          .isEqualTo(valueInVM1)
          .isBetween(expectedValue - 1, expectedValue);
    }
  }
Tests to make sure that we stop waiting for a member that we revoke.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java