@Test
  public void testPRWithCQsAndProfileUpdates() throws Exception {

    final Host host = Host.getHost(0);
    VM server1 = host.getVM(0);
    VM server2 = host.getVM(1);
    VM client = host.getVM(2);
    VM client2 = host.getVM(3);

    // creating cache server with data store. clients will connect to this
    // cache server.
    createServer(server1, false, 1);

    // create another server with data store.
    createServer(server2, false, 1);

    // Wait for server to initialize.
    Wait.pause(2000);

    final int port = server1.invoke(PrCqUsingPoolDUnitTest::getCacheServerPort);
    final String host0 = NetworkUtils.getServerHostName(server1.getHost());

    String poolName1 = "testPRWithCQsAndProfileUpdates1";
    createPool(client, poolName1, host0, port);

    String poolName2 = "testPRWithCQsAndProfileUpdates2";
    createPool(client2, poolName2, host0, port);


    // createClient(client, port, host0);
    createClient(client2, port, host0);

    // register cq.
    createCQ(client, poolName1, "testPRWithCQsAndProfileUpdates_0", cqs[0]); // SAME CQ REGISTERED
                                                                             // TWICE.
    createCQ(client, poolName1, "testPRWithCQsAndProfileUpdates_1", cqs[0]);
    cqHelper.executeCQ(client, "testPRWithCQsAndProfileUpdates_0", false, null);
    cqHelper.executeCQ(client, "testPRWithCQsAndProfileUpdates_1", false, null);

    // create values
    final int size = 200;
    createValues(client2, regions[0], size);
    createValues(client2, regions[1], size);

    // wait for last creates...
    for (int i = 1; i <= size; i++) {
      cqHelper.waitForCreated(client, "testPRWithCQsAndProfileUpdates_0", KEY + i);
      cqHelper.waitForCreated(client, "testPRWithCQsAndProfileUpdates_1", KEY + i);
    }

    // validate cq..
    cqHelper.validateCQ(client, "testPRWithCQsAndProfileUpdates_0",
        /* resultSize: */ CqQueryUsingPoolDUnitTest.noTest, /* creates: */ size, /* updates: */ 0,
        /* deletes; */ 0, /* queryInserts: */ size, /* queryUpdates: */ 0, /* queryDeletes: */ 0,
        /* totalEvents: */ size);
    cqHelper.validateCQ(client, "testPRWithCQsAndProfileUpdates_1",
        /* resultSize: */ CqQueryUsingPoolDUnitTest.noTest, /* creates: */ size, /* updates: */ 0,
        /* deletes; */ 0, /* queryInserts: */ size, /* queryUpdates: */ 0, /* queryDeletes: */ 0,
        /* totalEvents: */ size);


    // size = 2;

    // do updates
    createValues(client2, regions[0], size);
    createValues(client2, regions[1], size);

    for (int i = 1; i <= size; i++) {
      cqHelper.waitForUpdated(client, "testPRWithCQsAndProfileUpdates_0", KEY + i);
      cqHelper.waitForUpdated(client, "testPRWithCQsAndProfileUpdates_1", KEY + i);
    }

    // validate cqs again.
    cqHelper.validateCQ(client, "testPRWithCQsAndProfileUpdates_0",
        /* resultSize: */ CqQueryUsingPoolDUnitTest.noTest, /* creates: */ size,
        /* updates: */ size, /* deletes; */ 0, /* queryInserts: */ size, /* queryUpdates: */ size,
        /* queryDeletes: */ 0, /* totalEvents: */ (size + size));

    cqHelper.validateCQ(client, "testPRWithCQsAndProfileUpdates_1",
        /* resultSize: */ CqQueryUsingPoolDUnitTest.noTest, /* creates: */ size,
        /* updates: */ size, /* deletes; */ 0, /* queryInserts: */ size, /* queryUpdates: */ size,
        /* queryDeletes: */ 0, /* totalEvents: */ (size + size));

    // invalidate all the values.
    int numInvalidates = size;
    // cqHelper.invalidateValues(server1,regions[0], numInvalidates);
    cqHelper.deleteValues(client2, regions[0], numInvalidates);
    cqHelper.deleteValues(client2, regions[1], numInvalidates);

    for (int i = 1; i <= numInvalidates; i++) {
      cqHelper.waitForDestroyed(client, "testPRWithCQsAndProfileUpdates_0", KEY + i);
      cqHelper.waitForDestroyed(client, "testPRWithCQsAndProfileUpdates_1", KEY + i);
    }


    // validate cqs after invalidates on server2.

    cqHelper.validateCQ(client, "testPRWithCQsAndProfileUpdates_0",
        /* resultSize: */ CqQueryUsingPoolDUnitTest.noTest, /* creates: */ size,
        /* updates: */ size, /* deletes; */ numInvalidates, /* queryInserts: */ size,
        /* queryUpdates: */ size, /* queryDeletes: */ numInvalidates,
        /* totalEvents: */ (size + size + numInvalidates));


    cqHelper.validateCQ(client, "testPRWithCQsAndProfileUpdates_1",
        /* resultSize: */ CqQueryUsingPoolDUnitTest.noTest, /* creates: */ size,
        /* updates: */ size, /* deletes; */ numInvalidates, /* queryInserts: */ size,
        /* queryUpdates: */ size, /* queryDeletes: */ numInvalidates,
        /* totalEvents: */ (size + size + numInvalidates));

    // check for requries old value set.
    /*
     * server1.invoke(new CacheSerializableRunnable("Check requires old value") { public void run2()
     * { Cache cc = getCache(); PartitionedRegion region1 = (PartitionedRegion)cc
     * .getRegion("/root/regionA"); Set requiresOldValue = region1.getRegionAdvisor()
     * .adviseRequiresOldValue(); getLogWriter().info(
     * "ize of requires old value at server1 before closing cqs : " + requiresOldValue.size());
     * assertTrue("The size of requiresOldValue shoule be zero on server1", (0 ==
     * requiresOldValue.size())); } });
     *
     * server2.invoke(new CacheSerializableRunnable("Check requires old value") { public void run2()
     * { Cache cc = getCache(); PartitionedRegion region1 = (PartitionedRegion)cc
     * .getRegion("/root/regionA"); Set requiresOldValue = region1.getRegionAdvisor()
     * .adviseRequiresOldValue(); getLogWriter().info(
     * "size of requires old value at server2 before closing cqs :" + requiresOldValue.size());
     * assertTrue("The size of requiresOldValue should be one on server2 ", (1 ==
     * requiresOldValue.size())); } });
     */
    cqHelper.closeCQ(client, "testPRWithCQsAndProfileUpdates_0");
    cqHelper.closeCQ(client, "testPRWithCQsAndProfileUpdates_1");


    // check for requires old value set after closing all the cqs.
    /*
     * server1.invoke(new CacheSerializableRunnable("Check requires old value") { public void run2()
     * { Cache cc = getCache(); PartitionedRegion region1 = (PartitionedRegion)cc
     * .getRegion("/root/regionA"); Set requiresOldValue = region1.getRegionAdvisor()
     * .adviseRequiresOldValue(); getLogWriter().info(
     * "size of requires old value set at the end server1 : " + requiresOldValue.size());
     * assertTrue("The size of requiresOldValue shoule be zero on server1", (0 ==
     * requiresOldValue.size())); } });
     *
     *
     * server2.invoke(new CacheSerializableRunnable("Check requires old value") { public void run2()
     * { Cache cc = getCache(); PartitionedRegion region1 = (PartitionedRegion)cc
     * .getRegion("/root/regionA"); Set requiresOldValue = region1.getRegionAdvisor()
     * .adviseRequiresOldValue(); getLogWriter().info(
     * " size of requires old value set at the end server2 : " + requiresOldValue.size());
     * assertTrue(
     * "The size of requiresOldValue shoule be zero on server2 as well after closing all the cqs",
     * (0 == requiresOldValue.size())); } });
     */
    cqHelper.closeClient(client);
    cqHelper.closeClient(client2);
    cqHelper.closeServer(server2);
    cqHelper.closeServer(server1);

  }
tests multiple cqs on partitioned region on cache servers with profile update for not
requiring old values.
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/PrCqUsingPoolDUnitTest.java