@Test
  public void testCloseOpenRegion() throws InterruptedException {
    Region region = createRegion();

    putEntries(region, 0, 50, "A");

    final CountDownLatch recoveryDone1 = new CountDownLatch(1);
    DiskStoreObserver.setInstance(new DiskStoreObserver() {

      @Override
      public void afterAsyncValueRecovery(DiskStoreImpl store) {
        recoveryDone1.countDown();
      }
    });
    // This will trigger krf creation. Region close doesn't cut it.
    cache.close();
    cache = createCache();

    region = createRegion();

    // Make sure the first recovery is completely done.
    recoveryDone1.await();

    region.close();

    final CountDownLatch suspendRecovery = new CountDownLatch(1);
    final CountDownLatch recoveryDone = new CountDownLatch(1);
    DiskStoreObserver.setInstance(new DiskStoreObserver() {

      @Override
      public void beforeAsyncValueRecovery(DiskStoreImpl store) {
        try {
          suspendRecovery.await();
        } catch (InterruptedException e) {
          fail("interrupted");
        }
      }

      @Override
      public void afterAsyncValueRecovery(DiskStoreImpl store) {
        recoveryDone.countDown();
      }
    });

    Thread.sleep(1);
    try {
      region = createRegion();

      checkEntriesInMemory(region, 0, 50, "A", false);
      checkEntries(region, 0, 40, "A");

      putEntries(region, 0, 10, "B");
      invalidateEntries(region, 10, 20);
      removeEntries(region, 20, 30);

      suspendRecovery.countDown();
      recoveryDone.await();

      checkEntriesInMemory(region, 0, 10, "B", true);
      checkEntriesInMemory(region, 10, 20, Token.INVALID, true);
      checkEntries(region, 10, 20, null);
      checkEntries(region, 20, 30, null);
      checkEntriesInMemory(region, 30, 50, "A", true);
    } finally {
      suspendRecovery.countDown();
    }
  }
Test to make sure that we create missing krfs when we restart the system.
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegionAsyncRecoveryJUnitTest.java