diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java index 0e867a696dd..8a625934193 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Random; +import java.util.Collections; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.lucene.util.LuceneTestCase; @@ -5067,4 +5068,58 @@ public class TestIndexWriter extends LuceneTestCase { dir.close(); } + + public void testRandomStoredFields() throws IOException { + Directory dir = new MockRAMDirectory(); + Random rand = newRandom(); + RandomIndexWriter w = new RandomIndexWriter(rand, dir, newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(_TestUtil.nextInt(rand, 5, 20))); + final int docCount = 200*RANDOM_MULTIPLIER; + final int fieldCount = _TestUtil.nextInt(rand, 1, 5); + String[][] fields = new String[fieldCount][]; + for(int i=0;i fieldIDs = new ArrayList(); + + for(int i=0;i Number every so often + Collections.shuffle(fieldIDs); + } + } + + for(int x=0;x<2;x++) { + IndexReader r = w.getReader(); + + for(int iter=0;iter<1000*RANDOM_MULTIPLIER;iter++) { + int docID = rand.nextInt(docCount); + Document doc = r.document(docID); + for(int i=0;i