From b3b32353018c2db3b5ba21e2e68e1930851b934d Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 27 Jan 2012 19:10:11 +0000 Subject: [PATCH] add assert to prevent confusion when writing tests git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1236842 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/codecs/preflexrw/PreFlexRWSegmentInfosWriter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lucene/src/test-framework/java/org/apache/lucene/codecs/preflexrw/PreFlexRWSegmentInfosWriter.java b/lucene/src/test-framework/java/org/apache/lucene/codecs/preflexrw/PreFlexRWSegmentInfosWriter.java index d7bab1c9856..9896a18d130 100644 --- a/lucene/src/test-framework/java/org/apache/lucene/codecs/preflexrw/PreFlexRWSegmentInfosWriter.java +++ b/lucene/src/test-framework/java/org/apache/lucene/codecs/preflexrw/PreFlexRWSegmentInfosWriter.java @@ -22,6 +22,7 @@ import java.util.Map; import java.util.Map.Entry; import org.apache.lucene.codecs.SegmentInfosWriter; +import org.apache.lucene.codecs.lucene3x.Lucene3xCodec; import org.apache.lucene.index.SegmentInfo; import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.store.ChecksumIndexOutput; @@ -63,6 +64,9 @@ public class PreFlexRWSegmentInfosWriter extends SegmentInfosWriter { /** Save a single segment's info. */ private void writeInfo(IndexOutput output, SegmentInfo si) throws IOException { + // we are about to write this SI in 3.x format, dropping all codec information, etc. + // so it had better be a 3.x segment or you will get very confusing errors later. + assert si.getCodec() instanceof Lucene3xCodec : "broken test, trying to mix preflex with other codecs"; assert si.getDelCount() <= si.docCount: "delCount=" + si.getDelCount() + " docCount=" + si.docCount + " segment=" + si.name; // Write the Lucene version that created this segment, since 3.1 output.writeString(si.getVersion());