@Test
  public void testClientIndexUpdateWithRIOnClearedRegion() throws Exception {

    CqQueryUsingPoolDUnitTest cqDUnitTest = new CqQueryUsingPoolDUnitTest();

    final Host host = Host.getHost(0);
    VM server = host.getVM(0);
    VM client = host.getVM(1);

    createServer(server, 0, false);

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

    // Init values at server.
    final int size = 1000;
    createValues(server, cqDUnitTest.regions[0], size);

    String poolName = "testClientIndexUpdateWithRegisterInterest";
    cqDUnitTest.createPool(client, poolName, host0, port);

    // Create client.
    cqDUnitTest.createClient(client, port, host0);
    // Create Index on client
    cqDUnitTest.createFunctionalIndex(client, "IdIndex", "p.ID",
        SEPARATOR + "root" + SEPARATOR + "regionA p");

    // Create entries on client to clear region later
    createValues(client, cqDUnitTest.regions[0], size);

    // Register Interest in all Keys on server
    // client.invoke(this.getSRRegisterInterestList(cqDUnitTest.regions[0], size, -1 /* Default ALL
    // KEYS */, 0));
    // this.asyncRegisterInterestList(client, cqDUnitTest.regions[0], size, -1 /* Default ALL KEYS
    // */, 0);
    registerInterestList(client, cqDUnitTest.regions[0], size, -1);

    // Wait for Index to get updated.
    // pause(500);

    // Start clearing region on client asynchronously.
    // this.asyncClearRegion(client, cqDUnitTest.regions[0]);
    client.invoke(getSRClearRegion(cqDUnitTest.regions[0]));

    // Let register interest finish during region clearance
    // pause(5*1000);

    // This query execution should fail as it will run on client index and region has been cleared.
    // Validate query results.
    validateQueryOnIndexWithRegion(client, cqDUnitTest.cqs[0], 0, region);

    // Close.
    cqDUnitTest.closeClient(client);
    cqDUnitTest.closeServer(server);
  }
This test tests the RegionClearedException Path in AbsractRegionMap while doing
initialImagePut() during registerInterest on client.
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/dunit/QueryIndexUpdateRIDUnitTest.java