lucene/lucene-directory/src/test/java/org/infinispan/lucene/CacheTestSupport.java
/**
    * Used in test to verify an Index
    *
    * @param dir The Directory containing the Index to verify
    * @param term a single Term (after analysis) to be searched for
    * @param validDocumentIds The list of document identifiers which should contain the searched-for term
    * @throws IOException
    */
Used in test to verify an Index
@param dir The Directory containing the Index to verify
@param term a single Term (after analysis) to be searched for
@param validDocumentIds The list of document identifiers which should contain the searched-for term
@throws IOException
Used in test to verify an Index @param dir The Directory containing the Index to verify @param term a single Term ( after analysis ) to be searched for @param validDocumentIds The list of document identifiers which should contain the searched - for term @throws IOException
public static void assertTextIsFoundInIds(Directory dir, String term, Integer... validDocumentIds) throws IOException {
      int expectedResults = validDocumentIds.length;
      Set<Integer> expectedDocumendIds = new HashSet<Integer>(Arrays.asList(validDocumentIds));
      IndexReader reader = DirectoryReader.open(dir);
      IndexSearcher searcher = new IndexSearcher(reader);
      Query query = new TermQuery(new Term("body", term));
      TopDocs docs = searcher.search(query, expectedResults + 1);
      AssertJUnit.assertEquals(expectedResults, docs.totalHits);
      for (ScoreDoc scoreDoc : docs.scoreDocs) {
         int docId = scoreDoc.doc;
         Document document = searcher.doc(docId);
         String idString = document.get("id");
         AssertJUnit.assertNotNull(idString);
         Integer idFoundElement = Integer.valueOf(idString);
         assert expectedDocumendIds.contains(idFoundElement);
      }
      reader.close();
   }
public static void assertTextIsFoundInIds ( Directory dir , String term , Integer ... validDocumentIds ) throws IOException { int expectedResults = validDocumentIds . length ; Set < Integer > expectedDocumendIds = new HashSet < Integer > ( Arrays . asList ( validDocumentIds ) ) ; IndexReader reader = DirectoryReader . open ( dir ) ; IndexSearcher searcher = new IndexSearcher ( reader ) ; Query query = new TermQuery ( new Term ( "body" , term ) ) ; TopDocs docs = searcher . search ( query , expectedResults + 1 ) ; AssertJUnit . assertEquals ( expectedResults , docs . totalHits ) ; for ( ScoreDoc scoreDoc : docs . scoreDocs ) { int docId = scoreDoc . doc ; Document document = searcher . doc ( docId ) ; String idString = document . get ( "id" ) ; AssertJUnit . assertNotNull ( idString ) ; Integer idFoundElement = Integer . valueOf ( idString ) ; assert expectedDocumendIds . contains ( idFoundElement ) ; } reader . close ( ) ; }
Used in test to verify an Index
 @param dir The Directory containing the Index to verify
 @param term a single Term (after analysis) to be searched for
 @param validDocumentIds The list of document identifiers which should contain the searched-for term
 @throws IOException
Used in test to verify an Index @param dir The Directory containing the Index to verify @param term a single Term ( after analysis ) to be searched for @param validDocumentIds The list of document identifiers which should contain the searched - for term @throws IOException