@Test
  public void testIndexOnOverflowRegion() throws Exception {
    String regionName = "portfolios_overflow";

    // overflow region.
    AttributesFactory attributesFactory = new AttributesFactory();
    attributesFactory.setValueConstraint(Portfolio.class);
    attributesFactory.setEvictionAttributes(
        EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));

    Region region = CacheUtils.createRegion(regionName, attributesFactory.create(), true);

    for (int i = 0; i < 4; i++) {
      region.put(new Portfolio(i), new Portfolio(i));
    }

    QueryService qs = CacheUtils.getQueryService();
    // Currently supported with compact range-index.
    Index i1 = qs.createIndex("idIndex", IndexType.FUNCTIONAL, "pf.ID",
        SEPARATOR + "portfolios_overflow pf");
    Index i2 = qs.createIndex("keyIdIndex", IndexType.FUNCTIONAL, "key.ID",
        SEPARATOR + "portfolios_overflow.keys key");

    // Not yet supported with range-index.
    try {
      Index i3 = qs.createIndex("idIndex2", IndexType.FUNCTIONAL, "pf.ID",
          SEPARATOR + "portfolios_overflow pf, pf.positions pos");
      fail("Range index not supported on overflow region.");
    } catch (UnsupportedOperationException ex) {
      // Expected.
    }

    // Execute query.
    String[] queryStr =
        new String[] {"Select * from " + SEPARATOR + "portfolios_overflow pf where pf.ID = 2",
            "Select * from " + SEPARATOR + "portfolios_overflow.keys key where key.ID = 2",
            "Select * from " + SEPARATOR + "portfolios_overflow pf where pf.ID > 1",
            "Select * from " + SEPARATOR + "portfolios_overflow pf where pf.ID < 2",};

    int[] resultSize = new int[] {1, 1, 2, 2};

    for (int i = 0; i < queryStr.length; i++) {
      Query q = qs.newQuery(queryStr[i]);
      QueryObserverImpl observer = new QueryObserverImpl();
      QueryObserverHolder.setInstance(observer);
      SelectResults results = (SelectResults) q.execute();
      if (!observer.isIndexesUsed) {
        fail("Index not used for query. " + queryStr[i]);
      }
      assertEquals(results.size(), resultSize[i]);
    }

    for (int i = 0; i < 10; i++) {
      region.put(new Portfolio(i), new Portfolio(i));
    }

    // Persistent overflow region.

  }
Test the Index maiantenance as it may use the method keys() of QRegion instead of DummyQRegion
while running an IndexMaintenanceQuery
geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/IndexCreationJUnitTest.java