public void testExplain() throws ParseException { loadTestingData(); queryParser = createQueryParser("blurb"); Query luceneQuery = queryParser.parse("Eats"); CacheQuery<?> cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery); int matchCounter = 0; int i = 0; //The implementation is changed to this way as in case of NRT index manager the number of created documents may //differ comparing to the simple configuration. while (true) { try { Explanation found = cacheQuery.explain(i); if (found.isMatch()) matchCounter++; i++; if (i >= 10 || matchCounter == 3) break; } catch(ArrayIndexOutOfBoundsException ex) { break; } } assertEquals(3, matchCounter); StaticTestingErrorHandler.assertAllGood(cache); }