add a test that tests more than one document

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1177048 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-09-28 20:33:16 +00:00
parent 7cbcf2a2de
commit ab5a62cf46
1 changed files with 28 additions and 0 deletions

View File

@ -18,12 +18,14 @@ package org.apache.lucene.search;
*/
import org.apache.lucene.document.Document;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.English;
import org.apache.lucene.util.LuceneTestCase;
public class TestQueryWrapperFilter extends LuceneTestCase {
@ -80,4 +82,30 @@ public class TestQueryWrapperFilter extends LuceneTestCase {
reader.close();
dir.close();
}
public void testThousandDocuments() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
for (int i = 0; i < 1000; i++) {
Document doc = new Document();
doc.add(newField("field", English.intToEnglish(i), StringField.TYPE_UNSTORED));
writer.addDocument(doc);
}
IndexReader reader = writer.getReader();
writer.close();
IndexSearcher searcher = newSearcher(reader);
for (int i = 0; i < 1000; i++) {
TermQuery termQuery = new TermQuery(new Term("field", English.intToEnglish(i)));
QueryWrapperFilter qwf = new QueryWrapperFilter(termQuery);
TopDocs td = searcher.search(new MatchAllDocsQuery(), qwf, 10);
assertEquals(1, td.totalHits);
}
searcher.close();
reader.close();
dir.close();
}
}