@Test
  public void testAllIndexesOnCommitForPut() throws Exception {
    // create region
    AttributesFactory af = new AttributesFactory();
    af.setDataPolicy(DataPolicy.REPLICATE);
    Region region = cache.createRegion("sample", af.create());

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

    String[] queries = {"select * from " + SEPARATOR + "sample where ID = 5",
        "select ID from " + SEPARATOR + "sample where ID < 5",
        "select ID from " + SEPARATOR + "sample where ID > 5",
        "select ID from " + SEPARATOR + "sample where ID != 5",
        "select status from " + SEPARATOR + "sample where status = 'active'",
        "select status from " + SEPARATOR + "sample where status > 'active'",
        "select status from " + SEPARATOR + "sample where status < 'active'",
        "select status from " + SEPARATOR + "sample where status != 'active'",
        "select pos.secId from " + SEPARATOR
            + "sample p, p.positions.values pos where pos.secId = 'IBM'",
        "select pos.secId from " + SEPARATOR
            + "sample p, p.positions.values pos where pos.secId < 'VMW'",
        "select pos.secId from " + SEPARATOR
            + "sample p, p.positions.values pos where pos.secId > 'IBM'",
        "select pos.secId from " + SEPARATOR
            + "sample p, p.positions.values pos where pos.secId != 'IBM'"};

    SelectResults[][] sr = new SelectResults[queries.length][2];

    // execute queries without indexes
    for (int i = 0; i < queries.length; i++) {
      sr[i][0] = (SelectResults) qs.newQuery(queries[i]).execute();
    }

    // create indexes
    qs.createKeyIndex("IDIndex", "ID", SEPARATOR + "sample");
    qs.createIndex("statusIndex", "status", SEPARATOR + "sample");
    qs.createIndex("secIdIndex", "pos.secId", SEPARATOR + "sample p, p.positions.values pos");

    // begin transaction
    Context ctx = cache.getJNDIContext();
    UserTransaction utx = (UserTransaction) ctx.lookup("java:/UserTransaction");
    utx.begin();

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

    // execute queries with indexes during transaction
    for (int i = 0; i < queries.length; i++) {
      sr[i][1] = (SelectResults) qs.newQuery(queries[i]).execute();
    }

    // complete transaction
    utx.commit();

    // verify results
    org.apache.geode.cache.query.CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
  }
verify that queries on indexes work with transaction
geode-core/src/integrationTest/java/org/apache/geode/cache/query/transaction/QueryAndJtaJUnitTest.java