public static void waitForEvent(int event, String cqName, String key) {
    // Get CQ Service.
    QueryService cqService = null;
    try {
      cqService = cache.getQueryService();
    } catch (Exception cqe) {
      Assert.fail("Failed to getCQService.", cqe);
    }

    CqQuery cQuery = cqService.getCq(cqName);
    if (cQuery == null) {
      Assert.fail("Failed to get CqQuery for CQ : " + cqName,
          new Exception("Failed to get CqQuery for CQ : " + cqName));
    }

    CqAttributes cqAttr = cQuery.getCqAttributes();
    CqListener[] cqListener = cqAttr.getCqListeners();
    CqQueryTestListener listener = (CqQueryTestListener) cqListener[0];

    switch (event) {
      case CREATE:
        listener.waitForCreated(key);
        break;

      case UPDATE:
        listener.waitForUpdated(key);
        break;

      case DESTROY:
        listener.waitForDestroyed(key);
        break;

      case INVALIDATE:
        listener.waitForInvalidated(key);
        break;

      case CLOSE:
        listener.waitForClose();
        break;

      case REGION_CLEAR:
        listener.waitForRegionClear();
        break;

      case REGION_INVALIDATE:
        listener.waitForRegionInvalidate();
        break;
    }
  }
A helper for creating a subregion, potentially using a package protected method to do so.

@param root the parent region
@param name the name of the subregion to create
@param attrs the attributes used to create the subregion
@param internalArgs if not null, then use the package protected creation mechanism
@return the subregion whose parent is the provided root
@see Region#createSubregion(String, RegionAttributes)
@see LocalRegion#createSubregion(String, RegionAttributes, InternalRegionArguments)
geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/CQListGIIDistributedTest.java