@Test
  public void testIndexCreationFromXML() throws Exception {
    InternalDistributedSystem.getAnyInstance().disconnect();
    File file = new File("persistData0");
    file.mkdir();

    {
      Properties props = new Properties();
      props.setProperty(NAME, "test");
      props.setProperty(MCAST_PORT, "0");
      props.setProperty(CACHE_XML_FILE,
          getClass().getResource("index-creation-with-eviction.xml").toURI().getPath());
      DistributedSystem ds = DistributedSystem.connect(props);

      // Create the cache which causes the cache-xml-file to be parsed
      Cache cache = CacheFactory.create(ds);
      QueryService qs = cache.getQueryService();
      Region region = cache.getRegion("mainReportRegion");
      for (int i = 0; i < 100; i++) {
        Portfolio pf = new Portfolio(i);
        pf.setCreateTime(i);
        region.put("" + i, pf);
      }

      // verify that a query on the creation time works as expected
      SelectResults results = (SelectResults) qs
          .newQuery(
              "<trace>SELECT * FROM " + SEPARATOR
                  + "mainReportRegion.entrySet mr Where mr.value.createTime > 1L and mr.value.createTime < 3L")
          .execute();
      assertEquals("OQL index results did not match", 1, results.size());
      cache.close();
      ds.disconnect();
    }

    {
      Properties props = new Properties();
      props.setProperty(NAME, "test");
      props.setProperty(MCAST_PORT, "0");
      // Using a different cache.xml that changes some region properties
      // That will force the disk code to copy the region entries.
      props.setProperty(CACHE_XML_FILE,
          getClass().getResource("index-creation-without-eviction.xml").toURI().getPath());
      DistributedSystem ds = DistributedSystem.connect(props);
      Cache cache = CacheFactory.create(ds);
      QueryService qs = cache.getQueryService();
      Region region = cache.getRegion("mainReportRegion");

      // verify that a query on the creation time works as expected
      SelectResults results = (SelectResults) qs
          .newQuery(
              "<trace>SELECT * FROM " + SEPARATOR
                  + "mainReportRegion.entrySet mr Where mr.value.createTime > 1L and mr.value.createTime < 3L")
          .execute();
      assertEquals("OQL index results did not match", 1, results.size());
      ds.disconnect();
      FileUtils.deleteDirectory(file);
    }
  }
Test for bug 46872, make sure we recover the index correctly if the cache.xml changes for a
persistent region.
geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/IndexCreationJUnitTest.java