@Test
  public void testInvalidTokens() throws Exception {
    final Region r = utils.getCache().getRegion(SEPARATOR + "exampleRegion");
    r.put("0", new Portfolio(0));
    r.invalidate("0");
    index = utils.createIndex("compact range index", "p.status", SEPARATOR + "exampleRegion p");
    QueryService qs = utils.getCache().getQueryService();
    SelectResults results = (SelectResults) qs
        .newQuery("Select * from " + SEPARATOR + "exampleRegion r where r.status='active'")
        .execute();
    // the remove should have happened
    assertEquals(0, results.size());

    results = (SelectResults) qs
        .newQuery("Select * from " + SEPARATOR + "exampleRegion r where r.status!='inactive'")
        .execute();
    assertEquals(0, results.size());

    CompactRangeIndex cindex = (CompactRangeIndex) index;
    MemoryIndexStore indexStore = (MemoryIndexStore) cindex.getIndexStorage();
    CloseableIterator iterator = indexStore.get(QueryService.UNDEFINED);
    int count = 0;
    while (iterator.hasNext()) {
      count++;
      iterator.next();
    }
    assertEquals("incorrect number of entries in collection", 0, count);
  }
Tests race condition when we are transitioning index collection from elem array to concurrent
hash set The other thread could remove from the empty concurrent hash set. Instead we now set a
token, do all the puts into a collection and then unsets the token to the new collection
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/CompactRangeIndexJUnitTest.java