public static void createCQ(String cqName, String queryStr) {
    org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("### Create CQ. ###" + cqName);
    // Get CQ Service.
    QueryService cqService = null;
    try {
      cqService = cache.getQueryService();
    } catch (Exception cqe) {
      Assert.fail("Failed to getCQService.", cqe);
    }
    // Create CQ Attributes.
    CqAttributesFactory cqf = new CqAttributesFactory();
    CqListener[] cqListeners =
        {new CqQueryTestListener(org.apache.geode.test.dunit.LogWriterUtils.getLogWriter())};
    ((CqQueryTestListener) cqListeners[0]).cqName = cqName;

    cqf.initCqListeners(cqListeners);
    CqAttributes cqa = cqf.create();

    // Create CQ.
    try {
      CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
      assertTrue("newCq() state mismatch", cq1.getState().isStopped());
    } catch (Exception ex) {
      fail("Failed to create CQ " + cqName + " . ", ex);
    }
  }
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