diff --git a/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java b/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java index 53067ca92af..5a627d45a87 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java @@ -292,8 +292,7 @@ public class TestTermVectorsReader extends LuceneTestCase { //System.out.println("Term: " + term); assertEquals(testTerms[i], term); assertNotNull(termsEnum.postings(null, null)); - // nocommit: check - assertNull(termsEnum.postings(null, null, PostingsEnum.ALL)); // no pos + assertNotNull(termsEnum.postings(null, null, PostingsEnum.ALL)); } reader.close(); } diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java index ccbc1577660..1d1a07c07e1 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java @@ -453,15 +453,12 @@ public abstract class BaseTermVectorsFormatTestCase extends BaseIndexFileFormatT bits.clear(0); PostingsEnum docsAndPositionsEnum = termsEnum.postings(bits, random().nextBoolean() ? null : this.docsEnum.get(), PostingsEnum.POSITIONS); - assertEquals(ft.storeTermVectorOffsets() || ft.storeTermVectorPositions(), docsAndPositionsEnum != null); - // nocommit: check - if (docsAndPositionsEnum != null) { + if (terms.hasPositions()) { assertEquals(PostingsEnum.NO_MORE_DOCS, docsAndPositionsEnum.nextDoc()); } bits.set(0); docsAndPositionsEnum = termsEnum.postings(random().nextBoolean() ? bits : null, random().nextBoolean() ? null : docsAndPositionsEnum, PostingsEnum.POSITIONS); - assertEquals(ft.storeTermVectorOffsets() || ft.storeTermVectorPositions(), docsAndPositionsEnum != null); if (terms.hasPositions() || terms.hasOffsets()) { assertEquals(0, docsAndPositionsEnum.nextDoc()); final int freq = docsAndPositionsEnum.freq(); diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java index 0d81a8ee4e6..bb7cf454c8b 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java @@ -1087,9 +1087,10 @@ public final class TestUtil { return docs(random, termsEnum, liveDocs, reuse, flags); } - // Returns a DocsEnum from a positioned TermsEnum, but - // randomly sometimes uses a DocsAndFreqsEnum, DocsAndPositionsEnum. + // Returns a PostingsEnum with random features available public static PostingsEnum docs(Random random, TermsEnum termsEnum, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException { + // TODO: simplify this method? it would be easier to randomly either use the flags passed, or do the random selection, + // FREQS should be part fo the random selection instead of outside on its own? if (random.nextBoolean()) { if (random.nextBoolean()) { final int posFlags; @@ -1099,11 +1100,7 @@ public final class TestUtil { case 2: posFlags = PostingsEnum.PAYLOADS; break; default: posFlags = PostingsEnum.ALL; break; } - PostingsEnum docsAndPositions = termsEnum.postings(liveDocs, null, posFlags); - // nocommit: check - if (docsAndPositions != null) { - return docsAndPositions; - } + return termsEnum.postings(liveDocs, null, posFlags); } flags |= PostingsEnum.FREQS; }