diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index ae3f4c7760b..4ba97496c77 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -68,6 +68,7 @@
+
@@ -450,6 +451,8 @@
+
+
diff --git a/lucene/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java b/lucene/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
index ff1b182689b..9079cefda6c 100644
--- a/lucene/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
+++ b/lucene/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
@@ -115,7 +115,7 @@ public class JEStoreTest extends LuceneTestCase {
final int count = 250;
final int LENGTH_MASK = 0xffff;
- Random r = newRandom();
+ Random r = random;
final long seed = r.nextLong();
Random gen = new Random(seed);
int totalLength = 0;
@@ -261,7 +261,7 @@ public class JEStoreTest extends LuceneTestCase {
final int count = 250;
final int LENGTH_MASK = 0xffff;
- Random r = newRandom();
+ Random r = random;
final long seed = r.nextLong();
Random gen = new Random(seed);
int totalLength = 0;
@@ -493,7 +493,7 @@ public class JEStoreTest extends LuceneTestCase {
final int count = 250;
final int LENGTH_MASK = 0xffff;
- Random r = newRandom();
+ Random r = random;
final long seed = r.nextLong();
Random gen = new Random(seed);
int totalLength = 0;
diff --git a/lucene/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java b/lucene/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
index 5d08e4dbb11..f766bd516e9 100644
--- a/lucene/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
+++ b/lucene/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
@@ -116,7 +116,7 @@ public class DbStoreTest extends LuceneTestCase {
final int count = 250;
final int LENGTH_MASK = 0xffff;
- Random r = newRandom();
+ Random r = random;
final long seed = r.nextLong();
Random gen = new Random(seed);
@@ -267,7 +267,7 @@ public class DbStoreTest extends LuceneTestCase {
final int count = 250;
final int LENGTH_MASK = 0xffff;
- Random r = newRandom();
+ Random r = random;
final long seed = r.nextLong();
Random gen = new Random(seed);
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
index e1968e2353a..31752349dd2 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
@@ -18,7 +18,6 @@ package org.apache.lucene.search.highlight;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -53,13 +52,12 @@ import org.apache.lucene.util.OpenBitSet;
public class HighlighterPhraseTest extends LuceneTestCase {
private static final String FIELD = "text";
- private Random random = newRandom();
public void testConcurrentPhrase() throws CorruptIndexException,
LockObtainFailedException, IOException, InvalidTokenOffsetsException {
final String TEXT = "the fox jumped";
- final Directory directory = newDirectory(random);
+ final Directory directory = newDirectory();
final IndexWriter indexWriter = new IndexWriter(directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
try {
final Document document = new Document();
document.add(new Field(FIELD, new TokenStreamConcurrent(),
@@ -101,9 +99,9 @@ public class HighlighterPhraseTest extends LuceneTestCase {
public void testConcurrentSpan() throws CorruptIndexException,
LockObtainFailedException, IOException, InvalidTokenOffsetsException {
final String TEXT = "the fox jumped";
- final Directory directory = newDirectory(random);
+ final Directory directory = newDirectory();
final IndexWriter indexWriter = new IndexWriter(directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
try {
final Document document = new Document();
document.add(new Field(FIELD, new TokenStreamConcurrent(),
@@ -171,9 +169,9 @@ public class HighlighterPhraseTest extends LuceneTestCase {
public void testSparsePhrase() throws CorruptIndexException,
LockObtainFailedException, IOException, InvalidTokenOffsetsException {
final String TEXT = "the fox did not jump";
- final Directory directory = newDirectory(random);
+ final Directory directory = newDirectory();
final IndexWriter indexWriter = new IndexWriter(directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
try {
final Document document = new Document();
document.add(new Field(FIELD, new TokenStreamSparse(),
@@ -214,9 +212,9 @@ public class HighlighterPhraseTest extends LuceneTestCase {
public void testSparsePhraseWithNoPositions() throws CorruptIndexException,
LockObtainFailedException, IOException, InvalidTokenOffsetsException {
final String TEXT = "the fox did not jump";
- final Directory directory = newDirectory(random);
+ final Directory directory = newDirectory();
final IndexWriter indexWriter = new IndexWriter(directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
try {
final Document document = new Document();
document.add(new Field(FIELD, TEXT, Store.YES, Index.ANALYZED,
@@ -255,9 +253,9 @@ public class HighlighterPhraseTest extends LuceneTestCase {
public void testSparseSpan() throws CorruptIndexException,
LockObtainFailedException, IOException, InvalidTokenOffsetsException {
final String TEXT = "the fox did not jump";
- final Directory directory = newDirectory(random);
+ final Directory directory = newDirectory();
final IndexWriter indexWriter = new IndexWriter(directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
try {
final Document document = new Document();
document.add(new Field(FIELD, new TokenStreamSparse(),
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
index bf69b807a2f..b9bacec7198 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
@@ -26,7 +26,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Random;
import java.util.StringTokenizer;
import javax.xml.parsers.DocumentBuilder;
@@ -99,7 +98,6 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
int numHighlights = 0;
final Analyzer analyzer = new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true);
TopDocs hits;
- private Random random;
String[] texts = {
"Hello this is a piece of text that is very long and contains too much preamble and the meat is really here which says kennedy has been shot",
@@ -1322,8 +1320,8 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
public void testMultiSearcher() throws Exception {
// setup index 1
- Directory ramDir1 = newDirectory(random);
- IndexWriter writer1 = new IndexWriter(ramDir1, newIndexWriterConfig(random,
+ Directory ramDir1 = newDirectory();
+ IndexWriter writer1 = new IndexWriter(ramDir1, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
Document d = new Document();
Field f = new Field(FIELD_NAME, "multiOne", Field.Store.YES, Field.Index.ANALYZED);
@@ -1334,8 +1332,8 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
IndexReader reader1 = IndexReader.open(ramDir1, true);
// setup index 2
- Directory ramDir2 = newDirectory(random);
- IndexWriter writer2 = new IndexWriter(ramDir2, newIndexWriterConfig(random,
+ Directory ramDir2 = newDirectory();
+ IndexWriter writer2 = new IndexWriter(ramDir2, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
d = new Document();
f = new Field(FIELD_NAME, "multiTwo", Field.Store.YES, Field.Index.ANALYZED);
@@ -1723,10 +1721,9 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
- ramDir = newDirectory(random);
- IndexWriter writer = new IndexWriter(ramDir, newIndexWriterConfig(random,
+ dir = newDirectory();
+ ramDir = newDirectory();
+ IndexWriter writer = new IndexWriter(ramDir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
for (int i = 0; i < texts.length; i++) {
addDoc(writer, texts[i]);
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
index 193d07dfb8f..b57125b77a4 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
@@ -92,7 +92,7 @@ public abstract class AbstractTestCase extends LuceneTestCase {
analyzerK = new MockAnalyzer(MockTokenizer.KEYWORD, false);
paW = new QueryParser(TEST_VERSION_CURRENT, F, analyzerW );
paB = new QueryParser(TEST_VERSION_CURRENT, F, analyzerB );
- dir = newDirectory(newRandom());
+ dir = newDirectory();
}
@Override
diff --git a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java
index e4b037d1135..61dd6644860 100644
--- a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java
+++ b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java
@@ -59,9 +59,8 @@ public class TestEmptyIndex extends LuceneTestCase {
ii.close();
// make sure a Directory acts the same
- Random random = newRandom();
- Directory d = newDirectory(random);
- new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())).close();
+ Directory d = newDirectory();
+ new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())).close();
r = IndexReader.open(d, false);
testNorms(r);
r.close();
@@ -92,9 +91,8 @@ public class TestEmptyIndex extends LuceneTestCase {
ii.close();
// make sure a Directory acts the same
- Random random = newRandom();
- Directory d = newDirectory(random);
- new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())).close();
+ Directory d = newDirectory();
+ new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())).close();
r = IndexReader.open(d, false);
termsEnumTest(r);
r.close();
diff --git a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
index d8716d5d97a..fff436dccb4 100644
--- a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
+++ b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
@@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import java.util.Random;
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
@@ -61,11 +60,10 @@ public class TestIndicesEquals extends LuceneTestCase {
public void testLoadIndexReader() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// create dir data
- IndexWriter indexWriter = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter indexWriter = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 20; i++) {
Document document = new Document();
@@ -86,12 +84,11 @@ public class TestIndicesEquals extends LuceneTestCase {
public void testInstantiatedIndexWriter() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
InstantiatedIndex ii = new InstantiatedIndex();
// create dir data
- IndexWriter indexWriter = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter indexWriter = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 500; i++) {
Document document = new Document();
diff --git a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestSerialization.java b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestSerialization.java
index fa495287b9b..49dc1604157 100644
--- a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestSerialization.java
+++ b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestSerialization.java
@@ -27,15 +27,13 @@ import org.apache.lucene.document.Field;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
-import java.util.Random;
public class TestSerialization extends LuceneTestCase {
public void test() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
- IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("foo", "bar rab abr bra rba", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
doc.add(new Field("moo", "bar rab abr bra rba", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
diff --git a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestUnoptimizedReaderOnConstructor.java b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestUnoptimizedReaderOnConstructor.java
index 7f07840ec84..d3a06998edc 100644
--- a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestUnoptimizedReaderOnConstructor.java
+++ b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestUnoptimizedReaderOnConstructor.java
@@ -16,7 +16,6 @@ package org.apache.lucene.store.instantiated;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
@@ -34,8 +33,7 @@ import org.apache.lucene.document.Field;
public class TestUnoptimizedReaderOnConstructor extends LuceneTestCase {
public void test() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocument(iw, "Hello, world!");
addDocument(iw, "All work and no play makes jack a dull boy");
diff --git a/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java b/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
index 503048a750c..c3597d6d0b3 100644
--- a/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
+++ b/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
-import java.util.Random;
import java.util.Set;
import org.apache.lucene.analysis.Analyzer;
@@ -46,7 +45,6 @@ import org.apache.lucene.util._TestUtil;
*/
public class MemoryIndexTest extends BaseTokenStreamTestCase {
private Set queries = new HashSet();
- private Random random;
public static final int ITERATIONS = 100 * RANDOM_MULTIPLIER;
@@ -55,7 +53,6 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
super.setUp();
queries.addAll(readQueries("testqueries.txt"));
queries.addAll(readQueries("testqueries2.txt"));
- random = newRandom();
}
/**
@@ -106,7 +103,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
termField.append(randomTerm());
}
- Directory ramdir = newDirectory(random);
+ Directory ramdir = newDirectory();
Analyzer analyzer = randomAnalyzer();
IndexWriter writer = new IndexWriter(ramdir,
new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java
index 0b98350c1bd..cb8624e8362 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java
@@ -19,7 +19,6 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.Arrays;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -57,9 +56,8 @@ public class TestFieldNormModifier extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- store = newDirectory(random);
- IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(random,
+ store = newDirectory();
+ IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < NUM_DOCS; i++) {
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
index d38b34de4c6..1d2fa6729ff 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
@@ -16,8 +16,6 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -28,15 +26,13 @@ import org.apache.lucene.util.BytesRef;
public class TestMultiPassIndexSplitter extends LuceneTestCase {
IndexReader input;
int NUM_DOCS = 11;
- private Random random;
Directory dir;
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc;
for (int i = 0; i < NUM_DOCS; i++) {
doc = new Document();
@@ -66,9 +62,9 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase {
public void testSplitRR() throws Exception {
MultiPassIndexSplitter splitter = new MultiPassIndexSplitter();
Directory[] dirs = new Directory[]{
- newDirectory(random),
- newDirectory(random),
- newDirectory(random)
+ newDirectory(),
+ newDirectory(),
+ newDirectory()
};
splitter.split(input, dirs, false);
IndexReader ir;
@@ -111,9 +107,9 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase {
public void testSplitSeq() throws Exception {
MultiPassIndexSplitter splitter = new MultiPassIndexSplitter();
Directory[] dirs = new Directory[]{
- newDirectory(random),
- newDirectory(random),
- newDirectory(random)
+ newDirectory(),
+ newDirectory(),
+ newDirectory()
};
splitter.split(input, dirs, true);
IndexReader ir;
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
index 8858e1cc1ad..c58f500e4eb 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
@@ -6,7 +6,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
-import java.util.Random;
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,9 +24,8 @@ import java.util.Random;
public class TestTermVectorAccessor extends LuceneTestCase {
public void test() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
- IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc;
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java
index ad35de38b29..c4c96be0916 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java
@@ -17,8 +17,6 @@ package org.apache.lucene.misc;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.util.BytesRef;
@@ -37,9 +35,8 @@ public class TestHighFreqTerms extends LuceneTestCase {
public void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- dir= newDirectory(random);
- writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ dir= newDirectory();
+ writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))
.setMaxBufferedDocs(2));
indexDocs(writer);
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java
index a4fa6992754..df2bbc179d2 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java
@@ -18,7 +18,6 @@ package org.apache.lucene.misc;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -26,7 +25,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.FieldNormModifier;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.DefaultSimilarity;
@@ -61,9 +59,8 @@ public class TestLengthNormModifier extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- store = newDirectory(random);
- IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(random,
+ store = newDirectory();
+ IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < NUM_DOCS; i++) {
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java
index 1101fdc5270..9474f5351c0 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java
@@ -18,7 +18,6 @@ package org.apache.lucene.search;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -39,8 +38,7 @@ public class BooleanFilterTest extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory, new MockAnalyzer(MockTokenizer.WHITESPACE, false));
//Add series of docs with filterable fields : acces rights, prices, dates and "in-stock" flags
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java
index c2b895f22f7..632674eeb0a 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.util.Calendar;
import java.util.GregorianCalendar;
-import java.util.Random;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -53,13 +52,10 @@ public class ChainedFilterTest extends LuceneTestCase {
private QueryWrapperFilter bobFilter;
private QueryWrapperFilter sueFilter;
- private Random random;
-
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
Calendar cal = new GregorianCalendar();
cal.clear();
@@ -194,7 +190,7 @@ public class ChainedFilterTest extends LuceneTestCase {
*/
public void testWithCachingFilter() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
IndexReader reader = writer.getReader();
writer.close();
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
index dfa998255b6..1117e2da88d 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.util.HashSet;
-import java.util.Random;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -42,8 +41,7 @@ public class DuplicateFilterTest extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
//Add series of docs with filterable fields : url, text and dates flags
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
index bf8c564503a..269a50dc68b 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.util.HashSet;
-import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -40,8 +39,7 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
//Add series of docs with misspelt names
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
index 2e22de95954..1f0b4bea116 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
@@ -52,8 +52,7 @@ public class TermsFilterTest extends LuceneTestCase {
public void testMissingTerms() throws Exception {
String fieldName="field1";
- Random random = newRandom();
- Directory rd=newDirectory(random);
+ Directory rd=newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random, rd);
for (int i = 0; i < 100; i++) {
Document doc=new Document();
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
index e41e2a4e772..5246a955dae 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
@@ -17,8 +17,6 @@ package org.apache.lucene.search.regex;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.store.Directory;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
@@ -42,8 +40,7 @@ public class TestRegexQuery extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
Document doc = new Document();
doc.add(new Field(FN, "the quick brown fox jumps over the lazy dog", Field.Store.NO, Field.Index.ANALYZED));
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
index f35f8bb13e1..05312f19885 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
@@ -18,14 +18,12 @@ package org.apache.lucene.search.regex;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.IndexSearcher;
@@ -41,14 +39,12 @@ public class TestSpanRegexQuery extends LuceneTestCase {
Directory indexStoreA;
Directory indexStoreB;
- Random random;
@Override
public void setUp() throws Exception {
super.setUp();
- random = newRandom();
- indexStoreA = newDirectory(random);
- indexStoreB = newDirectory(random);
+ indexStoreA = newDirectory();
+ indexStoreB = newDirectory();
}
@Override
@@ -59,8 +55,8 @@ public class TestSpanRegexQuery extends LuceneTestCase {
}
public void testSpanRegex() throws Exception {
- Directory directory = newDirectory(random);
- IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random,
+ Directory directory = newDirectory();
+ IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
// doc.add(new Field("field", "the quick brown fox jumps over the lazy dog",
@@ -128,14 +124,14 @@ public class TestSpanRegexQuery extends LuceneTestCase {
Field.Index.ANALYZED_NO_NORMS));
// creating first index writer
- IndexWriter writerA = new IndexWriter(indexStoreA, newIndexWriterConfig(random,
+ IndexWriter writerA = new IndexWriter(indexStoreA, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
writerA.addDocument(lDoc);
writerA.optimize();
writerA.close();
// creating second index writer
- IndexWriter writerB = new IndexWriter(indexStoreB, newIndexWriterConfig(random,
+ IndexWriter writerB = new IndexWriter(indexStoreB, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
writerB.addDocument(lDoc2);
writerB.optimize();
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
index 3a71dd52de9..d903789ecbf 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
@@ -22,7 +22,6 @@ import java.io.StringReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -45,8 +44,7 @@ public class TestMoreLikeThis extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
// Add series of docs with specific information for MoreLikeThis
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
index ab5a66ed233..7e2e758897d 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
@@ -18,7 +18,6 @@ package org.apache.lucene.queryParser.complexPhrase;
*/
import java.util.HashSet;
-import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -112,9 +111,8 @@ public class TestComplexPhraseQuery extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- rd = newDirectory(random);
- IndexWriter w = new IndexWriter(rd, newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer));
+ rd = newDirectory();
+ IndexWriter w = new IndexWriter(rd, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
for (int i = 0; i < docsContent.length; i++) {
Document doc = new Document();
doc.add(new Field("name", docsContent[i].name, Field.Store.YES,
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
index fb3e01002e2..efeacb62346 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
@@ -20,7 +20,6 @@ package org.apache.lucene.queryParser.standard;
import java.io.Reader;
import java.util.HashMap;
import java.util.Map;
-import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
@@ -318,9 +317,8 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
public void testStopWordSearching() throws Exception {
Analyzer analyzer = new MockAnalyzer();
- Random random = newRandom();
- Directory ramDir = newDirectory(random);
- IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer));
+ Directory ramDir = newDirectory();
+ IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
Document doc = new Document();
doc.add(new Field("body", "blah the footest blah", Field.Store.NO,
Field.Index.ANALYZED));
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
index 7d82aaae5ca..4dc4612b849 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
@@ -320,7 +320,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
public void testStopWordSearching() throws Exception {
Analyzer analyzer = new MockAnalyzer();
- Directory ramDir = newDirectory(newRandom());
+ Directory ramDir = newDirectory();
IndexWriter iw = new IndexWriter(ramDir, analyzer, true,
IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
index ada321a2011..1a08dfb3d4d 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
@@ -30,7 +30,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -654,9 +653,8 @@ public class TestQPHelper extends LocalizedTestCase {
}
public void testFarsiRangeCollating() throws Exception {
- Random random = newRandom();
- Directory ramDir = newDirectory(random);
- IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ Directory ramDir = newDirectory();
+ IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
Document doc = new Document();
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
Field.Index.NOT_ANALYZED));
@@ -1078,9 +1076,8 @@ public class TestQPHelper extends LocalizedTestCase {
}
public void testLocalDateFormat() throws IOException, QueryNodeException {
- Random random = newRandom();
- Directory ramDir = newDirectory(random);
- IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ Directory ramDir = newDirectory();
+ IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
addDateDoc("b", 2005, 12, 4, 22, 15, 00, iw);
iw.close();
@@ -1306,9 +1303,8 @@ public class TestQPHelper extends LocalizedTestCase {
}
public void testMultiPhraseQuery() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new CannedAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new CannedAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "", Field.Store.NO, Field.Index.ANALYZED));
w.addDocument(doc);
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
index 3747bb3e55e..83836c8624c 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
@@ -654,7 +654,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
public void testFarsiRangeCollating() throws Exception {
- Directory ramDir = newDirectory(newRandom());
+ Directory ramDir = newDirectory();
IndexWriter iw = new IndexWriter(ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), true,
IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
@@ -1063,7 +1063,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
public void testLocalDateFormat() throws IOException, ParseException {
- Directory ramDir = newDirectory(newRandom());
+ Directory ramDir = newDirectory();
IndexWriter iw = new IndexWriter(ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), true,
IndexWriter.MaxFieldLength.LIMITED);
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
diff --git a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
index f9d2db5144a..83536f2c563 100644
--- a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
+++ b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -70,10 +69,9 @@ public class TestCartesian extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
- IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
setUpPlotter( 2, 15);
diff --git a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
index 46e5d8266d2..3f7543bf0cc 100644
--- a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
+++ b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
@@ -17,7 +17,6 @@
package org.apache.lucene.spatial.tier;
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -44,9 +43,8 @@ public class TestDistance extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
- writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ directory = newDirectory();
+ writer = new IndexWriter(directory, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addData(writer);
}
diff --git a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
index 65c78cd40d0..66241af406e 100644
--- a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
+++ b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
@@ -19,7 +19,6 @@ package org.apache.lucene.search.spell;
import java.io.IOException;
import java.util.Iterator;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -40,16 +39,14 @@ public class TestLuceneDictionary extends LuceneTestCase {
private Directory store;
private IndexReader indexReader = null;
- private Random random;
private LuceneDictionary ld;
private Iterator it;
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- store = newDirectory(random);
- IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ store = newDirectory();
+ IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
Document doc;
@@ -195,7 +192,7 @@ public class TestLuceneDictionary extends LuceneTestCase {
}
public void testSpellchecker() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
SpellChecker sc = new SpellChecker(dir);
indexReader = IndexReader.open(store, true);
sc.indexDictionary(new LuceneDictionary(indexReader, "contents"));
diff --git a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestPlainTextDictionary.java b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestPlainTextDictionary.java
index f99ab3b0048..94ee2ee8de2 100644
--- a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestPlainTextDictionary.java
+++ b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestPlainTextDictionary.java
@@ -33,7 +33,7 @@ public class TestPlainTextDictionary extends LuceneTestCase {
final String LF = System.getProperty("line.separator");
String input = "oneword" + LF + "twoword" + LF + "threeword";
PlainTextDictionary ptd = new PlainTextDictionary(new StringReader(input));
- Directory ramDir = newDirectory(newRandom());
+ Directory ramDir = newDirectory();
SpellChecker spellChecker = new SpellChecker(ramDir);
spellChecker.indexDictionary(ptd);
String[] similar = spellChecker.suggestSimilar("treeword", 2);
diff --git a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
index 888c2c0564d..7becbd2b65c 100755
--- a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
+++ b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -46,7 +45,6 @@ import org.apache.lucene.util.LuceneTestCase;
public class TestSpellChecker extends LuceneTestCase {
private SpellCheckerMock spellChecker;
private Directory userindex, spellindex;
- private final Random random = newRandom();
private List searchers;
@Override
@@ -54,7 +52,7 @@ public class TestSpellChecker extends LuceneTestCase {
super.setUp();
//create a user index
- userindex = newDirectory(random);
+ userindex = newDirectory();
IndexWriter writer = new IndexWriter(userindex, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
@@ -68,7 +66,7 @@ public class TestSpellChecker extends LuceneTestCase {
writer.close();
searchers = Collections.synchronizedList(new ArrayList());
// create the spellChecker
- spellindex = newDirectory(random);
+ spellindex = newDirectory();
spellChecker = new SpellCheckerMock(spellindex);
}
@@ -124,7 +122,7 @@ public class TestSpellChecker extends LuceneTestCase {
public void testComparator() throws Exception {
IndexReader r = IndexReader.open(userindex, true);
- Directory compIdx = newDirectory(random);
+ Directory compIdx = newDirectory();
SpellChecker compareSP = new SpellCheckerMock(compIdx, new LevensteinDistance(), new SuggestWordFrequencyComparator());
addwords(r, compareSP, "field3");
diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
index 35b06221dc8..bb0f82003f2 100644
--- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
+++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
@@ -4,7 +4,6 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -57,10 +56,9 @@ public class TestParser extends LuceneTestCase {
//initialize the parser
builder=new CorePlusExtensionsParser("contents",analyzer);
- Random random = newRandom();
BufferedReader d = new BufferedReader(new InputStreamReader(TestParser.class.getResourceAsStream("reuters21578.txt")));
- dir=newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, Version.LUCENE_24, analyzer));
+ dir=newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(Version.LUCENE_24, analyzer));
String line = d.readLine();
while(line!=null)
{
diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
index e5fd77db82a..621a3f6b02c 100644
--- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
+++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
@@ -2,7 +2,6 @@ package org.apache.lucene.xmlparser;
import java.io.IOException;
import java.util.Properties;
-import java.util.Random;
import java.util.StringTokenizer;
import javax.xml.parsers.ParserConfigurationException;
@@ -142,9 +141,8 @@ public class TestQueryTemplateManager extends LuceneTestCase {
//Create an index
- Random random = newRandom();
- dir=newDirectory(random);
- IndexWriter w=new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer));
+ dir=newDirectory();
+ IndexWriter w=new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
for (int i = 0; i < docFieldValues.length; i++)
{
w.addDocument(getDocumentFromString(docFieldValues[i]));
diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java
index b2e76c52d87..b74eb65d3d8 100644
--- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java
+++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java
@@ -20,7 +20,6 @@ package org.apache.lucene.xmlparser.builders;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Random;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -61,9 +60,8 @@ public class TestNumericRangeFilterBuilder extends LuceneTestCase {
String xml = "";
Document doc = getDocumentFromString(xml);
Filter filter = filterBuilder.getFilter(doc.getDocumentElement());
- Random random = newRandom();
- Directory ramDir = newDirectory(random);
- IndexWriter writer = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, null));
+ Directory ramDir = newDirectory();
+ IndexWriter writer = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
writer.commit();
try
{
diff --git a/lucene/src/test/org/apache/lucene/TestDemo.java b/lucene/src/test/org/apache/lucene/TestDemo.java
index 2e2c137dc11..363f826513f 100644
--- a/lucene/src/test/org/apache/lucene/TestDemo.java
+++ b/lucene/src/test/org/apache/lucene/TestDemo.java
@@ -33,7 +33,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
@@ -49,7 +48,7 @@ public class TestDemo extends LuceneTestCase {
Analyzer analyzer = new MockAnalyzer();
// Store the index in memory:
- Directory directory = newDirectory(newRandom());
+ Directory directory = newDirectory();
// To store an index on disk, use this instead:
//Directory directory = FSDirectory.open("/tmp/testindex");
IndexWriter iwriter = new IndexWriter(directory, new IndexWriterConfig(
diff --git a/lucene/src/test/org/apache/lucene/TestExternalCodecs.java b/lucene/src/test/org/apache/lucene/TestExternalCodecs.java
index 38e15e5b8f1..cb5e9bdeda2 100644
--- a/lucene/src/test/org/apache/lucene/TestExternalCodecs.java
+++ b/lucene/src/test/org/apache/lucene/TestExternalCodecs.java
@@ -600,10 +600,9 @@ public class TestExternalCodecs extends LuceneTestCase {
public void testPerFieldCodec() throws Exception {
final int NUM_DOCS = 173;
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(new MyCodecs()));
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(new MyCodecs()));
w.setMergeFactor(3);
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java b/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
index df73e027f78..d393ffd139f 100644
--- a/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
+++ b/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
@@ -17,7 +17,6 @@ package org.apache.lucene;
* limitations under the License.
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.store.MockDirectoryWrapper;
@@ -83,15 +82,14 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
}
public void testSubclassConcurrentMergeScheduler() throws IOException {
- Random random = newRandom();
- MockDirectoryWrapper dir = newDirectory(random);
+ MockDirectoryWrapper dir = newDirectory();
dir.failOn(new FailOnlyOnMerge());
Document doc = new Document();
Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
doc.add(idField);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new MyMergeScheduler())
.setMaxBufferedDocs(2).setRAMBufferSizeMB(
IndexWriterConfig.DISABLE_AUTO_FLUSH));
diff --git a/lucene/src/test/org/apache/lucene/TestSearch.java b/lucene/src/test/org/apache/lucene/TestSearch.java
index 0b8a41e8ad5..a5353e33ba3 100644
--- a/lucene/src/test/org/apache/lucene/TestSearch.java
+++ b/lucene/src/test/org/apache/lucene/TestSearch.java
@@ -51,7 +51,6 @@ public class TestSearch extends LuceneTestCase {
* single-file formats, even if the results are wrong.
*/
public void testSearch() throws Exception {
- Random random = newRandom();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
doTestSearch(random, pw, false);
@@ -73,9 +72,9 @@ public class TestSearch extends LuceneTestCase {
private void doTestSearch(Random random, PrintWriter out, boolean useCompoundFile)
throws Exception {
- Directory directory = newDirectory(random);
+ Directory directory = newDirectory();
Analyzer analyzer = new MockAnalyzer();
- IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer);
+ IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
LogMergePolicy lmp = (LogMergePolicy) conf.getMergePolicy();
lmp.setUseCompoundFile(useCompoundFile);
lmp.setUseCompoundDocStore(useCompoundFile);
diff --git a/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java b/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
index 8c88ea1f365..364ee43474b 100644
--- a/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
+++ b/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
@@ -59,7 +59,6 @@ public class TestSearchForDuplicates extends LuceneTestCase {
public void testRun() throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
- Random random = newRandom();
doTest(random, pw, false);
pw.close();
sw.close();
@@ -78,9 +77,9 @@ public class TestSearchForDuplicates extends LuceneTestCase {
private void doTest(Random random, PrintWriter out, boolean useCompoundFiles) throws Exception {
- Directory directory = newDirectory(random);
+ Directory directory = newDirectory();
Analyzer analyzer = new MockAnalyzer();
- IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer);
+ IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
LogMergePolicy lmp = (LogMergePolicy) conf.getMergePolicy();
lmp.setUseCompoundFile(useCompoundFiles);
lmp.setUseCompoundDocStore(useCompoundFiles);
diff --git a/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java b/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java
index 217b3e166b2..2e058770d45 100644
--- a/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java
+++ b/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java
@@ -19,7 +19,6 @@ package org.apache.lucene.analysis;
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -37,8 +36,7 @@ public class TestCachingTokenFilter extends BaseTokenStreamTestCase {
private String[] tokens = new String[] {"term1", "term2", "term3", "term2"};
public void testCaching() throws IOException {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
Document doc = new Document();
TokenStream stream = new TokenStream() {
diff --git a/lucene/src/test/org/apache/lucene/analysis/TestCharTokenizers.java b/lucene/src/test/org/apache/lucene/analysis/TestCharTokenizers.java
index 90414b5a915..28111b7e35d 100644
--- a/lucene/src/test/org/apache/lucene/analysis/TestCharTokenizers.java
+++ b/lucene/src/test/org/apache/lucene/analysis/TestCharTokenizers.java
@@ -20,10 +20,8 @@ package org.apache.lucene.analysis;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
-import java.util.Random;
import org.apache.lucene.util.Version;
-import org.apache.lucene.util._TestUtil;
/**
* Testcase for {@link CharTokenizer} subclasses
@@ -36,9 +34,8 @@ public class TestCharTokenizers extends BaseTokenStreamTestCase {
*/
public void testReadSupplementaryChars() throws IOException {
StringBuilder builder = new StringBuilder();
- Random newRandom = newRandom();
// create random input
- int num = 1024 + newRandom.nextInt(1024);
+ int num = 1024 + random.nextInt(1024);
num *= RANDOM_MULTIPLIER;
for (int i = 1; i < num; i++) {
builder.append("\ud801\udc1cabc");
diff --git a/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java b/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
index 19dca4e1580..20d6db627c9 100644
--- a/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
+++ b/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
@@ -1,7 +1,5 @@
package org.apache.lucene.document;
-import java.util.Random;
-
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.IndexReader;
@@ -57,8 +55,7 @@ public class TestBinaryDocument extends LuceneTestCase {
assertEquals(2, doc.fields.size());
/** add the doc to a ram index */
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);
@@ -97,8 +94,7 @@ public class TestBinaryDocument extends LuceneTestCase {
doc.add(stringFldCompressed);
/** add the doc to a ram index */
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);
diff --git a/lucene/src/test/org/apache/lucene/document/TestDocument.java b/lucene/src/test/org/apache/lucene/document/TestDocument.java
index bfd0b165589..3044e23d7ef 100644
--- a/lucene/src/test/org/apache/lucene/document/TestDocument.java
+++ b/lucene/src/test/org/apache/lucene/document/TestDocument.java
@@ -1,7 +1,5 @@
package org.apache.lucene.document;
-import java.util.Random;
-
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
@@ -154,8 +152,7 @@ public class TestDocument extends LuceneTestCase {
* @throws Exception on error
*/
public void testGetValuesForIndexedDocument() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(makeDocumentWithFields());
IndexReader reader = writer.getReader();
@@ -233,8 +230,7 @@ public class TestDocument extends LuceneTestCase {
doc.add(new Field("keyword", "test", Field.Store.YES,
Field.Index.NOT_ANALYZED));
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);
field.setValue("id2");
diff --git a/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java b/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
index bc98bebe303..f9857c7ba93 100755
--- a/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
+++ b/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -34,24 +33,17 @@ import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.PhraseQuery;
public class TestAddIndexes extends LuceneTestCase {
- private Random random;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
public void testSimpleCase() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// two auxiliary directories
- Directory aux = newDirectory(random);
- Directory aux2 = newDirectory(random);
+ Directory aux = newDirectory();
+ Directory aux2 = newDirectory();
IndexWriter writer = null;
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer())
.setOpenMode(OpenMode.CREATE));
// add 100 documents
@@ -60,7 +52,7 @@ public class TestAddIndexes extends LuceneTestCase {
writer.close();
_TestUtil.checkIndex(dir);
- writer = newWriter(aux, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ writer = newWriter(aux, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false); // use one without a compound file
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false); // use one without a compound file
// add 40 documents in separate files
@@ -68,14 +60,14 @@ public class TestAddIndexes extends LuceneTestCase {
assertEquals(40, writer.maxDoc());
writer.close();
- writer = newWriter(aux2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ writer = newWriter(aux2, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
// add 40 documents in compound files
addDocs2(writer, 50);
assertEquals(50, writer.maxDoc());
writer.close();
// test doc count before segments are merged
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
assertEquals(100, writer.maxDoc());
writer.addIndexes(new Directory[] { aux, aux2 });
assertEquals(190, writer.maxDoc());
@@ -89,15 +81,15 @@ public class TestAddIndexes extends LuceneTestCase {
verifyNumDocs(dir, 190);
// now add another set in.
- Directory aux3 = newDirectory(random);
- writer = newWriter(aux3, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory aux3 = newDirectory();
+ writer = newWriter(aux3, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
// add 40 documents
addDocs(writer, 40);
assertEquals(40, writer.maxDoc());
writer.close();
// test doc count before segments are merged/index is optimized
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
assertEquals(190, writer.maxDoc());
writer.addIndexes(new Directory[] { aux3 });
assertEquals(230, writer.maxDoc());
@@ -111,7 +103,7 @@ public class TestAddIndexes extends LuceneTestCase {
verifyTermDocs(dir, new Term("content", "bbb"), 50);
// now optimize it.
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
writer.optimize();
writer.close();
@@ -123,12 +115,12 @@ public class TestAddIndexes extends LuceneTestCase {
verifyTermDocs(dir, new Term("content", "bbb"), 50);
// now add a single document
- Directory aux4 = newDirectory(random);
- writer = newWriter(aux4, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory aux4 = newDirectory();
+ writer = newWriter(aux4, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocs2(writer, 1);
writer.close();
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
assertEquals(230, writer.maxDoc());
writer.addIndexes(new Directory[] { aux4 });
assertEquals(231, writer.maxDoc());
@@ -146,12 +138,12 @@ public class TestAddIndexes extends LuceneTestCase {
public void testWithPendingDeletes() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
+ Directory aux = newDirectory();
setUpDirs(dir, aux);
- IndexWriter writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ IndexWriter writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
writer.addIndexes(new Directory[] {aux});
// Adds 10 docs, then replaces them with another 10
@@ -183,12 +175,12 @@ public class TestAddIndexes extends LuceneTestCase {
public void testWithPendingDeletes2() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
+ Directory aux = newDirectory();
setUpDirs(dir, aux);
- IndexWriter writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ IndexWriter writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
// Adds 10 docs, then replaces them with another 10
// docs, so 10 pending deletes:
@@ -221,12 +213,12 @@ public class TestAddIndexes extends LuceneTestCase {
public void testWithPendingDeletes3() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
+ Directory aux = newDirectory();
setUpDirs(dir, aux);
- IndexWriter writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ IndexWriter writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
// Adds 10 docs, then replaces them with another 10
// docs, so 10 pending deletes:
@@ -261,31 +253,31 @@ public class TestAddIndexes extends LuceneTestCase {
// case 0: add self or exceed maxMergeDocs, expect exception
public void testAddSelf() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
+ Directory aux = newDirectory();
IndexWriter writer = null;
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
// add 100 documents
addDocs(writer, 100);
assertEquals(100, writer.maxDoc());
writer.close();
- writer = newWriter(aux, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(1000));
+ writer = newWriter(aux, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(1000));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false); // use one without a compound file
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false); // use one without a compound file
// add 140 documents in separate files
addDocs(writer, 40);
writer.close();
- writer = newWriter(aux, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(1000));
+ writer = newWriter(aux, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(1000));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false); // use one without a compound file
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false); // use one without a compound file
addDocs(writer, 100);
writer.close();
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
try {
// cannot add self
writer.addIndexes(new Directory[] { aux, dir });
@@ -307,13 +299,13 @@ public class TestAddIndexes extends LuceneTestCase {
// case 1: no tail segments
public void testNoTailSegments() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
+ Directory aux = newDirectory();
setUpDirs(dir, aux);
- IndexWriter writer = newWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = newWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
@@ -333,13 +325,13 @@ public class TestAddIndexes extends LuceneTestCase {
// case 2: tail segments, invariants hold, no copy
public void testNoCopySegments() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
+ Directory aux = newDirectory();
setUpDirs(dir, aux);
- IndexWriter writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(9));
+ IndexWriter writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(9));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
addDocs(writer, 2);
@@ -357,13 +349,13 @@ public class TestAddIndexes extends LuceneTestCase {
// case 3: tail segments, invariants hold, copy, invariants hold
public void testNoMergeAfterCopy() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
+ Directory aux = newDirectory();
setUpDirs(dir, aux);
- IndexWriter writer = newWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = newWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
@@ -382,9 +374,9 @@ public class TestAddIndexes extends LuceneTestCase {
// case 4: tail segments, invariants hold, copy, invariants not hold
public void testMergeAfterCopy() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
+ Directory aux = newDirectory();
setUpDirs(dir, aux);
@@ -395,7 +387,7 @@ public class TestAddIndexes extends LuceneTestCase {
assertEquals(10, reader.numDocs());
reader.close();
- IndexWriter writer = newWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = newWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(4));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
@@ -411,14 +403,14 @@ public class TestAddIndexes extends LuceneTestCase {
// case 5: tail segments, invariants not hold
public void testMoreMerges() throws IOException {
// main directory
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
// auxiliary directory
- Directory aux = newDirectory(random);
- Directory aux2 = newDirectory(random);
+ Directory aux = newDirectory();
+ Directory aux2 = newDirectory();
setUpDirs(dir, aux);
- IndexWriter writer = newWriter(aux2, newIndexWriterConfig(random,
+ IndexWriter writer = newWriter(aux2, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(100));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(10);
@@ -441,7 +433,7 @@ public class TestAddIndexes extends LuceneTestCase {
assertEquals(22, reader.numDocs());
reader.close();
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())
.setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(6));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
@@ -500,14 +492,14 @@ public class TestAddIndexes extends LuceneTestCase {
private void setUpDirs(Directory dir, Directory aux) throws IOException {
IndexWriter writer = null;
- writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(1000));
+ writer = newWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(1000));
// add 1000 documents in 1 segment
addDocs(writer, 1000);
assertEquals(1000, writer.maxDoc());
assertEquals(1, writer.getSegmentCount());
writer.close();
- writer = newWriter(aux, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(100));
+ writer = newWriter(aux, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(100));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false); // use one without a compound file
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false); // use one without a compound file
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(10);
@@ -515,7 +507,7 @@ public class TestAddIndexes extends LuceneTestCase {
for (int i = 0; i < 3; i++) {
addDocs(writer, 10);
writer.close();
- writer = newWriter(aux, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(100));
+ writer = newWriter(aux, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(100));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false); // use one without a compound file
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false); // use one without a compound file
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(10);
@@ -528,12 +520,12 @@ public class TestAddIndexes extends LuceneTestCase {
// LUCENE-1270
public void testHangOnClose() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
LogByteSizeMergePolicy lmp = new LogByteSizeMergePolicy();
lmp.setUseCompoundFile(false);
lmp.setUseCompoundDocStore(false);
lmp.setMergeFactor(100);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(5).setMergePolicy(lmp));
@@ -556,13 +548,13 @@ public class TestAddIndexes extends LuceneTestCase {
writer.addDocument(doc2);
writer.close();
- Directory dir2 = newDirectory(random);
+ Directory dir2 = newDirectory();
lmp = new LogByteSizeMergePolicy();
lmp.setMinMergeMB(0.0001);
lmp.setUseCompoundFile(false);
lmp.setUseCompoundDocStore(false);
lmp.setMergeFactor(4);
- writer = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(dir2, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer())
.setMergeScheduler(new SerialMergeScheduler()).setMergePolicy(lmp));
writer.addIndexes(new Directory[] {dir});
diff --git a/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java b/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
index 3ff926ed4bd..40c40db5d2c 100644
--- a/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
+++ b/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
@@ -185,7 +185,7 @@ public class TestAtomicUpdate extends LuceneTestCase {
FSDirectory.
*/
public void testAtomicUpdates() throws Exception {
- MockIndexWriter.RANDOM = newRandom();
+ MockIndexWriter.RANDOM = random;
Directory directory;
// First in a RAM directory:
diff --git a/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
index caf92ed3130..a6db7f07ef4 100644
--- a/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
+++ b/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
@@ -148,7 +148,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
/** This test checks that *only* IndexFormatTooOldExceptions are throws when you open and operate on too old indexes! */
public void testUnsupportedOldIndexes() throws Exception {
- final Random rnd = newRandom();
for(int i=0;i commitUserData = new HashMap();
commitUserData.put("foo", "fighters");
// set up writer
- IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2));
for(int i=0;i<27;i++)
@@ -113,7 +104,7 @@ public class TestIndexReader extends LuceneTestCase
assertTrue(c.equals(r.getIndexCommit()));
// Change the index
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(
OpenMode.APPEND).setMaxBufferedDocs(2));
for(int i=0;i<7;i++)
@@ -125,7 +116,7 @@ public class TestIndexReader extends LuceneTestCase
assertFalse(r2.getIndexCommit().isOptimized());
r3.close();
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer())
.setOpenMode(OpenMode.APPEND));
writer.optimize();
@@ -139,8 +130,8 @@ public class TestIndexReader extends LuceneTestCase
}
public void testIsCurrent() throws Exception {
- Directory d = newDirectory(random);
- IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
+ Directory d = newDirectory();
+ IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
writer.close();
@@ -148,13 +139,13 @@ public class TestIndexReader extends LuceneTestCase
IndexReader reader = IndexReader.open(d, false);
assertTrue(reader.isCurrent());
// modify index by adding another document:
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
addDocumentWithFields(writer);
writer.close();
assertFalse(reader.isCurrent());
// re-create index:
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
addDocumentWithFields(writer);
writer.close();
@@ -168,9 +159,9 @@ public class TestIndexReader extends LuceneTestCase
* @throws Exception on error
*/
public void testGetFieldNames() throws Exception {
- Directory d = newDirectory(random);
+ Directory d = newDirectory();
// set up writer
- IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
writer.close();
@@ -183,7 +174,7 @@ public class TestIndexReader extends LuceneTestCase
assertTrue(fieldNames.contains("unstored"));
reader.close();
// add more documents
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
// want to get some more segments here
int mergeFactor = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor();
@@ -260,9 +251,9 @@ public class TestIndexReader extends LuceneTestCase
}
public void testTermVectors() throws Exception {
- Directory d = newDirectory(random);
+ Directory d = newDirectory();
// set up writer
- IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
// want to get some more segments here
// new termvector fields
@@ -314,14 +305,14 @@ public class TestIndexReader extends LuceneTestCase
}
public void testBasicDelete() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter writer = null;
IndexReader reader = null;
Term searchTerm = new Term("content", "aaa");
// add 100 documents with term : aaa
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 100; i++) {
addDoc(writer, searchTerm.text());
}
@@ -358,10 +349,10 @@ public class TestIndexReader extends LuceneTestCase
}
public void testBinaryFields() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
byte[] bin = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 10; i++) {
addDoc(writer, "document number " + (i + 1));
@@ -370,7 +361,7 @@ public class TestIndexReader extends LuceneTestCase
addDocumentWithTermVectorFields(writer);
}
writer.close();
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
Document doc = new Document();
doc.add(new Field("bin1", bin));
doc.add(new Field("junk", "junk text", Field.Store.NO, Field.Index.ANALYZED));
@@ -407,7 +398,7 @@ public class TestIndexReader extends LuceneTestCase
// force optimize
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
writer.optimize();
writer.close();
reader = IndexReader.open(dir, false);
@@ -429,14 +420,14 @@ public class TestIndexReader extends LuceneTestCase
// Make sure attempts to make changes after reader is
// closed throws IOException:
public void testChangesAfterClose() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter writer = null;
IndexReader reader = null;
Term searchTerm = new Term("content", "aaa");
// add 11 documents with term : aaa
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 11; i++) {
addDoc(writer, searchTerm.text());
}
@@ -473,12 +464,12 @@ public class TestIndexReader extends LuceneTestCase
// Make sure we get lock obtain failed exception with 2 writers:
public void testLockObtainFailed() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
Term searchTerm = new Term("content", "aaa");
// add 11 documents with term : aaa
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.commit();
for (int i = 0; i < 11; i++) {
addDoc(writer, searchTerm.text());
@@ -523,7 +514,7 @@ public class TestIndexReader extends LuceneTestCase
Term searchTerm = new Term("content", "aaa");
// add 1 documents with term : aaa
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDoc(writer, searchTerm.text());
writer.close();
@@ -561,13 +552,13 @@ public class TestIndexReader extends LuceneTestCase
// Make sure you can set norms & commit, and there are
// no extra norms files left:
public void testWritingNormsNoReader() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter writer = null;
IndexReader reader = null;
Term searchTerm = new Term("content", "aaa");
// add 1 documents with term : aaa
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
addDoc(writer, searchTerm.text());
@@ -615,13 +606,13 @@ public class TestIndexReader extends LuceneTestCase
private void deleteReaderWriterConflict(boolean optimize) throws IOException {
//Directory dir = new RAMDirectory();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
Term searchTerm = new Term("content", "aaa");
Term searchTerm2 = new Term("content", "bbb");
// add 100 documents with term : aaa
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
for (int i = 0; i < 100; i++) {
addDoc(writer, searchTerm.text());
}
@@ -636,7 +627,7 @@ public class TestIndexReader extends LuceneTestCase
assertTermDocsCount("first reader", reader, searchTerm2, 0);
// add 100 documents with term : bbb
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
for (int i = 0; i < 100; i++) {
addDoc(writer, searchTerm2.text());
}
@@ -698,7 +689,7 @@ public class TestIndexReader extends LuceneTestCase
// Create initial data set
File dirFile = _TestUtil.getTempDir("TestIndexReader.testFilesOpenClose");
Directory dir = FSDirectory.open(dirFile);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDoc(writer, "test");
writer.close();
dir.close();
@@ -708,7 +699,7 @@ public class TestIndexReader extends LuceneTestCase
dir = FSDirectory.open(dirFile);
// Now create the data set again, just as before
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
addDoc(writer, "test");
writer.close();
dir.close();
@@ -726,9 +717,9 @@ public class TestIndexReader extends LuceneTestCase
public void testLastModified() throws Exception {
for(int i=0;i<2;i++) {
- final Directory dir = newDirectory(random);
+ final Directory dir = newDirectory();
assertFalse(IndexReader.indexExists(dir));
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
addDocumentWithFields(writer);
assertTrue(IndexWriter.isLocked(dir)); // writer open, so dir is locked
writer.close();
@@ -745,7 +736,7 @@ public class TestIndexReader extends LuceneTestCase
// incremented:
Thread.sleep(1000);
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
addDocumentWithFields(writer);
writer.close();
reader = IndexReader.open(dir, false);
@@ -756,9 +747,9 @@ public class TestIndexReader extends LuceneTestCase
}
public void testVersion() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
assertFalse(IndexReader.indexExists(dir));
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
assertTrue(IndexWriter.isLocked(dir)); // writer open, so dir is locked
writer.close();
@@ -769,7 +760,7 @@ public class TestIndexReader extends LuceneTestCase
reader.close();
// modify index and check version has been
// incremented:
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
addDocumentWithFields(writer);
writer.close();
reader = IndexReader.open(dir, false);
@@ -779,11 +770,11 @@ public class TestIndexReader extends LuceneTestCase
}
public void testLock() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
writer.close();
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
IndexReader reader = IndexReader.open(dir, false);
try {
reader.deleteDocument(0);
@@ -803,8 +794,8 @@ public class TestIndexReader extends LuceneTestCase
}
public void testUndeleteAll() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
addDocumentWithFields(writer);
writer.close();
@@ -820,8 +811,8 @@ public class TestIndexReader extends LuceneTestCase
}
public void testUndeleteAllAfterClose() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
addDocumentWithFields(writer);
writer.close();
@@ -837,8 +828,8 @@ public class TestIndexReader extends LuceneTestCase
}
public void testUndeleteAllAfterCloseThenReopen() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
addDocumentWithFields(writer);
writer.close();
@@ -874,8 +865,8 @@ public class TestIndexReader extends LuceneTestCase
int END_COUNT = 144;
// First build up a starting index:
- MockDirectoryWrapper startDir = newDirectory(random);
- IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ MockDirectoryWrapper startDir = newDirectory();
+ IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int i=0;i<157;i++) {
Document d = new Document();
d.add(new Field("id", Integer.toString(i), Field.Store.YES, Field.Index.NOT_ANALYZED));
@@ -1048,8 +1039,8 @@ public class TestIndexReader extends LuceneTestCase
}
public void testDocsOutOfOrderJIRA140() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int i=0;i<11;i++) {
addDoc(writer, "aaa");
}
@@ -1067,7 +1058,7 @@ public class TestIndexReader extends LuceneTestCase
}
reader.close();
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
// We must add more docs to get a new segment written
for(int i=0;i<11;i++) {
@@ -1088,8 +1079,8 @@ public class TestIndexReader extends LuceneTestCase
public void testExceptionReleaseWriteLockJIRA768() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
addDoc(writer, "aaa");
writer.close();
@@ -1143,7 +1134,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testMultiReaderDeletes() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random, dir);
Document doc = new Document();
doc.add(new Field("f", "doctor", Field.Store.NO, Field.Index.NOT_ANALYZED));
@@ -1173,7 +1164,7 @@ public class TestIndexReader extends LuceneTestCase
}
private void deleteReaderReaderConflict(boolean optimize) throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
Term searchTerm1 = new Term("content", "aaa");
Term searchTerm2 = new Term("content", "bbb");
@@ -1182,7 +1173,7 @@ public class TestIndexReader extends LuceneTestCase
// add 100 documents with term : aaa
// add 100 documents with term : bbb
// add 100 documents with term : ccc
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
for (int i = 0; i < 100; i++) {
addDoc(writer, searchTerm1.text());
addDoc(writer, searchTerm2.text());
@@ -1410,10 +1401,10 @@ public class TestIndexReader extends LuceneTestCase
public void testGetIndexCommit() throws IOException {
- Directory d = newDirectory(random);
+ Directory d = newDirectory();
// set up writer
- IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2));
((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
@@ -1431,7 +1422,7 @@ public class TestIndexReader extends LuceneTestCase
assertTrue(c.equals(r.getIndexCommit()));
// Change the index
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(
OpenMode.APPEND).setMaxBufferedDocs(2));
((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
@@ -1444,7 +1435,7 @@ public class TestIndexReader extends LuceneTestCase
assertFalse(r2.getIndexCommit().isOptimized());
r2.close();
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer())
.setOpenMode(OpenMode.APPEND));
writer.optimize();
@@ -1459,8 +1450,8 @@ public class TestIndexReader extends LuceneTestCase
}
public void testReadOnly() throws Throwable {
- Directory d = newDirectory(random);
- IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
+ Directory d = newDirectory();
+ IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
writer.commit();
@@ -1475,7 +1466,7 @@ public class TestIndexReader extends LuceneTestCase
// expected
}
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer())
.setOpenMode(OpenMode.APPEND));
((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
@@ -1495,7 +1486,7 @@ public class TestIndexReader extends LuceneTestCase
// expected
}
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer())
.setOpenMode(OpenMode.APPEND));
writer.optimize();
@@ -1516,7 +1507,7 @@ public class TestIndexReader extends LuceneTestCase
}
// Make sure write lock isn't held
- writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer())
.setOpenMode(OpenMode.APPEND));
writer.close();
@@ -1528,8 +1519,8 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1474
public void testIndexReader() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.addDocument(createDocument("a"));
writer.addDocument(createDocument("b"));
@@ -1546,9 +1537,9 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1647
public void testIndexReaderUnDeleteAll() throws Exception {
- MockDirectoryWrapper dir = newDirectory(random);
+ MockDirectoryWrapper dir = newDirectory();
dir.setPreventDoubleWrite(false);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.addDocument(createDocument("a"));
writer.addDocument(createDocument("b"));
@@ -1588,9 +1579,9 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1509
public void testNoDupCommitFileNames() throws Throwable {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2));
writer.addDocument(createDocument("a"));
@@ -1614,8 +1605,8 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1579: Ensure that on a cloned reader, segments
// reuse the doc values arrays in FieldCache
public void testFieldCacheReuseAfterClone() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("number", "17", Field.Store.NO, Field.Index.NOT_ANALYZED));
writer.addDocument(doc);
@@ -1645,8 +1636,8 @@ public class TestIndexReader extends LuceneTestCase
// shared segments reuse the doc values arrays in
// FieldCache
public void testFieldCacheReuseAfterReopen() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("number", "17", Field.Store.NO, Field.Index.NOT_ANALYZED));
((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
@@ -1678,8 +1669,8 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1579: Make sure all SegmentReaders are new when
// reopen switches readOnly
public void testReopenChangeReadonly() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(-1));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(-1));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(10);
Document doc = new Document();
doc.add(new Field("number", "17", Field.Store.NO, Field.Index.NOT_ANALYZED));
@@ -1720,8 +1711,8 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1586: getUniqueTermCount
public void testUniqueTermCount() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
Document doc = new Document();
doc.add(new Field("field", "a b c d e f g h i j k l m n o p q r s t u v w x y z", Field.Store.NO, Field.Index.ANALYZED));
doc.add(new Field("number", "0 1 2 3 4 5 6 7 8 9", Field.Store.NO, Field.Index.ANALYZED));
@@ -1753,8 +1744,8 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1609: don't load terms index
public void testNoTermsIndex() throws Throwable {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
Document doc = new Document();
doc.add(new Field("field", "a b c d e f g h i j k l m n o p q r s t u v w x y z", Field.Store.NO, Field.Index.ANALYZED));
doc.add(new Field("number", "0 1 2 3 4 5 6 7 8 9", Field.Store.NO, Field.Index.ANALYZED));
@@ -1771,7 +1762,7 @@ public class TestIndexReader extends LuceneTestCase
}
assertEquals(-1, ((SegmentReader) r.getSequentialSubReaders()[0]).getTermInfosIndexDivisor());
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
writer.addDocument(doc);
writer.close();
@@ -1795,8 +1786,8 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-2046
public void testPrepareCommitIsCurrent() throws Throwable {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.commit();
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java b/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java
index a7a662cdba8..a8b892d94a5 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java
@@ -17,8 +17,6 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.index.SegmentReader.Norm;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -35,16 +33,9 @@ import org.apache.lucene.util.Bits;
* implemented properly
*/
public class TestIndexReaderClone extends LuceneTestCase {
- Random random;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
public void testCloneReadOnlySegmentReader() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
IndexReader reader = IndexReader.open(dir1, false);
@@ -63,7 +54,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// open non-readOnly reader1, clone to non-readOnly
// reader2, make sure we can change reader2
public void testCloneNoChangesStillReadOnly() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader r1 = IndexReader.open(dir1, false);
@@ -79,7 +70,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// open non-readOnly reader1, clone to non-readOnly
// reader2, make sure we can change reader1
public void testCloneWriteToOrig() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader r1 = IndexReader.open(dir1, false);
@@ -95,7 +86,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// open non-readOnly reader1, clone to non-readOnly
// reader2, make sure we can change reader2
public void testCloneWriteToClone() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader r1 = IndexReader.open(dir1, false);
@@ -118,7 +109,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// SegmentReader, add docs, reopen to multireader, then do
// delete
public void testReopenSegmentReaderToMultiReader() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
IndexReader reader1 = IndexReader.open(dir1, false);
@@ -136,7 +127,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// open non-readOnly reader1, clone to readOnly reader2
public void testCloneWriteableToReadOnly() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader reader = IndexReader.open(dir1, false);
@@ -158,7 +149,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// open non-readOnly reader1, reopen to readOnly reader2
public void testReopenWriteableToReadOnly() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader reader = IndexReader.open(dir1, false);
@@ -179,7 +170,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// open readOnly reader1, clone to non-readOnly reader2
public void testCloneReadOnlyToWriteable() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader reader1 = IndexReader.open(dir1, true);
@@ -202,11 +193,11 @@ public class TestIndexReaderClone extends LuceneTestCase {
// open non-readOnly reader1 on multi-segment index, then
// optimize the index, then clone to readOnly reader2
public void testReadOnlyCloneAfterOptimize() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader reader1 = IndexReader.open(dir1, false);
- IndexWriter w = new IndexWriter(dir1, newIndexWriterConfig(random,
+ IndexWriter w = new IndexWriter(dir1, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
w.optimize();
w.close();
@@ -229,7 +220,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testCloneReadOnlyDirectoryReader() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader reader = IndexReader.open(dir1, false);
@@ -253,9 +244,9 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testParallelReader() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
- final Directory dir2 = newDirectory(random);
+ final Directory dir2 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir2, true);
IndexReader r1 = IndexReader.open(dir1, false);
IndexReader r2 = IndexReader.open(dir2, false);
@@ -304,9 +295,9 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testMixedReaders() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
- final Directory dir2 = newDirectory(random);
+ final Directory dir2 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir2, true);
IndexReader r1 = IndexReader.open(dir1, false);
IndexReader r2 = IndexReader.open(dir2, false);
@@ -319,7 +310,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testSegmentReaderUndeleteall() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
SegmentReader origSegmentReader = SegmentReader.getOnlySegmentReader(dir1);
origSegmentReader.deleteDocument(10);
@@ -332,7 +323,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testSegmentReaderCloseReferencing() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
SegmentReader origSegmentReader = SegmentReader.getOnlySegmentReader(dir1);
origSegmentReader.deleteDocument(1);
@@ -351,7 +342,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testSegmentReaderDelDocsReferenceCounting() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
IndexReader origReader = IndexReader.open(dir1, false);
@@ -415,7 +406,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// LUCENE-1648
public void testCloneWithDeletes() throws Throwable {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
IndexReader origReader = IndexReader.open(dir1, false);
origReader.deleteDocument(1);
@@ -432,7 +423,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
// LUCENE-1648
public void testCloneWithSetNorm() throws Throwable {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
IndexReader orig = IndexReader.open(dir1, false);
orig.setNorm(1, "field1", 17.0f);
@@ -461,7 +452,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testCloneSubreaders() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, true);
IndexReader reader = IndexReader.open(dir1, false);
@@ -481,7 +472,7 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testLucene1516Bug() throws Exception {
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
IndexReader r1 = IndexReader.open(dir1, false);
r1.incRef();
@@ -498,8 +489,8 @@ public class TestIndexReaderClone extends LuceneTestCase {
}
public void testCloseStoredFields() throws Exception {
- final Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ final Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
((LogMergePolicy) w.getConfig().getMergePolicy()).setUseCompoundFile(false);
((LogMergePolicy) w.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java b/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
index 9e2d206aa65..07adf6a7b95 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
@@ -83,7 +83,6 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
*/
public void testNorms() throws IOException {
// test with a single index: index1
- Random random = newRandom();
File indexDir1 = new File(TEMP_DIR, "lucenetestindex1");
Directory dir1 = FSDirectory.open(indexDir1);
IndexWriter.unlock(dir1);
@@ -114,7 +113,7 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
Directory dir3 = FSDirectory.open(indexDir3);
createIndex(random, dir3);
- IndexWriter iw = new IndexWriter(dir3, newIndexWriterConfig(random,
+ IndexWriter iw = new IndexWriter(dir3, newIndexWriterConfig(
TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
.setMaxBufferedDocs(5));
((LogMergePolicy) iw.getConfig().getMergePolicy()).setMergeFactor(3);
@@ -133,7 +132,7 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
doTestNorms(random, dir3);
// now with optimize
- iw = new IndexWriter(dir3, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ iw = new IndexWriter(dir3, newIndexWriterConfig( TEST_VERSION_CURRENT,
anlzr).setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(5));
((LogMergePolicy) iw.getConfig().getMergePolicy()).setMergeFactor(3);
iw.optimize();
@@ -165,8 +164,7 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
}
public void testNormsClose() throws IOException {
- Random random = newRandom();
- Directory dir1 = newDirectory(random);
+ Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
SegmentReader reader1 = SegmentReader.getOnlySegmentReader(dir1);
reader1.norms("field1");
@@ -182,8 +180,7 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
}
public void testNormsRefCounting() throws IOException {
- Random random = newRandom();
- Directory dir1 = newDirectory(random);
+ Directory dir1 = newDirectory();
TestIndexReaderReopen.createIndex(random, dir1, false);
IndexReader reader1 = IndexReader.open(dir1, false);
@@ -236,7 +233,7 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
}
private void createIndex(Random random, Directory dir) throws IOException {
- IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.CREATE)
.setMaxBufferedDocs(5).setSimilarity(similarityOne));
LogMergePolicy lmp = (LogMergePolicy) iw.getConfig().getMergePolicy();
@@ -289,7 +286,7 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
private void addDocs(Random random, Directory dir, int ndocs, boolean compound)
throws IOException {
- IndexWriterConfig conf = newIndexWriterConfig(random,
+ IndexWriterConfig conf = newIndexWriterConfig(
TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
.setMaxBufferedDocs(5).setSimilarity(similarityOne);
LogMergePolicy lmp = (LogMergePolicy) conf.getMergePolicy();
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java b/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
index a82c59ddc1a..ef4a9a89316 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
@@ -45,14 +45,14 @@ import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BitVector;
import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.LuceneTestCaseJ4;
public class TestIndexReaderReopen extends LuceneTestCase {
private File indexDir;
public void testReopen() throws Exception {
- Random random = newRandom();
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
createIndex(random, dir1, false);
performDefaultTests(new TestReopen() {
@@ -70,7 +70,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
});
dir1.close();
- final Directory dir2 = newDirectory(random);
+ final Directory dir2 = newDirectory();
createIndex(random, dir2, true);
performDefaultTests(new TestReopen() {
@@ -90,10 +90,9 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testParallelReaderReopen() throws Exception {
- Random random = newRandom();
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
createIndex(random, dir1, true);
- final Directory dir2 = newDirectory(random);
+ final Directory dir2 = newDirectory();
createIndex(random, dir2, true);
performDefaultTests(new TestReopen() {
@@ -116,9 +115,9 @@ public class TestIndexReaderReopen extends LuceneTestCase {
dir1.close();
dir2.close();
- final Directory dir3 = newDirectory(random);
+ final Directory dir3 = newDirectory();
createIndex(random, dir3, true);
- final Directory dir4 = newDirectory(random);
+ final Directory dir4 = newDirectory();
createIndex(random, dir4, true);
performTestsWithExceptionInReopen(new TestReopen() {
@@ -152,29 +151,27 @@ public class TestIndexReaderReopen extends LuceneTestCase {
// try this once with reopen once recreate, on both RAMDir and FSDir.
public void testCommitReopenFS () throws IOException {
Directory dir = FSDirectory.open(indexDir);
- doTestReopenWithCommit(newRandom(), dir, true);
+ doTestReopenWithCommit(random, dir, true);
dir.close();
}
public void testCommitRecreateFS () throws IOException {
Directory dir = FSDirectory.open(indexDir);
- doTestReopenWithCommit(newRandom(), dir, false);
+ doTestReopenWithCommit(random, dir, false);
dir.close();
}
public void testCommitReopenRAM () throws IOException {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
doTestReopenWithCommit(random, dir, true);
dir.close();
}
public void testCommitRecreateRAM () throws IOException {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
doTestReopenWithCommit(random, dir, false);
dir.close();
}
private void doTestReopenWithCommit (Random random, Directory dir, boolean withReopen) throws IOException {
- IndexWriter iwriter = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter iwriter = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(
OpenMode.CREATE).setMergeScheduler(new SerialMergeScheduler()));
iwriter.commit();
@@ -218,11 +215,10 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testMultiReaderReopen() throws Exception {
- Random random = newRandom();
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
createIndex(random, dir1, true);
- final Directory dir2 = newDirectory(random);
+ final Directory dir2 = newDirectory();
createIndex(random, dir2, true);
performDefaultTests(new TestReopen() {
@@ -245,10 +241,10 @@ public class TestIndexReaderReopen extends LuceneTestCase {
dir1.close();
dir2.close();
- final Directory dir3 = newDirectory(random);
+ final Directory dir3 = newDirectory();
createIndex(random, dir3, true);
- final Directory dir4 = newDirectory(random);
+ final Directory dir4 = newDirectory();
createIndex(random, dir4, true);
performTestsWithExceptionInReopen(new TestReopen() {
@@ -275,16 +271,15 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testMixedReaders() throws Exception {
- Random random = newRandom();
- final Directory dir1 = newDirectory(random);
+ final Directory dir1 = newDirectory();
createIndex(random, dir1, true);
- final Directory dir2 = newDirectory(random);
+ final Directory dir2 = newDirectory();
createIndex(random, dir2, true);
- final Directory dir3 = newDirectory(random);
+ final Directory dir3 = newDirectory();
createIndex(random, dir3, false);
- final Directory dir4 = newDirectory(random);
+ final Directory dir4 = newDirectory();
createIndex(random, dir4, true);
- final Directory dir5 = newDirectory(random);
+ final Directory dir5 = newDirectory();
createIndex(random, dir5, false);
performDefaultTests(new TestReopen() {
@@ -363,9 +358,8 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testReferenceCounting() throws IOException {
- Random random = newRandom();
for (int mode = 0; mode < 4; mode++) {
- Directory dir1 = newDirectory(random);
+ Directory dir1 = newDirectory();
createIndex(random, dir1, true);
IndexReader reader0 = IndexReader.open(dir1, false);
@@ -469,11 +463,10 @@ public class TestIndexReaderReopen extends LuceneTestCase {
public void testReferenceCountingMultiReader() throws IOException {
- Random random = newRandom();
for (int mode = 0; mode <=1; mode++) {
- Directory dir1 = newDirectory(random);
+ Directory dir1 = newDirectory();
createIndex(random, dir1, false);
- Directory dir2 = newDirectory(random);
+ Directory dir2 = newDirectory();
createIndex(random, dir2, true);
IndexReader reader1 = IndexReader.open(dir1, false);
@@ -541,11 +534,10 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testReferenceCountingParallelReader() throws IOException {
- Random random = newRandom();
for (int mode = 0; mode <=1; mode++) {
- Directory dir1 = newDirectory(random);
+ Directory dir1 = newDirectory();
createIndex(random, dir1, false);
- Directory dir2 = newDirectory(random);
+ Directory dir2 = newDirectory();
createIndex(random, dir2, true);
IndexReader reader1 = IndexReader.open(dir1, false);
@@ -617,8 +609,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testNormsRefCounting() throws IOException {
- Random random = newRandom();
- Directory dir1 = newDirectory(random);
+ Directory dir1 = newDirectory();
createIndex(random, dir1, false);
IndexReader reader1 = IndexReader.open(dir1, false);
@@ -708,10 +699,9 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testThreadSafety() throws Exception {
- Random random = newRandom();
- final Directory dir = newDirectory(random);
+ final Directory dir = newDirectory();
final int n = 30 * RANDOM_MULTIPLIER;
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < n; i++) {
writer.addDocument(createDocument(i, 3));
@@ -957,7 +947,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
public static void createIndex(Random random, Directory dir, boolean multiSegment) throws IOException {
IndexWriter.unlock(dir);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter w = new IndexWriter(dir, LuceneTestCaseJ4.newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMergePolicy(new LogDocMergePolicy()));
@@ -1109,8 +1099,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testCloseOrig() throws Throwable {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
createIndex(random, dir, false);
IndexReader r1 = IndexReader.open(dir, false);
IndexReader r2 = IndexReader.open(dir, false);
@@ -1131,8 +1120,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testDeletes() throws Throwable {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
createIndex(random, dir, false); // Create an index with a bunch of docs (1 segment)
modifyIndex(0, dir); // Get delete bitVector on 1st segment
@@ -1166,8 +1154,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testDeletes2() throws Throwable {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
createIndex(random, dir, false);
// Get delete bitVector
modifyIndex(0, dir);
@@ -1203,9 +1190,8 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
public void testReopenOnCommit() throws Throwable {
- Random random = newRandom();
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(new KeepAllCommits()).setMaxBufferedDocs(-1));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(10);
for(int i=0;i<4;i++) {
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
index bbbf7cf8b8a..290483a5c50 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -79,20 +79,13 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.Bits;
public class TestIndexWriter extends LuceneTestCase {
- Random random;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
public TestIndexWriter(String name) {
super(name);
}
public void testDocCount() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter writer = null;
IndexReader reader = null;
@@ -102,7 +95,7 @@ public class TestIndexWriter extends LuceneTestCase {
try {
IndexWriterConfig.setDefaultWriteLockTimeout(2000);
assertEquals(2000, IndexWriterConfig.getDefaultWriteLockTimeout());
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
} finally {
IndexWriterConfig.setDefaultWriteLockTimeout(savedWriteLockTimeout);
}
@@ -122,7 +115,7 @@ public class TestIndexWriter extends LuceneTestCase {
reader.close();
// test doc count before segments are merged/index is optimized
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
assertEquals(100, writer.maxDoc());
writer.close();
@@ -132,7 +125,7 @@ public class TestIndexWriter extends LuceneTestCase {
reader.close();
// optimize the index and check that the new doc count is correct
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
assertEquals(100, writer.maxDoc());
assertEquals(60, writer.numDocs());
writer.optimize();
@@ -148,7 +141,7 @@ public class TestIndexWriter extends LuceneTestCase {
// make sure opening a new index for create over
// this existing one works correctly:
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
assertEquals(0, writer.maxDoc());
assertEquals(0, writer.numDocs());
writer.close();
@@ -189,8 +182,8 @@ public class TestIndexWriter extends LuceneTestCase {
Directory[] dirs = new Directory[NUM_DIR];
long inputDiskUsage = 0;
for(int i=0;i data = new HashMap();
@@ -4029,7 +4022,7 @@ public class TestIndexWriter extends LuceneTestCase {
assertEquals("test1", r.getCommitUserData().get("label"));
r.close();
- w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
w.optimize();
w.close();
@@ -4039,8 +4032,8 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testOptimizeExceptions() throws IOException {
- Directory startDir = newDirectory(random);
- IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2);
+ Directory startDir = newDirectory();
+ IndexWriterConfig conf = newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2);
((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(100);
IndexWriter w = new IndexWriter(startDir, conf);
for(int i=0;i<27;i++)
@@ -4049,7 +4042,7 @@ public class TestIndexWriter extends LuceneTestCase {
for(int i=0;i<200;i++) {
MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(startDir));
- conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new ConcurrentMergeScheduler());
+ conf = newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new ConcurrentMergeScheduler());
((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
w = new IndexWriter(dir, conf);
dir.setRandomIOExceptionRate(0.5, 100);
@@ -4070,9 +4063,9 @@ public class TestIndexWriter extends LuceneTestCase {
public void testOutOfMemoryErrorCausesCloseToFail() throws Exception {
final List thrown = new ArrayList();
- final Directory dir = newDirectory(random);
+ final Directory dir = newDirectory();
final IndexWriter writer = new IndexWriter(dir,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())) {
+ newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())) {
@Override
public void message(final String message) {
if (message.startsWith("now flush at close") && 0 == thrown.size()) {
@@ -4097,8 +4090,8 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1442
public void testDoubleOffsetCounting() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
Field f = new Field("field", "abcd", Field.Store.NO, Field.Index.NOT_ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
@@ -4133,8 +4126,8 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1442
public void testDoubleOffsetCounting2() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
Field f = new Field("field", "abcd", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
doc.add(f);
@@ -4155,8 +4148,8 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionCharAnalyzer() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
Field f = new Field("field", "abcd ", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
doc.add(f);
@@ -4177,9 +4170,9 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionWithCachingTokenFilter() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
Analyzer analyzer = new MockAnalyzer();
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer));
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer));
Document doc = new Document();
TokenStream stream = new CachingTokenFilter(analyzer.tokenStream("field", new StringReader("abcd ")));
Field f = new Field("field", stream, Field.TermVector.WITH_POSITIONS_OFFSETS);
@@ -4201,8 +4194,8 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionStopFilter() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
Document doc = new Document();
Field f = new Field("field", "abcd the", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
@@ -4224,8 +4217,8 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandard() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
Field f = new Field("field", "abcd the ", Field.Store.NO,
@@ -4255,8 +4248,8 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandardEmptyField() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
Field f = new Field("field", "", Field.Store.NO,
@@ -4283,8 +4276,8 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandardEmptyField2() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@@ -4327,7 +4320,7 @@ public class TestIndexWriter extends LuceneTestCase {
out.writeByte((byte) 42);
out.close();
- new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())).close();
+ new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())).close();
assertTrue(dir.fileExists("myrandomfile"));
} finally {
@@ -4337,8 +4330,8 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testDeadlock() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
Document doc = new Document();
doc.add(new Field("content", "aaa bbb ccc ddd eee fff ggg hhh iii", Field.Store.YES,
Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
@@ -4348,8 +4341,8 @@ public class TestIndexWriter extends LuceneTestCase {
writer.commit();
// index has 2 segments
- Directory dir2 = newDirectory(random);
- IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir2 = newDirectory();
+ IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer2.addDocument(doc);
writer2.close();
@@ -4387,7 +4380,7 @@ public class TestIndexWriter extends LuceneTestCase {
if (w != null) {
w.close();
}
- IndexWriterConfig conf = newIndexWriterConfig(random,
+ IndexWriterConfig conf = newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2);
((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(2);
w = new IndexWriter(dir, conf);
@@ -4493,8 +4486,8 @@ public class TestIndexWriter extends LuceneTestCase {
public void testIndexStoreCombos() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
byte[] b = new byte[50];
for(int i=0;i<50;i++)
b[i] = (byte) (i+77);
@@ -4556,8 +4549,8 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1727: make sure doc fields are stored in order
public void testStoredFieldsOrder() throws Throwable {
- Directory d = newDirectory(random);
- IndexWriter w = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory d = newDirectory();
+ IndexWriter w = new IndexWriter(d, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("zzz", "a b c", Field.Store.YES, Field.Index.NO));
doc.add(new Field("aaa", "a b c", Field.Store.YES, Field.Index.NO));
@@ -4588,8 +4581,8 @@ public class TestIndexWriter extends LuceneTestCase {
public void testEmbeddedFFFF() throws Throwable {
- Directory d = newDirectory(random);
- IndexWriter w = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory d = newDirectory();
+ IndexWriter w = new IndexWriter(d, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "a a\uffffb", Field.Store.NO, Field.Index.ANALYZED));
w.addDocument(doc);
@@ -4605,8 +4598,8 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testNoDocsIndex() throws Throwable {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
LogMergePolicy lmp = (LogMergePolicy) writer.getConfig().getMergePolicy();
lmp.setUseCompoundFile(false);
@@ -4626,8 +4619,8 @@ public class TestIndexWriter extends LuceneTestCase {
public void testCommitThreadSafety() throws Throwable {
final int NUM_THREADS = 5;
final double RUN_SEC = 0.5;
- final Directory dir = newDirectory(random);
- final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ final Directory dir = newDirectory();
+ final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
w.commit();
final AtomicBoolean failed = new AtomicBoolean();
@@ -4734,7 +4727,7 @@ public class TestIndexWriter extends LuceneTestCase {
// sort in codepoint sort order by default
public void testTermUTF16SortOrder() throws Throwable {
Random rnd = random;
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(rnd, dir);
Document d = new Document();
// Single segment
@@ -4798,7 +4791,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testIndexDivisor() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, new MockAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
StringBuilder s = new StringBuilder();
// must be > 256
@@ -4827,8 +4820,8 @@ public class TestIndexWriter extends LuceneTestCase {
public void testDeleteUnusedFiles() throws Exception {
for(int iter=0;iter<2;iter++) {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
((LogMergePolicy) w.getMergePolicy()).setUseCompoundFile(true);
Document doc = new Document();
doc.add(new Field("field", "go", Field.Store.NO, Field.Index.ANALYZED));
@@ -4886,9 +4879,9 @@ public class TestIndexWriter extends LuceneTestCase {
public void testDeleteUnsedFiles2() throws Exception {
// Validates that iw.deleteUnusedFiles() also deletes unused index commits
// in case a deletion policy which holds onto commits is used.
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setIndexDeletionPolicy(sdp));
@@ -4931,8 +4924,8 @@ public class TestIndexWriter extends LuceneTestCase {
public void testIndexingThenDeleting() throws Exception {
final Random r = random;
- Directory dir = newDirectory(random);
- FlushCountingIndexWriter w = new FlushCountingIndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setRAMBufferSizeMB(0.5).setMaxBufferedDocs(-1).setMaxBufferedDeleteTerms(-1));
+ Directory dir = newDirectory();
+ FlushCountingIndexWriter w = new FlushCountingIndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setRAMBufferSizeMB(0.5).setMaxBufferedDocs(-1).setMaxBufferedDeleteTerms(-1));
//w.setInfoStream(System.out);
Document doc = new Document();
doc.add(new Field("field", "go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20", Field.Store.NO, Field.Index.ANALYZED));
@@ -4966,8 +4959,8 @@ public class TestIndexWriter extends LuceneTestCase {
// Tests that if we don't call commit(), the directory has 0 commits. This has
// changed since LUCENE-2386, where before IW would always commit on a fresh
// new index.
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
try {
IndexReader.listCommits(dir);
fail("listCommits should have thrown an exception over empty index");
@@ -4985,15 +4978,15 @@ public class TestIndexWriter extends LuceneTestCase {
// then IndexWriter ctor succeeds. Previously (LUCENE-2386) it failed
// when listAll() was called in IndexFileDeleter.
FSDirectory dir = FSDirectory.open(new File(TEMP_DIR, "emptyFSDirNoLock"), NoLockFactory.getNoLockFactory());
- new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())).close();
+ new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())).close();
}
public void testEmptyDirRollback() throws Exception {
// Tests that if IW is created over an empty Directory, some documents are
// indexed, flushed (but not committed) and then IW rolls back, then no
// files are left in the Directory.
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2));
String[] files = dir.listAll();
@@ -5037,14 +5030,14 @@ public class TestIndexWriter extends LuceneTestCase {
try {
Directory dir = FSDirectory.open(tempDir);
dir.setLockFactory(NoLockFactory.getNoLockFactory());
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
Document doc = new Document();
doc.add(new Field("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
w.addDocument(doc);
w.addDocument(doc);
- IndexWriter w2 = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter w2 = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2)
.setOpenMode(OpenMode.CREATE));
@@ -5058,9 +5051,9 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testFutureCommit() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE));
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE));
Document doc = new Document();
w.addDocument(doc);
@@ -5086,7 +5079,7 @@ public class TestIndexWriter extends LuceneTestCase {
assertNotNull(commit);
- w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE).setIndexCommit(commit));
+ w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE).setIndexCommit(commit));
assertEquals(1, w.numDocs());
@@ -5134,9 +5127,9 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testRandomStoredFields() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
Random rand = random;
- RandomIndexWriter w = new RandomIndexWriter(rand, dir, newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(_TestUtil.nextInt(rand, 5, 20)));
+ RandomIndexWriter w = new RandomIndexWriter(rand, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(_TestUtil.nextInt(rand, 5, 20)));
//w.w.setInfoStream(System.out);
//w.w.setUseCompoundFile(false);
if (VERBOSE) {
@@ -5247,10 +5240,10 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-2593
public void testCorruptionAfterDiskFullDuringMerge() throws IOException {
- MockDirectoryWrapper dir = newDirectory(random);
+ MockDirectoryWrapper dir = newDirectory();
final Random rand = random;
- //IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new MockAnalyzer()).setReaderPooling(true));
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new SerialMergeScheduler()).setReaderPooling(true));
+ //IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setReaderPooling(true));
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new SerialMergeScheduler()).setReaderPooling(true));
((LogMergePolicy) w.getMergePolicy()).setMergeFactor(2);
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
index b3b361f83a3..ba75af22970 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
@@ -263,7 +263,7 @@ public class TestIndexWriterConfig extends LuceneTestCaseJ4 {
// iw.getConfig().getXYZ(), he'll get the same value he passed to
// iw.setXYZ().
IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer());
- Directory dir = newDirectory(newRandom());
+ Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, conf);
writer.setSimilarity(new MySimilarity());
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
index 65ddbf75030..401f53d8519 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -34,13 +33,6 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
public class TestIndexWriterDelete extends LuceneTestCase {
- Random random;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
// test the simple case
public void testSimpleCase() throws IOException {
@@ -50,8 +42,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
"Venice has lots of canals" };
String[] text = { "Amsterdam", "Venice" };
- Directory dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDeleteTerms(1));
for (int i = 0; i < keywords.length; i++) {
@@ -85,8 +77,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// test when delete terms only apply to disk segments
public void testNonRAMDelete() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDocs(2)
.setMaxBufferedDeleteTerms(2));
@@ -119,8 +111,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
}
public void testMaxBufferedDeletes() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDeleteTerms(1));
writer.deleteDocuments(new Term("foobar", "1"));
writer.deleteDocuments(new Term("foobar", "1"));
@@ -133,8 +125,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// test when delete terms only apply to ram segments
public void testRAMDeletes() throws IOException {
for(int t=0;t<2;t++) {
- Directory dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDocs(4)
.setMaxBufferedDeleteTerms(4));
@@ -174,8 +166,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// test when delete terms apply to both disk and ram segments
public void testBothDeletes() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDocs(100)
.setMaxBufferedDeleteTerms(100));
@@ -208,8 +200,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// test that batched delete terms are flushed together
public void testBatchDeletes() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDocs(2)
.setMaxBufferedDeleteTerms(2));
@@ -251,8 +243,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// test deleteAll()
public void testDeleteAll() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDocs(2)
.setMaxBufferedDeleteTerms(2));
@@ -297,8 +289,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// test rollback of deleteAll()
public void testDeleteAllRollback() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDocs(2)
.setMaxBufferedDeleteTerms(2));
@@ -334,8 +326,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// test deleteAll() w/ near real-time reader
public void testDeleteAllNRT() throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDocs(2)
.setMaxBufferedDeleteTerms(2));
@@ -424,10 +416,10 @@ public class TestIndexWriterDelete extends LuceneTestCase {
int END_COUNT = 144;
// First build up a starting index:
- MockDirectoryWrapper startDir = newDirectory(random);
+ MockDirectoryWrapper startDir = newDirectory();
// TODO: find the resource leak that only occurs sometimes here.
startDir.setNoDeleteOpenFile(false);
- IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
for (int i = 0; i < 157; i++) {
Document d = new Document();
d.add(new Field("id", Integer.toString(i), Field.Store.YES,
@@ -450,7 +442,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(startDir));
dir.setPreventDoubleWrite(false);
IndexWriter modifier = new IndexWriter(dir,
- newIndexWriterConfig(random,
+ newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))
.setMaxBufferedDocs(1000)
.setMaxBufferedDeleteTerms(1000)
@@ -663,8 +655,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
"Venice has lots of canals" };
String[] text = { "Amsterdam", "Venice" };
- MockDirectoryWrapper dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
+ MockDirectoryWrapper dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDeleteTerms(2).setReaderPooling(false));
LogMergePolicy lmp = (LogMergePolicy) modifier.getConfig().getMergePolicy();
lmp.setUseCompoundFile(true);
@@ -773,8 +765,8 @@ public class TestIndexWriterDelete extends LuceneTestCase {
"Venice has lots of canals" };
String[] text = { "Amsterdam", "Venice" };
- MockDirectoryWrapper dir = newDirectory(random);
- IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
+ MockDirectoryWrapper dir = newDirectory();
+ IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
modifier.commit();
dir.failOn(failure.reset());
@@ -801,7 +793,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
}
public void testDeleteNullQuery() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter modifier = new IndexWriter(dir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), IndexWriter.MaxFieldLength.UNLIMITED);
for (int i = 0; i < 5; i++) {
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
index 2f32e3ea0d1..940b8d78b91 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
@@ -129,10 +129,9 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
}
public void testRandomExceptions() throws Throwable {
- Random random = newRandom();
- MockDirectoryWrapper dir = newDirectory(random);
+ MockDirectoryWrapper dir = newDirectory();
- MockIndexWriter writer = new MockIndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
+ MockIndexWriter writer = new MockIndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())
.setRAMBufferSizeMB(0.1).setMergeScheduler(new ConcurrentMergeScheduler()));
((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).setSuppressExceptions();
//writer.setMaxBufferedDocs(10);
@@ -170,9 +169,8 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
}
public void testRandomExceptionsThreads() throws Throwable {
- Random random = newRandom();
- MockDirectoryWrapper dir = newDirectory(random);
- MockIndexWriter writer = new MockIndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
+ MockDirectoryWrapper dir = newDirectory();
+ MockIndexWriter writer = new MockIndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())
.setRAMBufferSizeMB(0.2).setMergeScheduler(new ConcurrentMergeScheduler()));
((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).setSuppressExceptions();
//writer.setMaxBufferedDocs(10);
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
index b472358cc1b..1cc03bccd24 100755
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -30,19 +29,12 @@ import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.LuceneTestCase;
public class TestIndexWriterMergePolicy extends LuceneTestCase {
- private Random random;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
// Test the normal case
public void testNormalCase() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(10).setMergePolicy(new LogDocMergePolicy()));
@@ -57,9 +49,9 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test to see if there is over merge
public void testNoOverMerge() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(10).setMergePolicy(new LogDocMergePolicy()));
@@ -79,12 +71,12 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the case where flush is forced after every addDoc
public void testForceFlush() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
LogDocMergePolicy mp = new LogDocMergePolicy();
mp.setMinMergeDocs(100);
mp.setMergeFactor(10);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(10).setMergePolicy(mp));
@@ -94,7 +86,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
mp = new LogDocMergePolicy();
mp.setMergeFactor(10);
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(
OpenMode.APPEND).setMaxBufferedDocs(10).setMergePolicy(mp));
mp.setMinMergeDocs(100);
@@ -107,9 +99,9 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the case where mergeFactor changes
public void testMergeFactorChange() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(10).setMergePolicy(new LogDocMergePolicy()));
@@ -133,9 +125,9 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the case where both mergeFactor and maxBufferedDocs change
public void testMaxBufferedDocsChange() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(101).setMergePolicy(new LogDocMergePolicy()));
@@ -148,7 +140,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
}
writer.close();
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(
OpenMode.APPEND).setMaxBufferedDocs(101).setMergePolicy(
new LogDocMergePolicy()));
@@ -157,7 +149,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
writer.close();
LogDocMergePolicy ldmp = new LogDocMergePolicy();
ldmp.setMergeFactor(10);
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(
OpenMode.APPEND).setMaxBufferedDocs(10).setMergePolicy(ldmp).setMergeScheduler(new ConcurrentMergeScheduler()));
@@ -182,11 +174,11 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the case where a merge results in no doc at all
public void testMergeDocCount0() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
LogDocMergePolicy ldmp = new LogDocMergePolicy();
ldmp.setMergeFactor(100);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(10).setMergePolicy(ldmp));
@@ -202,7 +194,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
ldmp = new LogDocMergePolicy();
ldmp.setMergeFactor(5);
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(
OpenMode.APPEND).setMaxBufferedDocs(10).setMergePolicy(ldmp).setMergeScheduler(new ConcurrentMergeScheduler()));
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
index bce7bc3028e..2ffa6d486e0 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
@@ -34,11 +34,10 @@ public class TestIndexWriterMerging extends LuceneTestCase
* change the index order of documents.
*/
public void testLucene() throws IOException {
- Random random = newRandom();
int num=100;
- Directory indexA = newDirectory(random);
- Directory indexB = newDirectory(random);
+ Directory indexA = newDirectory();
+ Directory indexB = newDirectory();
fillIndex(random, indexA, 0, num);
boolean fail = verifyIndex(indexA, 0);
@@ -54,9 +53,9 @@ public class TestIndexWriterMerging extends LuceneTestCase
fail("Index b is invalid");
}
- Directory merged = newDirectory(random);
+ Directory merged = newDirectory();
- IndexWriter writer = new IndexWriter(merged, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter writer = new IndexWriter(merged, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
writer.addIndexes(new Directory[]{indexA, indexB});
@@ -95,7 +94,7 @@ public class TestIndexWriterMerging extends LuceneTestCase
private void fillIndex(Random random, Directory dir, int start, int numDocs) throws IOException {
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT,
new MockAnalyzer())
.setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(2));
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
index df8bff67e33..9ebce4da6b4 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
@@ -38,6 +38,7 @@ import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.LuceneTestCaseJ4;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ThreadInterruptedException;
@@ -45,13 +46,6 @@ import java.util.concurrent.atomic.AtomicInteger;
public class TestIndexWriterReader extends LuceneTestCase {
static PrintStream infoStream;
- private Random random;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
public static int count(Term t, IndexReader r) throws IOException {
int count = 0;
@@ -71,8 +65,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
public void testUpdateDocument() throws Exception {
boolean optimize = true;
- Directory dir1 = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir1 = newDirectory();
+ IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
// create the index
createIndexNoClose(!optimize, "index1", writer);
@@ -106,7 +100,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
assertEquals(0, count(new Term("id", id10), r3));
assertEquals(1, count(new Term("id", Integer.toString(8000)), r3));
- writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "a b c", Field.Store.NO, Field.Index.ANALYZED));
writer.addDocument(doc);
@@ -132,16 +126,16 @@ public class TestIndexWriterReader extends LuceneTestCase {
public void testAddIndexes() throws Exception {
boolean optimize = false;
- Directory dir1 = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir1 = newDirectory();
+ IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.setInfoStream(infoStream);
// create the index
createIndexNoClose(!optimize, "index1", writer);
writer.flush(false, true, true);
// create a 2nd index
- Directory dir2 = newDirectory(random);
- IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir2 = newDirectory();
+ IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer2.setInfoStream(infoStream);
createIndexNoClose(!optimize, "index2", writer2);
writer2.close();
@@ -178,13 +172,13 @@ public class TestIndexWriterReader extends LuceneTestCase {
public void testAddIndexes2() throws Exception {
boolean optimize = false;
- Directory dir1 = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir1 = newDirectory();
+ IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.setInfoStream(infoStream);
// create a 2nd index
- Directory dir2 = newDirectory(random);
- IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir2 = newDirectory();
+ IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer2.setInfoStream(infoStream);
createIndexNoClose(!optimize, "index2", writer2);
writer2.close();
@@ -212,8 +206,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
public void testDeleteFromIndexWriter() throws Exception {
boolean optimize = true;
- Directory dir1 = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setReaderTermsIndexDivisor(2));
+ Directory dir1 = newDirectory();
+ IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setReaderTermsIndexDivisor(2));
writer.setInfoStream(infoStream);
// create the index
createIndexNoClose(!optimize, "index1", writer);
@@ -251,7 +245,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
writer.close();
// reopen the writer to verify the delete made it to the directory
- writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.setInfoStream(infoStream);
IndexReader w2r1 = writer.getReader();
assertEquals(0, count(new Term("id", id10), w2r1));
@@ -264,8 +258,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
final int numIter = 2;
int numDirs = 3;
- Directory mainDir = newDirectory(random);
- IndexWriter mainWriter = new IndexWriter(mainDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory mainDir = newDirectory();
+ IndexWriter mainWriter = new IndexWriter(mainDir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
mainWriter.setInfoStream(infoStream);
AddDirectoriesThreads addDirThreads = new AddDirectoriesThreads(numIter, mainWriter);
addDirThreads.launchThreads(numDirs);
@@ -307,8 +301,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
public AddDirectoriesThreads(int numDirs, IndexWriter mainWriter) throws Throwable {
this.numDirs = numDirs;
this.mainWriter = mainWriter;
- addDir = newDirectory(random);
- IndexWriter writer = new IndexWriter(addDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
+ addDir = newDirectory();
+ IndexWriter writer = new IndexWriter(addDir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
for (int i = 0; i < NUM_INIT_DOCS; i++) {
Document doc = createDocument(i, "addindex", 4);
writer.addDocument(doc);
@@ -413,8 +407,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
* IW.getReader
*/
public void doTestIndexWriterReopenSegment(boolean optimize) throws Exception {
- Directory dir1 = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir1 = newDirectory();
+ IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.setInfoStream(infoStream);
IndexReader r1 = writer.getReader();
assertEquals(0, r1.maxDoc());
@@ -451,7 +445,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
writer.close();
// test whether the changes made it to the directory
- writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
IndexReader w2r1 = writer.getReader();
// insure the deletes were actually flushed to the directory
assertEquals(200, w2r1.maxDoc());
@@ -490,7 +484,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
public static void createIndex(Random random, Directory dir1, String indexName,
boolean multiSegment) throws IOException {
- IndexWriter w = new IndexWriter(dir1, newIndexWriterConfig(random,
+ IndexWriter w = new IndexWriter(dir1, LuceneTestCaseJ4.newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMergePolicy(new LogDocMergePolicy()));
for (int i = 0; i < 100; i++) {
@@ -524,10 +518,10 @@ public class TestIndexWriterReader extends LuceneTestCase {
public void testMergeWarmer() throws Exception {
- Directory dir1 = newDirectory(random);
+ Directory dir1 = newDirectory();
// Enroll warmer
MyWarmer warmer = new MyWarmer();
- IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2).setMergedSegmentWarmer(warmer).setMergeScheduler(new ConcurrentMergeScheduler()));
writer.setInfoStream(infoStream);
@@ -559,8 +553,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
}
public void testAfterCommit() throws Exception {
- Directory dir1 = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new ConcurrentMergeScheduler()));
+ Directory dir1 = newDirectory();
+ IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new ConcurrentMergeScheduler()));
writer.commit();
writer.setInfoStream(infoStream);
@@ -592,8 +586,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
// Make sure reader remains usable even if IndexWriter closes
public void testAfterClose() throws Exception {
- Directory dir1 = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir1 = newDirectory();
+ IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.setInfoStream(infoStream);
// create the index
@@ -621,8 +615,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
// Stress test reopen during addIndexes
public void testDuringAddIndexes() throws Exception {
- Directory dir1 = newDirectory(random);
- final IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir1 = newDirectory();
+ final IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.setInfoStream(infoStream);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
@@ -699,8 +693,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
// Stress test reopen during add/delete
public void testDuringAddDelete() throws Exception {
- Directory dir1 = newDirectory(random);
- final IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir1 = newDirectory();
+ final IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.setInfoStream(infoStream);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
@@ -779,8 +773,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
}
public void testExpungeDeletes() throws Throwable {
- Directory dir = newDirectory(random);
- final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "a b c", Field.Store.NO, Field.Index.ANALYZED));
Field id = new Field("id", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
@@ -803,8 +797,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
}
public void testDeletesNumDocs() throws Throwable {
- Directory dir = newDirectory(random);
- final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "a b c", Field.Store.NO, Field.Index.ANALYZED));
Field id = new Field("id", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
@@ -833,8 +827,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
public void testEmptyIndex() throws Exception {
// Ensures that getReader works on an empty index, which hasn't been committed yet.
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
IndexReader r = w.getReader();
assertEquals(0, r.numDocs());
r.close();
@@ -843,8 +837,8 @@ public class TestIndexWriterReader extends LuceneTestCase {
}
public void testSegmentWarmer() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2).setReaderPooling(true));
((LogMergePolicy) w.getMergePolicy()).setMergeFactor(10);
w.setMergedSegmentWarmer(new IndexWriter.IndexReaderWarmer() {
diff --git a/lucene/src/test/org/apache/lucene/index/TestIsCurrent.java b/lucene/src/test/org/apache/lucene/index/TestIsCurrent.java
index 52650f4258b..15ade02a404 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIsCurrent.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIsCurrent.java
@@ -22,14 +22,12 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.util.*;
-import org.apache.lucene.analysis.*;
import org.apache.lucene.store.*;
import static org.junit.Assert.*;
import org.junit.Test;
import java.io.IOException;
-import java.util.Random;
public class TestIsCurrent extends LuceneTestCaseJ4 {
@@ -37,17 +35,13 @@ public class TestIsCurrent extends LuceneTestCaseJ4 {
private Directory directory;
- private Random rand;
-
@Override
public void setUp() throws Exception {
super.setUp();
- rand = newRandom();
-
// initialize directory
- directory = newDirectory(rand);
- writer = new RandomIndexWriter(rand, directory);
+ directory = newDirectory();
+ writer = new RandomIndexWriter(random, directory);
// write document
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/index/TestLazyBug.java b/lucene/src/test/org/apache/lucene/index/TestLazyBug.java
index a9f3bfee743..1c04a26cdd5 100755
--- a/lucene/src/test/org/apache/lucene/index/TestLazyBug.java
+++ b/lucene/src/test/org/apache/lucene/index/TestLazyBug.java
@@ -67,10 +67,9 @@ public class TestLazyBug extends LuceneTestCase {
};
private Directory makeIndex() throws Exception {
- Random r = newRandom();
- Directory dir = newDirectory(r);
+ Directory dir = newDirectory();
try {
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(r,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
LogMergePolicy lmp = (LogMergePolicy) writer.getConfig().getMergePolicy();
lmp.setUseCompoundFile(false);
@@ -81,7 +80,7 @@ public class TestLazyBug extends LuceneTestCase {
for (int f = 1; f <= NUM_FIELDS; f++ ) {
doc.add(new Field("f"+f,
data[f % data.length]
- + '#' + data[r.nextInt(data.length)],
+ + '#' + data[random.nextInt(data.length)],
Field.Store.YES,
Field.Index.ANALYZED));
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java b/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
index 87aa0f72162..5febc0ecbd9 100755
--- a/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
+++ b/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
@@ -68,7 +68,7 @@ public class TestLazyProxSkipping extends LuceneTestCase {
int numDocs = 500;
Directory directory = new SeekCountingDirectory(new RAMDirectory());
- IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
+ IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
for (int i = 0; i < numDocs; i++) {
@@ -120,15 +120,13 @@ public class TestLazyProxSkipping extends LuceneTestCase {
public void testLazySkipping() throws IOException {
// test whether only the minimum amount of seeks() are performed
- Random random = newRandom();
performTest(random, 5);
performTest(random, 10);
}
public void testSeek() throws IOException {
- Random random = newRandom();
- Directory directory = newDirectory(random);
- IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory directory = newDirectory();
+ IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 10; i++) {
Document doc = new Document();
doc.add(new Field(this.field, "a b", Field.Store.YES, Field.Index.ANALYZED));
diff --git a/lucene/src/test/org/apache/lucene/index/TestMultiFields.java b/lucene/src/test/org/apache/lucene/index/TestMultiFields.java
index 96c836176b5..da1bc726088 100644
--- a/lucene/src/test/org/apache/lucene/index/TestMultiFields.java
+++ b/lucene/src/test/org/apache/lucene/index/TestMultiFields.java
@@ -27,36 +27,34 @@ public class TestMultiFields extends LuceneTestCase {
public void testRandom() throws Exception {
- Random r = newRandom();
-
int num = 2 * RANDOM_MULTIPLIER;
for (int iter = 0; iter < num; iter++) {
- Directory dir = newDirectory(r);
+ Directory dir = newDirectory();
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(r, TEST_VERSION_CURRENT, new MockAnalyzer()).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
Map> docs = new HashMap>();
Set deleted = new HashSet();
List terms = new ArrayList();
- int numDocs = _TestUtil.nextInt(r, 1, 100 * RANDOM_MULTIPLIER);
+ int numDocs = _TestUtil.nextInt(random, 1, 100 * RANDOM_MULTIPLIER);
Document doc = new Document();
Field f = new Field("field", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
doc.add(f);
Field id = new Field("id", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
doc.add(id);
- boolean onlyUniqueTerms = r.nextBoolean();
+ boolean onlyUniqueTerms = random.nextBoolean();
Set uniqueTerms = new HashSet();
for(int i=0;i 0) {
+ if (!onlyUniqueTerms && random.nextBoolean() && terms.size() > 0) {
// re-use existing term
- BytesRef term = terms.get(r.nextInt(terms.size()));
+ BytesRef term = terms.get(random.nextInt(terms.size()));
docs.get(term).add(i);
f.setValue(term.utf8ToString());
} else {
- String s = _TestUtil.randomUnicodeString(r, 10);
+ String s = _TestUtil.randomUnicodeString(random, 10);
BytesRef term = new BytesRef(s);
if (!docs.containsKey(term)) {
docs.put(term, new ArrayList());
@@ -68,11 +66,11 @@ public class TestMultiFields extends LuceneTestCase {
}
id.setValue(""+i);
w.addDocument(doc);
- if (r.nextInt(4) == 1) {
+ if (random.nextInt(4) == 1) {
w.commit();
}
- if (i > 0 && r.nextInt(20) == 1) {
- int delID = r.nextInt(i);
+ if (i > 0 && random.nextInt(20) == 1) {
+ int delID = random.nextInt(i);
deleted.add(delID);
w.deleteDocuments(new Term("id", ""+delID));
}
@@ -98,7 +96,7 @@ public class TestMultiFields extends LuceneTestCase {
Terms terms2 = MultiFields.getTerms(reader, "field");
for(int i=0;i<100;i++) {
- BytesRef term = terms.get(r.nextInt(terms.size()));
+ BytesRef term = terms.get(random.nextInt(terms.size()));
DocsEnum docsEnum = terms2.docs(delDocs, term, null);
assertNotNull(docsEnum);
@@ -131,9 +129,8 @@ public class TestMultiFields extends LuceneTestCase {
*/
public void testSeparateEnums() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document d = new Document();
d.add(new Field("f", "j", Field.Store.NO, Field.Index.NOT_ANALYZED));
w.addDocument(d);
diff --git a/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java b/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java
index b975db93196..2f0475ac5a1 100644
--- a/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java
+++ b/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java
@@ -62,7 +62,7 @@ public class TestMultiLevelSkipList extends LuceneTestCase {
public void testSimpleSkip() throws IOException {
Directory dir = new CountingRAMDirectory(new RAMDirectory());
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(newRandom(), TEST_VERSION_CURRENT, new PayloadAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new PayloadAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
Term term = new Term("test", "a");
for (int i = 0; i < 5000; i++) {
Document d1 = new Document();
diff --git a/lucene/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java b/lucene/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
index 1ea8d02d9b3..cf62fd4612a 100644
--- a/lucene/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
+++ b/lucene/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
@@ -30,8 +30,8 @@ public class TestNRTReaderWithThreads extends LuceneTestCase {
AtomicInteger seq = new AtomicInteger(1);
public void testIndexing() throws Exception {
- Directory mainDir = newDirectory(random);
- IndexWriter writer = new IndexWriter(mainDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
+ Directory mainDir = newDirectory();
+ IndexWriter writer = new IndexWriter(mainDir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
diff --git a/lucene/src/test/org/apache/lucene/index/TestNewestSegment.java b/lucene/src/test/org/apache/lucene/index/TestNewestSegment.java
index 5cbe91edf8e..38c4c557d17 100644
--- a/lucene/src/test/org/apache/lucene/index/TestNewestSegment.java
+++ b/lucene/src/test/org/apache/lucene/index/TestNewestSegment.java
@@ -17,19 +17,14 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import java.util.Random;
-
-import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.index.IndexWriter.MaxFieldLength;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class TestNewestSegment extends LuceneTestCase {
public void testNewestSegment() throws Exception {
- Random random = newRandom();
- Directory directory = newDirectory(random);
- IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory directory = newDirectory();
+ IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
assertNull(writer.newestSegment());
writer.close();
directory.close();
diff --git a/lucene/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java b/lucene/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java
index 2932ffb288e..13d7689c59e 100644
--- a/lucene/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java
+++ b/lucene/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java
@@ -73,9 +73,8 @@ public class TestNoDeletionPolicy extends LuceneTestCaseJ4 {
@Test
public void testAllCommitsRemain() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE));
for (int i = 0; i < 10; i++) {
diff --git a/lucene/src/test/org/apache/lucene/index/TestNorms.java b/lucene/src/test/org/apache/lucene/index/TestNorms.java
index c028b84813a..7a4f0f2c1b9 100755
--- a/lucene/src/test/org/apache/lucene/index/TestNorms.java
+++ b/lucene/src/test/org/apache/lucene/index/TestNorms.java
@@ -74,8 +74,7 @@ public class TestNorms extends LuceneTestCase {
* Including optimize.
*/
public void testNorms() throws IOException {
- Random random = newRandom();
- Directory dir1 = newDirectory(random);
+ Directory dir1 = newDirectory();
norms = new ArrayList();
modifiedNorms = new ArrayList();
@@ -92,16 +91,16 @@ public class TestNorms extends LuceneTestCase {
modifiedNorms = new ArrayList();
numDocNorms = 0;
- Directory dir2 = newDirectory(random);
+ Directory dir2 = newDirectory();
createIndex(random, dir2);
doTestNorms(random, dir2);
// add index1 and index2 to a third index: index3
- Directory dir3 = newDirectory(random);
+ Directory dir3 = newDirectory();
createIndex(random, dir3);
- IndexWriter iw = new IndexWriter(dir3, newIndexWriterConfig(random,
+ IndexWriter iw = new IndexWriter(dir3, newIndexWriterConfig(
TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
.setMaxBufferedDocs(5));
((LogMergePolicy) iw.getConfig().getMergePolicy()).setMergeFactor(3);
@@ -120,7 +119,7 @@ public class TestNorms extends LuceneTestCase {
doTestNorms(random, dir3);
// now with optimize
- iw = new IndexWriter(dir3, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ iw = new IndexWriter(dir3, newIndexWriterConfig( TEST_VERSION_CURRENT,
anlzr).setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(5));
((LogMergePolicy) iw.getConfig().getMergePolicy()).setMergeFactor(3);
iw.optimize();
@@ -146,7 +145,7 @@ public class TestNorms extends LuceneTestCase {
}
private void createIndex(Random random, Directory dir) throws IOException {
- IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.CREATE)
.setMaxBufferedDocs(5).setSimilarity(similarityOne));
LogMergePolicy lmp = (LogMergePolicy) iw.getConfig().getMergePolicy();
@@ -191,7 +190,7 @@ public class TestNorms extends LuceneTestCase {
}
private void addDocs(Random random, Directory dir, int ndocs, boolean compound) throws IOException {
- IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
.setMaxBufferedDocs(5).setSimilarity(similarityOne));
LogMergePolicy lmp = (LogMergePolicy) iw.getConfig().getMergePolicy();
diff --git a/lucene/src/test/org/apache/lucene/index/TestOmitTf.java b/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
index 947a1ff347f..29c1623d2e2 100644
--- a/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
+++ b/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
@@ -19,7 +19,6 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.Collection;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
@@ -34,13 +33,6 @@ import org.apache.lucene.search.Explanation.IDFExplanation;
public class TestOmitTf extends LuceneTestCase {
- private Random random;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
public static class SimpleSimilarity extends Similarity {
@Override public float lengthNorm(String field, int numTerms) { return 1.0f; }
@@ -66,9 +58,9 @@ public class TestOmitTf extends LuceneTestCase {
// Tests whether the DocumentWriter correctly enable the
// omitTermFreqAndPositions bit in the FieldInfo
public void testOmitTermFreqAndPositions() throws Exception {
- Directory ram = newDirectory(random);
+ Directory ram = newDirectory();
Analyzer analyzer = new MockAnalyzer();
- IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer));
+ IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer));
Document d = new Document();
// this field will have Tf
@@ -113,9 +105,9 @@ public class TestOmitTf extends LuceneTestCase {
// Tests whether merging of docs that have different
// omitTermFreqAndPositions for the same field works
public void testMixedMerge() throws Exception {
- Directory ram = newDirectory(random);
+ Directory ram = newDirectory();
Analyzer analyzer = new MockAnalyzer();
- IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(
TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(3));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
Document d = new Document();
@@ -166,9 +158,9 @@ public class TestOmitTf extends LuceneTestCase {
// field X, then adding docs that do omitTermFreqAndPositions for that same
// field,
public void testMixedRAM() throws Exception {
- Directory ram = newDirectory(random);
+ Directory ram = newDirectory();
Analyzer analyzer = new MockAnalyzer();
- IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(
TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
Document d = new Document();
@@ -214,9 +206,9 @@ public class TestOmitTf extends LuceneTestCase {
// Verifies no *.prx exists when all fields omit term freq:
public void testNoPrxFile() throws Throwable {
- Directory ram = newDirectory(random);
+ Directory ram = newDirectory();
Analyzer analyzer = new MockAnalyzer();
- IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(
TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(3));
LogMergePolicy lmp = (LogMergePolicy) writer.getConfig().getMergePolicy();
lmp.setMergeFactor(2);
@@ -247,9 +239,9 @@ public class TestOmitTf extends LuceneTestCase {
// Test scores with one field with Term Freqs and one without, otherwise with equal content
public void testBasic() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
Analyzer analyzer = new MockAnalyzer();
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(2)
.setSimilarity(new SimpleSimilarity()));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
diff --git a/lucene/src/test/org/apache/lucene/index/TestParallelReader.java b/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
index 1bcdceb0e0f..27ba9d463ef 100644
--- a/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
@@ -39,13 +39,11 @@ public class TestParallelReader extends LuceneTestCase {
private IndexSearcher parallel;
private IndexSearcher single;
- private Random random;
private Directory dir, dir1, dir2;
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
single = single(random);
parallel = parallel(random);
}
@@ -122,8 +120,8 @@ public class TestParallelReader extends LuceneTestCase {
Directory dir1 = getDir1(random);
// one document only:
- Directory dir2 = newDirectory(random);
- IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir2 = newDirectory();
+ IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document d3 = new Document();
d3.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
w2.addDocument(d3);
@@ -176,14 +174,14 @@ public class TestParallelReader extends LuceneTestCase {
Directory dir2 = getDir2(random);
// add another document to ensure that the indexes are not optimized
- IndexWriter modifier = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter modifier = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
((LogMergePolicy) modifier.getMergePolicy()).setMergeFactor(10);
Document d = new Document();
d.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
modifier.addDocument(d);
modifier.close();
- modifier = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ modifier = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
((LogMergePolicy) modifier.getMergePolicy()).setMergeFactor(10);
d = new Document();
d.add(new Field("f2", "v2", Field.Store.YES, Field.Index.ANALYZED));
@@ -197,7 +195,7 @@ public class TestParallelReader extends LuceneTestCase {
assertFalse(pr.isOptimized());
pr.close();
- modifier = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ modifier = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
modifier.optimize();
modifier.close();
@@ -209,7 +207,7 @@ public class TestParallelReader extends LuceneTestCase {
pr.close();
- modifier = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ modifier = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
modifier.optimize();
modifier.close();
@@ -240,8 +238,8 @@ public class TestParallelReader extends LuceneTestCase {
// Fields 1-4 indexed together:
private IndexSearcher single(Random random) throws IOException {
- dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document d1 = new Document();
d1.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
d1.add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
@@ -270,8 +268,8 @@ public class TestParallelReader extends LuceneTestCase {
}
private Directory getDir1(Random random) throws IOException {
- Directory dir1 = newDirectory(random);
- IndexWriter w1 = new IndexWriter(dir1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir1 = newDirectory();
+ IndexWriter w1 = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document d1 = new Document();
d1.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
d1.add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
@@ -285,8 +283,8 @@ public class TestParallelReader extends LuceneTestCase {
}
private Directory getDir2(Random random) throws IOException {
- Directory dir2 = newDirectory(random);
- IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir2 = newDirectory();
+ IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document d3 = new Document();
d3.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
d3.add(new Field("f4", "v1", Field.Store.YES, Field.Index.ANALYZED));
diff --git a/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java b/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java
index babc68861c9..0408e46f31b 100644
--- a/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java
+++ b/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
@@ -46,16 +45,15 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase {
* @throws IOException
*/
public void testEmptyIndex() throws IOException {
- Random random = newRandom();
- Directory rd1 = newDirectory(random);
- IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory rd1 = newDirectory();
+ IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
iw.close();
- Directory rd2 = newDirectory(random, rd1);
+ Directory rd2 = newDirectory(rd1);
- Directory rdOut = newDirectory(random);
+ Directory rdOut = newDirectory();
- IndexWriter iwOut = new IndexWriter(rdOut, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter iwOut = new IndexWriter(rdOut, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
ParallelReader pr = new ParallelReader();
pr.add(IndexReader.open(rd1,true));
pr.add(IndexReader.open(rd2,true));
@@ -77,10 +75,9 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase {
* any exception.
*/
public void testEmptyIndexWithVectors() throws IOException {
- Random random = newRandom();
- Directory rd1 = newDirectory(random);
+ Directory rd1 = newDirectory();
{
- IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("test", "", Store.NO, Index.ANALYZED,
TermVector.YES));
@@ -94,22 +91,22 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase {
ir.deleteDocument(0);
ir.close();
- iw = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ iw = new IndexWriter(rd1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
iw.optimize();
iw.close();
}
- Directory rd2 = newDirectory(random);
+ Directory rd2 = newDirectory();
{
- IndexWriter iw = new IndexWriter(rd2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter iw = new IndexWriter(rd2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
iw.addDocument(doc);
iw.close();
}
- Directory rdOut = newDirectory(random);
+ Directory rdOut = newDirectory();
- IndexWriter iwOut = new IndexWriter(rdOut, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter iwOut = new IndexWriter(rdOut, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
ParallelReader pr = new ParallelReader();
pr.add(IndexReader.open(rd1,true));
pr.add(IndexReader.open(rd2,true));
diff --git a/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java b/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java
index 5d9ac86d4de..420051d655a 100755
--- a/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java
+++ b/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -39,9 +38,8 @@ public class TestParallelTermEnum extends LuceneTestCase {
protected void setUp() throws Exception {
super.setUp();
Document doc;
- Random random = newRandom();
- rd1 = newDirectory(random);
- IndexWriter iw1 = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ rd1 = newDirectory();
+ IndexWriter iw1 = new IndexWriter(rd1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
doc = new Document();
doc.add(new Field("field1", "the quick brown fox jumps", Store.YES,
@@ -52,8 +50,8 @@ public class TestParallelTermEnum extends LuceneTestCase {
iw1.addDocument(doc);
iw1.close();
- rd2 = newDirectory(random);
- IndexWriter iw2 = new IndexWriter(rd2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ rd2 = newDirectory();
+ IndexWriter iw2 = new IndexWriter(rd2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
doc = new Document();
doc.add(new Field("field0", "", Store.NO, Index.ANALYZED));
diff --git a/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java b/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
index c53142959f8..9e3aac0d93c 100644
--- a/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
+++ b/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
@@ -119,13 +119,13 @@ public class TestPayloadProcessorProvider extends LuceneTestCaseJ4 {
private static final int NUM_DOCS = 10;
private IndexWriterConfig getConfig(Random random) {
- return newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false));
+ return newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false));
}
private void populateDirs(Random random, Directory[] dirs, boolean multipleCommits)
throws IOException {
for (int i = 0; i < dirs.length; i++) {
- dirs[i] = newDirectory(random);
+ dirs[i] = newDirectory();
populateDocs(random, dirs[i], multipleCommits);
verifyPayloadExists(dirs[i], "p", new BytesRef("p1"), NUM_DOCS);
verifyPayloadExists(dirs[i], "p", new BytesRef("p2"), NUM_DOCS);
@@ -178,7 +178,7 @@ public class TestPayloadProcessorProvider extends LuceneTestCaseJ4 {
Directory[] dirs = new Directory[2];
populateDirs(random, dirs, multipleCommits);
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
if (!addToEmptyIndex) {
populateDocs(random, dir, multipleCommits);
verifyPayloadExists(dir, "p", new BytesRef("p1"), NUM_DOCS);
@@ -218,7 +218,6 @@ public class TestPayloadProcessorProvider extends LuceneTestCaseJ4 {
@Test
public void testAddIndexes() throws Exception {
- Random random = newRandom();
// addIndexes - single commit in each
doTest(random, true, 0, false);
@@ -228,7 +227,6 @@ public class TestPayloadProcessorProvider extends LuceneTestCaseJ4 {
@Test
public void testAddIndexesIntoExisting() throws Exception {
- Random random = newRandom();
// addIndexes - single commit in each
doTest(random, false, NUM_DOCS, false);
@@ -238,8 +236,7 @@ public class TestPayloadProcessorProvider extends LuceneTestCaseJ4 {
@Test
public void testRegularMerges() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
populateDocs(random, dir, true);
verifyPayloadExists(dir, "p", new BytesRef("p1"), NUM_DOCS);
verifyPayloadExists(dir, "p", new BytesRef("p2"), NUM_DOCS);
diff --git a/lucene/src/test/org/apache/lucene/index/TestPayloads.java b/lucene/src/test/org/apache/lucene/index/TestPayloads.java
index 19040eda65d..6a0bf0de91a 100644
--- a/lucene/src/test/org/apache/lucene/index/TestPayloads.java
+++ b/lucene/src/test/org/apache/lucene/index/TestPayloads.java
@@ -50,7 +50,6 @@ public class TestPayloads extends LuceneTestCase {
// Simple tests to test the Payload class
public void testPayload() throws Exception {
- rnd = newRandom();
byte[] testData = "This is a test!".getBytes();
Payload payload = new Payload(testData);
assertEquals("Wrong payload length.", testData.length, payload.length());
@@ -99,10 +98,9 @@ public class TestPayloads extends LuceneTestCase {
// Tests whether the DocumentWriter and SegmentMerger correctly enable the
// payload bit in the FieldInfo
public void testPayloadFieldBit() throws Exception {
- rnd = newRandom();
- Directory ram = newDirectory(rnd);
+ Directory ram = newDirectory();
PayloadAnalyzer analyzer = new PayloadAnalyzer();
- IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(rnd, TEST_VERSION_CURRENT, analyzer));
+ IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer));
Document d = new Document();
// this field won't have any payloads
d.add(new Field("f1", "This field has no payloads", Field.Store.NO, Field.Index.ANALYZED));
@@ -129,7 +127,7 @@ public class TestPayloads extends LuceneTestCase {
// now we add another document which has payloads for field f3 and verify if the SegmentMerger
// enabled payloads for that field
- writer = new IndexWriter(ram, newIndexWriterConfig(rnd, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(ram, newIndexWriterConfig( TEST_VERSION_CURRENT,
analyzer).setOpenMode(OpenMode.CREATE));
d = new Document();
d.add(new Field("f1", "This field has no payloads", Field.Store.NO, Field.Index.ANALYZED));
@@ -157,15 +155,14 @@ public class TestPayloads extends LuceneTestCase {
// Tests if payloads are correctly stored and loaded using both RamDirectory and FSDirectory
public void testPayloadsEncoding() throws Exception {
- rnd = newRandom();
// first perform the test using a RAMDirectory
- Directory dir = newDirectory(rnd);
- performTest(rnd, dir);
+ Directory dir = newDirectory();
+ performTest(random, dir);
dir.close();
// now use a FSDirectory and repeat same test
File dirName = _TestUtil.getTempDir("test_payloads");
dir = FSDirectory.open(dirName);
- performTest(rnd, dir);
+ performTest(random, dir);
_TestUtil.rmDir(dirName);
dir.close();
}
@@ -174,7 +171,7 @@ public class TestPayloads extends LuceneTestCase {
// different tests to verify the payload encoding
private void performTest(Random random, Directory dir) throws Exception {
PayloadAnalyzer analyzer = new PayloadAnalyzer();
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, analyzer)
.setOpenMode(OpenMode.CREATE));
@@ -315,7 +312,7 @@ public class TestPayloads extends LuceneTestCase {
// test long payload
analyzer = new PayloadAnalyzer();
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT,
analyzer).setOpenMode(OpenMode.CREATE));
String singleTerm = "lucene";
@@ -349,10 +346,8 @@ public class TestPayloads extends LuceneTestCase {
}
- private Random rnd;
-
private void generateRandomData(byte[] data) {
- rnd.nextBytes(data);
+ random.nextBytes(data);
}
private byte[] generateRandomData(int n) {
@@ -485,13 +480,12 @@ public class TestPayloads extends LuceneTestCase {
}
public void testThreadSafety() throws Exception {
- rnd = newRandom();
final int numThreads = 5;
final int numDocs = 50 * RANDOM_MULTIPLIER;
final ByteArrayPool pool = new ByteArrayPool(numThreads, 5);
- Directory dir = newDirectory(rnd);
- final IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(rnd,
+ Directory dir = newDirectory();
+ final IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
final String field = "test";
diff --git a/lucene/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java b/lucene/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java
index 118eb0e5682..2ee907eb0df 100644
--- a/lucene/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java
+++ b/lucene/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java
@@ -39,7 +39,7 @@ public class TestPersistentSnapshotDeletionPolicy extends TestSnapshotDeletionPo
@Override
public void setUp() throws Exception {
super.setUp();
- snapshotDir = newDirectory(random);
+ snapshotDir = newDirectory();
}
@After
@@ -52,7 +52,7 @@ public class TestPersistentSnapshotDeletionPolicy extends TestSnapshotDeletionPo
@Override
protected SnapshotDeletionPolicy getDeletionPolicy() throws IOException {
snapshotDir.close();
- snapshotDir = newDirectory(random);
+ snapshotDir = newDirectory();
return new PersistentSnapshotDeletionPolicy(
new KeepOnlyLastCommitDeletionPolicy(), snapshotDir, OpenMode.CREATE,
TEST_VERSION_CURRENT);
@@ -73,7 +73,7 @@ public class TestPersistentSnapshotDeletionPolicy extends TestSnapshotDeletionPo
@Test
public void testExistingSnapshots() throws Exception {
int numSnapshots = 3;
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random, psdp));
prepareIndexAndSnapshots(psdp, writer, numSnapshots, "snapshot");
@@ -137,7 +137,7 @@ public class TestPersistentSnapshotDeletionPolicy extends TestSnapshotDeletionPo
@Test
public void testSnapshotRelease() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random, psdp));
prepareIndexAndSnapshots(psdp, writer, 1, "snapshot");
@@ -160,7 +160,7 @@ public class TestPersistentSnapshotDeletionPolicy extends TestSnapshotDeletionPo
// prevents reading the snapshots information. This test checks that the
// static read method works.
int numSnapshots = 1;
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random, psdp));
prepareIndexAndSnapshots(psdp, writer, numSnapshots, "snapshot");
diff --git a/lucene/src/test/org/apache/lucene/index/TestRollback.java b/lucene/src/test/org/apache/lucene/index/TestRollback.java
index 23c537b415d..87cdd0b5755 100644
--- a/lucene/src/test/org/apache/lucene/index/TestRollback.java
+++ b/lucene/src/test/org/apache/lucene/index/TestRollback.java
@@ -17,8 +17,6 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -31,8 +29,7 @@ public class TestRollback extends LuceneTestCase {
// LUCENE-2536
public void testRollbackIntegrityWithBufferFlush() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter rw = new RandomIndexWriter(random, dir);
for (int i = 0; i < 5; i++) {
Document doc = new Document();
@@ -42,7 +39,7 @@ public class TestRollback extends LuceneTestCase {
rw.close();
// If buffer size is small enough to cause a flush, errors ensue...
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2).setOpenMode(IndexWriterConfig.OpenMode.APPEND));
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2).setOpenMode(IndexWriterConfig.OpenMode.APPEND));
Term pkTerm = new Term("pk", "");
for (int i = 0; i < 3; i++) {
diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java b/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
index 94bb0d4c6e9..4227e827839 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
@@ -26,7 +26,6 @@ import org.apache.lucene.util.BytesRef;
import java.io.IOException;
import java.util.Collection;
-import java.util.Random;
public class TestSegmentMerger extends LuceneTestCase {
//The variables for the new merged segment
@@ -49,10 +48,9 @@ public class TestSegmentMerger extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- mergedDir = newDirectory(random);
- merge1Dir = newDirectory(random);
- merge2Dir = newDirectory(random);
+ mergedDir = newDirectory();
+ merge1Dir = newDirectory();
+ merge2Dir = newDirectory();
DocHelper.setupDoc(doc1);
SegmentInfo info1 = DocHelper.writeDoc(merge1Dir, doc1);
DocHelper.setupDoc(doc2);
diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java b/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
index 4427c2632e7..49c722c727f 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
@@ -43,7 +43,7 @@ public class TestSegmentReader extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- dir = newDirectory(newRandom());
+ dir = newDirectory();
DocHelper.setupDoc(testDoc);
SegmentInfo info = DocHelper.writeDoc(dir, testDoc);
reader = SegmentReader.get(true, info, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR);
diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java b/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java
index 5f0a504cadf..6ba77921dca 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java
@@ -25,13 +25,11 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.util.BytesRef;
import java.io.IOException;
-import java.util.Random;
public class TestSegmentTermDocs extends LuceneTestCase {
private Document testDoc = new Document();
private Directory dir;
private SegmentInfo info;
- private Random random;
public TestSegmentTermDocs(String s) {
super(s);
@@ -40,8 +38,7 @@ public class TestSegmentTermDocs extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
+ dir = newDirectory();
DocHelper.setupDoc(testDoc);
info = DocHelper.writeDoc(dir, testDoc);
}
@@ -111,8 +108,8 @@ public class TestSegmentTermDocs extends LuceneTestCase {
}
public void testSkipTo(int indexDivisor) throws IOException {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Term ta = new Term("content","aaa");
for(int i = 0; i < 10; i++)
diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java b/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java
index 9ff59c07927..e5003791fab 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
@@ -33,13 +32,11 @@ import org.apache.lucene.store.Directory;
public class TestSegmentTermEnum extends LuceneTestCase {
Directory dir;
- Random random;
@Override
public void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
+ dir = newDirectory();
}
@Override
@@ -51,7 +48,7 @@ public class TestSegmentTermEnum extends LuceneTestCase {
public void testTermEnum() throws IOException {
IndexWriter writer = null;
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
// ADD 100 documents with term : aaa
// add 100 documents with terms: aaa bbb
@@ -67,7 +64,7 @@ public class TestSegmentTermEnum extends LuceneTestCase {
verifyDocFreq();
// merge segments by optimizing the index
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
writer.optimize();
writer.close();
@@ -77,7 +74,7 @@ public class TestSegmentTermEnum extends LuceneTestCase {
public void testPrevTermAtEnd() throws IOException
{
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
addDoc(writer, "aaa bbb");
writer.close();
SegmentReader reader = SegmentReader.getOnlySegmentReader(dir);
diff --git a/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java b/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
index 7ee2f7e6300..d54e2579f41 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
@@ -22,7 +22,6 @@ import org.apache.lucene.index.SnapshotDeletionPolicy;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.apache.lucene.util.ThreadInterruptedException;
import org.apache.lucene.util._TestUtil;
-import org.junit.Before;
import org.junit.Test;
//
@@ -31,18 +30,10 @@ import org.junit.Test;
//
public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
- protected Random random;
public static final String INDEX_PATH = "test.snapshots";
-
- @Before
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
protected IndexWriterConfig getConfig(Random random, IndexDeletionPolicy dp) {
- IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer());
+ IndexWriterConfig conf = newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer());
if (dp != null) {
conf.setIndexDeletionPolicy(dp);
}
@@ -101,7 +92,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
_TestUtil.rmDir(dir);
}
- Directory dir2 = newDirectory(random);
+ Directory dir2 = newDirectory();
runTest(random, dir2);
dir2.close();
}
@@ -111,7 +102,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
final long stopTime = System.currentTimeMillis() + 1000;
SnapshotDeletionPolicy dp = getDeletionPolicy();
- final IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ final IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(dp)
.setMaxBufferedDocs(2));
writer.commit();
@@ -239,7 +230,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
SnapshotDeletionPolicy sdp = getDeletionPolicy();
// Create 3 snapshots: snapshot0, snapshot1, snapshot2
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, getConfig(random, sdp));
prepareIndexAndSnapshots(sdp, writer, numSnapshots, "snapshot");
writer.close();
@@ -269,7 +260,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
@Test
public void testMultiThreadedSnapshotting() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
final SnapshotDeletionPolicy sdp = getDeletionPolicy();
final IndexWriter writer = new IndexWriter(dir, getConfig(random, sdp));
@@ -314,7 +305,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
@Test
public void testRollbackToOldSnapshot() throws Exception {
int numSnapshots = 2;
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
SnapshotDeletionPolicy sdp = getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random, sdp));
prepareIndexAndSnapshots(sdp, writer, numSnapshots, "snapshot");
@@ -336,7 +327,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
@Test
public void testReleaseSnapshot() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
SnapshotDeletionPolicy sdp = getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random, sdp));
prepareIndexAndSnapshots(sdp, writer, 1, "snapshot");
@@ -368,7 +359,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
// Tests the ability to construct a SDP from existing snapshots, and
// asserts that those snapshots/commit points are protected.
int numSnapshots = 3;
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
SnapshotDeletionPolicy sdp = getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random, sdp));
prepareIndexAndSnapshots(sdp, writer, numSnapshots, "snapshot");
@@ -386,7 +377,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
@Test
public void testSnapshotLastCommitTwice() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
SnapshotDeletionPolicy sdp = getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random, sdp));
writer.addDocument(new Document());
@@ -415,7 +406,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
public void testMissingCommits() throws Exception {
// Tests the behavior of SDP when commits that are given at ctor are missing
// on onInit().
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
SnapshotDeletionPolicy sdp = getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random, sdp));
writer.addDocument(new Document());
diff --git a/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java b/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java
index a109f751d12..56d4a2de409 100644
--- a/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java
+++ b/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java
@@ -23,12 +23,9 @@ import org.apache.lucene.document.*;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.*;
-import java.util.Random;
import java.io.File;
public class TestStressIndexing extends MultiCodecTestCase {
- private Random RANDOM;
-
private static abstract class TimedThread extends Thread {
volatile boolean failed;
int count;
@@ -82,7 +79,7 @@ public class TestStressIndexing extends MultiCodecTestCase {
// Add 10 docs:
for(int j=0; j<10; j++) {
Document d = new Document();
- int n = RANDOM.nextInt();
+ int n = random.nextInt();
d.add(new Field("id", Integer.toString(nextID++), Field.Store.YES, Field.Index.NOT_ANALYZED));
d.add(new Field("contents", English.intToEnglish(n), Field.Store.NO, Field.Index.ANALYZED));
writer.addDocument(d);
@@ -118,7 +115,7 @@ public class TestStressIndexing extends MultiCodecTestCase {
stress test.
*/
public void runStressTest(Directory directory, MergeScheduler mergeScheduler) throws Exception {
- IndexWriter modifier = new IndexWriter(directory, newIndexWriterConfig(RANDOM,
+ IndexWriter modifier = new IndexWriter(directory, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(10).setMergeScheduler(
mergeScheduler));
@@ -166,10 +163,8 @@ public class TestStressIndexing extends MultiCodecTestCase {
FSDirectory.
*/
public void testStressIndexAndSearching() throws Exception {
- RANDOM = newRandom();
-
// With ConcurrentMergeScheduler, in RAMDir
- Directory directory = newDirectory(RANDOM);
+ Directory directory = newDirectory();
runStressTest(directory, new ConcurrentMergeScheduler());
directory.close();
diff --git a/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java b/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java
index 0290b1f4d80..9d0742f5b24 100644
--- a/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java
+++ b/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java
@@ -44,8 +44,6 @@ public class TestStressIndexing2 extends MultiCodecTestCase {
static int maxBufferedDocs=3;
static int seed=0;
- Random r;
-
public class MockIndexWriter extends IndexWriter {
public MockIndexWriter(Directory dir, IndexWriterConfig conf) throws IOException {
@@ -55,36 +53,34 @@ public class TestStressIndexing2 extends MultiCodecTestCase {
@Override
boolean testPoint(String name) {
// if (name.equals("startCommit")) {
- if (r.nextInt(4) == 2)
+ if (random.nextInt(4) == 2)
Thread.yield();
return true;
}
}
public void testRandomIWReader() throws Throwable {
- r = newRandom();
- Directory dir = newDirectory(r);
+ Directory dir = newDirectory();
// TODO: verify equals using IW.getReader
DocsAndWriter dw = indexRandomIWReader(5, 3, 100, dir);
IndexReader reader = dw.writer.getReader();
dw.writer.commit();
- verifyEquals(r, reader, dir, "id");
+ verifyEquals(random, reader, dir, "id");
reader.close();
dw.writer.close();
dir.close();
}
public void testRandom() throws Throwable {
- r = newRandom();
- Directory dir1 = newDirectory(r);
+ Directory dir1 = newDirectory();
// dir1 = FSDirectory.open("foofoofoo");
- Directory dir2 = newDirectory(r);
+ Directory dir2 = newDirectory();
// mergeFactor=2; maxBufferedDocs=2; Map docs = indexRandom(1, 3, 2, dir1);
- int maxThreadStates = 1+r.nextInt(10);
- boolean doReaderPooling = r.nextBoolean();
+ int maxThreadStates = 1+random.nextInt(10);
+ boolean doReaderPooling = random.nextBoolean();
Map docs = indexRandom(5, 3, 100, dir1, maxThreadStates, doReaderPooling);
- indexSerial(r, docs, dir2);
+ indexSerial(random, docs, dir2);
// verifying verify
// verifyEquals(dir1, dir1, "id");
@@ -98,25 +94,23 @@ public class TestStressIndexing2 extends MultiCodecTestCase {
public void testMultiConfig() throws Throwable {
// test lots of smaller different params together
- r = newRandom();
-
int num = 3 * RANDOM_MULTIPLIER;
for (int i = 0; i < num; i++) { // increase iterations for better testing
- sameFieldOrder=r.nextBoolean();
- mergeFactor=r.nextInt(3)+2;
- maxBufferedDocs=r.nextInt(3)+2;
- int maxThreadStates = 1+r.nextInt(10);
- boolean doReaderPooling = r.nextBoolean();
+ sameFieldOrder=random.nextBoolean();
+ mergeFactor=random.nextInt(3)+2;
+ maxBufferedDocs=random.nextInt(3)+2;
+ int maxThreadStates = 1+random.nextInt(10);
+ boolean doReaderPooling = random.nextBoolean();
seed++;
- int nThreads=r.nextInt(5)+1;
- int iter=r.nextInt(5)+1;
- int range=r.nextInt(20)+1;
- Directory dir1 = newDirectory(r);
- Directory dir2 = newDirectory(r);
+ int nThreads=random.nextInt(5)+1;
+ int iter=random.nextInt(5)+1;
+ int range=random.nextInt(20)+1;
+ Directory dir1 = newDirectory();
+ Directory dir2 = newDirectory();
Map docs = indexRandom(nThreads, iter, range, dir1, maxThreadStates, doReaderPooling);
//System.out.println("TEST: index serial");
- indexSerial(r, docs, dir2);
+ indexSerial(random, docs, dir2);
//System.out.println("TEST: verify");
verifyEquals(dir1, dir2, "id");
dir1.close();
@@ -144,7 +138,7 @@ public class TestStressIndexing2 extends MultiCodecTestCase {
public DocsAndWriter indexRandomIWReader(int nThreads, int iterations, int range, Directory dir) throws IOException, InterruptedException {
Map docs = new HashMap();
- IndexWriter w = new MockIndexWriter(dir, newIndexWriterConfig(r,
+ IndexWriter w = new MockIndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setRAMBufferSizeMB(
0.1).setMaxBufferedDocs(maxBufferedDocs));
w.commit();
@@ -197,7 +191,7 @@ public class TestStressIndexing2 extends MultiCodecTestCase {
boolean doReaderPooling) throws IOException, InterruptedException {
Map docs = new HashMap();
for(int iter=0;iter<3;iter++) {
- IndexWriter w = new MockIndexWriter(dir, newIndexWriterConfig(r,
+ IndexWriter w = new MockIndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE)
.setRAMBufferSizeMB(0.1).setMaxBufferedDocs(maxBufferedDocs).setMaxThreadStates(maxThreadStates)
.setReaderPooling(doReaderPooling));
@@ -242,7 +236,7 @@ public class TestStressIndexing2 extends MultiCodecTestCase {
public static void indexSerial(Random random, Map docs, Directory dir) throws IOException {
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter w = new IndexWriter(dir, LuceneTestCaseJ4.newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
// index all docs in a single thread
Iterator iter = docs.values().iterator();
diff --git a/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java b/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
index 6963360aaa3..6ea2562d343 100644
--- a/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
@@ -22,7 +22,6 @@ import java.io.Reader;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
-import java.util.Random;
import java.util.SortedSet;
import org.apache.lucene.analysis.Analyzer;
@@ -94,9 +93,8 @@ public class TestTermVectorsReader extends LuceneTestCase {
}
Arrays.sort(tokens);
- Random random = newRandom();
- dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MyAnalyzer()).setMaxBufferedDocs(-1));
+ dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MyAnalyzer()).setMaxBufferedDocs(-1));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(10);
diff --git a/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java b/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java
index e25402abe62..0f57af9bb41 100644
--- a/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java
+++ b/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java
@@ -70,7 +70,7 @@ public class TestTermdocPerf extends LuceneTestCase {
Document doc = new Document();
doc.add(new Field(field,val, Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, analyzer)
.setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(100));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(100);
@@ -85,8 +85,7 @@ public class TestTermdocPerf extends LuceneTestCase {
public int doTest(int iter, int ndocs, int maxTF, float percentDocs) throws IOException {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
long start = System.currentTimeMillis();
addDocs(random, dir, ndocs, "foo", "val", maxTF, percentDocs);
diff --git a/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java b/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java
index 0da52f51a6e..6f6d3a7aba7 100644
--- a/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java
+++ b/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java
@@ -54,7 +54,7 @@ public class TestThreadedOptimize extends LuceneTestCase {
public void runTest(Random random, Directory directory, MergeScheduler merger) throws Exception {
- IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(
TEST_VERSION_CURRENT, ANALYZER)
.setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(2).setMergeScheduler(
merger));
@@ -119,7 +119,7 @@ public class TestThreadedOptimize extends LuceneTestCase {
assertEquals(expectedDocCount, writer.maxDoc());
writer.close();
- writer = new IndexWriter(directory, newIndexWriterConfig(random,
+ writer = new IndexWriter(directory, newIndexWriterConfig(
TEST_VERSION_CURRENT, ANALYZER).setOpenMode(
OpenMode.APPEND).setMaxBufferedDocs(2));
@@ -136,8 +136,7 @@ public class TestThreadedOptimize extends LuceneTestCase {
FSDirectory.
*/
public void testThreadedOptimize() throws Exception {
- Random random = newRandom();
- Directory directory = newDirectory(random);
+ Directory directory = newDirectory();
runTest(random, directory, new SerialMergeScheduler());
runTest(random, directory, new ConcurrentMergeScheduler());
directory.close();
diff --git a/lucene/src/test/org/apache/lucene/index/TestTransactionRollback.java b/lucene/src/test/org/apache/lucene/index/TestTransactionRollback.java
index 410be42a2c2..da5d406b701 100644
--- a/lucene/src/test/org/apache/lucene/index/TestTransactionRollback.java
+++ b/lucene/src/test/org/apache/lucene/index/TestTransactionRollback.java
@@ -25,7 +25,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -45,7 +44,6 @@ public class TestTransactionRollback extends LuceneTestCase {
private static final String FIELD_RECORD_ID = "record_id";
private Directory dir;
- private Random random;
//Rolls back index to a chosen ID
private void rollBackLast(int id) throws Exception {
@@ -65,7 +63,7 @@ public class TestTransactionRollback extends LuceneTestCase {
if (last==null)
throw new RuntimeException("Couldn't find commit point "+id);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(
new RollbackDeletionPolicy(id)).setIndexCommit(last));
Map data = new HashMap();
@@ -126,11 +124,10 @@ public class TestTransactionRollback extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
+ dir = newDirectory();
//Build index, of records 1 to 100, committing after each batch of 10
IndexDeletionPolicy sdp=new KeepAllDeletionPolicy();
- IndexWriter w=new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(sdp));
+ IndexWriter w=new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(sdp));
for(int currentRecordId=1;currentRecordId<=100;currentRecordId++) {
Document doc=new Document();
doc.add(new Field(FIELD_RECORD_ID,""+currentRecordId,Field.Store.YES,Field.Index.ANALYZED));
@@ -204,7 +201,7 @@ public class TestTransactionRollback extends LuceneTestCase {
for(int i=0;i<2;i++) {
// Unless you specify a prior commit point, rollback
// should not work:
- new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
+ new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())
.setIndexDeletionPolicy(new DeleteLastCommitPolicy())).close();
IndexReader r = IndexReader.open(dir, true);
assertEquals(100, r.numDocs());
diff --git a/lucene/src/test/org/apache/lucene/index/TestTransactions.java b/lucene/src/test/org/apache/lucene/index/TestTransactions.java
index 7ddd30e3c83..d2587f6f37e 100644
--- a/lucene/src/test/org/apache/lucene/index/TestTransactions.java
+++ b/lucene/src/test/org/apache/lucene/index/TestTransactions.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -28,17 +27,15 @@ import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.English;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
public class TestTransactions extends LuceneTestCase {
- private Random RANDOM;
private static volatile boolean doFail;
private class RandomFailure extends MockDirectoryWrapper.Failure {
@Override
public void eval(MockDirectoryWrapper dir) throws IOException {
- if (TestTransactions.doFail && RANDOM.nextInt() % 10 <= 3)
+ if (TestTransactions.doFail && random.nextInt() % 10 <= 3)
throw new IOException("now failing randomly but on purpose");
}
}
@@ -94,14 +91,14 @@ public class TestTransactions extends LuceneTestCase {
@Override
public void doWork() throws Throwable {
- IndexWriter writer1 = new IndexWriter(dir1, newIndexWriterConfig(RANDOM, TEST_VERSION_CURRENT, new MockAnalyzer())
+ IndexWriter writer1 = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(3).setMergeScheduler(new ConcurrentMergeScheduler()));
((LogMergePolicy) writer1.getConfig().getMergePolicy()).setMergeFactor(2);
((ConcurrentMergeScheduler) writer1.getConfig().getMergeScheduler()).setSuppressExceptions();
// Intentionally use different params so flush/merge
// happen @ different times
- IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig(RANDOM, TEST_VERSION_CURRENT, new MockAnalyzer())
+ IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2).setMergeScheduler(new ConcurrentMergeScheduler()));
((LogMergePolicy) writer2.getConfig().getMergePolicy()).setMergeFactor(3);
((ConcurrentMergeScheduler) writer2.getConfig().getMergeScheduler()).setSuppressExceptions();
@@ -142,7 +139,7 @@ public class TestTransactions extends LuceneTestCase {
// Add 10 docs:
for(int j=0; j<10; j++) {
Document d = new Document();
- int n = RANDOM.nextInt();
+ int n = random.nextInt();
d.add(new Field("id", Integer.toString(nextID++), Field.Store.YES, Field.Index.NOT_ANALYZED));
d.add(new Field("contents", English.intToEnglish(n), Field.Store.NO, Field.Index.ANALYZED));
writer.addDocument(d);
@@ -184,10 +181,10 @@ public class TestTransactions extends LuceneTestCase {
}
public void initIndex(Directory dir) throws Throwable {
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(RANDOM, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int j=0; j<7; j++) {
Document d = new Document();
- int n = RANDOM.nextInt();
+ int n = random.nextInt();
d.add(new Field("contents", English.intToEnglish(n), Field.Store.NO, Field.Index.ANALYZED));
writer.addDocument(d);
}
@@ -195,7 +192,6 @@ public class TestTransactions extends LuceneTestCase {
}
public void testTransactions() throws Throwable {
- RANDOM = newRandom();
// we cant use non-ramdir on windows, because this test needs to double-write.
MockDirectoryWrapper dir1 = new MockDirectoryWrapper(new RAMDirectory());
MockDirectoryWrapper dir2 = new MockDirectoryWrapper(new RAMDirectory());
diff --git a/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java b/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java
index f8ea07047b8..71f155f634f 100644
--- a/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java
+++ b/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java
@@ -25,7 +25,7 @@ import org.apache.lucene.index.codecs.mockintblock.*;
public class TestIntBlockCodec extends LuceneTestCase {
public void testSimpleIntBlocks() throws Exception {
- Directory dir = newDirectory(newRandom());
+ Directory dir = newDirectory();
IntStreamFactory f = new MockFixedIntBlockCodec(128).getIntFactory();
@@ -47,7 +47,7 @@ public class TestIntBlockCodec extends LuceneTestCase {
}
public void testEmptySimpleIntBlocks() throws Exception {
- Directory dir = newDirectory(newRandom());
+ Directory dir = newDirectory();
IntStreamFactory f = new MockFixedIntBlockCodec(128).getIntFactory();
IntIndexOutput out = f.createOutput(dir, "test");
diff --git a/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java b/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java
index d1ff288fdf9..7d07a0070a7 100644
--- a/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java
+++ b/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java
@@ -272,15 +272,13 @@ public class TestSurrogates extends LuceneTestCaseJ4 {
@Test
public void testSurrogatesOrder() throws Exception {
- Random r = newRandom();
-
- Directory dir = newDirectory(r);
- RandomIndexWriter w = new RandomIndexWriter(r,
+ Directory dir = newDirectory();
+ RandomIndexWriter w = new RandomIndexWriter(random,
dir,
- newIndexWriterConfig(r, TEST_VERSION_CURRENT,
+ newIndexWriterConfig( TEST_VERSION_CURRENT,
new MockAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec(new PreFlexRWCodec())));
- final int numField = _TestUtil.nextInt(r, 2, 5);
+ final int numField = _TestUtil.nextInt(random, 2, 5);
int uniqueTermCount = 0;
@@ -295,7 +293,7 @@ public class TestSurrogates extends LuceneTestCaseJ4 {
final Set uniqueTerms = new HashSet();
for(int i=0;i termsSet = new HashSet();
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java b/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
index 4ea1ecb815d..f736070d291 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
@@ -26,7 +26,6 @@ import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.store.Directory;
import java.io.IOException;
-import java.util.Random;
/**
* Tests {@link MultiSearcher} ranking, i.e. makes sure this bug is fixed:
@@ -110,14 +109,13 @@ public class TestMultiSearcherRanking extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
// create MultiSearcher from two seperate searchers
- d1 = newDirectory(random);
- IndexWriter iw1 = new IndexWriter(d1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ d1 = newDirectory();
+ IndexWriter iw1 = new IndexWriter(d1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
addCollection1(iw1);
iw1.close();
- d2 = newDirectory(random);
- IndexWriter iw2 = new IndexWriter(d2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ d2 = newDirectory();
+ IndexWriter iw2 = new IndexWriter(d2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
addCollection2(iw2);
iw2.close();
@@ -127,8 +125,8 @@ public class TestMultiSearcherRanking extends LuceneTestCase {
multiSearcher = new MultiSearcher(s);
// create IndexSearcher which contains all documents
- d = newDirectory(random);
- IndexWriter iw = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ d = newDirectory();
+ IndexWriter iw = new IndexWriter(d, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
addCollection1(iw);
addCollection2(iw);
iw.close();
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java b/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
index 20f62b4e269..9cb6ec11633 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
@@ -54,8 +54,8 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
"B 2 4 5 6", "Y 3 5 6", null, "C 3 6",
"X 4 5 6" };
- small = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, small, new MockAnalyzer(MockTokenizer.WHITESPACE, false));
+ small = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, small, new MockAnalyzer(MockTokenizer.WHITESPACE, false));
for (int i = 0; i < data.length; i++) {
Document doc = new Document();
@@ -608,8 +608,8 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
public void testFarsi() throws Exception {
/* build an index */
- Directory farsiIndex = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, farsiIndex, new MockAnalyzer(MockTokenizer.SIMPLE, true));
+ Directory farsiIndex = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, farsiIndex, new MockAnalyzer(MockTokenizer.SIMPLE, true));
Document doc = new Document();
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
Field.Index.NOT_ANALYZED));
@@ -648,8 +648,8 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
public void testDanish() throws Exception {
/* build an index */
- Directory danishIndex = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, danishIndex, new MockAnalyzer(MockTokenizer.SIMPLE, true));
+ Directory danishIndex = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, danishIndex, new MockAnalyzer(MockTokenizer.SIMPLE, true));
// Danish collation orders the words below in the given order
// (example taken from TestSort.testInternationalSort() ).
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java b/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java
index cabde91122c..b4f539cefc6 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java
@@ -28,7 +28,6 @@ import org.apache.lucene.store.Directory;
import org.apache.lucene.util.English;
import java.io.IOException;
-import java.util.Random;
public class TestMultiThreadTermVectors extends LuceneTestCase {
private Directory directory;
@@ -42,9 +41,8 @@ public class TestMultiThreadTermVectors extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
- IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ directory = newDirectory();
+ IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
//writer.setUseCompoundFile(false);
//writer.infoStream = System.out;
for (int i = 0; i < numDocs; i++) {
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java b/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
index c2185b0240e..0b9a0e7a023 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
@@ -17,7 +17,6 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.util.Random;
import java.util.Locale;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
@@ -38,18 +37,16 @@ public class TestMultiValuedNumericRangeQuery extends LuceneTestCase {
* do not interfere with multiple numeric values.
*/
public void testMultiValuedNRQ() throws Exception {
- final Random rnd = newRandom();
-
- Directory directory = newDirectory(rnd);
- RandomIndexWriter writer = new RandomIndexWriter(rnd, directory);
+ Directory directory = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, directory);
DecimalFormat format = new DecimalFormat("00000000000", new DecimalFormatSymbols(Locale.US));
int num = 5000 * RANDOM_MULTIPLIER;
for (int l = 0; l < num; l++) {
Document doc = new Document();
- for (int m=0, c=rnd.nextInt(10); m<=c; m++) {
- int value = rnd.nextInt(Integer.MAX_VALUE);
+ for (int m=0, c=random.nextInt(10); m<=c; m++) {
+ int value = random.nextInt(Integer.MAX_VALUE);
doc.add(new Field("asc", format.format(value), Field.Store.NO, Field.Index.NOT_ANALYZED));
doc.add(new NumericField("trie", Field.Store.NO, true).setIntValue(value));
}
@@ -61,8 +58,8 @@ public class TestMultiValuedNumericRangeQuery extends LuceneTestCase {
Searcher searcher=new IndexSearcher(reader);
num = 50 * RANDOM_MULTIPLIER;
for (int i = 0; i < num; i++) {
- int lower=rnd.nextInt(Integer.MAX_VALUE);
- int upper=rnd.nextInt(Integer.MAX_VALUE);
+ int lower=random.nextInt(Integer.MAX_VALUE);
+ int upper=random.nextInt(Integer.MAX_VALUE);
if (lower>upper) {
int a=lower; lower=upper; upper=a;
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestNot.java b/lucene/src/test/org/apache/lucene/search/TestNot.java
index 26b7f252bf3..638f9fcc497 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNot.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNot.java
@@ -17,8 +17,6 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.IndexReader;
@@ -40,8 +38,7 @@ public class TestNot extends LuceneTestCase {
}
public void testNot() throws Exception {
- Random random = newRandom();
- Directory store = newDirectory(random);
+ Directory store = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, store);
Document d1 = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
index 762fcbaa6ea..213f1328859 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
@@ -25,7 +25,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.store.Directory;
@@ -281,8 +280,8 @@ public class TestNumericRangeQuery32 extends LuceneTestCaseJ4 {
@Test
public void testInfiniteValues() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new NumericField("float").setFloatValue(Float.NEGATIVE_INFINITY));
doc.add(new NumericField("int").setIntValue(Integer.MIN_VALUE));
@@ -330,13 +329,12 @@ public class TestNumericRangeQuery32 extends LuceneTestCaseJ4 {
}
private void testRandomTrieAndClassicRangeQuery(int precisionStep) throws Exception {
- final Random rnd=newRandom();
String field="field"+precisionStep;
int termCountT=0,termCountC=0;
int num = 10 * RANDOM_MULTIPLIER;
for (int i = 0; i < num; i++) {
- int lower=(int)(rnd.nextDouble()*noDocs*distance)+startOffset;
- int upper=(int)(rnd.nextDouble()*noDocs*distance)+startOffset;
+ int lower=(int)(random.nextDouble()*noDocs*distance)+startOffset;
+ int upper=(int)(random.nextDouble()*noDocs*distance)+startOffset;
if (lower>upper) {
int a=lower; lower=upper; upper=a;
}
@@ -409,13 +407,12 @@ public class TestNumericRangeQuery32 extends LuceneTestCaseJ4 {
}
private void testRangeSplit(int precisionStep) throws Exception {
- final Random rnd=newRandom();
String field="ascfield"+precisionStep;
// 10 random tests
int num = 10 * RANDOM_MULTIPLIER;
for (int i =0; i< num; i++) {
- int lower=(int)(rnd.nextDouble()*noDocs - noDocs/2);
- int upper=(int)(rnd.nextDouble()*noDocs - noDocs/2);
+ int lower=(int)(random.nextDouble()*noDocs - noDocs/2);
+ int upper=(int)(random.nextDouble()*noDocs - noDocs/2);
if (lower>upper) {
int a=lower; lower=upper; upper=a;
}
@@ -485,14 +482,13 @@ public class TestNumericRangeQuery32 extends LuceneTestCaseJ4 {
}
private void testSorting(int precisionStep) throws Exception {
- final Random rnd=newRandom();
String field="field"+precisionStep;
// 10 random tests, the index order is ascending,
// so using a reverse sort field should retun descending documents
int num = 10 * RANDOM_MULTIPLIER;
for (int i = 0; i < num; i++) {
- int lower=(int)(rnd.nextDouble()*noDocs*distance)+startOffset;
- int upper=(int)(rnd.nextDouble()*noDocs*distance)+startOffset;
+ int lower=(int)(random.nextDouble()*noDocs*distance)+startOffset;
+ int upper=(int)(random.nextDouble()*noDocs*distance)+startOffset;
if (lower>upper) {
int a=lower; lower=upper; upper=a;
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
index a5464078d48..24961ecc8fd 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
@@ -25,7 +25,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
@@ -299,8 +298,8 @@ public class TestNumericRangeQuery64 extends LuceneTestCaseJ4 {
@Test
public void testInfiniteValues() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new NumericField("double").setDoubleValue(Double.NEGATIVE_INFINITY));
@@ -349,13 +348,12 @@ public class TestNumericRangeQuery64 extends LuceneTestCaseJ4 {
}
private void testRandomTrieAndClassicRangeQuery(int precisionStep) throws Exception {
- final Random rnd=newRandom();
String field="field"+precisionStep;
int termCountT=0,termCountC=0;
int num = 10 * RANDOM_MULTIPLIER;
for (int i = 0; i < num; i++) {
- long lower=(long)(rnd.nextDouble()*noDocs*distance)+startOffset;
- long upper=(long)(rnd.nextDouble()*noDocs*distance)+startOffset;
+ long lower=(long)(random.nextDouble()*noDocs*distance)+startOffset;
+ long upper=(long)(random.nextDouble()*noDocs*distance)+startOffset;
if (lower>upper) {
long a=lower; lower=upper; upper=a;
}
@@ -433,13 +431,12 @@ public class TestNumericRangeQuery64 extends LuceneTestCaseJ4 {
}
private void testRangeSplit(int precisionStep) throws Exception {
- final Random rnd=newRandom();
String field="ascfield"+precisionStep;
// 10 random tests
int num = 10 * RANDOM_MULTIPLIER;
for (int i = 0; i < num; i++) {
- long lower=(long)(rnd.nextDouble()*noDocs - noDocs/2);
- long upper=(long)(rnd.nextDouble()*noDocs - noDocs/2);
+ long lower=(long)(random.nextDouble()*noDocs - noDocs/2);
+ long upper=(long)(random.nextDouble()*noDocs - noDocs/2);
if (lower>upper) {
long a=lower; lower=upper; upper=a;
}
@@ -519,14 +516,13 @@ public class TestNumericRangeQuery64 extends LuceneTestCaseJ4 {
}
private void testSorting(int precisionStep) throws Exception {
- final Random rnd=newRandom();
String field="field"+precisionStep;
// 10 random tests, the index order is ascending,
// so using a reverse sort field should retun descending documents
int num = 10 * RANDOM_MULTIPLIER;
for (int i = 0; i < num; i++) {
- long lower=(long)(rnd.nextDouble()*noDocs*distance)+startOffset;
- long upper=(long)(rnd.nextDouble()*noDocs*distance)+startOffset;
+ long lower=(long)(random.nextDouble()*noDocs*distance)+startOffset;
+ long upper=(long)(random.nextDouble()*noDocs*distance)+startOffset;
if (lower>upper) {
long a=lower; lower=upper; upper=a;
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java b/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
index 3ad3d2f684b..d3a812b051a 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
@@ -30,7 +30,6 @@ import org.apache.lucene.store.Directory;
import java.io.IOException;
import java.util.LinkedList;
-import java.util.Random;
/**
* This class tests PhrasePrefixQuery class.
@@ -44,8 +43,7 @@ public class TestPhrasePrefixQuery extends LuceneTestCase {
*
*/
public void testPhrasePrefix() throws IOException {
- Random random = newRandom();
- Directory indexStore = newDirectory(random);
+ Directory indexStore = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, indexStore);
Document doc1 = new Document();
Document doc2 = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java b/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
index 9ff91630df6..b3195828b55 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
@@ -49,13 +49,11 @@ public class TestPhraseQuery extends LuceneTestCase {
private IndexReader reader;
private PhraseQuery query;
private Directory directory;
- private Random random;
@Override
public void setUp() throws Exception {
super.setUp();
- random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
Analyzer analyzer = new Analyzer() {
@Override
public TokenStream tokenStream(String fieldName, Reader reader) {
@@ -213,10 +211,10 @@ public class TestPhraseQuery extends LuceneTestCase {
}
public void testPhraseQueryWithStopAnalyzer() throws Exception {
- Directory directory = newDirectory(random);
+ Directory directory = newDirectory();
Analyzer stopAnalyzer = new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, false);
RandomIndexWriter writer = new RandomIndexWriter(random, directory,
- newIndexWriterConfig(random, Version.LUCENE_24, stopAnalyzer));
+ newIndexWriterConfig( Version.LUCENE_24, stopAnalyzer));
Document doc = new Document();
doc.add(new Field("field", "the stop words are here", Field.Store.YES, Field.Index.ANALYZED));
writer.addDocument(doc);
@@ -249,7 +247,7 @@ public class TestPhraseQuery extends LuceneTestCase {
}
public void testPhraseQueryInConjunctionScorer() throws Exception {
- Directory directory = newDirectory(random);
+ Directory directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
Document doc = new Document();
@@ -287,7 +285,7 @@ public class TestPhraseQuery extends LuceneTestCase {
reader.close();
writer = new RandomIndexWriter(random, directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
doc = new Document();
doc.add(new Field("contents", "map entry woo", Field.Store.YES, Field.Index.ANALYZED));
writer.addDocument(doc);
@@ -336,7 +334,7 @@ public class TestPhraseQuery extends LuceneTestCase {
}
public void testSlopScoring() throws IOException {
- Directory directory = newDirectory(random);
+ Directory directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
Document doc = new Document();
@@ -597,7 +595,7 @@ public class TestPhraseQuery extends LuceneTestCase {
}
public void testRandomPhrases() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
Analyzer analyzer = new MockAnalyzer();
RandomIndexWriter w = new RandomIndexWriter(random, dir, analyzer);
diff --git a/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java b/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
index 35437d310ae..d14d440fbc9 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
@@ -90,8 +90,7 @@ public class TestPositionIncrement extends LuceneTestCase {
};
}
};
- Random random = newRandom();
- Directory store = newDirectory(random);
+ Directory store = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, store, analyzer);
Document d = new Document();
d.add(new Field("field", "bogus", Field.Store.YES, Field.Index.ANALYZED));
@@ -241,8 +240,7 @@ public class TestPositionIncrement extends LuceneTestCase {
new CharacterRunAutomaton(new RegExp("[sS][tT][oO][pP]").toAutomaton());
public void testPayloadsPos0() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir, new TestPayloadAnalyzer());
Document doc = new Document();
doc.add(new Field("content", new StringReader(
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
index a4f092cf084..c79d332feb6 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
@@ -17,8 +17,6 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.store.Directory;
import org.apache.lucene.index.IndexReader;
@@ -33,8 +31,7 @@ import org.apache.lucene.document.Field;
*/
public class TestPrefixFilter extends LuceneTestCase {
public void testPrefixFilter() throws Exception {
- Random random = newRandom();
- Directory directory = newDirectory(random);
+ Directory directory = newDirectory();
String[] categories = new String[] {"/Computers/Linux",
"/Computers/Mac/One",
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
index 8e1b3e62f9b..f5532190d6a 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
@@ -17,8 +17,6 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -47,8 +45,7 @@ public class TestPrefixInBooleanQuery extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
for (int i = 0; i < 5137; ++i) {
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
index d0e5d21bd38..9ce2893e809 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
@@ -17,8 +17,6 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.IndexReader;
@@ -33,8 +31,7 @@ import org.apache.lucene.document.Field;
*/
public class TestPrefixQuery extends LuceneTestCase {
public void testPrefixQuery() throws Exception {
- Random random = newRandom();
- Directory directory = newDirectory(random);
+ Directory directory = newDirectory();
String[] categories = new String[] {"/Computers",
"/Computers/Mac",
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java b/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
index 4505e69504a..05dca284508 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
@@ -18,7 +18,6 @@ package org.apache.lucene.search;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -41,13 +40,11 @@ public class TestPrefixRandom extends LuceneTestCase {
private IndexSearcher searcher;
private IndexReader reader;
private Directory dir;
- private Random random;
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
+ dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir, new MockAnalyzer(MockTokenizer.KEYWORD, false));
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
index 59a4ebbc6c2..afe2c733d84 100644
--- a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
@@ -17,8 +17,6 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Index;
@@ -33,8 +31,7 @@ import org.apache.lucene.util.LuceneTestCase;
public class TestQueryWrapperFilter extends LuceneTestCase {
public void testBasic() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
Document doc = new Document();
doc.add(new Field("field", "value", Store.NO, Index.ANALYZED));
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java b/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
index c961e0ba025..6db0cd888ce 100644
--- a/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.util.Arrays;
-import java.util.Random;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -45,8 +44,7 @@ public class TestRegexpQuery extends LuceneTestCase {
public void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
Document doc = new Document();
doc.add(new Field(FN,
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
index ccf045ce085..a4592814a13 100644
--- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
@@ -21,7 +21,6 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Locale;
-import java.util.Random;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -40,13 +39,11 @@ public class TestRegexpRandom extends LuceneTestCase {
private Searcher searcher;
private IndexReader reader;
private Directory dir;
- private Random random;
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
+ dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
index d1487938082..82d1e010463 100644
--- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
@@ -18,7 +18,6 @@ package org.apache.lucene.search;
*/
import java.io.IOException;
-import java.util.Random;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
@@ -49,13 +48,11 @@ public class TestRegexpRandom2 extends LuceneTestCase {
private IndexSearcher searcher;
private IndexReader reader;
private Directory dir;
- private Random random;
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
+ dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir, new MockAnalyzer(MockTokenizer.KEYWORD, false));
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
index 77eba4ac652..9662765593e 100755
--- a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
+++ b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
@@ -3,7 +3,6 @@ package org.apache.lucene.search;
import org.apache.lucene.util.DocIdBitSet;
import org.apache.lucene.util.LuceneTestCase;
-import java.util.Random;
import java.util.BitSet;
import java.io.IOException;
@@ -34,7 +33,6 @@ import org.apache.lucene.document.Field;
*/
public class TestScorerPerf extends LuceneTestCase {
- Random r = newRandom();
boolean validate = true; // set to false when doing performance testing
BitSet[] sets;
@@ -45,8 +43,8 @@ public class TestScorerPerf extends LuceneTestCase {
public void createDummySearcher() throws Exception {
// Create a dummy index with nothing in it.
// This could possibly fail if Lucene starts checking for docid ranges...
- d = newDirectory(r);
- IndexWriter iw = new IndexWriter(d, newIndexWriterConfig(r, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ d = newDirectory();
+ IndexWriter iw = new IndexWriter(d, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
iw.addDocument(new Document());
iw.close();
s = new IndexSearcher(d, true);
@@ -61,11 +59,11 @@ public class TestScorerPerf extends LuceneTestCase {
terms[i] = new Term("f",Character.toString((char)('A'+i)));
}
- IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(r, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
+ IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE));
for (int i=0; i=termsInIndex) tnum=termflag.nextClearBit(0);
termflag.set(tnum);
@@ -255,17 +253,17 @@ public class TestScorerPerf extends LuceneTestCase {
int ret=0;
long nMatches=0;
for (int i=0; i=25) tnum=termflag.nextClearBit(0);
termflag.set(tnum);
@@ -295,10 +293,10 @@ public class TestScorerPerf extends LuceneTestCase {
int ret=0;
for (int i=0; i 0 should succeed.
@@ -125,7 +115,7 @@ public class TestSloppyPhraseQuery extends LuceneTestCase {
private float checkPhraseQuery(Document doc, PhraseQuery query, int slop, int expectedNumResults) throws Exception {
query.setSlop(slop);
- Directory ramDir = newDirectory(random);
+ Directory ramDir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false));
writer.addDocument(doc);
diff --git a/lucene/src/test/org/apache/lucene/search/TestSort.java b/lucene/src/test/org/apache/lucene/search/TestSort.java
index 86d89c09d7a..694af78f03c 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSort.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSort.java
@@ -24,7 +24,6 @@ import java.util.BitSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
-import java.util.Random;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -70,8 +69,6 @@ public class TestSort extends LuceneTestCase implements Serializable {
private Query queryG;
private Sort sort;
- private Random random = newRandom();
-
public TestSort (String name) {
super (name);
}
@@ -109,7 +106,7 @@ public class TestSort extends LuceneTestCase implements Serializable {
// create an index of all the documents, or just the x, or just the y documents
private IndexSearcher getIndex (boolean even, boolean odd)
throws IOException {
- Directory indexStore = newDirectory(random);
+ Directory indexStore = newDirectory();
dirs.add(indexStore);
RandomIndexWriter writer = new RandomIndexWriter(random, indexStore);
@@ -145,7 +142,7 @@ public class TestSort extends LuceneTestCase implements Serializable {
}
private IndexSearcher getFullStrings() throws CorruptIndexException, LockObtainFailedException, IOException {
- Directory indexStore = newDirectory (random);
+ Directory indexStore = newDirectory();
dirs.add(indexStore);
IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(4));
@@ -189,11 +186,9 @@ public class TestSort extends LuceneTestCase implements Serializable {
return sb.toString();
}
- Random r;
-
public int getRandomNumber(final int low, final int high) {
- int randInt = (Math.abs(r.nextInt()) % (high - low)) + low;
+ int randInt = (Math.abs(random.nextInt()) % (high - low)) + low;
return randInt;
}
@@ -289,7 +284,6 @@ public class TestSort extends LuceneTestCase implements Serializable {
* Test String sorting: small queue to many matches, multi field sort, reverse sort
*/
public void testStringSort() throws IOException, ParseException {
- r = newRandom();
ScoreDoc[] result = null;
IndexSearcher searcher = getFullStrings();
sort.setSort(
@@ -1101,8 +1095,8 @@ public class TestSort extends LuceneTestCase implements Serializable {
}
public void testEmptyStringVsNullStringSort() throws Exception {
- Directory dir = newDirectory(random);
- IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("f", "", Field.Store.NO, Field.Index.NOT_ANALYZED));
@@ -1126,8 +1120,8 @@ public class TestSort extends LuceneTestCase implements Serializable {
}
public void testLUCENE2142() throws IOException {
- Directory indexStore = newDirectory (random);
- IndexWriter writer = new IndexWriter(indexStore, newIndexWriterConfig(random,
+ Directory indexStore = newDirectory();
+ IndexWriter writer = new IndexWriter(indexStore, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i=0; i<5; i++) {
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestSpanQueryFilter.java b/lucene/src/test/org/apache/lucene/search/TestSpanQueryFilter.java
index a68f4888806..5fa728c3d54 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSpanQueryFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSpanQueryFilter.java
@@ -17,7 +17,6 @@ package org.apache.lucene.search;
*/
import java.util.List;
-import java.util.Random;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -38,8 +37,7 @@ public class TestSpanQueryFilter extends LuceneTestCase {
}
public void testFilterWorks() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
for (int i = 0; i < 500; i++) {
Document document = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java b/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
index 2fbc9fcc01e..1c17172f40c 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
@@ -398,8 +398,8 @@ public class TestTermRangeFilter extends BaseTestRangeFilter {
public void testFarsi() throws Exception {
/* build an index */
- Directory farsiIndex = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, farsiIndex);
+ Directory farsiIndex = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, farsiIndex);
Document doc = new Document();
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
Field.Index.NOT_ANALYZED));
@@ -438,8 +438,8 @@ public class TestTermRangeFilter extends BaseTestRangeFilter {
public void testDanish() throws Exception {
/* build an index */
- Directory danishIndex = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, danishIndex);
+ Directory danishIndex = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, danishIndex);
// Danish collation orders the words below in the given order
// (example taken from TestSort.testInternationalSort() ).
String[] words = {"H\u00D8T", "H\u00C5T", "MAND"};
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java b/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
index e8d880dc9de..5b6594d41e6 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
@@ -33,7 +33,6 @@ import org.apache.lucene.util.LuceneTestCase;
import java.io.IOException;
import java.io.Reader;
import java.util.Locale;
-import java.util.Random;
import java.util.Set;
import java.util.HashSet;
import java.util.Arrays;
@@ -44,13 +43,11 @@ public class TestTermRangeQuery extends LuceneTestCase {
private int docCount = 0;
private Directory dir;
- private Random random;
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- dir = newDirectory(random);
+ dir = newDirectory();
}
@Override
@@ -341,7 +338,7 @@ public class TestTermRangeQuery extends LuceneTestCase {
}
private void initializeIndex(String[] values, Analyzer analyzer) throws IOException {
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, analyzer).setOpenMode(OpenMode.CREATE));
for (int i = 0; i < values.length; i++) {
insertDoc(writer, values[i]);
@@ -350,7 +347,7 @@ public class TestTermRangeQuery extends LuceneTestCase {
}
private void addDoc(String content) throws IOException {
- IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setOpenMode(OpenMode.APPEND));
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setOpenMode(OpenMode.APPEND));
insertDoc(writer, content);
writer.close();
}
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermScorer.java b/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
index 0780f35a610..0131ac78605 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
@@ -20,7 +20,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.document.Document;
@@ -47,8 +46,7 @@ public class TestTermScorer extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
for (int i = 0; i < values.length; i++) {
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermVectors.java b/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
index 5414b39fc1d..01bd500a76c 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
@@ -31,7 +31,6 @@ import org.apache.lucene.util.English;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import java.util.Random;
import java.util.SortedSet;
public class TestTermVectors extends LuceneTestCase {
@@ -39,8 +38,6 @@ public class TestTermVectors extends LuceneTestCase {
private IndexReader reader;
private Directory directory;
- private Random random;
-
public TestTermVectors(String s) {
super(s);
}
@@ -48,8 +45,7 @@ public class TestTermVectors extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory, new MockAnalyzer(MockTokenizer.SIMPLE, true));
//writer.setUseCompoundFile(true);
//writer.infoStream = System.out;
@@ -115,7 +111,7 @@ public class TestTermVectors extends LuceneTestCase {
}
public void testTermVectorsFieldOrder() throws IOException {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir, new MockAnalyzer(MockTokenizer.SIMPLE, true));
Document doc = new Document();
doc.add(new Field("c", "some content here", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
@@ -243,10 +239,10 @@ public class TestTermVectors extends LuceneTestCase {
Document testDoc4 = new Document();
setupDoc(testDoc4, test4);
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true))
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true))
.setOpenMode(OpenMode.CREATE));
writer.addDocument(testDoc1);
writer.addDocument(testDoc2);
@@ -359,7 +355,7 @@ public class TestTermVectors extends LuceneTestCase {
// Test only a few docs having vectors
public void testRareVectors() throws IOException {
RandomIndexWriter writer = new RandomIndexWriter(random, directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true))
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true))
.setOpenMode(OpenMode.CREATE));
for (int i = 0; i < 100; i++) {
Document doc = new Document();
@@ -394,7 +390,7 @@ public class TestTermVectors extends LuceneTestCase {
// vectors up
public void testMixedVectrosVectors() throws IOException {
RandomIndexWriter writer = new RandomIndexWriter(random, directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT,
+ newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(MockTokenizer.SIMPLE, true)).setOpenMode(OpenMode.CREATE));
Document doc = new Document();
doc.add(new Field("field", "one",
diff --git a/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java b/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java
index 2ae2c680ab0..dbc7ce6789f 100755
--- a/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java
+++ b/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java
@@ -30,7 +30,6 @@ import java.util.List;
import java.io.IOException;
public class TestThreadSafe extends LuceneTestCase {
- Random r;
Directory dir1;
IndexReader ir1;
@@ -107,11 +106,11 @@ public class TestThreadSafe extends LuceneTestCase {
TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(10));
for (int j=0; j();
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
@@ -297,41 +299,10 @@ public abstract class LuceneTestCase extends TestCase {
Iterator