You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2012/04/15 16:42:01 UTC
svn commit: r1326351 [12/22] - in /lucene/dev/trunk: ./ dev-tools/eclipse/
lucene/
lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/
lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/custom/
lucene/contrib/hig...
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java Sun Apr 15 14:41:44 2012
@@ -43,16 +43,16 @@ public class TestFileSwitchDirectory ext
fileExtensions.add(Lucene40StoredFieldsWriter.FIELDS_EXTENSION);
fileExtensions.add(Lucene40StoredFieldsWriter.FIELDS_INDEX_EXTENSION);
- MockDirectoryWrapper primaryDir = new MockDirectoryWrapper(random, new RAMDirectory());
+ MockDirectoryWrapper primaryDir = new MockDirectoryWrapper(random(), new RAMDirectory());
primaryDir.setCheckIndexOnClose(false); // only part of an index
- MockDirectoryWrapper secondaryDir = new MockDirectoryWrapper(random, new RAMDirectory());
+ MockDirectoryWrapper secondaryDir = new MockDirectoryWrapper(random(), new RAMDirectory());
secondaryDir.setCheckIndexOnClose(false); // only part of an index
FileSwitchDirectory fsd = new FileSwitchDirectory(fileExtensions, primaryDir, secondaryDir, true);
// for now we wire Lucene40Codec because we rely upon its specific impl
IndexWriter writer = new IndexWriter(
fsd,
- new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).
+ new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).
setMergePolicy(newLogMergePolicy(false)).setCodec(Codec.forName("Lucene40"))
);
TestIndexWriterReader.createIndexNoClose(true, "ram", writer);
@@ -87,7 +87,7 @@ public class TestFileSwitchDirectory ext
Directory a = new SimpleFSDirectory(_TestUtil.getTempDir("foo"));
Directory b = new SimpleFSDirectory(_TestUtil.getTempDir("bar"));
FileSwitchDirectory switchDir = new FileSwitchDirectory(primaryExtensions, a, b, true);
- return new MockDirectoryWrapper(random, switchDir);
+ return new MockDirectoryWrapper(random(), switchDir);
}
// LUCENE-3380 -- make sure we get exception if the directory really does not exist.
@@ -107,7 +107,7 @@ public class TestFileSwitchDirectory ext
Directory dir = newFSSwitchDirectory(Collections.<String>emptySet());
String name = "file";
try {
- dir.createOutput(name, newIOContext(random)).close();
+ dir.createOutput(name, newIOContext(random())).close();
assertTrue(dir.fileExists(name));
assertTrue(Arrays.asList(dir.listAll()).contains(name));
} finally {
@@ -118,12 +118,12 @@ public class TestFileSwitchDirectory ext
// LUCENE-3380 test that delegate compound files correctly.
public void testCompoundFileAppendTwice() throws IOException {
Directory newDir = newFSSwitchDirectory(Collections.singleton("cfs"));
- CompoundFileDirectory csw = new CompoundFileDirectory(newDir, "d.cfs", newIOContext(random), true);
+ CompoundFileDirectory csw = new CompoundFileDirectory(newDir, "d.cfs", newIOContext(random()), true);
createSequenceFile(newDir, "d1", (byte) 0, 15);
- IndexOutput out = csw.createOutput("d.xyz", newIOContext(random));
+ IndexOutput out = csw.createOutput("d.xyz", newIOContext(random()));
out.writeInt(0);
try {
- newDir.copy(csw, "d1", "d1", newIOContext(random));
+ newDir.copy(csw, "d1", "d1", newIOContext(random()));
fail("file does already exist");
} catch (IllegalArgumentException e) {
//
@@ -134,7 +134,7 @@ public class TestFileSwitchDirectory ext
csw.close();
- CompoundFileDirectory cfr = new CompoundFileDirectory(newDir, "d.cfs", newIOContext(random), false);
+ CompoundFileDirectory cfr = new CompoundFileDirectory(newDir, "d.cfs", newIOContext(random()), false);
assertEquals(1, cfr.listAll().length);
assertEquals("d.xyz", cfr.listAll()[0]);
cfr.close();
@@ -146,7 +146,7 @@ public class TestFileSwitchDirectory ext
* computed as start + offset where offset is the number of the byte.
*/
private void createSequenceFile(Directory dir, String name, byte start, int size) throws IOException {
- IndexOutput os = dir.createOutput(name, newIOContext(random));
+ IndexOutput os = dir.createOutput(name, newIOContext(random()));
for (int i=0; i < size; i++) {
os.writeByte(start);
start ++;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java Sun Apr 15 14:41:44 2012
@@ -43,14 +43,14 @@ public class TestLockFactory extends Luc
// methods are called at the right time, locks are created, etc.
public void testCustomLockFactory() throws IOException {
- Directory dir = new MockDirectoryWrapper(random, new RAMDirectory());
+ Directory dir = new MockDirectoryWrapper(random(), new RAMDirectory());
MockLockFactory lf = new MockLockFactory();
dir.setLockFactory(lf);
// Lock prefix should have been set:
assertTrue("lock prefix was not set by the RAMDirectory", lf.lockPrefixSet);
- IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
// add 100 documents (so that commit lock is used)
for (int i = 0; i < 100; i++) {
@@ -76,19 +76,19 @@ public class TestLockFactory extends Luc
// exceptions raised:
// Verify: NoLockFactory allows two IndexWriters
public void testRAMDirectoryNoLocking() throws IOException {
- Directory dir = new MockDirectoryWrapper(random, new RAMDirectory());
+ Directory dir = new MockDirectoryWrapper(random(), new RAMDirectory());
dir.setLockFactory(NoLockFactory.getNoLockFactory());
assertTrue("RAMDirectory.setLockFactory did not take",
NoLockFactory.class.isInstance(dir.getLockFactory()));
- IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
writer.commit(); // required so the second open succeed
// Create a 2nd IndexWriter. This is normally not allowed but it should run through since we're not
// using any locks:
IndexWriter writer2 = null;
try {
- writer2 = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
+ writer2 = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
} catch (Exception e) {
e.printStackTrace(System.out);
fail("Should not have hit an IOException with no locking");
@@ -108,12 +108,12 @@ public class TestLockFactory extends Luc
assertTrue("RAMDirectory did not use correct LockFactory: got " + dir.getLockFactory(),
SingleInstanceLockFactory.class.isInstance(dir.getLockFactory()));
- IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
// Create a 2nd IndexWriter. This should fail:
IndexWriter writer2 = null;
try {
- writer2 = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
+ writer2 = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
fail("Should have hit an IOException with two IndexWriters on default SingleInstanceLockFactory");
} catch (IOException e) {
}
@@ -151,7 +151,7 @@ public class TestLockFactory extends Luc
Directory dir = newFSDirectory(indexDir, lockFactory);
// First create a 1 doc index:
- IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
+ IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));
addDoc(w);
w.close();
@@ -289,7 +289,7 @@ public class TestLockFactory extends Luc
IndexWriter writer = null;
for(int i=0;i<this.numIteration;i++) {
try {
- writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
} catch (IOException e) {
if (e.toString().indexOf(" timed out:") == -1) {
hitException = true;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java Sun Apr 15 14:41:44 2012
@@ -51,7 +51,7 @@ public class TestMultiMMap extends Lucen
public void testCloneSafety() throws Exception {
MMapDirectory mmapDir = new MMapDirectory(_TestUtil.getTempDir("testCloneSafety"));
- IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random));
+ IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
io.writeVInt(5);
io.close();
IndexInput one = mmapDir.openInput("bytes", IOContext.DEFAULT);
@@ -82,9 +82,9 @@ public class TestMultiMMap extends Lucen
for (int i = 0; i < 31; i++) {
MMapDirectory mmapDir = new MMapDirectory(_TestUtil.getTempDir("testSeekZero"));
mmapDir.setMaxChunkSize(1<<i);
- IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random));
+ IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
io.close();
- IndexInput ii = mmapDir.openInput("zeroBytes", newIOContext(random));
+ IndexInput ii = mmapDir.openInput("zeroBytes", newIOContext(random()));
ii.seek(0L);
ii.close();
mmapDir.close();
@@ -95,12 +95,12 @@ public class TestMultiMMap extends Lucen
for (int i = 0; i < 17; i++) {
MMapDirectory mmapDir = new MMapDirectory(_TestUtil.getTempDir("testSeekEnd"));
mmapDir.setMaxChunkSize(1<<i);
- IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random));
+ IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
byte bytes[] = new byte[1<<i];
- random.nextBytes(bytes);
+ random().nextBytes(bytes);
io.writeBytes(bytes, bytes.length);
io.close();
- IndexInput ii = mmapDir.openInput("bytes", newIOContext(random));
+ IndexInput ii = mmapDir.openInput("bytes", newIOContext(random()));
byte actual[] = new byte[1<<i];
ii.readBytes(actual, 0, actual.length);
assertEquals(new BytesRef(bytes), new BytesRef(actual));
@@ -114,12 +114,12 @@ public class TestMultiMMap extends Lucen
for (int i = 0; i < 10; i++) {
MMapDirectory mmapDir = new MMapDirectory(_TestUtil.getTempDir("testSeeking"));
mmapDir.setMaxChunkSize(1<<i);
- IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random));
+ IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
byte bytes[] = new byte[1<<(i+1)]; // make sure we switch buffers
- random.nextBytes(bytes);
+ random().nextBytes(bytes);
io.writeBytes(bytes, bytes.length);
io.close();
- IndexInput ii = mmapDir.openInput("bytes", newIOContext(random));
+ IndexInput ii = mmapDir.openInput("bytes", newIOContext(random()));
byte actual[] = new byte[1<<(i+1)]; // first read all bytes
ii.readBytes(actual, 0, actual.length);
assertEquals(new BytesRef(bytes), new BytesRef(actual));
@@ -139,7 +139,7 @@ public class TestMultiMMap extends Lucen
public void testRandomChunkSizes() throws Exception {
int num = atLeast(10);
for (int i = 0; i < num; i++)
- assertChunking(random, _TestUtil.nextInt(random, 20, 100));
+ assertChunking(random(), _TestUtil.nextInt(random(), 20, 100));
}
private void assertChunking(Random random, int chunkSize) throws Exception {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java Sun Apr 15 14:41:44 2012
@@ -46,11 +46,11 @@ public class TestNRTCachingDirectory ext
public void testNRTAndCommit() throws Exception {
Directory dir = newDirectory();
NRTCachingDirectory cachedDir = new NRTCachingDirectory(dir, 2.0, 25.0);
- IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));
- RandomIndexWriter w = new RandomIndexWriter(random, cachedDir, conf);
- final LineFileDocs docs = new LineFileDocs(random,
+ IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+ RandomIndexWriter w = new RandomIndexWriter(random(), cachedDir, conf);
+ final LineFileDocs docs = new LineFileDocs(random(),
defaultCodecSupportsDocValues());
- final int numDocs = _TestUtil.nextInt(random, 100, 400);
+ final int numDocs = _TestUtil.nextInt(random(), 100, 400);
if (VERBOSE) {
System.out.println("TEST: numDocs=" + numDocs);
@@ -62,7 +62,7 @@ public class TestNRTCachingDirectory ext
final Document doc = docs.nextDoc();
ids.add(new BytesRef(doc.get("docid")));
w.addDocument(doc);
- if (random.nextInt(20) == 17) {
+ if (random().nextInt(20) == 17) {
if (r == null) {
r = IndexReader.open(w.w, false);
} else {
@@ -138,7 +138,7 @@ public class TestNRTCachingDirectory ext
Directory dir = new NRTCachingDirectory(newFSDirectory(_TestUtil.getTempDir("foo")), 2.0, 25.0);
String name = "file";
try {
- dir.createOutput(name, newIOContext(random)).close();
+ dir.createOutput(name, newIOContext(random())).close();
assertTrue(dir.fileExists(name));
assertTrue(Arrays.asList(dir.listAll()).contains(name));
} finally {
@@ -149,12 +149,12 @@ public class TestNRTCachingDirectory ext
// LUCENE-3382 test that delegate compound files correctly.
public void testCompoundFileAppendTwice() throws IOException {
Directory newDir = new NRTCachingDirectory(newDirectory(), 2.0, 25.0);
- CompoundFileDirectory csw = new CompoundFileDirectory(newDir, "d.cfs", newIOContext(random), true);
+ CompoundFileDirectory csw = new CompoundFileDirectory(newDir, "d.cfs", newIOContext(random()), true);
createSequenceFile(newDir, "d1", (byte) 0, 15);
- IndexOutput out = csw.createOutput("d.xyz", newIOContext(random));
+ IndexOutput out = csw.createOutput("d.xyz", newIOContext(random()));
out.writeInt(0);
try {
- newDir.copy(csw, "d1", "d1", newIOContext(random));
+ newDir.copy(csw, "d1", "d1", newIOContext(random()));
fail("file does already exist");
} catch (IllegalArgumentException e) {
//
@@ -165,7 +165,7 @@ public class TestNRTCachingDirectory ext
csw.close();
- CompoundFileDirectory cfr = new CompoundFileDirectory(newDir, "d.cfs", newIOContext(random), false);
+ CompoundFileDirectory cfr = new CompoundFileDirectory(newDir, "d.cfs", newIOContext(random()), false);
assertEquals(1, cfr.listAll().length);
assertEquals("d.xyz", cfr.listAll()[0]);
cfr.close();
@@ -177,7 +177,7 @@ public class TestNRTCachingDirectory ext
* computed as start + offset where offset is the number of the byte.
*/
private void createSequenceFile(Directory dir, String name, byte start, int size) throws IOException {
- IndexOutput os = dir.createOutput(name, newIOContext(random));
+ IndexOutput os = dir.createOutput(name, newIOContext(random()));
for (int i=0; i < size; i++) {
os.writeByte(start);
start ++;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java Sun Apr 15 14:41:44 2012
@@ -51,7 +51,7 @@ public class TestRAMDirectory extends Lu
Directory dir = newFSDirectory(indexDir);
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
- TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
+ TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE));
// add some documents
Document doc = null;
for (int i = 0; i < docsToAdd; i++) {
@@ -67,7 +67,7 @@ public class TestRAMDirectory extends Lu
public void testRAMDirectory () throws IOException {
Directory dir = newFSDirectory(indexDir);
- MockDirectoryWrapper ramDir = new MockDirectoryWrapper(random, new RAMDirectory(dir, newIOContext(random)));
+ MockDirectoryWrapper ramDir = new MockDirectoryWrapper(random(), new RAMDirectory(dir, newIOContext(random())));
// close the underlaying directory
dir.close();
@@ -98,11 +98,11 @@ public class TestRAMDirectory extends Lu
public void testRAMDirectorySize() throws IOException, InterruptedException {
Directory dir = newFSDirectory(indexDir);
- final MockDirectoryWrapper ramDir = new MockDirectoryWrapper(random, new RAMDirectory(dir, newIOContext(random)));
+ final MockDirectoryWrapper ramDir = new MockDirectoryWrapper(random(), new RAMDirectory(dir, newIOContext(random())));
dir.close();
final IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig(
- TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
+ TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
writer.forceMerge(1);
assertEquals(ramDir.sizeInBytes(), ramDir.getRecomputedSizeInBytes());
@@ -148,11 +148,11 @@ public class TestRAMDirectory extends Lu
// LUCENE-1196
public void testIllegalEOF() throws Exception {
RAMDirectory dir = new RAMDirectory();
- IndexOutput o = dir.createOutput("out", newIOContext(random));
+ IndexOutput o = dir.createOutput("out", newIOContext(random()));
byte[] b = new byte[1024];
o.writeBytes(b, 0, 1024);
o.close();
- IndexInput i = dir.openInput("out", newIOContext(random));
+ IndexInput i = dir.openInput("out", newIOContext(random()));
i.seek(1024);
i.close();
dir.close();
@@ -170,12 +170,12 @@ public class TestRAMDirectory extends Lu
public void testSeekToEOFThenBack() throws Exception {
RAMDirectory dir = new RAMDirectory();
- IndexOutput o = dir.createOutput("out", newIOContext(random));
+ IndexOutput o = dir.createOutput("out", newIOContext(random()));
byte[] bytes = new byte[3*RAMInputStream.BUFFER_SIZE];
o.writeBytes(bytes, 0, bytes.length);
o.close();
- IndexInput i = dir.openInput("out", newIOContext(random));
+ IndexInput i = dir.openInput("out", newIOContext(random()));
i.seek(2*RAMInputStream.BUFFER_SIZE-1);
i.seek(3*RAMInputStream.BUFFER_SIZE);
i.seek(RAMInputStream.BUFFER_SIZE);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java Sun Apr 15 14:41:44 2012
@@ -41,17 +41,17 @@ public class TestWindowsMMap extends Luc
}
private String randomToken() {
- int tl = 1 + random.nextInt(7);
+ int tl = 1 + random().nextInt(7);
StringBuilder sb = new StringBuilder();
for(int cx = 0; cx < tl; cx ++) {
- int c = random.nextInt(25);
+ int c = random().nextInt(25);
sb.append(alphabet.substring(c, c+1));
}
return sb.toString();
}
private String randomField() {
- int fl = 1 + random.nextInt(3);
+ int fl = 1 + random().nextInt(3);
StringBuilder fb = new StringBuilder();
for(int fx = 0; fx < fl; fx ++) {
fb.append(randomToken());
@@ -73,7 +73,7 @@ public class TestWindowsMMap extends Luc
// plan to add a set of useful stopwords, consider changing some of the
// interior filters.
- MockAnalyzer analyzer = new MockAnalyzer(random);
+ MockAnalyzer analyzer = new MockAnalyzer(random());
// TODO: something about lock timeouts and leftover locks.
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
TEST_VERSION_CURRENT, analyzer)
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java Sun Apr 15 14:41:44 2012
@@ -52,7 +52,7 @@ public class StressRamUsageEstimator ext
public void testChainedEstimation() {
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
- Random rnd = random;
+ Random rnd = random();
Entry first = new Entry();
try {
while (true) {
@@ -82,7 +82,7 @@ public class StressRamUsageEstimator ext
long before = memoryMXBean.getHeapMemoryUsage().getUsed();
Object [] all = new Object [1000000];
for (int i = 0; i < all.length; i++) {
- all[i] = new byte[random.nextInt(3)];
+ all[i] = new byte[random().nextInt(3)];
}
causeGc();
long after = memoryMXBean.getHeapMemoryUsage().getUsed();
@@ -135,7 +135,7 @@ public class StressRamUsageEstimator ext
all = Arrays.copyOf(all, all.length + 1);
all[all.length - 1] = seg;
for (int i = 0; i < seg.length; i++) {
- seg[i] = new byte[random.nextInt(7)];
+ seg[i] = new byte[random().nextInt(7)];
}
}
} catch (OutOfMemoryError e) {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestArrayUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestArrayUtil.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestArrayUtil.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestArrayUtil.java Sun Apr 15 14:41:44 2012
@@ -51,8 +51,8 @@ public class TestArrayUtil extends Lucen
public void testInvalidElementSizes() {
int num = atLeast(10000);
for (int iter = 0; iter < num; iter++) {
- final int minTargetSize = random.nextInt(Integer.MAX_VALUE);
- final int elemSize = random.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);
}
@@ -118,9 +118,9 @@ public class TestArrayUtil extends Lucen
}
private Integer[] createRandomArray(int maxSize) {
- final Integer[] a = new Integer[random.nextInt(maxSize) + 1];
+ final Integer[] a = new Integer[random().nextInt(maxSize) + 1];
for (int i = 0; i < a.length; i++) {
- a[i] = Integer.valueOf(random.nextInt(a.length));
+ a[i] = Integer.valueOf(random().nextInt(a.length));
}
return a;
}
@@ -146,9 +146,9 @@ public class TestArrayUtil extends Lucen
}
private Integer[] createSparseRandomArray(int maxSize) {
- final Integer[] a = new Integer[random.nextInt(maxSize) + 1];
+ final Integer[] a = new Integer[random().nextInt(maxSize) + 1];
for (int i = 0; i < a.length; i++) {
- a[i] = Integer.valueOf(random.nextInt(2));
+ a[i] = Integer.valueOf(random().nextInt(2));
}
return a;
}
@@ -228,8 +228,8 @@ public class TestArrayUtil extends Lucen
// so they should always be in order after sorting.
// The other half has defined order, but no (-1) value (they should appear after
// all above, when sorted).
- final boolean equal = random.nextBoolean();
- items[i] = new Item(equal ? (i+1) : -1, equal ? 0 : (random.nextInt(1000)+1));
+ final boolean equal = random().nextBoolean();
+ items[i] = new Item(equal ? (i+1) : -1, equal ? 0 : (random().nextInt(1000)+1));
}
if (VERBOSE) System.out.println("Before: " + Arrays.toString(items));
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestByteBlockPool.java Sun Apr 15 14:41:44 2012
@@ -35,18 +35,18 @@ public class TestByteBlockPool extends L
final int numValues = atLeast(100);
BytesRef ref = new BytesRef();
for (int i = 0; i < numValues; i++) {
- final String value = _TestUtil.randomRealisticUnicodeString(random,
+ final String value = _TestUtil.randomRealisticUnicodeString(random(),
maxLength);
list.add(value);
ref.copyChars(value);
pool.copy(ref);
}
RAMDirectory dir = new RAMDirectory();
- IndexOutput stream = dir.createOutput("foo.txt", newIOContext(random));
+ IndexOutput stream = dir.createOutput("foo.txt", newIOContext(random()));
pool.writePool(stream);
stream.flush();
stream.close();
- IndexInput input = dir.openInput("foo.txt", newIOContext(random));
+ IndexInput input = dir.openInput("foo.txt", newIOContext(random()));
assertEquals(pool.byteOffset + pool.byteUpto, stream.length());
BytesRef expected = new BytesRef();
BytesRef actual = new BytesRef();
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestBytesRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestBytesRef.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestBytesRef.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestBytesRef.java Sun Apr 15 14:41:44 2012
@@ -40,7 +40,7 @@ public class TestBytesRef extends Lucene
public void testFromChars() {
for (int i = 0; i < 100; i++) {
- String s = _TestUtil.randomUnicodeString(random);
+ String s = _TestUtil.randomUnicodeString(random());
String s2 = new BytesRef(s).utf8ToString();
assertEquals(s, s2);
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestBytesRefHash.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestBytesRefHash.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestBytesRefHash.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestBytesRefHash.java Sun Apr 15 14:41:44 2012
@@ -49,13 +49,13 @@ public class TestBytesRefHash extends Lu
}
private ByteBlockPool newPool(){
- return random.nextBoolean() && pool != null ? pool
- : new ByteBlockPool(new RecyclingByteBlockAllocator(ByteBlockPool.BYTE_BLOCK_SIZE, random.nextInt(25)));
+ return random().nextBoolean() && pool != null ? pool
+ : new ByteBlockPool(new RecyclingByteBlockAllocator(ByteBlockPool.BYTE_BLOCK_SIZE, random().nextInt(25)));
}
private BytesRefHash newHash(ByteBlockPool blockPool) {
- final int initSize = 2 << 1 + random.nextInt(5);
- return random.nextBoolean() ? new BytesRefHash(blockPool) : new BytesRefHash(
+ final int initSize = 2 << 1 + random().nextInt(5);
+ return random().nextBoolean() ? new BytesRefHash(blockPool) : new BytesRefHash(
blockPool, initSize, new BytesRefHash.DirectBytesStartArray(initSize));
}
@@ -67,11 +67,11 @@ public class TestBytesRefHash extends Lu
BytesRef ref = new BytesRef();
int num = atLeast(2);
for (int j = 0; j < num; j++) {
- final int mod = 1+random.nextInt(39);
+ final int mod = 1+random().nextInt(39);
for (int i = 0; i < 797; i++) {
String str;
do {
- str = _TestUtil.randomRealisticUnicodeString(random, 1000);
+ str = _TestUtil.randomRealisticUnicodeString(random(), 1000);
} while (str.length() == 0);
ref.copyChars(str);
int count = hash.size();
@@ -105,7 +105,7 @@ public class TestBytesRefHash extends Lu
for (int i = 0; i < 797; i++) {
String str;
do {
- str = _TestUtil.randomRealisticUnicodeString(random, 1000);
+ str = _TestUtil.randomRealisticUnicodeString(random(), 1000);
} while (str.length() == 0);
ref.copyChars(str);
int count = hash.size();
@@ -144,7 +144,7 @@ public class TestBytesRefHash extends Lu
for (int i = 0; i < size; i++) {
String str;
do {
- str = _TestUtil.randomRealisticUnicodeString(random, 1000);
+ str = _TestUtil.randomRealisticUnicodeString(random(), 1000);
} while (str.length() == 0);
ref.copyChars(str);
final int key = hash.add(ref);
@@ -184,7 +184,7 @@ public class TestBytesRefHash extends Lu
for (int i = 0; i < 797; i++) {
String str;
do {
- str = _TestUtil.randomRealisticUnicodeString(random, 1000);
+ str = _TestUtil.randomRealisticUnicodeString(random(), 1000);
} while (str.length() == 0);
ref.copyChars(str);
hash.add(ref);
@@ -223,7 +223,7 @@ public class TestBytesRefHash extends Lu
for (int i = 0; i < 797; i++) {
String str;
do {
- str = _TestUtil.randomRealisticUnicodeString(random, 1000);
+ str = _TestUtil.randomRealisticUnicodeString(random(), 1000);
} while (str.length() == 0);
ref.copyChars(str);
int count = hash.size();
@@ -251,9 +251,9 @@ public class TestBytesRefHash extends Lu
@Test(expected = MaxBytesLengthExceededException.class)
public void testLargeValue() {
- int[] sizes = new int[] { random.nextInt(5),
- ByteBlockPool.BYTE_BLOCK_SIZE - 33 + random.nextInt(31),
- ByteBlockPool.BYTE_BLOCK_SIZE - 1 + random.nextInt(37) };
+ int[] sizes = new int[] { random().nextInt(5),
+ ByteBlockPool.BYTE_BLOCK_SIZE - 33 + random().nextInt(31),
+ ByteBlockPool.BYTE_BLOCK_SIZE - 1 + random().nextInt(37) };
BytesRef ref = new BytesRef();
for (int i = 0; i < sizes.length; i++) {
ref.bytes = new byte[sizes[i]];
@@ -286,7 +286,7 @@ public class TestBytesRefHash extends Lu
for (int i = 0; i < 797; i++) {
String str;
do {
- str = _TestUtil.randomRealisticUnicodeString(random, 1000);
+ str = _TestUtil.randomRealisticUnicodeString(random(), 1000);
} while (str.length() == 0);
ref.copyChars(str);
int count = hash.size();
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java Sun Apr 15 14:41:44 2012
@@ -26,7 +26,7 @@ public class TestCharsRef extends Lucene
CharsRef utf16[] = new CharsRef[numStrings];
for (int i = 0; i < numStrings; i++) {
- String s = _TestUtil.randomUnicodeString(random);
+ String s = _TestUtil.randomUnicodeString(random());
utf8[i] = new BytesRef(s);
utf16[i] = new CharsRef(s);
}
@@ -44,8 +44,8 @@ public class TestCharsRef extends Lucene
StringBuilder builder = new StringBuilder();
int numStrings = atLeast(10);
for (int i = 0; i < numStrings; i++) {
- char[] charArray = _TestUtil.randomRealisticUnicodeString(random, 1, 100).toCharArray();
- int offset = random.nextInt(charArray.length);
+ char[] charArray = _TestUtil.randomRealisticUnicodeString(random(), 1, 100).toCharArray();
+ int offset = random().nextInt(charArray.length);
int length = charArray.length - offset;
builder.append(charArray, offset, length);
ref.append(charArray, offset, length);
@@ -58,8 +58,8 @@ public class TestCharsRef extends Lucene
int numIters = atLeast(10);
for (int i = 0; i < numIters; i++) {
CharsRef ref = new CharsRef();
- char[] charArray = _TestUtil.randomRealisticUnicodeString(random, 1, 100).toCharArray();
- int offset = random.nextInt(charArray.length);
+ char[] charArray = _TestUtil.randomRealisticUnicodeString(random(), 1, 100).toCharArray();
+ int offset = random().nextInt(charArray.length);
int length = charArray.length - offset;
String str = new String(charArray, offset, length);
ref.copyChars(charArray, offset, length);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestCollectionUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestCollectionUtil.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestCollectionUtil.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestCollectionUtil.java Sun Apr 15 14:41:44 2012
@@ -26,9 +26,9 @@ import java.util.List;
public class TestCollectionUtil extends LuceneTestCase {
private List<Integer> createRandomList(int maxSize) {
- final Integer[] a = new Integer[random.nextInt(maxSize) + 1];
+ final Integer[] a = new Integer[random().nextInt(maxSize) + 1];
for (int i = 0; i < a.length; i++) {
- a[i] = Integer.valueOf(random.nextInt(a.length));
+ a[i] = Integer.valueOf(random().nextInt(a.length));
}
return Arrays.asList(a);
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java Sun Apr 15 14:41:44 2012
@@ -46,8 +46,8 @@ public class TestFieldCacheSanityChecker
dirA = newDirectory();
dirB = newDirectory();
- IndexWriter wA = new IndexWriter(dirA, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
- IndexWriter wB = new IndexWriter(dirB, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ IndexWriter wA = new IndexWriter(dirA, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
+ IndexWriter wB = new IndexWriter(dirB, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
long theLong = Long.MAX_VALUE;
double theDouble = Double.MAX_VALUE;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java Sun Apr 15 14:41:44 2012
@@ -43,7 +43,7 @@ public class TestFixedBitSet extends Luc
}
void doPrevSetBit(BitSet a, FixedBitSet b) {
- int aa = a.size() + random.nextInt(100);
+ int aa = a.size() + random().nextInt(100);
int bb = aa;
do {
// aa = a.prevSetBit(aa-1);
@@ -75,7 +75,7 @@ public class TestFixedBitSet extends Luc
DocIdSetIterator iterator = b.iterator();
do {
aa = a.nextSetBit(aa+1);
- bb = (bb < b.length() && random.nextBoolean()) ? iterator.nextDoc() : iterator.advance(bb + 1);
+ bb = (bb < b.length() && random().nextBoolean()) ? iterator.nextDoc() : iterator.advance(bb + 1);
assertEquals(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
} while (aa>=0);
}
@@ -85,7 +85,7 @@ public class TestFixedBitSet extends Luc
DocIdSetIterator iterator = b.iterator();
do {
aa = a.nextSetBit(aa+1);
- bb = random.nextBoolean() ? iterator.nextDoc() : iterator.advance(bb + 1);
+ bb = random().nextBoolean() ? iterator.nextDoc() : iterator.advance(bb + 1);
assertEquals(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
} while (aa>=0);
}
@@ -95,29 +95,29 @@ public class TestFixedBitSet extends Luc
FixedBitSet b0=null;
for (int i=0; i<iter; i++) {
- int sz = _TestUtil.nextInt(random, 2, maxSize);
+ int sz = _TestUtil.nextInt(random(), 2, maxSize);
BitSet a = new BitSet(sz);
FixedBitSet b = new FixedBitSet(sz);
// test the various ways of setting bits
if (sz>0) {
- int nOper = random.nextInt(sz);
+ int nOper = random().nextInt(sz);
for (int j=0; j<nOper; j++) {
int idx;
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.set(idx);
b.set(idx);
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.clear(idx);
b.clear(idx);
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.flip(idx);
b.flip(idx, idx+1);
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.flip(idx);
b.flip(idx, idx+1);
@@ -136,15 +136,15 @@ public class TestFixedBitSet extends Luc
// test ranges, including possible extension
int fromIndex, toIndex;
- fromIndex = random.nextInt(sz/2);
- toIndex = fromIndex + random.nextInt(sz - fromIndex);
+ fromIndex = random().nextInt(sz/2);
+ toIndex = fromIndex + random().nextInt(sz - fromIndex);
BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex);
FixedBitSet bb = b.clone(); bb.flip(fromIndex,toIndex);
doIterate(aa,bb, mode); // a problem here is from flip or doIterate
- fromIndex = random.nextInt(sz/2);
- toIndex = fromIndex + random.nextInt(sz - fromIndex);
+ fromIndex = random().nextInt(sz/2);
+ toIndex = fromIndex + random().nextInt(sz - fromIndex);
aa = (BitSet)a.clone(); aa.clear(fromIndex,toIndex);
bb = b.clone(); bb.clear(fromIndex,toIndex);
@@ -152,8 +152,8 @@ public class TestFixedBitSet extends Luc
doPrevSetBit(aa,bb);
- fromIndex = random.nextInt(sz/2);
- toIndex = fromIndex + random.nextInt(sz - fromIndex);
+ fromIndex = random().nextInt(sz/2);
+ toIndex = fromIndex + random().nextInt(sz - fromIndex);
aa = (BitSet)a.clone(); aa.set(fromIndex,toIndex);
bb = b.clone(); bb.set(fromIndex,toIndex);
@@ -206,13 +206,13 @@ public class TestFixedBitSet extends Luc
public void testEquals() {
// This test can't handle numBits==0:
- final int numBits = random.nextInt(2000) + 1;
+ final int numBits = random().nextInt(2000) + 1;
FixedBitSet b1 = new FixedBitSet(numBits);
FixedBitSet b2 = new FixedBitSet(numBits);
assertTrue(b1.equals(b2));
assertTrue(b2.equals(b1));
for(int iter=0;iter<10*RANDOM_MULTIPLIER;iter++) {
- int idx = random.nextInt(numBits);
+ int idx = random().nextInt(numBits);
if (!b1.get(idx)) {
b1.set(idx);
assertFalse(b1.equals(b2));
@@ -229,13 +229,13 @@ public class TestFixedBitSet extends Luc
public void testHashCodeEquals() {
// This test can't handle numBits==0:
- final int numBits = random.nextInt(2000) + 1;
+ final int numBits = random().nextInt(2000) + 1;
FixedBitSet b1 = new FixedBitSet(numBits);
FixedBitSet b2 = new FixedBitSet(numBits);
assertTrue(b1.equals(b2));
assertTrue(b2.equals(b1));
for(int iter=0;iter<10*RANDOM_MULTIPLIER;iter++) {
- int idx = random.nextInt(numBits);
+ int idx = random().nextInt(numBits);
if (!b1.get(idx)) {
b1.set(idx);
assertFalse(b1.equals(b2));
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestIdentityHashSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestIdentityHashSet.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestIdentityHashSet.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestIdentityHashSet.java Sun Apr 15 14:41:44 2012
@@ -25,7 +25,7 @@ import org.junit.Test;
public class TestIdentityHashSet extends LuceneTestCase {
@Test
public void testCheck() {
- Random rnd = random;
+ Random rnd = random();
Set<Object> jdk = Collections.newSetFromMap(
new IdentityHashMap<Object,Boolean>());
RamUsageEstimator.IdentityHashSet<Object> us = new RamUsageEstimator.IdentityHashSet<Object>();
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java Sun Apr 15 14:41:44 2012
@@ -69,18 +69,18 @@ public class TestIndexableBinaryStringTo
char[] encoded2 = new char[MAX_RANDOM_BINARY_LENGTH * 10];
for (int testNum = 0; testNum < NUM_RANDOM_TESTS; ++testNum) {
- int numBytes1 = random.nextInt(MAX_RANDOM_BINARY_LENGTH - 1) + 1; // Min == 1
+ int numBytes1 = random().nextInt(MAX_RANDOM_BINARY_LENGTH - 1) + 1; // Min == 1
for (int byteNum = 0; byteNum < numBytes1; ++byteNum) {
- int randomInt = random.nextInt(0x100);
+ int randomInt = random().nextInt(0x100);
originalArray1[byteNum] = (byte) randomInt;
originalString1[byteNum] = (char) randomInt;
}
- int numBytes2 = random.nextInt(MAX_RANDOM_BINARY_LENGTH - 1) + 1; // Min == 1
+ int numBytes2 = random().nextInt(MAX_RANDOM_BINARY_LENGTH - 1) + 1; // Min == 1
for (int byteNum = 0; byteNum < numBytes2; ++byteNum) {
- int randomInt = random.nextInt(0x100);
+ int randomInt = random().nextInt(0x100);
original2[byteNum] = (byte) randomInt;
originalString2[byteNum] = (char) randomInt;
}
@@ -169,10 +169,10 @@ public class TestIndexableBinaryStringTo
char[] encoded = new char[MAX_RANDOM_BINARY_LENGTH * 10];
byte[] decoded = new byte[MAX_RANDOM_BINARY_LENGTH];
for (int testNum = 0; testNum < NUM_RANDOM_TESTS; ++testNum) {
- int numBytes = random.nextInt(MAX_RANDOM_BINARY_LENGTH - 1) + 1; // Min == 1
+ int numBytes = random().nextInt(MAX_RANDOM_BINARY_LENGTH - 1) + 1; // Min == 1
for (int byteNum = 0; byteNum < numBytes; ++byteNum) {
- binary[byteNum] = (byte) random.nextInt(0x100);
+ binary[byteNum] = (byte) random().nextInt(0x100);
}
int encodedLen = IndexableBinaryStringTools.getEncodedLength(binary, 0,
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestNumericUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestNumericUtils.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestNumericUtils.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestNumericUtils.java Sun Apr 15 14:41:44 2012
@@ -347,7 +347,7 @@ public class TestNumericUtils extends Lu
public void testRandomSplit() throws Exception {
long num = (long) atLeast(10);
for (long i=0; i < num; i++) {
- executeOneRandomSplit(random);
+ executeOneRandomSplit(random());
}
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestOpenBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestOpenBitSet.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestOpenBitSet.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestOpenBitSet.java Sun Apr 15 14:41:44 2012
@@ -65,7 +65,7 @@ public class TestOpenBitSet extends Luce
}
void doPrevSetBit(BitSet a, OpenBitSet b) {
- int aa = a.size() + random.nextInt(100);
+ int aa = a.size() + random().nextInt(100);
int bb = aa;
do {
// aa = a.prevSetBit(aa-1);
@@ -79,7 +79,7 @@ public class TestOpenBitSet extends Luce
}
void doPrevSetBitLong(BitSet a, OpenBitSet b) {
- int aa = a.size() + random.nextInt(100);
+ int aa = a.size() + random().nextInt(100);
int bb = aa;
do {
// aa = a.prevSetBit(aa-1);
@@ -103,7 +103,7 @@ public class TestOpenBitSet extends Luce
OpenBitSetIterator iterator = new OpenBitSetIterator(b);
do {
aa = a.nextSetBit(aa+1);
- bb = random.nextBoolean() ? iterator.nextDoc() : iterator.advance(bb + 1);
+ bb = random().nextBoolean() ? iterator.nextDoc() : iterator.advance(bb + 1);
assertEquals(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
} while (aa>=0);
}
@@ -113,7 +113,7 @@ public class TestOpenBitSet extends Luce
OpenBitSetIterator iterator = new OpenBitSetIterator(b);
do {
aa = a.nextSetBit(aa+1);
- bb = random.nextBoolean() ? iterator.nextDoc() : iterator.advance(bb + 1);
+ bb = random().nextBoolean() ? iterator.nextDoc() : iterator.advance(bb + 1);
assertEquals(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
} while (aa>=0);
}
@@ -123,33 +123,33 @@ public class TestOpenBitSet extends Luce
OpenBitSet b0=null;
for (int i=0; i<iter; i++) {
- int sz = random.nextInt(maxSize);
+ int sz = random().nextInt(maxSize);
BitSet a = new BitSet(sz);
OpenBitSet b = new OpenBitSet(sz);
// test the various ways of setting bits
if (sz>0) {
- int nOper = random.nextInt(sz);
+ int nOper = random().nextInt(sz);
for (int j=0; j<nOper; j++) {
int idx;
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.set(idx);
b.fastSet(idx);
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.set(idx);
b.fastSet((long) idx);
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.clear(idx);
b.fastClear(idx);
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.clear(idx);
b.fastClear((long) idx);
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.flip(idx);
b.fastFlip(idx);
@@ -157,7 +157,7 @@ public class TestOpenBitSet extends Luce
boolean val2 = b.flipAndGet(idx);
assertTrue(val != val2);
- idx = random.nextInt(sz);
+ idx = random().nextInt(sz);
a.flip(idx);
b.fastFlip((long) idx);
@@ -180,15 +180,15 @@ public class TestOpenBitSet extends Luce
// test ranges, including possible extension
int fromIndex, toIndex;
- fromIndex = random.nextInt(sz+80);
- toIndex = fromIndex + random.nextInt((sz>>1)+1);
+ fromIndex = random().nextInt(sz+80);
+ toIndex = fromIndex + random().nextInt((sz>>1)+1);
BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex);
OpenBitSet bb = b.clone(); bb.flip(fromIndex,toIndex);
doIterate(aa,bb, mode); // a problem here is from flip or doIterate
- fromIndex = random.nextInt(sz+80);
- toIndex = fromIndex + random.nextInt((sz>>1)+1);
+ fromIndex = random().nextInt(sz+80);
+ toIndex = fromIndex + random().nextInt((sz>>1)+1);
aa = (BitSet)a.clone(); aa.clear(fromIndex,toIndex);
bb = b.clone(); bb.clear(fromIndex,toIndex);
@@ -198,8 +198,8 @@ public class TestOpenBitSet extends Luce
doPrevSetBit(aa,bb);
doPrevSetBitLong(aa,bb);
- fromIndex = random.nextInt(sz+80);
- toIndex = fromIndex + random.nextInt((sz>>1)+1);
+ fromIndex = random().nextInt(sz+80);
+ toIndex = fromIndex + random().nextInt((sz>>1)+1);
aa = (BitSet)a.clone(); aa.set(fromIndex,toIndex);
bb = b.clone(); bb.set(fromIndex,toIndex);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestPagedBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestPagedBytes.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestPagedBytes.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestPagedBytes.java Sun Apr 15 14:41:44 2012
@@ -17,9 +17,7 @@
package org.apache.lucene.util;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.DataOutput;
@@ -27,21 +25,22 @@ import org.apache.lucene.store.DataOutpu
public class TestPagedBytes extends LuceneTestCase {
public void testDataInputOutput() throws Exception {
+ Random random = random();
for(int iter=0;iter<5*RANDOM_MULTIPLIER;iter++) {
final int blockBits = _TestUtil.nextInt(random, 1, 20);
final int blockSize = 1 << blockBits;
final PagedBytes p = new PagedBytes(blockBits);
final DataOutput out = p.getDataOutput();
- final int numBytes = random.nextInt(10000000);
+ final int numBytes = random().nextInt(10000000);
final byte[] answer = new byte[numBytes];
- random.nextBytes(answer);
+ random().nextBytes(answer);
int written = 0;
while(written < numBytes) {
- if (random.nextInt(10) == 7) {
+ if (random().nextInt(10) == 7) {
out.writeByte(answer[written++]);
} else {
- int chunk = Math.min(random.nextInt(1000), numBytes - written);
+ int chunk = Math.min(random().nextInt(1000), numBytes - written);
out.writeBytes(answer, written, chunk);
written += chunk;
}
@@ -54,10 +53,10 @@ public class TestPagedBytes extends Luce
final byte[] verify = new byte[numBytes];
int read = 0;
while(read < numBytes) {
- if (random.nextInt(10) == 7) {
+ if (random().nextInt(10) == 7) {
verify[read++] = in.readByte();
} else {
- int chunk = Math.min(random.nextInt(1000), numBytes - read);
+ int chunk = Math.min(random().nextInt(1000), numBytes - read);
in.readBytes(verify, read, chunk);
read += chunk;
}
@@ -77,6 +76,7 @@ public class TestPagedBytes extends Luce
}
public void testLengthPrefix() throws Exception {
+ Random random = random();
for(int iter=0;iter<5*RANDOM_MULTIPLIER;iter++) {
final int blockBits = _TestUtil.nextInt(random, 2, 20);
final int blockSize = 1 << blockBits;
@@ -113,6 +113,7 @@ public class TestPagedBytes extends Luce
// sure if caller writes their own prefix followed by the
// bytes, it still works:
public void testLengthPrefixAcrossTwoBlocks() throws Exception {
+ Random random = random();
final PagedBytes p = new PagedBytes(10);
final DataOutput out = p.getDataOutput();
final byte[] bytes1 = new byte[1000];
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestPriorityQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestPriorityQueue.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestPriorityQueue.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestPriorityQueue.java Sun Apr 15 14:41:44 2012
@@ -33,7 +33,7 @@ public class TestPriorityQueue extends L
}
public void testPQ() throws Exception {
- testPQ(atLeast(10000), random);
+ testPQ(atLeast(10000), random());
}
public static void testPQ(int count, Random gen) {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRamUsageEstimator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRamUsageEstimator.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRamUsageEstimator.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRamUsageEstimator.java Sun Apr 15 14:41:44 2012
@@ -44,7 +44,7 @@ public class TestRamUsageEstimator exten
}
public void testStaticOverloads() {
- Random rnd = random;
+ Random rnd = random();
{
byte[] array = new byte[rnd.nextInt(1024)];
assertEquals(sizeOf(array), sizeOf((Object) array));
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRecyclingByteBlockAllocator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRecyclingByteBlockAllocator.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRecyclingByteBlockAllocator.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRecyclingByteBlockAllocator.java Sun Apr 15 14:41:44 2012
@@ -38,8 +38,8 @@ public class TestRecyclingByteBlockAlloc
}
private RecyclingByteBlockAllocator newAllocator() {
- return new RecyclingByteBlockAllocator(1 << (2 + random.nextInt(15)),
- random.nextInt(97), new AtomicLong());
+ return new RecyclingByteBlockAllocator(1 << (2 + random().nextInt(15)),
+ random().nextInt(97), new AtomicLong());
}
@Test
@@ -74,7 +74,7 @@ public class TestRecyclingByteBlockAlloc
int numIters = atLeast(97);
for (int i = 0; i < numIters; i++) {
- int num = 1 + random.nextInt(39);
+ int num = 1 + random().nextInt(39);
for (int j = 0; j < num; j++) {
block = allocator.getByteBlock();
assertNotNull(block);
@@ -84,8 +84,8 @@ public class TestRecyclingByteBlockAlloc
.bytesUsed());
}
byte[][] array = allocated.toArray(new byte[0][]);
- int begin = random.nextInt(array.length);
- int end = begin + random.nextInt(array.length - begin);
+ int begin = random().nextInt(array.length);
+ int end = begin + random().nextInt(array.length - begin);
List<byte[]> selected = new ArrayList<byte[]>();
for (int j = begin; j < end; j++) {
selected.add(array[j]);
@@ -111,7 +111,7 @@ public class TestRecyclingByteBlockAlloc
int numIters = atLeast(97);
for (int i = 0; i < numIters; i++) {
- int num = 1 + random.nextInt(39);
+ int num = 1 + random().nextInt(39);
for (int j = 0; j < num; j++) {
block = allocator.getByteBlock();
freeButAllocated = Math.max(0, freeButAllocated - 1);
@@ -123,8 +123,8 @@ public class TestRecyclingByteBlockAlloc
}
byte[][] array = allocated.toArray(new byte[0][]);
- int begin = random.nextInt(array.length);
- int end = begin + random.nextInt(array.length - begin);
+ int begin = random().nextInt(array.length);
+ int end = begin + random().nextInt(array.length - begin);
for (int j = begin; j < end; j++) {
byte[] b = array[j];
assertTrue(allocated.remove(b));
@@ -135,7 +135,7 @@ public class TestRecyclingByteBlockAlloc
}
// randomly free blocks
int numFreeBlocks = allocator.numBufferedBlocks();
- int freeBlocks = allocator.freeBlocks(random.nextInt(7 + allocator
+ int freeBlocks = allocator.freeBlocks(random().nextInt(7 + allocator
.maxBufferedBlocks()));
assertEquals(allocator.numBufferedBlocks(), numFreeBlocks - freeBlocks);
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRollingBuffer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRollingBuffer.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRollingBuffer.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRollingBuffer.java Sun Apr 15 14:41:44 2012
@@ -1,5 +1,7 @@
package org.apache.lucene.util;
+import java.util.Random;
+
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -45,6 +47,7 @@ public class TestRollingBuffer extends L
final int maxPos = atLeast(10000);
final FixedBitSet posSet = new FixedBitSet(maxPos + 1000);
int posUpto = 0;
+ Random random = random();
while (freeBeforePos < maxPos) {
if (random.nextInt(4) == 1) {
final int limit = rarely() ? 1000 : 20;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRollingCharBuffer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRollingCharBuffer.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRollingCharBuffer.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestRollingCharBuffer.java Sun Apr 15 14:41:44 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.util;
*/
import java.io.StringReader;
+import java.util.Random;
public class TestRollingCharBuffer extends LuceneTestCase {
@@ -26,6 +27,7 @@ public class TestRollingCharBuffer exten
RollingCharBuffer buffer = new RollingCharBuffer();
+ Random random = random();
for(int iter=0;iter<ITERS;iter++) {
final int stringLen = random.nextBoolean() ? random.nextInt(50) : random.nextInt(20000);
final String s;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSentinelIntSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSentinelIntSet.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSentinelIntSet.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSentinelIntSet.java Sun Apr 15 14:41:44 2012
@@ -52,15 +52,15 @@ public class TestSentinelIntSet extends
@Test
public void testRandom() throws Exception {
for (int i=0; i<10000; i++) {
- int initSz = random.nextInt(20);
- int num = random.nextInt(30);
- int maxVal = (random.nextBoolean() ? random.nextInt(50) : random.nextInt(Integer.MAX_VALUE)) + 1;
+ int initSz = random().nextInt(20);
+ int num = random().nextInt(30);
+ int maxVal = (random().nextBoolean() ? random().nextInt(50) : random().nextInt(Integer.MAX_VALUE)) + 1;
HashSet<Integer> a = new HashSet<Integer>(initSz);
SentinelIntSet b = new SentinelIntSet(initSz, -1);
for (int j=0; j<num; j++) {
- int val = random.nextInt(maxVal);
+ int val = random().nextInt(maxVal);
boolean exists = !a.add(val);
boolean existsB = b.exists(val);
assertEquals(exists, existsB);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSetOnce.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSetOnce.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSetOnce.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSetOnce.java Sun Apr 15 14:41:44 2012
@@ -75,7 +75,7 @@ public class TestSetOnce extends LuceneT
final SetOnce<Integer> set = new SetOnce<Integer>();
SetOnceThread[] threads = new SetOnceThread[10];
for (int i = 0; i < threads.length; i++) {
- threads[i] = new SetOnceThread(random);
+ threads[i] = new SetOnceThread(random());
threads[i].setName("t-" + (i+1));
threads[i].set = set;
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSmallFloat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSmallFloat.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSmallFloat.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestSmallFloat.java Sun Apr 15 14:41:44 2012
@@ -114,7 +114,7 @@ public class TestSmallFloat extends Luce
// up iterations for more exhaustive test after changing something
int num = atLeast(100000);
for (int i = 0; i < num; i++) {
- float f = Float.intBitsToFloat(random.nextInt());
+ float f = Float.intBitsToFloat(random().nextInt());
if (Float.isNaN(f)) continue; // skip NaN
byte b1 = orig_floatToByte(f);
byte b2 = SmallFloat.floatToByte(f,3,15);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestTwoPhaseCommitTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestTwoPhaseCommitTool.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestTwoPhaseCommitTool.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestTwoPhaseCommitTool.java Sun Apr 15 14:41:44 2012
@@ -91,13 +91,13 @@ public class TestTwoPhaseCommitTool exte
public void testRollback() throws Exception {
// tests that rollback is called if failure occurs at any stage
- int numObjects = random.nextInt(8) + 3; // between [3, 10]
+ int numObjects = random().nextInt(8) + 3; // between [3, 10]
TwoPhaseCommitImpl[] objects = new TwoPhaseCommitImpl[numObjects];
for (int i = 0; i < objects.length; i++) {
- boolean failOnPrepare = random.nextBoolean();
+ boolean failOnPrepare = random().nextBoolean();
// we should not hit failures on commit usually
- boolean failOnCommit = random.nextDouble() < 0.05;
- boolean railOnRollback = random.nextBoolean();
+ boolean failOnCommit = random().nextDouble() < 0.05;
+ boolean railOnRollback = random().nextBoolean();
objects[i] = new TwoPhaseCommitImpl(failOnPrepare, failOnCommit, railOnRollback);
}
@@ -138,11 +138,11 @@ public class TestTwoPhaseCommitTool exte
}
public void testNullTPCs() throws Exception {
- int numObjects = random.nextInt(4) + 3; // between [3, 6]
+ int numObjects = random().nextInt(4) + 3; // between [3, 6]
TwoPhaseCommit[] tpcs = new TwoPhaseCommit[numObjects];
boolean setNull = false;
for (int i = 0; i < tpcs.length; i++) {
- boolean isNull = random.nextDouble() < 0.3;
+ boolean isNull = random().nextDouble() < 0.3;
if (isNull) {
setNull = true;
tpcs[i] = null;
@@ -153,7 +153,7 @@ public class TestTwoPhaseCommitTool exte
if (!setNull) {
// none of the TPCs were picked to be null, pick one at random
- int idx = random.nextInt(numObjects);
+ int idx = random().nextInt(numObjects);
tpcs[idx] = null;
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestUnicodeUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestUnicodeUtil.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestUnicodeUtil.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestUnicodeUtil.java Sun Apr 15 14:41:44 2012
@@ -90,7 +90,7 @@ public class TestUnicodeUtil extends Luc
BytesRef utf8 = new BytesRef(20);
int num = atLeast(50000);
for (int i = 0; i < num; i++) {
- final String s = _TestUtil.randomUnicodeString(random);
+ final String s = _TestUtil.randomUnicodeString(random());
UnicodeUtil.UTF16toUTF8(s, 0, s.length(), utf8);
assertEquals(s.codePointCount(0, s.length()),
UnicodeUtil.codePointCount(utf8));
@@ -103,7 +103,7 @@ public class TestUnicodeUtil extends Luc
int[] codePoints = new int[20];
int num = atLeast(50000);
for (int i = 0; i < num; i++) {
- final String s = _TestUtil.randomUnicodeString(random);
+ final String s = _TestUtil.randomUnicodeString(random());
UnicodeUtil.UTF16toUTF8(s, 0, s.length(), utf8);
UnicodeUtil.UTF8toUTF32(utf8, utf32);
@@ -170,11 +170,11 @@ public class TestUnicodeUtil extends Luc
public void testUTF8UTF16CharsRef() {
int num = atLeast(3989);
for (int i = 0; i < num; i++) {
- String unicode = _TestUtil.randomRealisticUnicodeString(random);
+ String unicode = _TestUtil.randomRealisticUnicodeString(random());
BytesRef ref = new BytesRef(unicode);
- char[] arr = new char[1 + random.nextInt(100)];
- int offset = random.nextInt(arr.length);
- int len = random.nextInt(arr.length - offset);
+ char[] arr = new char[1 + random().nextInt(100)];
+ int offset = random().nextInt(arr.length);
+ int len = random().nextInt(arr.length - offset);
CharsRef cRef = new CharsRef(arr, offset, len);
UnicodeUtil.UTF8toUTF16(ref, cRef);
assertEquals(cRef.toString(), unicode);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java Sun Apr 15 14:41:44 2012
@@ -127,7 +127,7 @@ public class TestWeakIdentityMap extends
try {
for (int t = 0; t < threadCount; t++) {
- final Random rnd = new Random(random.nextLong());
+ final Random rnd = new Random(random().nextLong());
exec.execute(new Runnable() {
public void run() {
final int count = atLeast(rnd, 10000);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestBasicOperations.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestBasicOperations.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestBasicOperations.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestBasicOperations.java Sun Apr 15 14:41:44 2012
@@ -94,7 +94,7 @@ public class TestBasicOperations extends
final int ITER2 = atLeast(100);
for(int i=0;i<ITER1;i++) {
- final RegExp re = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE);
+ final RegExp re = new RegExp(AutomatonTestUtil.randomRegexp(random()), RegExp.NONE);
final Automaton a = re.toAutomaton();
assertFalse(BasicOperations.isEmpty(a));
@@ -102,7 +102,7 @@ public class TestBasicOperations extends
for(int j=0;j<ITER2;j++) {
int[] acc = null;
try {
- acc = rx.getRandomAcceptedString(random);
+ acc = rx.getRandomAcceptedString(random());
final String s = UnicodeUtil.newString(acc, 0, acc.length);
assertTrue(BasicOperations.run(a, s));
} catch (Throwable t) {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestCompiledAutomaton.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestCompiledAutomaton.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestCompiledAutomaton.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestCompiledAutomaton.java Sun Apr 15 14:41:44 2012
@@ -69,7 +69,7 @@ public class TestCompiledAutomaton exten
}
for(int iter=0;iter<100*RANDOM_MULTIPLIER;iter++) {
- final String s = random.nextInt(10) == 1 ? terms[random.nextInt(terms.length)] : randomString();
+ final String s = random().nextInt(10) == 1 ? terms[random().nextInt(terms.length)] : randomString();
if (VERBOSE) {
System.out.println("\nTEST: floor(" + s + ")");
}
@@ -104,7 +104,7 @@ public class TestCompiledAutomaton exten
private String randomString() {
// return _TestUtil.randomSimpleString(random);
- return _TestUtil.randomRealisticUnicodeString(random);
+ return _TestUtil.randomRealisticUnicodeString(random());
}
public void testBasic() throws Exception {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestDeterminism.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestDeterminism.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestDeterminism.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestDeterminism.java Sun Apr 15 14:41:44 2012
@@ -29,14 +29,14 @@ public class TestDeterminism extends Luc
public void testRegexps() throws Exception {
int num = atLeast(500);
for (int i = 0; i < num; i++)
- assertAutomaton(new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton());
+ assertAutomaton(new RegExp(AutomatonTestUtil.randomRegexp(random()), RegExp.NONE).toAutomaton());
}
/** test against a simple, unoptimized det */
public void testAgainstSimple() throws Exception {
int num = atLeast(200);
for (int i = 0; i < num; i++) {
- Automaton a = AutomatonTestUtil.randomAutomaton(random);
+ Automaton a = AutomatonTestUtil.randomAutomaton(random());
Automaton b = a.clone();
AutomatonTestUtil.determinizeSimple(a);
b.deterministic = false; // force det
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestDeterminizeLexicon.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestDeterminizeLexicon.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestDeterminizeLexicon.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestDeterminizeLexicon.java Sun Apr 15 14:41:44 2012
@@ -38,7 +38,7 @@ public class TestDeterminizeLexicon exte
automata.clear();
terms.clear();
for (int j = 0; j < 5000; j++) {
- String randomString = _TestUtil.randomUnicodeString(random);
+ String randomString = _TestUtil.randomUnicodeString(random());
terms.add(randomString);
automata.add(BasicAutomata.makeString(randomString));
}
@@ -47,7 +47,7 @@ public class TestDeterminizeLexicon exte
}
public void assertLexicon() throws Exception {
- Collections.shuffle(automata, random);
+ Collections.shuffle(automata, random());
final Automaton lex = BasicOperations.union(automata);
lex.determinize();
assertTrue(SpecialOperations.isFinite(lex));
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestMinimize.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestMinimize.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestMinimize.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestMinimize.java Sun Apr 15 14:41:44 2012
@@ -27,7 +27,7 @@ public class TestMinimize extends Lucene
public void test() {
int num = atLeast(200);
for (int i = 0; i < num; i++) {
- Automaton a = AutomatonTestUtil.randomAutomaton(random);
+ Automaton a = AutomatonTestUtil.randomAutomaton(random());
Automaton b = a.clone();
MinimizationOperations.minimize(b);
assertTrue(BasicOperations.sameLanguage(a, b));
@@ -40,7 +40,7 @@ public class TestMinimize extends Lucene
public void testAgainstBrzozowski() {
int num = atLeast(200);
for (int i = 0; i < num; i++) {
- Automaton a = AutomatonTestUtil.randomAutomaton(random);
+ Automaton a = AutomatonTestUtil.randomAutomaton(random());
AutomatonTestUtil.minimizeSimple(a);
Automaton b = a.clone();
MinimizationOperations.minimize(b);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestSpecialOperations.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestSpecialOperations.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestSpecialOperations.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestSpecialOperations.java Sun Apr 15 14:41:44 2012
@@ -26,7 +26,7 @@ public class TestSpecialOperations exten
public void testIsFinite() {
int num = atLeast(200);
for (int i = 0; i < num; i++) {
- Automaton a = AutomatonTestUtil.randomAutomaton(random);
+ Automaton a = AutomatonTestUtil.randomAutomaton(random());
Automaton b = a.clone();
assertEquals(AutomatonTestUtil.isFiniteSlow(a), SpecialOperations.isFinite(b));
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestUTF32ToUTF8.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestUTF32ToUTF8.java?rev=1326351&r1=1326350&r2=1326351&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestUTF32ToUTF8.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/automaton/TestUTF32ToUTF8.java Sun Apr 15 14:41:44 2012
@@ -129,7 +129,7 @@ public class TestUTF32ToUTF8 extends Luc
}
public void testRandomRanges() throws Exception {
- final Random r = random;
+ final Random r = random();
int ITERS = atLeast(10);
int ITERS_PER_DFA = atLeast(100);
for(int iter=0;iter<ITERS;iter++) {
@@ -204,7 +204,7 @@ public class TestUTF32ToUTF8 extends Luc
public void testRandomRegexes() throws Exception {
int num = atLeast(250);
for (int i = 0; i < num; i++) {
- assertAutomaton(new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton());
+ assertAutomaton(new RegExp(AutomatonTestUtil.randomRegexp(random()), RegExp.NONE).toAutomaton());
}
}
@@ -216,12 +216,12 @@ public class TestUTF32ToUTF8 extends Luc
int num = atLeast(1000);
for (int i = 0; i < num; i++) {
final String string;
- if (random.nextBoolean()) {
+ if (random().nextBoolean()) {
// likely not accepted
- string = _TestUtil.randomUnicodeString(random);
+ string = _TestUtil.randomUnicodeString(random());
} else {
// will be accepted
- int[] codepoints = ras.getRandomAcceptedString(random);
+ int[] codepoints = ras.getRandomAcceptedString(random());
try {
string = UnicodeUtil.newString(codepoints, 0, codepoints.length);
} catch (Exception e) {