@Test
  public void testRangeMerging() {
    // populate:
    TestClass t1 = new TestClass();
    t1.setInt(51);
    pm.makePersistent(t1);
    pm.currentTransaction().commit();
    pm.currentTransaction().begin();

    String qf = "(_int > 1 && _int < 52) || _int > 50 && _int <= 123";

    // no indexing
    checkAdvices(qf, 1);
    checkResults(qf, 1);

    // indexing
    ZooJdoHelper.schema(pm).getClass(TestClass.class).createIndex("_int", true);
    checkAdvices(qf, 1);
    checkResults(qf, 1);
  }
  /**
   * Test the OR splitting. A query is split up at every OR, but only if both sub-queries use index
   * attributes. Without index there should be only one resulting query. With index there should be
   * two resulting queries.
   */
  @Test
  public void testOrSplitterWithoutIndex() {
    // populate:
    TestClass t1a = new TestClass();
    t1a.setInt(200); // test1
    t1a.setShort((short) 11);
    TestClass t1b = new TestClass();
    t1b.setInt(201); // test1
    t1b.setShort((short) 32000);
    pm.makePersistent(t1a);
    pm.makePersistent(t1b);
    pm.currentTransaction().commit();
    pm.currentTransaction().begin();

    // Equivalent to:
    // 123 <= _int < 12345 && _short==32000 || 123 <= _int < 12345 && _short==11
    // Ideally: Split if short is indexed. Do not split (or at least merge afterwards)
    // if _short is not indexed. If _short and _int are both indexed, it depends on the
    // selectiveness of the _int and _short ranges.
    String qf = "_int < 12345 && (_short == 32000 || _short == 11) && _int >= 123";

    // no indexing
    checkAdvices(qf, 1);
    checkResults(qf, 2);

    // single indexing outside OR
    ZooJdoHelper.schema(pm).getClass(TestClass.class).createIndex("_int", true);
    checkAdvices(qf, 1);
    checkResults(qf, 2);

    // double indexing inside OR
    ZooJdoHelper.schema(pm).getClass(TestClass.class).createIndex("_short", true);
    checkAdvices(qf, 2);
    checkResults(qf, 2);

    // single indexing inside OR
    ZooJdoHelper.schema(pm).getClass(TestClass.class).removeIndex("_int");
    checkAdvices(qf, 2);
    checkResults(qf, 2);
  }