Apache Lucene open-source search software
LUCENE-6866: limit max token length
Michael McCandlessd1a198a1f7ec
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java b/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.javaindex 5d201ded633..46157551b9b 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java@@ -17,18 +17,12 @@ package org.apache.lucene.index;* limitations under the License.*/-import java.io.IOException;import java.io.ByteArrayOutputStream;+import java.io.IOException;import java.io.PrintStream;-import java.util.List;import java.util.ArrayList;+import java.util.List;-import org.apache.lucene.util.IOUtils;-import org.apache.lucene.util.LineFileDocs;-import org.apache.lucene.util.LuceneTestCase;-import org.apache.lucene.store.Directory;-import org.apache.lucene.store.LockObtainFailedException;-import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.analysis.CannedTokenStream;import org.apache.lucene.analysis.MockAnalyzer;import org.apache.lucene.analysis.Token;@@ -36,6 +30,12 @@ import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;import org.apache.lucene.document.FieldType;import org.apache.lucene.document.TextField;+import org.apache.lucene.store.Directory;+import org.apache.lucene.store.LockObtainFailedException;+import org.apache.lucene.util.IOUtils;+import org.apache.lucene.util.LineFileDocs;+import org.apache.lucene.util.LuceneTestCase;+import org.apache.lucene.util.TestUtil;public class TestCheckIndex extends LuceneTestCase {@@ -126,7 +126,8 @@ public class TestCheckIndex extends LuceneTestCase {public void testChecksumsOnly() throws IOException {LineFileDocs lf = new LineFileDocs(random());Directory dir = newDirectory();- Analyzer analyzer = new MockAnalyzer(random());+ MockAnalyzer analyzer = new MockAnalyzer(random());+ analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(analyzer));for (int i = 0; i < 100; i++) {iw.addDocument(lf.nextDoc());@@ -150,7 +151,8 @@ public class TestCheckIndex extends LuceneTestCase {public void testChecksumsOnlyVerbose() throws IOException {LineFileDocs lf = new LineFileDocs(random());Directory dir = newDirectory();- Analyzer analyzer = new MockAnalyzer(random());+ MockAnalyzer analyzer = new MockAnalyzer(random());+ analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(analyzer));for (int i = 0; i < 100; i++) {iw.addDocument(lf.nextDoc());