private void work() throws CacheException {
        LogWriterUtils.getLogWriter().info("### DEBUG EXECUTE CQ START ####");

        // Get CQ Service.
        QueryService cqService = null;
        CqQuery cq1 = null;
        cqService = getCache().getQueryService();

        // Get CqQuery object.
        try {
          cq1 = cqService.getCq(cqName);
          if (cq1 == null) {
            LogWriterUtils.getLogWriter()
                .info("Failed to get CqQuery object for CQ name: " + cqName);
            fail("Failed to get CQ " + cqName);
          } else {
            LogWriterUtils.getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
            assertTrue("newCq() state mismatch", cq1.getState().isStopped());
          }
        } catch (Exception ex) {
          LogWriterUtils.getLogWriter().info("CqService is :" + cqService);
          LogWriterUtils.getLogWriter().error(ex);
          Assert.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);
          }
          LogWriterUtils.getLogWriter().info("initial result size = " + cqResults.size());
          assertTrue("executeWithInitialResults() state mismatch", cq1.getState().isRunning());
          if (expectedResultsSize >= 0) {
            assertEquals(
                "Unexpected results size for CQ: " + cqName + " CQ Query :" + cq1.getQueryString(),
                expectedResultsSize, cqResults.size());
          }

          if (expectedKeys != null) {
            HashSet resultKeys = new HashSet();
            for (Object o : cqResults.asList()) {
              Struct s = (Struct) o;
              resultKeys.add(s.get("key"));
            }
            for (final String expectedKey : expectedKeys) {
              assertTrue(
                  "Expected key :" + expectedKey + " Not found in CqResults for CQ: " + cqName
                      + " CQ Query :" + cq1.getQueryString() + " Keys in CqResults :" + resultKeys,
                  resultKeys.contains(expectedKey));
            }
          }
        } else {
          try {
            cq1.execute();
          } catch (Exception ex) {
            if (expectedErr == null) {
              LogWriterUtils.getLogWriter().info("CqService is :" + cqService, ex);
            }
            Assert.fail("Failed to execute  CQ " + cqName, ex);
          }
          assertTrue("execute() state mismatch", cq1.getState().isRunning());
        }
      }
Execute/register CQ as running.

@param initialResults true if initialResults are requested
@param expectedResultsSize if >= 0, validate results against this size
@param expectedErr if not null, an error we expect
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/CqQueryUsingPoolDUnitTest.java