You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/10/30 19:08:46 UTC

svn commit: r1711531 - /lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java

Author: mikemccand
Date: Fri Oct 30 18:08:46 2015
New Revision: 1711531

URL: http://svn.apache.org/viewvc?rev=1711531&view=rev
Log:
LUCENE-6866: limit max token length

Modified:
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java?rev=1711531&r1=1711530&r2=1711531&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java Fri Oct 30 18:08:46 2015
@@ -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.Docume
 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 Luce
   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 Luce
   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());