@Test
  public void testCQAndPartitionedRegion() throws Exception {
    // creating servers.
    final Host host = Host.getHost(0);
    VM server1 = host.getVM(0);
    VM server2 = host.getVM(1);
    VM client = host.getVM(2);

    createServer(server1);

    createServer(server2);

    // create client

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

    // createClient(client, port, host0);
    String poolName = "testCQAndPartitionedRegion";
    createPool(client, poolName, host0, port);

    // register cq.
    createCQ(client, poolName, "testCQEvents_0", cqs[0]);
    cqHelper.executeCQ(client, "testCQEvents_0", false, null);


    // create values
    int size = 40;
    createValues(server1, regions[0], size);

    // wait for last creates...

    cqHelper.waitForCreated(client, "testCQEvents_0", KEY + size);

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

    // size = 2;

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

    cqHelper.waitForUpdated(client, "testCQEvents_0", KEY + size);

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


    // destroy all the values.
    int numDestroys = size;
    cqHelper.deleteValues(server2, regions[0], numDestroys);

    cqHelper.waitForDestroyed(client, "testCQEvents_0", KEY + numDestroys);

    // validate cqs after destroyes on server2.


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

    // invalidate some entries.
    /*
     * final int numInvalidates = 5;
     *
     * server2.invoke(new CacheSerializableRunnable("Invalidate values") { public void run2() throws
     * CacheException { Region region1 = getRootRegion().getSubregion(regions[0]); for (int i =
     * numInvalidates; i <= (numInvalidates+4); i++) { region1.invalidate(KEY+i); } } });
     *
     * cqHelper.waitForInvalidated(client, "testCQEvents_0", KEY+(numInvalidates+4));
     */
    // cqHelper.validateCQ(client, "testCQEvents_0",
    // /* resultSize: */ cqHelper.noTest,
    // /* creates: */ size,
    // /* updates: */ size,
    // /* deletes; */ (numDestroys+numInvalidates),
    // /* queryInserts: */ size,
    // /* queryUpdates: */ size,
    // /* queryDeletes: */ (numDestroys+numInvalidates),
    // /* totalEvents: */ (size+size+numDestroys + numInvalidates));

    cqHelper.closeClient(client);
    cqHelper.closeServer(server2);
    cqHelper.closeServer(server1);
  }
Test class for Partitioned Region and CQs

@since GemFire 5.5
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/PrCqUsingPoolDUnitTest.java