diff --git a/src/test/org/apache/lucene/search/TestThreadSafe.java b/src/test/org/apache/lucene/search/TestThreadSafe.java new file mode 100755 index 00000000000..a2b45f4dcc1 --- /dev/null +++ b/src/test/org/apache/lucene/search/TestThreadSafe.java @@ -0,0 +1,156 @@ +package org.apache.lucene.search; +/** + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import junit.framework.TestCase; +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.analysis.WhitespaceAnalyzer; +import org.apache.lucene.document.*; + +import java.util.Random; +import java.util.List; +import java.io.IOException; + +/** + * @author yonik + * @version $Id$ + */ +public class TestThreadSafe extends TestCase { + Random r = new Random(); + Directory dir1; + Directory dir2; + + IndexReader ir1; + IndexReader ir2; + + String failure=null; + + + class Thr extends Thread { + 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) { + this.iter = iter; + this.rand = rand; + } + + public void run() { + try { + for (int i=0; i