LUCENE-2858: fix tests

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene2858@1237378 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-01-29 17:34:36 +00:00
parent 40ee62e573
commit bc95fc57e6
3 changed files with 16 additions and 13 deletions

View File

@ -284,11 +284,13 @@ public class TestPostingsOffsets extends LuceneTestCase {
doc.add(new Field("content", new CannedAnalyzer.CannedTokenizer(tokens.toArray(new Token[tokens.size()])), ft));
w.addDocument(doc);
}
final IndexReader r = w.getReader();
final DirectoryReader r = w.getReader();
w.close();
final String[] terms = new String[] {"a", "b", "c", "d"};
for(IndexReader sub : r.getSequentialSubReaders()) {
for(IndexReader reader : r.getSequentialSubReaders()) {
// TODO: improve this
AtomicIndexReader sub = (AtomicIndexReader) reader;
//System.out.println("\nsub=" + sub);
final TermsEnum termsEnum = sub.fields().terms("content").iterator(null);
DocsEnum docs = null;

View File

@ -53,8 +53,8 @@ public class TestSegmentMerger extends LuceneTestCase {
SegmentInfo info1 = DocHelper.writeDoc(random, merge1Dir, doc1);
DocHelper.setupDoc(doc2);
SegmentInfo info2 = DocHelper.writeDoc(random, merge2Dir, doc2);
reader1 = new SegmentReader(info1, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
reader2 = new SegmentReader(info2, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
reader1 = new SegmentReader(info1, DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
reader2 = new SegmentReader(info2, DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
}
@Override
@ -87,7 +87,7 @@ public class TestSegmentMerger extends LuceneTestCase {
//Should be able to open a new SegmentReader against the new directory
SegmentReader mergedReader = new SegmentReader(new SegmentInfo(mergedSegment, docsMerged, mergedDir, false,
codec, fieldInfos),
IndexReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
assertTrue(mergedReader != null);
assertTrue(mergedReader.numDocs() == 2);
Document newDoc1 = mergedReader.document(0);

View File

@ -66,7 +66,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
// TODO: verify equals using IW.getReader
DocsAndWriter dw = indexRandomIWReader(5, 3, 100, dir);
IndexReader reader = dw.writer.getReader();
DirectoryReader reader = dw.writer.getReader();
dw.writer.commit();
verifyEquals(random, reader, dir, "id");
reader.close();
@ -265,24 +265,25 @@ public class TestStressIndexing2 extends LuceneTestCase {
w.close();
}
public static void verifyEquals(Random r, IndexReader r1, Directory dir2, String idField) throws Throwable {
IndexReader r2 = IndexReader.open(dir2);
public static void verifyEquals(Random r, DirectoryReader r1, Directory dir2, String idField) throws Throwable {
DirectoryReader r2 = IndexReader.open(dir2);
verifyEquals(r1, r2, idField);
r2.close();
}
public static void verifyEquals(Directory dir1, Directory dir2, String idField) throws Throwable {
IndexReader r1 = IndexReader.open(dir1);
IndexReader r2 = IndexReader.open(dir2);
DirectoryReader r1 = IndexReader.open(dir1);
DirectoryReader r2 = IndexReader.open(dir2);
verifyEquals(r1, r2, idField);
r1.close();
r2.close();
}
private static void printDocs(IndexReader r) throws Throwable {
private static void printDocs(DirectoryReader r) throws Throwable {
IndexReader[] subs = r.getSequentialSubReaders();
for(IndexReader sub : subs) {
Bits liveDocs = sub.getLiveDocs();
// TODO: improve this
Bits liveDocs = ((AtomicIndexReader)sub).getLiveDocs();
System.out.println(" " + ((SegmentReader) sub).getSegmentInfo());
for(int docID=0;docID<sub.maxDoc();docID++) {
Document doc = sub.document(docID);
@ -296,7 +297,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
}
public static void verifyEquals(IndexReader r1, IndexReader r2, String idField) throws Throwable {
public static void verifyEquals(DirectoryReader r1, DirectoryReader r2, String idField) throws Throwable {
if (VERBOSE) {
System.out.println("\nr1 docs:");
printDocs(r1);