You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2010/09/10 14:34:32 UTC
svn commit: r995772 [7/8] - in /lucene/dev/trunk: lucene/
lucene/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/
lucene/contrib/db/bdb/src/test/org/apache/lucene/store/db/
lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/ l...
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java Fri Sep 10 12:34:18 2010
@@ -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 exten
*
*/
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();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java Fri Sep 10 12:34:18 2010
@@ -49,13 +49,11 @@ public class TestPhraseQuery extends Luc
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 Luc
}
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 Luc
}
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 Luc
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 Luc
}
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 Luc
}
public void testRandomPhrases() throws Exception {
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
Analyzer analyzer = new MockAnalyzer();
RandomIndexWriter w = new RandomIndexWriter(random, dir, analyzer);
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java Fri Sep 10 12:34:18 2010
@@ -90,8 +90,7 @@ public class TestPositionIncrement exten
};
}
};
- 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 exten
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(
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java Fri Sep 10 12:34:18 2010
@@ -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",
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java Fri Sep 10 12:34:18 2010
@@ -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 ex
@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) {
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java Fri Sep 10 12:34:18 2010
@@ -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",
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java Fri Sep 10 12:34:18 2010
@@ -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 Lu
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();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java Fri Sep 10 12:34:18 2010
@@ -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.LuceneTest
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));
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java Fri Sep 10 12:34:18 2010
@@ -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 Luc
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,
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java Fri Sep 10 12:34:18 2010
@@ -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 Lu
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();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java Fri Sep 10 12:34:18 2010
@@ -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 L
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();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java Fri Sep 10 12:34:18 2010
@@ -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 Luce
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 Luce
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<nDocs; i++) {
Document d = new Document();
for (int j=0; j<nTerms; j++) {
- if (r.nextInt(freq[j]) == 0) {
+ if (random.nextInt(freq[j]) == 0) {
d.add(new Field("f", terms[j].text(), Field.Store.NO, Field.Index.NOT_ANALYZED));
//System.out.println(d);
}
@@ -80,7 +78,7 @@ public class TestScorerPerf extends Luce
public BitSet randBitSet(int sz, int numBitsToSet) {
BitSet set = new BitSet(sz);
for (int i=0; i<numBitsToSet; i++) {
- set.set(r.nextInt(sz));
+ set.set(random.nextInt(sz));
}
return set;
}
@@ -88,7 +86,7 @@ public class TestScorerPerf extends Luce
public BitSet[] randBitSets(int numSets, int setSize) {
BitSet[] sets = new BitSet[numSets];
for (int i=0; i<sets.length; i++) {
- sets[i] = randBitSet(setSize, r.nextInt(setSize));
+ sets[i] = randBitSet(setSize, random.nextInt(setSize));
}
return sets;
}
@@ -140,7 +138,7 @@ public class TestScorerPerf extends Luce
BitSet addClause(BooleanQuery bq, BitSet result) {
- final BitSet rnd = sets[r.nextInt(sets.length)];
+ final BitSet rnd = sets[random.nextInt(sets.length)];
Query q = new ConstantScoreQuery(new Filter() {
@Override
public DocIdSet getDocIdSet(IndexReader reader) {
@@ -160,7 +158,7 @@ public class TestScorerPerf extends Luce
int ret=0;
for (int i=0; i<iter; i++) {
- int nClauses = r.nextInt(maxClauses-1)+2; // min 2 clauses
+ int nClauses = random.nextInt(maxClauses-1)+2; // min 2 clauses
BooleanQuery bq = new BooleanQuery();
BitSet result=null;
for (int j=0; j<nClauses; j++) {
@@ -184,13 +182,13 @@ public class TestScorerPerf extends Luce
long nMatches=0;
for (int i=0; i<iter; i++) {
- int oClauses = r.nextInt(maxOuterClauses-1)+2;
+ int oClauses = random.nextInt(maxOuterClauses-1)+2;
BooleanQuery oq = new BooleanQuery();
BitSet result=null;
for (int o=0; o<oClauses; o++) {
- int nClauses = r.nextInt(maxClauses-1)+2; // min 2 clauses
+ int nClauses = random.nextInt(maxClauses-1)+2; // min 2 clauses
BooleanQuery bq = new BooleanQuery();
for (int j=0; j<nClauses; j++) {
result = addClause(bq,result);
@@ -221,13 +219,13 @@ public class TestScorerPerf extends Luce
long nMatches=0;
for (int i=0; i<iter; i++) {
- int nClauses = r.nextInt(maxClauses-1)+2; // min 2 clauses
+ int nClauses = random.nextInt(maxClauses-1)+2; // min 2 clauses
BooleanQuery bq = new BooleanQuery();
BitSet termflag = new BitSet(termsInIndex);
for (int j=0; j<nClauses; j++) {
int tnum;
// don't pick same clause twice
- tnum = r.nextInt(termsInIndex);
+ tnum = random.nextInt(termsInIndex);
if (termflag.get(tnum)) tnum=termflag.nextClearBit(tnum);
if (tnum<0 || tnum>=termsInIndex) tnum=termflag.nextClearBit(0);
termflag.set(tnum);
@@ -255,17 +253,17 @@ public class TestScorerPerf extends Luce
int ret=0;
long nMatches=0;
for (int i=0; i<iter; i++) {
- int oClauses = r.nextInt(maxOuterClauses-1)+2;
+ int oClauses = random.nextInt(maxOuterClauses-1)+2;
BooleanQuery oq = new BooleanQuery();
for (int o=0; o<oClauses; o++) {
- int nClauses = r.nextInt(maxClauses-1)+2; // min 2 clauses
+ int nClauses = random.nextInt(maxClauses-1)+2; // min 2 clauses
BooleanQuery bq = new BooleanQuery();
BitSet termflag = new BitSet(termsInIndex);
for (int j=0; j<nClauses; j++) {
int tnum;
// don't pick same clause twice
- tnum = r.nextInt(termsInIndex);
+ tnum = random.nextInt(termsInIndex);
if (termflag.get(tnum)) tnum=termflag.nextClearBit(tnum);
if (tnum<0 || tnum>=25) tnum=termflag.nextClearBit(0);
termflag.set(tnum);
@@ -295,10 +293,10 @@ public class TestScorerPerf extends Luce
int ret=0;
for (int i=0; i<iter; i++) {
- int nClauses = r.nextInt(maxClauses-1)+2; // min 2 clauses
+ int nClauses = random.nextInt(maxClauses-1)+2; // min 2 clauses
PhraseQuery q = new PhraseQuery();
for (int j=0; j<nClauses; j++) {
- int tnum = r.nextInt(termsInIndex);
+ int tnum = random.nextInt(termsInIndex);
q.add(new Term("f",Character.toString((char)(tnum+'A'))), j);
}
q.setSlop(termsInIndex); // this could be random too
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSetNorm.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSetNorm.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSetNorm.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSetNorm.java Fri Sep 10 12:34:18 2010
@@ -18,7 +18,6 @@ package org.apache.lucene.search;
*/
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 TestSetNorm extends LuceneT
}
public void testSetNorm() throws Exception {
- Random random = newRandom();
- Directory store = newDirectory(random);
- IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
+ Directory store = newDirectory();
+ IndexWriter writer = new IndexWriter(store, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()));
// add the same document four times
Fieldable f1 = new Field("field", "word", Field.Store.YES, Field.Index.ANALYZED);
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarity.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarity.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarity.java Fri Sep 10 12:34:18 2010
@@ -20,7 +20,6 @@ package org.apache.lucene.search;
import org.apache.lucene.util.LuceneTestCase;
import java.io.IOException;
import java.util.Collection;
-import java.util.Random;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
@@ -63,10 +62,9 @@ public class TestSimilarity extends Luce
}
public void testSimilarity() throws Exception {
- Random random = newRandom();
- Directory store = newDirectory(random);
+ Directory store = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, store,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
+ newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())
.setSimilarity(new SimpleSimilarity()));
Document d1 = new Document();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java Fri Sep 10 12:34:18 2010
@@ -305,8 +305,8 @@ public class TestSimpleExplanations exte
public void testTermQueryMultiSearcherExplain() throws Exception {
// creating two directories for indices
- Directory indexStoreA = newDirectory(random);
- Directory indexStoreB = newDirectory(random);
+ Directory indexStoreA = newDirectory();
+ Directory indexStoreB = newDirectory();
Document lDoc = new Document();
lDoc.add(new Field("handle", "1 2", Field.Store.YES, Field.Index.ANALYZED));
@@ -315,9 +315,9 @@ public class TestSimpleExplanations exte
Document lDoc3 = new Document();
lDoc3.add(new Field("handle", "1 2", Field.Store.YES, Field.Index.ANALYZED));
- IndexWriter writerA = new IndexWriter(indexStoreA, newIndexWriterConfig(random,
+ IndexWriter writerA = new IndexWriter(indexStoreA, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
- IndexWriter writerB = new IndexWriter(indexStoreB, newIndexWriterConfig(random,
+ IndexWriter writerB = new IndexWriter(indexStoreB, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
writerA.addDocument(lDoc);
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java Fri Sep 10 12:34:18 2010
@@ -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.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -48,14 +46,6 @@ public class TestSloppyPhraseQuery exten
private static final PhraseQuery QUERY_2 = makePhraseQuery( S_2 );
private static final PhraseQuery QUERY_4 = makePhraseQuery( "X A A");
- private Random random;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- random = newRandom();
- }
-
/**
* Test DOC_4 and QUERY_4.
* QUERY_4 has a fuzzy (len=1) match to DOC_4, so all slop values > 0 should succeed.
@@ -125,7 +115,7 @@ public class TestSloppyPhraseQuery exten
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);
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSort.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSort.java Fri Sep 10 12:34:18 2010
@@ -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 LuceneTest
private Query queryG;
private Sort sort;
- private Random random = newRandom();
-
public TestSort (String name) {
super (name);
}
@@ -109,7 +106,7 @@ public class TestSort extends LuceneTest
// 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 LuceneTest
}
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 LuceneTest
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 LuceneTest
* 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 LuceneTest
}
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 LuceneTest
}
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();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSpanQueryFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSpanQueryFilter.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSpanQueryFilter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSpanQueryFilter.java Fri Sep 10 12:34:18 2010
@@ -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
}
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();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java Fri Sep 10 12:34:18 2010
@@ -398,8 +398,8 @@ public class TestTermRangeFilter extends
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
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"};
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java Fri Sep 10 12:34:18 2010
@@ -33,7 +33,6 @@ import org.apache.lucene.util.LuceneTest
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
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
}
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
}
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();
}
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermScorer.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermScorer.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermScorer.java Fri Sep 10 12:34:18 2010
@@ -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 Luce
@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++) {
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java Fri Sep 10 12:34:18 2010
@@ -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 Luc
private IndexReader reader;
private Directory directory;
- private Random random;
-
public TestTermVectors(String s) {
super(s);
}
@@ -48,8 +45,7 @@ public class TestTermVectors extends Luc
@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 Luc
}
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 Luc
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 Luc
// 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 Luc
// 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",
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java Fri Sep 10 12:34:18 2010
@@ -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 Luce
TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(10));
for (int j=0; j<nDocs; j++) {
Document d = new Document();
- int nFields = r.nextInt(maxFields);
+ int nFields = random.nextInt(maxFields);
for (int i=0; i<nFields; i++) {
- int flen = r.nextInt(maxFieldLen);
+ int flen = random.nextInt(maxFieldLen);
StringBuilder sb = new StringBuilder("^ ");
- while (sb.length() < flen) sb.append(' ').append(words[r.nextInt(words.length)]);
+ while (sb.length() < flen) sb.append(' ').append(words[random.nextInt(words.length)]);
sb.append(" $");
Field.Store store = Field.Store.YES; // make random later
Field.Index index = Field.Index.ANALYZED; // make random later
@@ -126,7 +125,7 @@ public class TestThreadSafe extends Luce
void doTest(int iter, int nThreads) throws Exception {
Thr[] tarr = new Thr[nThreads];
for (int i=0; i<nThreads; i++) {
- tarr[i] = new Thr(iter, new Random(r.nextLong()));
+ tarr[i] = new Thr(iter, new Random(random.nextLong()));
tarr[i].start();
}
for (int i=0; i<nThreads; i++) {
@@ -138,8 +137,7 @@ public class TestThreadSafe extends Luce
}
public void testLazyLoadThreadSafety() throws Exception{
- r = newRandom();
- dir1 = newDirectory(r);
+ dir1 = newDirectory();
// test w/ field sizes bigger than the buffer of an index input
buildDir(dir1, 15, 5, 2000);
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Fri Sep 10 12:34:18 2010
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.util.BitSet;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -76,8 +75,7 @@ public class TestTimeLimitingCollector e
"blueberry strudel",
"blueberry pizza",
};
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter iw = new RandomIndexWriter(random, directory);
for (int i=0; i<N_DOCS; i++) {
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java Fri Sep 10 12:34:18 2010
@@ -18,7 +18,6 @@ package org.apache.lucene.search;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
@@ -108,8 +107,7 @@ public class TestTopDocsCollector extend
// populate an index with 30 documents, this should be enough for the test.
// The documents have no content - the test uses MatchAllDocsQuery().
- Random random = newRandom();
- dir = newDirectory(random);
+ dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
for (int i = 0; i < 30; i++) {
writer.addDocument(new Document());
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java Fri Sep 10 12:34:18 2010
@@ -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.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
@@ -36,8 +34,7 @@ public class TestTopScoreDocCollector ex
}
public void testOutOfOrderCollection() throws Exception {
- Random random = newRandom();
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
for (int i = 0; i < 10; i++) {
writer.addDocument(new Document());
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcard.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcard.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcard.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcard.java Fri Sep 10 12:34:18 2010
@@ -29,19 +29,16 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.QueryParser;
import java.io.IOException;
-import java.util.Random;
/**
* TestWildcard tests the '*' and '?' wildcard characters.
*/
public class TestWildcard
extends LuceneTestCase {
- private Random random;
@Override
public void setUp() throws Exception {
super.setUp();
- random = newRandom();
}
public void testEquals() {
@@ -210,7 +207,7 @@ public class TestWildcard
private Directory getIndexStore(String field, String[] contents)
throws IOException {
- Directory indexStore = newDirectory(random);
+ Directory indexStore = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, indexStore);
for (int i = 0; i < contents.length; ++i) {
Document doc = new Document();
@@ -266,7 +263,7 @@ public class TestWildcard
};
// prepare the index
- Directory dir = newDirectory(random);
+ Directory dir = newDirectory();
RandomIndexWriter iw = new RandomIndexWriter(random, dir);
for (int i = 0; i < docs.length; i++) {
Document doc = new Document();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java Fri Sep 10 12:34:18 2010
@@ -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;
@@ -39,14 +38,12 @@ import org.apache.lucene.util.LuceneTest
public class TestWildcardRandom extends LuceneTestCase {
private Searcher searcher;
private IndexReader reader;
- private Random random;
private Directory dir;
@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();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java Fri Sep 10 12:34:18 2010
@@ -27,7 +27,6 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.apache.lucene.util._TestUtil;
-import java.util.Random;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -95,14 +94,13 @@ public class FunctionTestSetup extends L
public void setUp() throws Exception {
super.setUp();
// prepare a small index with just a few documents.
- Random r = newRandom();
- dir = newDirectory(r);
+ dir = newDirectory();
anlzr = new MockAnalyzer();
- IndexWriterConfig iwc = newIndexWriterConfig(r, TEST_VERSION_CURRENT, anlzr);
+ IndexWriterConfig iwc = newIndexWriterConfig( TEST_VERSION_CURRENT, anlzr);
if (doMultiSegment) {
- iwc.setMaxBufferedDocs(_TestUtil.nextInt(r, 2, 7));
+ iwc.setMaxBufferedDocs(_TestUtil.nextInt(random, 2, 7));
}
- RandomIndexWriter iw = new RandomIndexWriter(r, dir, iwc);
+ RandomIndexWriter iw = new RandomIndexWriter(random, dir, iwc);
// add docs not exactly in natural ID order, to verify we do check the order of docs by scores
int remaining = N_DOCS;
boolean done[] = new boolean[N_DOCS];
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java Fri Sep 10 12:34:18 2010
@@ -20,7 +20,6 @@ package org.apache.lucene.search.functio
import org.apache.lucene.util.*;
import org.apache.lucene.store.*;
import org.apache.lucene.search.*;
-import org.apache.lucene.search.function.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.index.*;
import org.apache.lucene.document.*;
@@ -28,7 +27,7 @@ import org.apache.lucene.document.*;
public class TestValueSource extends LuceneTestCase {
public void testMultiValueSource() throws Exception {
- Directory dir = newDirectory(newRandom());
+ Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, new MockAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
Document doc = new Document();
Field f = new Field("field", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java Fri Sep 10 12:34:18 2010
@@ -18,7 +18,6 @@ package org.apache.lucene.search.payload
import java.io.IOException;
import java.io.Reader;
import java.util.Collection;
-import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -34,7 +33,6 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryUtils;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Searcher;
@@ -108,10 +106,9 @@ public class TestPayloadNearQuery extend
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new PayloadAnalyzer())
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new PayloadAnalyzer())
.setSimilarity(similarity));
//writer.infoStream = System.out;
for (int i = 0; i < 1000; i++) {
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java Fri Sep 10 12:34:18 2010
@@ -45,7 +45,6 @@ import org.apache.lucene.document.Field;
import java.io.Reader;
import java.io.IOException;
-import java.util.Random;
/**
@@ -112,10 +111,9 @@ public class TestPayloadTermQuery extend
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new PayloadAnalyzer())
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new PayloadAnalyzer())
.setSimilarity(similarity));
//writer.infoStream = System.out;
for (int i = 0; i < 1000; i++) {
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java Fri Sep 10 12:34:18 2010
@@ -18,7 +18,6 @@ package org.apache.lucene.search.spans;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -60,8 +59,7 @@ public class TestBasics extends LuceneTe
@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.SIMPLE, true));
//writer.infoStream = System.out;
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java Fri Sep 10 12:34:18 2010
@@ -18,7 +18,6 @@ package org.apache.lucene.search.spans;
*/
import java.util.HashSet;
-import java.util.Random;
import java.util.Set;
import org.apache.lucene.document.Document;
@@ -55,8 +54,7 @@ public class TestFieldMaskingSpanQuery e
@Override
protected void setUp() throws Exception {
super.setUp();
- Random random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer= new RandomIndexWriter(random, directory);
writer.addDocument(doc(new Field[] { field("id", "0")
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java Fri Sep 10 12:34:18 2010
@@ -17,8 +17,6 @@ package org.apache.lucene.search.spans;
* 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;
@@ -55,8 +53,7 @@ public class TestNearSpansOrdered extend
@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 < docFields.length; i++) {
Document doc = new Document();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java Fri Sep 10 12:34:18 2010
@@ -22,7 +22,6 @@ import java.io.StringReader;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -55,7 +54,6 @@ public class TestPayloadSpans extends Lu
private Similarity similarity = new DefaultSimilarity();
protected IndexReader indexReader;
private IndexReader closeIndexReader;
- private Random rand;
private Directory directory;
public TestPayloadSpans(String s) {
@@ -65,7 +63,6 @@ public class TestPayloadSpans extends Lu
@Override
protected void setUp() throws Exception {
super.setUp();
- rand = newRandom();
PayloadHelper helper = new PayloadHelper();
searcher = helper.setUp(similarity, 1000);
indexReader = searcher.getIndexReader();
@@ -116,9 +113,9 @@ public class TestPayloadSpans extends Lu
- Directory directory = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
- newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity));
+ Directory directory = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, directory,
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity));
Document doc = new Document();
doc.add(new Field(PayloadHelper.FIELD, "one two three one four three",
@@ -260,9 +257,9 @@ public class TestPayloadSpans extends Lu
public void testShrinkToAfterShortestMatch() throws CorruptIndexException,
LockObtainFailedException, IOException {
- Directory directory = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
- newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
+ Directory directory = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, directory,
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
Document doc = new Document();
doc.add(new Field("content", new StringReader("a b c d e f g h i j a k")));
@@ -298,9 +295,9 @@ public class TestPayloadSpans extends Lu
public void testShrinkToAfterShortestMatch2() throws CorruptIndexException,
LockObtainFailedException, IOException {
- Directory directory = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
- newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
+ Directory directory = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, directory,
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
Document doc = new Document();
doc.add(new Field("content", new StringReader("a b a d k f a h i k a k")));
@@ -334,9 +331,9 @@ public class TestPayloadSpans extends Lu
public void testShrinkToAfterShortestMatch3() throws CorruptIndexException,
LockObtainFailedException, IOException {
- Directory directory = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
- newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
+ Directory directory = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, directory,
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
Document doc = new Document();
doc.add(new Field("content", new StringReader("j k a l f k k p a t a k l k t a")));
@@ -375,9 +372,9 @@ public class TestPayloadSpans extends Lu
}
public void testPayloadSpanUtil() throws Exception {
- Directory directory = newDirectory(rand);
- RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
- newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity));
+ Directory directory = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, directory,
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity));
Document doc = new Document();
doc.add(new Field(PayloadHelper.FIELD,"xx rr yy mm pp", Field.Store.YES, Field.Index.ANALYZED));
@@ -434,10 +431,10 @@ public class TestPayloadSpans extends Lu
}
private IndexSearcher getSearcher() throws Exception {
- directory = newDirectory(rand);
+ directory = newDirectory();
String[] docs = new String[]{"xx rr yy mm pp","xx yy mm rr pp", "nopayload qq ss pp np", "one two three four five six seven eight nine ten eleven", "nine one two three four five six seven eight eleven ten"};
- RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
- newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity));
+ RandomIndexWriter writer = new RandomIndexWriter(random, directory,
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity));
Document doc = null;
for(int i = 0; i < docs.length; i++) {
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java Fri Sep 10 12:34:18 2010
@@ -38,21 +38,18 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.document.Field;
import org.apache.lucene.util.LuceneTestCase;
import java.io.IOException;
-import java.util.Random;
public class TestSpans extends LuceneTestCase {
private IndexSearcher searcher;
private IndexReader reader;
private Directory directory;
- private Random random;
public static final String field = "field";
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
- directory = newDirectory(random);
+ directory = newDirectory();
RandomIndexWriter writer= new RandomIndexWriter(random, directory);
for (int i = 0; i < docFields.length; i++) {
Document doc = new Document();
@@ -463,7 +460,7 @@ public class TestSpans extends LuceneTes
// LUCENE-1404
public void testNPESpanQuery() throws Throwable {
- final Directory dir = newDirectory(random);
+ final Directory dir = newDirectory();
final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java Fri Sep 10 12:34:18 2010
@@ -18,7 +18,6 @@ package org.apache.lucene.search.spans;
*/
import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
@@ -44,7 +43,6 @@ public class TestSpansAdvanced extends L
protected Directory mDirectory;
protected IndexReader reader;
protected IndexSearcher searcher;
- protected Random random;
// field names in the index
private final static String FIELD_ID = "ID";
@@ -56,9 +54,8 @@ public class TestSpansAdvanced extends L
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
// create test index
- mDirectory = newDirectory(random);
+ mDirectory = newDirectory();
final RandomIndexWriter writer = new RandomIndexWriter(random,
mDirectory, new MockAnalyzer(MockTokenizer.SIMPLE, true,
MockTokenFilter.ENGLISH_STOPSET, true));
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java Fri Sep 10 12:34:18 2010
@@ -46,7 +46,7 @@ public class TestSpansAdvanced2 extends
// create test index
final RandomIndexWriter writer = new RandomIndexWriter(random, mDirectory,
- newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(
+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(
MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true))
.setOpenMode(OpenMode.APPEND));
addDocument(writer, "A", "Should we, could we, would we?");
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Fri Sep 10 12:34:18 2010
@@ -78,10 +78,8 @@ public class TestBufferedIndexInput exte
// Our input comes from a dynamically generated "file" -
// see MyBufferedIndexInput below.
public void testReadBytes() throws Exception {
- final Random r = newRandom();
-
MyBufferedIndexInput input = new MyBufferedIndexInput();
- runReadBytes(input, BufferedIndexInput.BUFFER_SIZE, r);
+ runReadBytes(input, BufferedIndexInput.BUFFER_SIZE, random);
// This tests the workaround code for LUCENE-1566 where readBytesInternal
// provides a workaround for a JVM Bug that incorrectly raises a OOM Error
@@ -95,11 +93,11 @@ public class TestBufferedIndexInput exte
// run test with chunk size of 10 bytes
runReadBytesAndClose(new SimpleFSIndexInput(tmpInputFile,
- inputBufferSize, 10), inputBufferSize, r);
+ inputBufferSize, 10), inputBufferSize, random);
// run test with chunk size of 10 bytes
runReadBytesAndClose(new NIOFSIndexInput(tmpInputFile,
- inputBufferSize, 10), inputBufferSize, r);
+ inputBufferSize, 10), inputBufferSize, random);
}
private void runReadBytesAndClose(IndexInput input, int bufferSize, Random r)
@@ -243,7 +241,7 @@ public class TestBufferedIndexInput exte
public void testSetBufferSize() throws IOException {
File indexDir = new File(TEMP_DIR, "testSetBufferSize");
- MockFSDirectory dir = new MockFSDirectory(indexDir, newRandom());
+ MockFSDirectory dir = new MockFSDirectory(indexDir, random);
try {
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java Fri Sep 10 12:34:18 2010
@@ -18,8 +18,6 @@ package org.apache.lucene.store;
*/
-import java.io.IOException;
-import java.util.Random;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.apache.lucene.util._TestUtil;
@@ -35,17 +33,16 @@ public class TestCopyBytes extends Lucen
@Test
public void testCopyBytes() throws Exception {
- Random rand = newRandom();
for(int iter=0;iter<10*RANDOM_MULTIPLIER;iter++) {
- Directory dir = newDirectory(rand);
+ Directory dir = newDirectory();
if (VERBOSE) {
System.out.println("TEST: iter=" + iter + " dir=" + dir);
}
// make random file
IndexOutput out = dir.createOutput("test");
- byte[] bytes = new byte[_TestUtil.nextInt(rand, 1, 77777)];
- final int size = _TestUtil.nextInt(rand, 1, 1777777);
+ byte[] bytes = new byte[_TestUtil.nextInt(random, 1, 77777)];
+ final int size = _TestUtil.nextInt(random, 1, 1777777);
int upto = 0;
int byteUpto = 0;
while(upto < size) {
@@ -69,11 +66,11 @@ public class TestCopyBytes extends Lucen
upto = 0;
while(upto < size) {
- if (rand.nextBoolean()) {
+ if (random.nextBoolean()) {
out.writeByte(in.readByte());
upto++;
} else {
- final int chunk = Math.min(_TestUtil.nextInt(rand, 1, bytes.length), size-upto);
+ final int chunk = Math.min(_TestUtil.nextInt(random, 1, bytes.length), size-upto);
out.copyBytes(in, chunk);
upto += chunk;
}
@@ -86,12 +83,12 @@ public class TestCopyBytes extends Lucen
IndexInput in2 = dir.openInput("test2");
upto = 0;
while(upto < size) {
- if (rand.nextBoolean()) {
+ if (random.nextBoolean()) {
final byte v = in2.readByte();
assertEquals(value(upto), v);
upto++;
} else {
- final int limit = Math.min(_TestUtil.nextInt(rand, 1, bytes.length), size-upto);
+ final int limit = Math.min(_TestUtil.nextInt(random, 1, bytes.length), size-upto);
in2.readBytes(bytes, 0, limit);
for(int byteIdx=0;byteIdx<limit;byteIdx++) {
assertEquals(value(upto), bytes[byteIdx]);
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestMultiMMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestMultiMMap.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestMultiMMap.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestMultiMMap.java Fri Sep 10 12:34:18 2010
@@ -45,7 +45,6 @@ public class TestMultiMMap extends Lucen
}
public void testRandomChunkSizes() throws Exception {
- Random random = newRandom();
for (int i = 0; i < 10*RANDOM_MULTIPLIER; i++)
assertChunking(random, _TestUtil.nextInt(random, 20, 100));
}
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestWindowsMMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestWindowsMMap.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestWindowsMMap.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestWindowsMMap.java Fri Sep 10 12:34:18 2010
@@ -17,7 +17,6 @@ package org.apache.lucene.store;
* limitations under the License.
*/
-import java.util.Random;
import java.io.File;
import org.apache.lucene.util.LuceneTestCase;
@@ -33,12 +32,10 @@ import org.apache.lucene.search.IndexSea
public class TestWindowsMMap extends LuceneTestCase {
private final static String alphabet = "abcdefghijklmnopqrstuvwzyz";
- private Random random;
@Override
protected void setUp() throws Exception {
super.setUp();
- random = newRandom();
}
private String randomToken() {
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java Fri Sep 10 12:34:18 2010
@@ -42,9 +42,7 @@ import org.apache.lucene.search.BooleanQ
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.CacheEntry;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
-import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
/**
@@ -88,6 +86,8 @@ public abstract class LuceneTestCase ext
static final String TEST_TIMEZONE = LuceneTestCaseJ4.TEST_TIMEZONE;
/** Gets the directory to run tests with */
static final String TEST_DIRECTORY = LuceneTestCaseJ4.TEST_DIRECTORY;
+ /** Get the random seed for tests */
+ static final String TEST_SEED = LuceneTestCaseJ4.TEST_SEED;
/**
* A random multiplier which you should use when writing random tests:
@@ -134,6 +134,8 @@ public abstract class LuceneTestCase ext
protected void setUp() throws Exception {
super.setUp();
assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup);
+ seed = Long.valueOf(TEST_SEED.equals("random") ? seedRnd.nextLong() : Long.parseLong(TEST_SEED));
+ random = new Random(seed);
setup = true;
stores = new IdentityHashMap<MockDirectoryWrapper,StackTraceElement[]>();
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
@@ -297,41 +299,10 @@ public abstract class LuceneTestCase ext
Iterator<Object> iter = (null == objs) ? null : Arrays.asList(objs).iterator();
dumpIterator(label, iter, stream);
}
-
- /**
- * Returns a {@link Random} instance for generating random numbers during the test.
- * The random seed is logged during test execution and printed to System.out on any failure
- * for reproducing the test using {@link #newRandom(long)} with the recorded seed
- *.
- */
- public Random newRandom() {
- if (seed != null) {
- throw new IllegalStateException("please call LuceneTestCase.newRandom only once per test");
- }
- this.seed = Long.valueOf(seedRnd.nextLong());
- if (VERBOSE) {
- System.out.println("NOTE: random seed of testcase '" + getName() + "' is: " + this.seed);
- }
- return new Random(seed);
- }
-
- /**
- * Returns a {@link Random} instance for generating random numbers during the test.
- * If an error occurs in the test that is not reproducible, you can use this method to
- * initialize the number generator with the seed that was printed out during the failing test.
- */
- public Random newRandom(long seed) {
- if (this.seed != null) {
- throw new IllegalStateException("please call LuceneTestCase.newRandom only once per test");
- }
- System.out.println("WARNING: random seed of testcase '" + getName() + "' is fixed to: " + seed);
- this.seed = Long.valueOf(seed);
- return new Random(seed);
- }
/** create a new index writer config with random defaults */
- public static IndexWriterConfig newIndexWriterConfig(Random r, Version v, Analyzer a) {
- return LuceneTestCaseJ4.newIndexWriterConfig(r, v, a);
+ public IndexWriterConfig newIndexWriterConfig(Version v, Analyzer a) {
+ return LuceneTestCaseJ4.newIndexWriterConfig(random, v, a);
}
/**
@@ -344,9 +315,9 @@ public abstract class LuceneTestCase ext
* some features of Windows, such as not allowing open files to be
* overwritten.
*/
- public MockDirectoryWrapper newDirectory(Random r) throws IOException {
+ public MockDirectoryWrapper newDirectory() throws IOException {
StackTraceElement[] stack = new Exception().getStackTrace();
- Directory impl = LuceneTestCaseJ4.newDirectoryImpl(r, TEST_DIRECTORY);
+ Directory impl = LuceneTestCaseJ4.newDirectoryImpl(random, TEST_DIRECTORY);
MockDirectoryWrapper dir = new MockDirectoryWrapper(impl);
stores.put(dir, stack);
return dir;
@@ -354,12 +325,12 @@ public abstract class LuceneTestCase ext
/**
* Returns a new Dictionary instance, with contents copied from the
- * provided directory. See {@link #newDirectory(Random)} for more
+ * provided directory. See {@link #newDirectory()} for more
* information.
*/
- public MockDirectoryWrapper newDirectory(Random r, Directory d) throws IOException {
+ public MockDirectoryWrapper newDirectory(Directory d) throws IOException {
StackTraceElement[] stack = new Exception().getStackTrace();
- Directory impl = LuceneTestCaseJ4.newDirectoryImpl(r, TEST_DIRECTORY);
+ Directory impl = LuceneTestCaseJ4.newDirectoryImpl(random, TEST_DIRECTORY);
for (String file : d.listAll()) {
d.copy(impl, file, file);
}
@@ -412,6 +383,7 @@ public abstract class LuceneTestCase ext
// recorded seed
protected Long seed = null;
+ protected Random random = null;
// static members
private static final Random seedRnd = new Random();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java Fri Sep 10 12:34:18 2010
@@ -156,6 +156,8 @@ public abstract class LuceneTestCaseJ4 {
static final String TEST_DIRECTORY = System.getProperty("tests.directory", "random");
/** Get the number of times to run tests */
static final int TEST_ITER = Integer.parseInt(System.getProperty("tests.iter", "1"));
+ /** Get the random seed for tests */
+ static final String TEST_SEED = System.getProperty("tests.seed", "random");
private static final Pattern codecWithParam = Pattern.compile("(.*)\\(\\s*(\\d+)\\s*\\)");
@@ -349,6 +351,8 @@ public abstract class LuceneTestCaseJ4 {
public void setUp() throws Exception {
Assert.assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup);
setup = true;
+ seed = Long.valueOf(TEST_SEED.equals("random") ? seedRnd.nextLong() : Long.parseLong(TEST_SEED));
+ random = new Random(seed);
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
@@ -500,37 +504,6 @@ public abstract class LuceneTestCaseJ4 {
dumpIterator(label, iter, stream);
}
- /**
- * Returns a {@link Random} instance for generating random numbers during the test.
- * The random seed is logged during test execution and printed to System.out on any failure
- * for reproducing the test using {@link #newRandom(long)} with the recorded seed
- * .
- */
- public Random newRandom() {
- if (seed != null) {
- throw new IllegalStateException("please call LuceneTestCaseJ4.newRandom only once per test");
- }
- this.seed = Long.valueOf(seedRnd.nextLong());
- if (VERBOSE) {
- System.out.println("NOTE: random seed of testcase '" + getName() + "' is: " + this.seed);
- }
- return new Random(seed);
- }
-
- /**
- * Returns a {@link Random} instance for generating random numbers during the test.
- * If an error occurs in the test that is not reproducible, you can use this method to
- * initialize the number generator with the seed that was printed out during the failing test.
- */
- public Random newRandom(long seed) {
- if (this.seed != null) {
- throw new IllegalStateException("please call LuceneTestCaseJ4.newRandom only once per test");
- }
- System.out.println("WARNING: random seed of testcase '" + getName() + "' is fixed to: " + seed);
- this.seed = Long.valueOf(seed);
- return new Random(seed);
- }
-
private static final Map<Class<? extends LuceneTestCaseJ4>,Long> staticSeeds =
Collections.synchronizedMap(new WeakHashMap<Class<? extends LuceneTestCaseJ4>,Long>());
@@ -560,6 +533,10 @@ public abstract class LuceneTestCaseJ4 {
}
/** create a new index writer config with random defaults */
+ public IndexWriterConfig newIndexWriterConfig(Version v, Analyzer a) {
+ return newIndexWriterConfig(random, v, a);
+ }
+
public static IndexWriterConfig newIndexWriterConfig(Random r, Version v, Analyzer a) {
IndexWriterConfig c = new IndexWriterConfig(v, a);
if (r.nextBoolean()) {
@@ -601,6 +578,10 @@ public abstract class LuceneTestCaseJ4 {
* some features of Windows, such as not allowing open files to be
* overwritten.
*/
+ public MockDirectoryWrapper newDirectory() throws IOException {
+ return newDirectory(random);
+ }
+
public static MockDirectoryWrapper newDirectory(Random r) throws IOException {
StackTraceElement[] stack = new Exception().getStackTrace();
Directory impl = newDirectoryImpl(r, TEST_DIRECTORY);
@@ -611,10 +592,14 @@ public abstract class LuceneTestCaseJ4 {
/**
* Returns a new Dictionary instance, with contents copied from the
- * provided directory. See {@link #newDirectory(Random)} for more
+ * provided directory. See {@link #newDirectory()} for more
* information.
*/
- public static MockDirectoryWrapper newDirectory(Random r, Directory d) throws IOException {
+ public MockDirectoryWrapper newDirectory(Directory d) throws IOException {
+ return newDirectory(random, d);
+ }
+
+ private static MockDirectoryWrapper newDirectory(Random r, Directory d) throws IOException {
StackTraceElement[] stack = new Exception().getStackTrace();
Directory impl = newDirectoryImpl(r, TEST_DIRECTORY);
for (String file : d.listAll()) {
@@ -730,7 +715,8 @@ public abstract class LuceneTestCaseJ4 {
// recorded seed
protected Long seed = null;
-
+ protected Random random = null;
+
// static members
private static final Random seedRnd = new Random();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestArrayUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestArrayUtil.java?rev=995772&r1=995771&r2=995772&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestArrayUtil.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestArrayUtil.java Fri Sep 10 12:34:18 2010
@@ -17,8 +17,6 @@ package org.apache.lucene.util;
* limitations under the License.
*/
-import java.util.Random;
-
public class TestArrayUtil extends LuceneTestCase {
// Ensure ArrayUtil.getNextSize gives linear amortized cost of realloc/copy
@@ -48,11 +46,10 @@ public class TestArrayUtil extends Lucen
}
public void testInvalidElementSizes() {
- final Random r = newRandom();
int num = 10000 * RANDOM_MULTIPLIER;
for (int iter = 0; iter < num; iter++) {
- final int minTargetSize = r.nextInt(Integer.MAX_VALUE);
- final int elemSize = r.nextInt(11);
+ final int minTargetSize = random.nextInt(Integer.MAX_VALUE);
+ final int elemSize = random.nextInt(11);
final int v = ArrayUtil.oversize(minTargetSize, elemSize);
assertTrue(v >= minTargetSize);
}