public static void executeCQ(String cqName, Boolean initialResults) {
    org.apache.geode.test.dunit.LogWriterUtils.getLogWriter()
        .info("### DEBUG EXECUTE CQ START ####");
    // Get CQ Service.
    QueryService cqService = null;
    CqQuery cq1 = null;
    cqService = cache.getQueryService();

    // Get CqQuery object.
    try {
      cq1 = cqService.getCq(cqName);
      if (cq1 == null) {
        org.apache.geode.test.dunit.LogWriterUtils.getLogWriter()
            .info("Failed to get CqQuery object for CQ name: " + cqName);
        Assert.fail("Failed to get CQ " + cqName, new Exception("Failed to get CQ " + cqName));
      } else {
        org.apache.geode.test.dunit.LogWriterUtils.getLogWriter()
            .info("Obtained CQ, CQ name: " + cq1.getName());
        assertTrue("newCq() state mismatch", cq1.getState().isStopped());
      }
    } catch (Exception ex) {
      fail("Failed to execute  CQ " + cqName, ex);
    }

    if (initialResults) {
      SelectResults cqResults = null;

      try {
        cqResults = cq1.executeWithInitialResults();
      } catch (Exception ex) {
        fail("Failed to execute  CQ " + cqName, ex);
      }
      org.apache.geode.test.dunit.LogWriterUtils.getLogWriter()
          .info("initial result size = " + cqResults.size());
      assertTrue("executeWithInitialResults() state mismatch", cq1.getState().isRunning());
    } else {

      try {
        cq1.execute();
      } catch (Exception ex) {
        fail("Failed to execute  CQ " + cqName, ex);
      }
      assertTrue("execute() state mismatch", cq1.getState().isRunning());
    }
  }
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