public static void waitTillMessagesAreDispatched(Integer port, Long waitLimit) {
    try {
      boolean dispatched = false;
      Map haContainer = null;
      haContainer = cache.getRegion(
          SEPARATOR + CacheServerImpl.generateNameForClientMsgsRegion(port));
      if (haContainer == null) {
        Object[] servers = cache.getCacheServers().toArray();
        for (final Object server : servers) {
          if (port == ((CacheServerImpl) server).getPort()) {
            haContainer = ((CacheServerImpl) server).getAcceptor().getCacheClientNotifier()
                .getHaContainer();
            break;
          }
        }
      }
      long startTime = System.currentTimeMillis();
      while (waitLimit > (System.currentTimeMillis() - startTime)) {
        if (haContainer.size() == 0) {
          dispatched = true;
          break;
        }
        try {
          Thread.sleep(50);
        } catch (InterruptedException ie) {
          fail("interrupted", ie);
        }
      }
      logger.fine("Exiting sleep, time elapsed was: " + (System.currentTimeMillis() - startTime));
      if (!dispatched) {
        throw new Exception(
            "Test tuning issue: The HARegionQueue is not fully drained, so cannot continue the test.");
      }
    } catch (Exception e) {
      fail("failed in waitTillMessagesAreDispatched()", e);
    }
  }
This test asserts that cq list of a client for an event is not lost if that client's queue has
been GII'ed to a server where that event already existed.
geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/CQListGIIDistributedTest.java