make test more evil

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1045315 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-12-13 19:12:03 +00:00
parent 64e19107d9
commit 1cfb936649
1 changed files with 12 additions and 22 deletions

View File

@ -22,28 +22,28 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Map;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BitVector;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
public class TestIndexReaderReopen extends LuceneTestCase {
@ -750,7 +750,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
ReaderThreadTask task;
if (i < 4 ||( i >=10 && i < 14) || i > 18) {
if (i < 4 || (i >=10 && i < 14) || i > 18) {
task = new ReaderThreadTask() {
@Override
@ -768,7 +768,6 @@ public class TestIndexReaderReopen extends LuceneTestCase {
// not synchronized
IndexReader refreshed = r.reopen();
IndexSearcher searcher = new IndexSearcher(refreshed);
ScoreDoc[] hits = searcher.search(
new TermQuery(new Term("field1", "a" + rnd.nextInt(refreshed.maxDoc()))),
@ -777,19 +776,12 @@ public class TestIndexReaderReopen extends LuceneTestCase {
searcher.doc(hits[0].doc);
}
// r might have changed because this is not a
// synchronized method. However we don't want
// to make it synchronized to test
// thread-safety of IndexReader.close().
// That's why we add refreshed also to
// readersToClose, because double closing is fine
if (refreshed != r) {
refreshed.close();
}
readersToClose.add(refreshed);
}
synchronized(this) {
wait(1000);
wait(_TestUtil.nextInt(random, 1, 100));
}
}
}
@ -807,12 +799,10 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
synchronized(this) {
wait(100);
wait(_TestUtil.nextInt(random, 1, 100));
}
}
}
};
}
@ -869,7 +859,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
private abstract static class ReaderThreadTask {
protected boolean stopped;
protected volatile boolean stopped;
public void stop() {
this.stopped = true;
}