@Test
  public void testCqExecuteWithoutQueryExecution() throws Exception {
    final Host host = Host.getHost(0);
    final VM server = host.getVM(0);
    final VM client = host.getVM(1);
    final int numOfEntries = 10;
    final String cqName = "testCqExecuteWithoutQueryExecution_1";

    createServer(server);
    // Create values.
    createValues(server, regions[0], numOfEntries);

    final int thePort = server.invoke(CqQueryDUnitTest::getCacheServerPort);
    final String host0 = NetworkUtils.getServerHostName(server.getHost());

    // Create client.
    createClient(client, thePort, host0);

    /* Create CQs. */
    createCQ(client, cqName, cqs[0]);

    validateCQCount(client, 1);

    executeCQ(client, cqName, false, null);

    server.invoke(new CacheSerializableRunnable("execute cq") {
      @Override
      public void run2() throws CacheException {
        assertFalse("CqServiceImpl.EXECUTE_QUERY_DURING_INIT flag should be false ",
            CqServiceImpl.EXECUTE_QUERY_DURING_INIT);
        long numOfQueryExecutions = (Long) getCache().getCachePerfStats()
            .getStats().get("queryExecutions");
        assertEquals("Number of query executions for cq.execute should be 0 ", 0,
            numOfQueryExecutions);
      }
    });

    // Create more values.
    server.invoke(new CacheSerializableRunnable("Create values") {
      @Override
      public void run2() throws CacheException {
        Region region1 = getRootRegion().getSubregion(regions[0]);
        for (int i = numOfEntries + 1; i <= numOfEntries * 2; i++) {
          region1.put(KEY + i, new Portfolio(i));
        }
        LogWriterUtils.getLogWriter()
            .info("### Number of Entries in Region :" + region1.keySet().size());
      }
    });


    waitForCreated(client, cqName, KEY + numOfEntries * 2);

    validateCQ(client, cqName, /* resultSize: */ noTest, /* creates: */ numOfEntries,
        /* updates: */ 0, /* deletes; */ 0, /* queryInserts: */ numOfEntries, /* queryUpdates: */ 0,
        /* queryDeletes: */ 0, /* totalEvents: */ numOfEntries);

    // Update values.
    createValues(server, regions[0], 5);
    createValues(server, regions[0], 10);

    waitForUpdated(client, cqName, KEY + numOfEntries);


    // validate Update events.
    validateCQ(client, cqName, /* resultSize: */ noTest, /* creates: */ numOfEntries,
        /* updates: */ 15, /* deletes; */ 0, /* queryInserts: */ numOfEntries,
        /* queryUpdates: */ 15, /* queryDeletes: */ 0, /* totalEvents: */ numOfEntries + 15);

    // Validate delete events.
    deleteValues(server, regions[0], 5);
    waitForDestroyed(client, cqName, KEY + 5);

    validateCQ(client, cqName, /* resultSize: */ noTest, /* creates: */ numOfEntries,
        /* updates: */ 15, /* deletes; */5, /* queryInserts: */ numOfEntries,
        /* queryUpdates: */ 15, /* queryDeletes: */ 5, /* totalEvents: */ numOfEntries + 15 + 5);

    closeClient(client);
    closeServer(server);
  }
Test class for testing {@link CqServiceImpl#EXECUTE_QUERY_DURING_INIT} flag
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/CqQueryOptimizedExecuteDUnitTest.java