protected static Boolean verifyDisconnected() {
    if (SystemFailure.getFailure() == null) {
      fail("No system failure present!");
      return Boolean.FALSE;
    }
    GemFireCacheImpl gfc = (GemFireCacheImpl) cache;

    // Allow cache time to finish disconnecting
    long done = System.currentTimeMillis() + MAX_WAIT;
    for (;;) {
      long now = System.currentTimeMillis();
      if (now >= done) {
        fail("Time out waiting for cache to close: " + cache.toString());
        return Boolean.FALSE;
      }
      if (gfc.isClosed()) {
        break;
      }
      try {
        Thread.sleep(2000);
      } catch (InterruptedException e) {
        fail("interrupted");
        return Boolean.FALSE;
      }
    }

    // At this point, the cache we peeked earlier should be unavailable
    assertTrue(GemFireCacheImpl.getInstance() == null);

    // Ditto for the distributed system
    InternalDistributedSystem ids = (InternalDistributedSystem) gfc.getDistributedSystem();
    if (ids == null) {
      return Boolean.TRUE; // uhhh, pretty dead!
    }
    try {
      ClusterDistributionManager dm = (ClusterDistributionManager) ids.getDistributionManager();
      if (dm == null) {
        return Boolean.TRUE;
      }
      return dm.getCancelCriterion().isCancelInProgress();
    } catch (CancelException e) {
      // TODO -- it would be nice to avoid the checkConnected() call above
      return Boolean.TRUE;
    }
  }
Verify that listener gets called, and exactly once.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/SystemFailureDUnitTest.java