Index: src/test/org/apache/lucene/store/TestWindowsMMap.java =================================================================== --- src/test/org/apache/lucene/store/TestWindowsMMap.java (revision 740762) +++ src/test/org/apache/lucene/store/TestWindowsMMap.java (working copy) @@ -28,7 +28,6 @@ import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.store.FSDirectory; public class TestWindowsMMap extends LuceneTestCase { @@ -37,7 +36,7 @@ public void setUp() throws Exception { super.setUp(); - random = new Random(); + random = newRandom(); System.setProperty("org.apache.lucene.FSDirectory.class", "org.apache.lucene.store.MMapDirectory"); } Index: src/test/org/apache/lucene/store/TestBufferedIndexInput.java =================================================================== --- src/test/org/apache/lucene/store/TestBufferedIndexInput.java (revision 740762) +++ src/test/org/apache/lucene/store/TestBufferedIndexInput.java (working copy) @@ -157,7 +157,7 @@ public void testSetBufferSize() throws IOException { File indexDir = new File(System.getProperty("tempDir"), "testSetBufferSize"); - MockFSDirectory dir = new MockFSDirectory(indexDir); + MockFSDirectory dir = new MockFSDirectory(indexDir, newRandom()); try { IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); writer.setUseCompoundFile(false); @@ -205,11 +205,12 @@ List allIndexInputs = new ArrayList(); - Random rand = new Random(788); + Random rand; private Directory dir; - public MockFSDirectory(File path) throws IOException { + public MockFSDirectory(File path, Random rand) throws IOException { + this.rand = rand; lockFactory = new NoLockFactory(); dir = FSDirectory.getDirectory(path); } Index: src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java =================================================================== --- src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (revision 740762) +++ src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (working copy) @@ -296,7 +296,7 @@ } public void testRandomQueries() throws Exception { - final Random rnd = new Random(0); + final Random rnd = newRandom(); String field="data"; String[] vals = {"1","2","3","4","5","6","A","Z","B","Y","Z","X","foo"}; @@ -319,9 +319,10 @@ // increase number of iterations for more complete testing for (int i=0; i<1000; i++) { int lev = rnd.nextInt(maxLev); - BooleanQuery q1 = TestBoolean2.randBoolQuery(new Random(i), lev, field, vals, null); - // BooleanQuery q2 = TestBoolean2.randBoolQuery(new Random(i), lev, field, vals, minNrCB); - BooleanQuery q2 = TestBoolean2.randBoolQuery(new Random(i), lev, field, vals, null); + final long seed = rnd.nextLong(); + BooleanQuery q1 = TestBoolean2.randBoolQuery(new Random(seed), lev, field, vals, null); + // BooleanQuery q2 = TestBoolean2.randBoolQuery(new Random(seed), lev, field, vals, minNrCB); + BooleanQuery q2 = TestBoolean2.randBoolQuery(new Random(seed), lev, field, vals, null); // only set minimumNumberShouldMatch on the top level query since setting // at a lower level can change the score. minNrCB.postCreate(q2); Index: src/test/org/apache/lucene/search/TestSort.java =================================================================== --- src/test/org/apache/lucene/search/TestSort.java (revision 740762) +++ src/test/org/apache/lucene/search/TestSort.java (working copy) @@ -180,7 +180,7 @@ return new IndexSearcher (indexStore); } - public static String getRandomNumberString(int num, int low, int high) { + public String getRandomNumberString(int num, int low, int high) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < num; i++) { sb.append(getRandomNumber(low, high)); @@ -188,11 +188,11 @@ return sb.toString(); } - public static String getRandomCharString(int num) { + public String getRandomCharString(int num) { return getRandomCharString(num, 48, 122); } - public static String getRandomCharString(int num, int start, int end) { + public String getRandomCharString(int num, int start, int end) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < num; i++) { sb.append(new Character((char) getRandomNumber(start, end))); @@ -200,9 +200,9 @@ return sb.toString(); } - static Random r = new Random(); + Random r; - public static int getRandomNumber(final int low, final int high) { + public int getRandomNumber(final int low, final int high) { int randInt = (Math.abs(r.nextInt()) % (high - low)) + low; @@ -284,6 +284,7 @@ * 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(new SortField[] { Index: src/test/org/apache/lucene/search/BaseTestRangeFilter.java =================================================================== --- src/test/org/apache/lucene/search/BaseTestRangeFilter.java (revision 740762) +++ src/test/org/apache/lucene/search/BaseTestRangeFilter.java (working copy) @@ -32,7 +32,7 @@ public static final boolean F = false; public static final boolean T = true; - Random rand = new Random(101); // use a set seed to test is deterministic + protected Random rand; /** * Collation interacts badly with hyphens -- collation produces different @@ -83,10 +83,12 @@ public BaseTestRangeFilter(String name) { super(name); + rand = newRandom(); build(signedIndex); build(unsignedIndex); } public BaseTestRangeFilter() { + rand = newRandom(); build(signedIndex); build(unsignedIndex); } Index: src/test/org/apache/lucene/search/TestBoolean2.java =================================================================== --- src/test/org/apache/lucene/search/TestBoolean2.java (revision 740762) +++ src/test/org/apache/lucene/search/TestBoolean2.java (working copy) @@ -152,7 +152,7 @@ } public void testRandomQueries() throws Exception { - Random rnd = new Random(0); + Random rnd = newRandom(); String[] vals = {"w1","w2","w3","w4","w5","xx","yy","zzz"}; @@ -163,7 +163,7 @@ // increase number of iterations for more complete testing for (int i=0; i<1000; i++) { int level = rnd.nextInt(3); - BooleanQuery q1 = randBoolQuery(new Random(i), level, field, vals, null); + BooleanQuery q1 = randBoolQuery(new Random(rnd.nextLong()), level, field, vals, null); // Can't sort by relevance since floating point numbers may not quite // match up. Index: src/test/org/apache/lucene/search/TestThreadSafe.java =================================================================== --- src/test/org/apache/lucene/search/TestThreadSafe.java (revision 740762) +++ src/test/org/apache/lucene/search/TestThreadSafe.java (working copy) @@ -34,7 +34,7 @@ * @version $Id$ */ public class TestThreadSafe extends LuceneTestCase { - Random r = new Random(); + Random r; Directory dir1; Directory dir2; @@ -48,7 +48,7 @@ final int iter; final Random rand; // pass in random in case we want to make things reproducable - public Thr(int iter, Random rand, int level) { + public Thr(int iter, Random rand) { this.iter = iter; this.rand = rand; } @@ -132,7 +132,7 @@ void doTest(int iter, int nThreads) throws Exception { Thr[] tarr = new Thr[nThreads]; for (int i=0; i + + + + + + + + + + + + + + + Index: contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieRangeQuery.java =================================================================== --- contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieRangeQuery.java (revision 740762) +++ contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieRangeQuery.java (working copy) @@ -36,11 +36,10 @@ { private static final long distance=66666; - private static Random rnd=new Random(); - private static RAMDirectory directory; - private static IndexSearcher searcher; + private static final RAMDirectory directory; + private static final IndexSearcher searcher; static { - try { + try { directory = new RAMDirectory(); IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, MaxFieldLength.UNLIMITED); @@ -136,6 +135,7 @@ } private void testRandomTrieAndClassicRangeQuery(final TrieUtils variant) throws Exception { + final Random rnd=newRandom(); String field="field"+variant.TRIE_BITS; // 50 random tests, the tests may also return 0 results, if min>max, but this is ok for (int i=0; i<50; i++) { @@ -185,6 +185,7 @@ } private void testRangeSplit(final TrieUtils variant) throws Exception { + final Random rnd=newRandom(); String field="ascfield"+variant.TRIE_BITS; // 50 random tests for (int i=0; i<50; i++) { @@ -225,6 +226,7 @@ } private void testSorting(final TrieUtils variant) throws Exception { + final Random rnd=newRandom(); String field="field"+variant.TRIE_BITS; // 10 random tests, the index order is ascending, // so using a reverse sort field should retun descending documents