t = aprioriTermEnum.term();
aprioriTermEnum.close();
testTermEnum.close();
TermDocs aprioriTermDocs = aprioriReader.termDocs(t);
TermDocs testTermDocs = testReader.termDocs(t);
assertEquals(aprioriTermDocs.next(), testTermDocs.next());
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
if (aprioriTermDocs.skipTo(4)) {
assertTrue(testTermDocs.skipTo(4));
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
} else {
assertFalse(testTermDocs.skipTo(4));
}
if (aprioriTermDocs.next()) {
assertTrue(testTermDocs.next());
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
} else {
assertFalse(testTermDocs.next());
}
// beyond this point all next and skipto will return false
if (aprioriTermDocs.skipTo(100)) {
assertTrue(testTermDocs.skipTo(100));
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
} else {
assertFalse(testTermDocs.skipTo(100));
}
if (aprioriTermDocs.next()) {
assertTrue(testTermDocs.next());
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
} else {
assertFalse(testTermDocs.next());
}
if (aprioriTermDocs.skipTo(110)) {
assertTrue(testTermDocs.skipTo(110));
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
} else {
assertFalse(testTermDocs.skipTo(110));
}
if (aprioriTermDocs.skipTo(10)) {
assertTrue(testTermDocs.skipTo(10));
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
} else {
assertFalse(testTermDocs.skipTo(10));
}
if (aprioriTermDocs.skipTo(210)) {
assertTrue(testTermDocs.skipTo(210));
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
} else {
assertFalse(testTermDocs.skipTo(210));
}
aprioriTermDocs.close();
testTermDocs.close();
// test seek null (AllTermDocs)
aprioriTermDocs = aprioriReader.termDocs(null);
testTermDocs = testReader.termDocs(null);
while (aprioriTermDocs.next()) {
assertTrue(testTermDocs.next());
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
}
assertFalse(testTermDocs.next());
aprioriTermDocs.close();
testTermDocs.close();
// test seek default
aprioriTermDocs = aprioriReader.termDocs();
testTermDocs = testReader.termDocs();
// this is invalid use of the API,
// but if the response differs then it's an indication that something might have changed.
// in 2.9 and 3.0 the two TermDocs-implementations returned different values at this point.
// assertEquals("Descripency during invalid use of the TermDocs API, see comments in test code for details.",
// aprioriTermDocs.next(), testTermDocs.next());
// start using the API the way one is supposed to use it
t = new Term("", "");
aprioriTermDocs.seek(t);
testTermDocs.seek(t);
while (aprioriTermDocs.next()) {
assertTrue(testTermDocs.next());
assertEquals(aprioriTermDocs.freq(), testTermDocs.freq());
assertEquals(aprioriTermDocs.doc(), testTermDocs.doc());
}
assertFalse(testTermDocs.next());
aprioriTermDocs.close();
testTermDocs.close();
// clean up
aprioriReader.close();
testReader.close();