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 2014/04/04 19:38:00 UTC
svn commit: r1584832 [2/2] - in /lucene/dev/branches/solr5914:
lucene/analysis/common/src/test/org/apache/lucene/analysis/util/
lucene/analysis/stempel/src/test/org/egothor/stemmer/
lucene/benchmark/src/test/org/apache/lucene/benchmark/ lucene/benchmar...
Modified: lucene/dev/branches/solr5914/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java (original)
+++ lucene/dev/branches/solr5914/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java Fri Apr 4 17:37:58 2014
@@ -28,8 +28,8 @@ import org.apache.lucene.util.TestUtil;
public class TestIndexSplitter extends LuceneTestCase {
public void test() throws Exception {
- File dir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
- File destDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ File dir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ File destDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
Directory fsDir = newFSDirectory(dir);
// IndexSplitter.split makes its own commit directly with SIPC/SegmentInfos,
// so the unreferenced files are expected.
@@ -76,7 +76,7 @@ public class TestIndexSplitter extends L
fsDirDest.close();
// now test cmdline
- File destDir2 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ File destDir2 = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
IndexSplitter.main(new String[] {dir.getAbsolutePath(), destDir2.getAbsolutePath(), splitSegName});
assertEquals(5, destDir2.listFiles().length);
Directory fsDirDest2 = newFSDirectory(destDir2);
Modified: lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java (original)
+++ lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java Fri Apr 4 17:37:58 2014
@@ -191,7 +191,7 @@ public class IndexAndTaxonomyReplication
publishTaxoDir = newDirectory();
handlerIndexDir = newMockDirectory();
handlerTaxoDir = newMockDirectory();
- clientWorkDir = TestUtil.createTempDir("replicationClientTest");
+ clientWorkDir = createTempDir("replicationClientTest");
sourceDirFactory = new PerSessionDirectoryFactory(clientWorkDir);
replicator = new LocalReplicator();
callback = new IndexAndTaxonomyReadyCallback(handlerIndexDir, handlerTaxoDir);
Modified: lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java (original)
+++ lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java Fri Apr 4 17:37:58 2014
@@ -136,7 +136,7 @@ public class IndexReplicationClientTest
super.setUp();
publishDir = newMockDirectory();
handlerDir = newMockDirectory();
- sourceDirFactory = new PerSessionDirectoryFactory(TestUtil.createTempDir("replicationClientTest"));
+ sourceDirFactory = new PerSessionDirectoryFactory(createTempDir("replicationClientTest"));
replicator = new LocalReplicator();
callback = new IndexReadyCallback(handlerDir);
handler = new IndexReplicationHandler(handlerDir, callback);
Modified: lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java (original)
+++ lucene/dev/branches/solr5914/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java Fri Apr 4 17:37:58 2014
@@ -68,7 +68,7 @@ public class HttpReplicatorTest extends
public void setUp() throws Exception {
super.setUp();
System.setProperty("org.eclipse.jetty.LEVEL", "DEBUG"); // sets stderr logging to DEBUG level
- clientWorkDir = TestUtil.createTempDir("httpReplicatorTest");
+ clientWorkDir = createTempDir("httpReplicatorTest");
handlerIndexDir = newDirectory();
serverIndexDir = newDirectory();
serverReplicator = new LocalReplicator();
Modified: lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/LookupBenchmarkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/LookupBenchmarkTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/LookupBenchmarkTest.java (original)
+++ lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/LookupBenchmarkTest.java Fri Apr 4 17:37:58 2014
@@ -163,7 +163,7 @@ public class LookupBenchmarkTest extends
} catch (InstantiationException e) {
Analyzer a = new MockAnalyzer(random, MockTokenizer.KEYWORD, false);
if (cls == AnalyzingInfixSuggester.class) {
- lookup = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, FSDirectory.open(TestUtil.createTempDir("LookupBenchmarkTest")), a);
+ lookup = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, FSDirectory.open(createTempDir("LookupBenchmarkTest")), a);
} else {
Constructor<? extends Lookup> ctor = cls.getConstructor(Analyzer.class);
lookup = ctor.newInstance(a);
Modified: lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java (original)
+++ lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java Fri Apr 4 17:37:58 2014
@@ -70,7 +70,7 @@ public class PersistenceTest extends Luc
lookup.build(new InputArrayIterator(keys));
// Store the suggester.
- File storeDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ File storeDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
lookup.store(new FileOutputStream(new File(storeDir, "lookup.dat")));
// Re-read it from disk.
Modified: lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java (original)
+++ lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java Fri Apr 4 17:37:58 2014
@@ -91,7 +91,7 @@ public class AnalyzingInfixSuggesterTest
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
};
- File tempDir = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
+ File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a, 3);
@@ -210,7 +210,7 @@ public class AnalyzingInfixSuggesterTest
new Input("lend me your ear", 8, new BytesRef("foobar")),
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
};
- File tempDir = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
+ File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
int minPrefixLength = random().nextInt(10);
@@ -471,7 +471,7 @@ public class AnalyzingInfixSuggesterTest
}
public void testRandomNRT() throws Exception {
- final File tempDir = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
+ final File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
int minPrefixChars = random().nextInt(7);
if (VERBOSE) {
@@ -806,7 +806,7 @@ public class AnalyzingInfixSuggesterTest
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz"), asSet("foo", "baz"))
};
- File tempDir = TestUtil.createTempDir("analyzingInfixContext");
+ File tempDir = createTempDir("analyzingInfixContext");
for(int iter=0;iter<2;iter++) {
AnalyzingInfixSuggester suggester;
Modified: lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java (original)
+++ lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java Fri Apr 4 17:37:58 2014
@@ -921,7 +921,7 @@ public class AnalyzingSuggesterTest exte
assertEquals(3, results.get(2).value);
// Try again after save/load:
- File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
+ File tmpDir = createTempDir("AnalyzingSuggesterTest");
tmpDir.mkdir();
File path = new File(tmpDir, "suggester");
@@ -983,7 +983,7 @@ public class AnalyzingSuggesterTest exte
assertEquals(5, results.get(1).value);
// Try again after save/load:
- File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
+ File tmpDir = createTempDir("AnalyzingSuggesterTest");
tmpDir.mkdir();
File path = new File(tmpDir, "suggester");
@@ -1053,7 +1053,7 @@ public class AnalyzingSuggesterTest exte
assertEquals(5, results.get(1).value);
// Try again after save/load:
- File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
+ File tmpDir = createTempDir("AnalyzingSuggesterTest");
tmpDir.mkdir();
File path = new File(tmpDir, "suggester");
Modified: lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/BlendedInfixSuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/BlendedInfixSuggesterTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/BlendedInfixSuggesterTest.java (original)
+++ lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/BlendedInfixSuggesterTest.java Fri Apr 4 17:37:58 2014
@@ -17,6 +17,10 @@ package org.apache.lucene.search.suggest
* limitations under the License.
*/
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.util.CharArraySet;
@@ -25,11 +29,6 @@ import org.apache.lucene.search.suggest.
import org.apache.lucene.search.suggest.Lookup;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.TestUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
public class BlendedInfixSuggesterTest extends LuceneTestCase {
@@ -45,7 +44,7 @@ public class BlendedInfixSuggesterTest e
new Input("star wars: episode v - the empire strikes back", 8, payload)
};
- File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
+ File tempDir = createTempDir("BlendedInfixSuggesterTest");
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
BlendedInfixSuggester suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a,
@@ -84,7 +83,7 @@ public class BlendedInfixSuggesterTest e
new Input("top of the lake", w, pl)
};
- File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
+ File tempDir = createTempDir("BlendedInfixSuggesterTest");
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
// BlenderType.LINEAR is used by default (remove position*10%)
@@ -125,7 +124,7 @@ public class BlendedInfixSuggesterTest e
new Input("the returned", 10, ret),
};
- File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
+ File tempDir = createTempDir("BlendedInfixSuggesterTest");
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
// if factor is small, we don't get the expected element
@@ -175,7 +174,7 @@ public class BlendedInfixSuggesterTest e
new Input("the returned", 10, ret),
};
- File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
+ File tempDir = createTempDir("BlendedInfixSuggesterTest");
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
// if factor is small, we don't get the expected element
Modified: lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java (original)
+++ lucene/dev/branches/solr5914/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java Fri Apr 4 17:37:58 2014
@@ -82,7 +82,7 @@ public class TestFreeTextSuggester exten
toString(sug.lookup("b", 10)));
// Try again after save/load:
- File tmpDir = TestUtil.createTempDir("FreeTextSuggesterTest");
+ File tmpDir = createTempDir("FreeTextSuggesterTest");
tmpDir.mkdir();
File path = new File(tmpDir, "suggester");
Modified: lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java (original)
+++ lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java Fri Apr 4 17:37:58 2014
@@ -503,7 +503,7 @@ public abstract class BaseTokenStreamTes
!(postingsFormat.equals("Memory") ||
postingsFormat.equals("SimpleText"));
if (rarely(random) && codecOk) {
- dir = newFSDirectory(TestUtil.createTempDir("bttc"));
+ dir = newFSDirectory(createTempDir("bttc"));
iw = new RandomIndexWriter(new Random(seed), dir, a);
}
boolean success = false;
Modified: lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java (original)
+++ lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java Fri Apr 4 17:37:58 2014
@@ -2615,7 +2615,7 @@ public abstract class BaseDocValuesForma
Analyzer analyzer = new MockAnalyzer(random());
// FSDirectory because SimpleText will consume gobbs of
// space when storing big binary values:
- Directory d = newFSDirectory(TestUtil.createTempDir("hugeBinaryValues"));
+ Directory d = newFSDirectory(createTempDir("hugeBinaryValues"));
boolean doFixed = random().nextBoolean();
int numDocs;
int fixedLength = 0;
@@ -2713,7 +2713,7 @@ public abstract class BaseDocValuesForma
Analyzer analyzer = new MockAnalyzer(random());
// FSDirectory because SimpleText will consume gobbs of
// space when storing big binary values:
- Directory d = newFSDirectory(TestUtil.createTempDir("hugeBinaryValues"));
+ Directory d = newFSDirectory(createTempDir("hugeBinaryValues"));
boolean doFixed = random().nextBoolean();
int numDocs;
int fixedLength = 0;
Modified: lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java (original)
+++ lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java Fri Apr 4 17:37:58 2014
@@ -1203,7 +1203,7 @@ public abstract class BasePostingsFormat
/** Indexes all fields/terms at the specified
* IndexOptions, and fully tests at that IndexOptions. */
private void testFull(IndexOptions options, boolean withPayloads) throws Exception {
- File path = TestUtil.createTempDir("testPostingsFormat.testExact");
+ File path = createTempDir("testPostingsFormat.testExact");
Directory dir = newFSDirectory(path);
// TODO test thread safety of buildIndex too
@@ -1256,7 +1256,7 @@ public abstract class BasePostingsFormat
int iters = 5;
for(int iter=0;iter<iters;iter++) {
- File path = TestUtil.createTempDir("testPostingsFormat");
+ File path = createTempDir("testPostingsFormat");
Directory dir = newFSDirectory(path);
boolean indexPayloads = random().nextBoolean();
Modified: lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java (original)
+++ lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java Fri Apr 4 17:37:58 2014
@@ -599,7 +599,7 @@ public abstract class BaseStoredFieldsFo
// for this test we force a FS dir
// we can't just use newFSDirectory, because this test doesn't really index anything.
// so if we get NRTCachingDir+SimpleText, we make massive stored fields and OOM (LUCENE-4484)
- Directory dir = new MockDirectoryWrapper(random(), new MMapDirectory(TestUtil.createTempDir("testBigDocuments")));
+ Directory dir = new MockDirectoryWrapper(random(), new MMapDirectory(createTempDir("testBigDocuments")));
IndexWriterConfig iwConf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
Modified: lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java (original)
+++ lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java Fri Apr 4 17:37:58 2014
@@ -435,7 +435,7 @@ public abstract class ThreadedIndexingAn
Random random = new Random(random().nextLong());
final LineFileDocs docs = new LineFileDocs(random, true);
- final File tempDir = TestUtil.createTempDir(testName);
+ final File tempDir = createTempDir(testName);
dir = getDirectory(newMockFSDirectory(tempDir)); // some subclasses rely on this being MDW
if (dir instanceof BaseDirectoryWrapper) {
((BaseDirectoryWrapper) dir).setCheckIndexOnClose(false); // don't double-checkIndex, we do it ourselves.
Modified: lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java (original)
+++ lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java Fri Apr 4 17:37:58 2014
@@ -447,7 +447,7 @@ public abstract class ShardSearchingTest
public NodeState(Random random, int nodeID, int numNodes) throws IOException {
myNodeID = nodeID;
- dir = newFSDirectory(TestUtil.createTempDir("ShardSearchingTestBase"));
+ dir = newFSDirectory(createTempDir("ShardSearchingTestBase"));
// TODO: set warmer
MockAnalyzer analyzer = new MockAnalyzer(random());
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
Modified: lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Fri Apr 4 17:37:58 2014
@@ -17,55 +17,153 @@ package org.apache.lucene.util;
* limitations under the License.
*/
-import java.io.*;
-import java.nio.file.NoSuchFileException;
-import java.lang.annotation.*;
+import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
+import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsInt;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.*;
-import java.util.concurrent.*;
+import java.nio.file.NoSuchFileException;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Deque;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Random;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.TreeSet;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
+import org.apache.lucene.index.AlcoholicMergePolicy;
+import org.apache.lucene.index.AssertingAtomicReader;
+import org.apache.lucene.index.AssertingDirectoryReader;
+import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.BinaryDocValues;
+import org.apache.lucene.index.CompositeReader;
+import org.apache.lucene.index.ConcurrentMergeScheduler;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.DocsAndPositionsEnum;
+import org.apache.lucene.index.DocsEnum;
+import org.apache.lucene.index.FieldFilterAtomicReader;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.Fields;
+import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReader.ReaderClosedListener;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LogByteSizeMergePolicy;
+import org.apache.lucene.index.LogDocMergePolicy;
+import org.apache.lucene.index.LogMergePolicy;
+import org.apache.lucene.index.MergePolicy;
+import org.apache.lucene.index.MockRandomMergePolicy;
+import org.apache.lucene.index.MultiDocValues;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.index.ParallelAtomicReader;
+import org.apache.lucene.index.ParallelCompositeReader;
+import org.apache.lucene.index.SegmentReader;
+import org.apache.lucene.index.SerialMergeScheduler;
+import org.apache.lucene.index.SimpleMergedSegmentWarmer;
+import org.apache.lucene.index.SlowCompositeReaderWrapper;
+import org.apache.lucene.index.SortedDocValues;
+import org.apache.lucene.index.SortedSetDocValues;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.index.TermsEnum.SeekStatus;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.TieredMergePolicy;
+import org.apache.lucene.search.AssertingIndexSearcher;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.CacheEntry;
+import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.QueryUtils.FCInvisibleMultiReader;
-import org.apache.lucene.store.*;
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.FlushInfo;
+import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IOContext.Context;
+import org.apache.lucene.store.LockFactory;
+import org.apache.lucene.store.MergeInfo;
+import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.MockDirectoryWrapper.Throttling;
+import org.apache.lucene.store.NRTCachingDirectory;
+import org.apache.lucene.store.RateLimitedDirectoryWrapper;
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
import org.apache.lucene.util.automaton.AutomatonTestUtil;
import org.apache.lucene.util.automaton.CompiledAutomaton;
import org.apache.lucene.util.automaton.RegExp;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
-import com.carrotsearch.randomizedtesting.*;
-import com.carrotsearch.randomizedtesting.annotations.*;
+
+import com.carrotsearch.randomizedtesting.JUnit4MethodProvider;
+import com.carrotsearch.randomizedtesting.LifecycleScope;
+import com.carrotsearch.randomizedtesting.MixWithSuiteName;
+import com.carrotsearch.randomizedtesting.RandomizedContext;
+import com.carrotsearch.randomizedtesting.RandomizedRunner;
+import com.carrotsearch.randomizedtesting.RandomizedTest;
+import com.carrotsearch.randomizedtesting.annotations.Listeners;
+import com.carrotsearch.randomizedtesting.annotations.SeedDecorators;
+import com.carrotsearch.randomizedtesting.annotations.TestGroup;
+import com.carrotsearch.randomizedtesting.annotations.TestMethodProviders;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakGroup;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakGroup.Group;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;
+import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import com.carrotsearch.randomizedtesting.rules.NoClassHooksShadowingRule;
import com.carrotsearch.randomizedtesting.rules.NoInstanceHooksOverridesRule;
import com.carrotsearch.randomizedtesting.rules.StaticFieldsInvariantRule;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule;
-
-import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
-import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsInt;
+import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter;
/**
* Base class for all Lucene unit tests, Junit3 or Junit4 variant.
@@ -112,13 +210,6 @@ import static com.carrotsearch.randomize
* context ({@link RandomizedContext#current()}) and then calling
* {@link RandomizedContext#getRunnerSeedAsString()}.</li>
* </ul>
- *
- * <p>There is a number of other facilities tests can use, like:
- * <ul>
- * <li>{@link #closeAfterTest(Closeable)} and {@link #closeAfterSuite(Closeable)} to
- * register resources to be closed after each scope (if close fails, the scope
- * will fail too).</li>
- * </ul>
*/
@RunWith(RandomizedRunner.class)
@TestMethodProviders({
@@ -233,8 +324,8 @@ public abstract class LuceneTestCase ext
* files. This may prevent temp. files and folders from being cleaned
* up after the suite is completed.
*
- * @see TestUtil#createTempDir()
- * @see TestUtil#createTempFile(String, String)
+ * @see LuceneTestCase#createTempDir()
+ * @see LuceneTestCase#createTempFile(String, String)
*/
@Documented
@Inherited
@@ -444,6 +535,7 @@ public abstract class LuceneTestCase ext
.around(ignoreAfterMaxFailures)
.around(suiteFailureMarker = new TestRuleMarkFailure())
.around(new TestRuleAssertionsRequired())
+ .around(new TemporaryFilesCleanupRule())
.around(new StaticFieldsInvariantRule(STATIC_LEAK_THRESHOLD, true) {
@Override
protected boolean accept(java.lang.reflect.Field field) {
@@ -1178,7 +1270,7 @@ public abstract class LuceneTestCase ext
final Class<? extends Directory> clazz = CommandLineUtil.loadDirectoryClass(clazzName);
// If it is a FSDirectory type, try its ctor(File)
if (FSDirectory.class.isAssignableFrom(clazz)) {
- final File dir = new File(TestUtil.createTempDir(), "index");
+ final File dir = createTempDir("index-" + clazzName);
dir.mkdirs(); // ensure it's created so we 'have' it.
return newFSDirectoryImpl(clazz.asSubclass(FSDirectory.class), dir);
}
@@ -2091,4 +2183,148 @@ public abstract class LuceneTestCase ext
return false;
}
}
+
+ /**
+ * A base location for temporary files of a given test. Helps in figuring out
+ * which tests left which files and where.
+ */
+ private static File tempDirBase;
+
+ /**
+ * Retry to create temporary file name this many times.
+ */
+ private static final int TEMP_NAME_RETRY_THRESHOLD = 9999;
+
+ /**
+ */
+ private static File getTempDirBase() {
+ synchronized (LuceneTestCase.class) {
+ if (tempDirBase == null) {
+ File directory = new File(System.getProperty("tempDir", System.getProperty("java.io.tmpdir")));
+ assert directory.exists() &&
+ directory.isDirectory() &&
+ directory.canWrite();
+
+ RandomizedContext ctx = RandomizedContext.current();
+ Class<?> clazz = ctx.getTargetClass();
+ String prefix = clazz.getName();
+ prefix = prefix.replaceFirst("^org.apache.lucene.", "oa.lucene.");
+ prefix = prefix.replaceFirst("^org.apache.solr.", "oa.solr.");
+
+ int attempt = 0;
+ File f;
+ do {
+ if (attempt++ >= TEMP_NAME_RETRY_THRESHOLD) {
+ throw new RuntimeException(
+ "Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: "
+ + directory.getAbsolutePath());
+ }
+ f = new File(directory, prefix + "-" + ctx.getRunnerSeedAsString()
+ + "-" + String.format(Locale.ENGLISH, "%3d", attempt));
+ } while (!f.mkdirs());
+
+ tempDirBase = f;
+ registerToRemoveAfterSuite(tempDirBase);
+ }
+ }
+ return tempDirBase;
+ }
+
+ /**
+ */
+ protected static File createTempDir(String prefix) {
+ File base = getTempDirBase();
+
+ int attempt = 0;
+ File f;
+ do {
+ if (attempt++ >= TEMP_NAME_RETRY_THRESHOLD) {
+ throw new RuntimeException(
+ "Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: "
+ + base.getAbsolutePath());
+ }
+ f = new File(base, prefix + "-" + String.format(Locale.ENGLISH, "%3d", attempt));
+ } while (!f.mkdirs());
+
+ registerToRemoveAfterSuite(f);
+ return f;
+ }
+
+ /**
+ */
+ protected static File createTempFile(String prefix, String suffix) throws IOException {
+ File base = getTempDirBase();
+
+ int attempt = 0;
+ File f;
+ do {
+ if (attempt++ >= TEMP_NAME_RETRY_THRESHOLD) {
+ throw new RuntimeException(
+ "Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: "
+ + base.getAbsolutePath());
+ }
+ f = new File(base, prefix + "-" + String.format(Locale.ENGLISH, "%3d", attempt) + suffix);
+ } while (!f.createNewFile());
+
+ registerToRemoveAfterSuite(f);
+ return f;
+ }
+
+ /**
+ */
+ protected static File createTempDir() {
+ return createTempDir("tempDir");
+ }
+
+ /**
+ */
+ protected static File createTempFile() throws IOException {
+ return createTempFile("tempFile", ".tmp");
+ }
+
+ /**
+ * A queue of temporary resources to be removed after the
+ * suite completes.
+ * @see #registerToRemoveAfterSuite(File)
+ */
+ private final static Deque<File> cleanupQueue = new ArrayDeque<File>();
+
+ /**
+ * Register temporary folder for removal after the suite completes.
+ */
+ private static void registerToRemoveAfterSuite(File f) {
+ assert f != null;
+
+ if (LuceneTestCase.LEAVE_TEMPORARY) {
+ System.err.println("INFO: Will leave temporary file: " + f.getAbsolutePath());
+ return;
+ }
+
+ Class<?> suiteClass = RandomizedContext.current().getTargetClass();
+ if (suiteClass.isAnnotationPresent(SuppressTempFileChecks.class)) {
+ System.err.println("WARNING: Will leave temporary files (bugUrl: "
+ + suiteClass.getAnnotation(SuppressTempFileChecks.class).bugUrl() + "): "
+ + f.getAbsolutePath());
+ return;
+ }
+
+ synchronized (cleanupQueue) {
+ cleanupQueue.addLast(f);
+ }
+ }
+
+ private static class TemporaryFilesCleanupRule extends TestRuleAdapter {
+ @Override
+ protected void afterIfSuccessful() throws Throwable {
+ synchronized (cleanupQueue) {
+ File [] everything = new File [cleanupQueue.size()];
+ for (int i = 0; !cleanupQueue.isEmpty(); i++) {
+ everything[i] = cleanupQueue.removeFirst();
+ }
+
+ // Will throw an IOException on un-removable files.
+ TestUtil.rm(everything);
+ }
+ }
+ }
}
Modified: lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java (original)
+++ lucene/dev/branches/solr5914/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java Fri Apr 4 17:37:58 2014
@@ -37,7 +37,6 @@ import java.util.Map;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.zip.ZipEntry;
@@ -87,10 +86,8 @@ import org.apache.lucene.search.Filtered
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.LuceneTestCase.SuppressTempFileChecks;
import org.junit.Assert;
-import com.carrotsearch.randomizedtesting.RandomizedContext;
import com.carrotsearch.randomizedtesting.generators.RandomInts;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
@@ -102,14 +99,14 @@ public final class TestUtil {
//
}
- // the max number of retries we're going to do in getTempDir
- private static final int GET_TEMP_DIR_RETRY_THRESHOLD = 1000;
-
/**
- * Deletes a file or a directory (and everything underneath it).
+ * Deletes one or more files or directories (and everything underneath it).
+ *
+ * @throws IOException if any of the given files (or their subhierarchy files in case
+ * of directories) cannot be removed.
*/
- public static void rm(File location) throws IOException {
- ArrayList<File> unremoved = rm(location, new ArrayList<File>());
+ public static void rm(File... locations) throws IOException {
+ ArrayList<File> unremoved = rm(new ArrayList<File>(), locations);
if (!unremoved.isEmpty()) {
StringBuilder b = new StringBuilder("Could not remove the following files (in the order of attempts):\n");
for (File f : unremoved) {
@@ -121,16 +118,16 @@ public final class TestUtil {
}
}
- private static ArrayList<File> rm(File location, ArrayList<File> unremoved) {
- if (location.exists()) {
- if (location.isDirectory()) {
- for (File f : location.listFiles()) {
- rm(f, unremoved);
+ private static ArrayList<File> rm(ArrayList<File> unremoved, File... locations) {
+ for (File location : locations) {
+ if (location.exists()) {
+ if (location.isDirectory()) {
+ rm(unremoved, location.listFiles());
+ }
+
+ if (!location.delete()) {
+ unremoved.add(location);
}
- }
-
- if (!location.delete()) {
- unremoved.add(location);
}
}
return unremoved;
@@ -789,131 +786,6 @@ public final class TestUtil {
});
Assert.assertEquals("Reflection does not produce same map", reflectedValues, map);
}
-
- /**
- * Returns a new, empty temporary folder, based on the current test class's name.
- *
- * @see #createTempDir(String, File)
- */
- public static File createTempDir() {
- Class<?> clazz = RandomizedContext.current().getTargetClass();
- String prefix = clazz.getName();
- prefix = prefix.replaceFirst("^org.apache.lucene.", "lucene-");
- prefix = prefix.replaceFirst("^org.apache.solr.", "solr-");
- return createTempDir(prefix);
- }
-
- /**
- * @see #createTempDir(String, File)
- */
- public static File createTempDir(String prefix) {
- return createTempDir(prefix, null);
- }
-
- /**
- * Returns a new and empty temporary folder, based on the given name. The folder will be
- * deleted at the end of the test suite. Failure to delete the temporary folder will cause
- * an exception (typically happens on Windows on unclosed file handles).
- */
- public static File createTempDir(String prefix, File parent) {
- if (prefix.length() < 3) {
- throw new IllegalArgumentException("The prefix must be at least 3 characters: " + prefix);
- }
-
- if (parent == null) {
- parent = tempDirectory();
- }
-
- if (!parent.exists()) {
- throw new RuntimeException("Parent location does not exist: " + parent.getAbsolutePath());
- }
-
- if (!parent.isDirectory()) {
- throw new RuntimeException("Parent location is not a folder: " + parent.getAbsolutePath());
- }
-
- if (!parent.canWrite()) {
- throw new RuntimeException("Parent folder not writeable: " + parent.getAbsolutePath());
- }
-
- // Always pull a long from master random. that way, the randomness of the test
- // is not affected by whether it initialized the counter (in genTempFile) or not.
- // note that the Random used by genTempFile is *not* the master Random, and therefore
- // does not affect the randomness of the test.
- int attempt = 0;
- File f;
- do {
- f = genTempFile(prefix + "_", "", parent);
- } while (!f.mkdir() && (attempt++) < GET_TEMP_DIR_RETRY_THRESHOLD);
-
- if (attempt > GET_TEMP_DIR_RETRY_THRESHOLD) {
- throw new RuntimeException(
- "Failed to get a temporary dir too many times, check your temp directory and consider manually cleaning it: "
- + parent.getAbsolutePath());
- }
-
- return maybeRemoveAfterSuite(f);
- }
-
- private static File maybeRemoveAfterSuite(File f) {
- if (LuceneTestCase.LEAVE_TEMPORARY) {
- System.err.println("INFO: Will leave temporary file: " + f.getAbsolutePath());
- return f;
- }
-
- Class<?> suiteClass = RandomizedContext.current().getTargetClass();
- if (suiteClass.isAnnotationPresent(SuppressTempFileChecks.class)) {
- System.err.println("WARNING: Will leave temporary files (bugUrl: "
- + suiteClass.getAnnotation(SuppressTempFileChecks.class).bugUrl() + "): "
- + f.getAbsolutePath());
- return f;
- }
-
- LuceneTestCase.closeAfterSuite(new RemoveUponClose(f, LuceneTestCase.suiteFailureMarker));
- return f;
- }
-
- public static File createTempFile(String prefix, String suffix) throws IOException {
- return createTempFile(prefix, suffix, tempDirectory());
- }
-
- /**
- * Do NOT expose this method public. Use {@link #createTempDir()} instead.
- */
- private static File tempDirectory() {
- File directory = new File(System.getProperty("tempDir", System.getProperty("java.io.tmpdir")));
- assert directory.exists() &&
- directory.isDirectory() &&
- directory.canWrite();
- return directory;
- }
-
- /**
- * Insecure, fast version of {@link File#createTempFile(String, String)}, uses
- * Random instead of SecureRandom.
- */
- public static File createTempFile(String prefix, String suffix, File directory) throws IOException {
- if (prefix.length() < 3) {
- throw new IllegalArgumentException("prefix must be at least 3 characters");
- }
- String newSuffix = suffix == null ? ".tmp" : suffix;
- File result;
- do {
- result = genTempFile(prefix, newSuffix, directory);
- } while (!result.createNewFile());
- return maybeRemoveAfterSuite(result);
- }
-
- /* Temp file counter */
- private static final AtomicInteger counter = new AtomicInteger();
-
- private static File genTempFile(String prefix, String suffix, File directory) {
- return new File(directory,
- prefix
- + RandomizedContext.current().getRunnerSeedAsString()
- + "-" + counter.incrementAndGet()
- + suffix);
- }
public static void assertEquals(TopDocs expected, TopDocs actual) {
Assert.assertEquals("wrong total hits", expected.totalHits, actual.totalHits);
Modified: lucene/dev/branches/solr5914/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestFileListWithLineEntityProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestFileListWithLineEntityProcessor.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestFileListWithLineEntityProcessor.java (original)
+++ lucene/dev/branches/solr5914/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestFileListWithLineEntityProcessor.java Fri Apr 4 17:37:58 2014
@@ -32,7 +32,7 @@ public class TestFileListWithLineEntityP
}
public void test() throws Exception {
- File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ File tmpdir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
createFile(tmpdir, "a.txt", "a line one\na line two\na line three".getBytes(StandardCharsets.UTF_8), false);
createFile(tmpdir, "b.txt", "b line one\nb line two".getBytes(StandardCharsets.UTF_8), false);
createFile(tmpdir, "c.txt", "c line one\nc line two\nc line three\nc line four".getBytes(StandardCharsets.UTF_8), false);
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java Fri Apr 4 17:37:58 2014
@@ -60,7 +60,7 @@ public class ResourceLoaderTest extends
}
public void testEscapeInstanceDir() throws Exception {
- File temp = TestUtil.createTempDir("testEscapeInstanceDir");
+ File temp = createTempDir("testEscapeInstanceDir");
try {
temp.mkdirs();
new File(temp, "dummy.txt").createNewFile();
@@ -170,7 +170,7 @@ public class ResourceLoaderTest extends
}
public void testClassLoaderLibs() throws Exception {
- File tmpRoot = TestUtil.createTempDir("testClassLoaderLibs");
+ File tmpRoot = createTempDir("testClassLoaderLibs");
File lib = new File(tmpRoot, "lib");
lib.mkdirs();
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java Fri Apr 4 17:37:58 2014
@@ -233,7 +233,7 @@ public class TestCoreContainer extends S
@Test
public void testSharedLib() throws Exception {
- File tmpRoot = TestUtil.createTempDir("testSharedLib");
+ File tmpRoot = createTempDir("testSharedLib");
File lib = new File(tmpRoot, "lib");
lib.mkdirs();
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java Fri Apr 4 17:37:58 2014
@@ -81,12 +81,10 @@ public class TestSolrXMLSerializer exten
}
assertResults(w.toString().getBytes(StandardCharsets.UTF_8));
-
+
// again with default file
- File tmpFile = TestUtil.createTempFile("solr.xml", null, createTempDir());
-
+ File tmpFile = new File(createTempDir(), "solr.xml");
serializer.persistFile(tmpFile, solrXMLDef);
-
assertResults(FileUtils.readFileToByteArray(tmpFile));
tmpFile.delete();
}
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java Fri Apr 4 17:37:58 2014
@@ -66,7 +66,7 @@ public class TestSolrXmlPersistence exte
@Before
public void setupTest() {
- solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ solrHomeDirectory = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
}
private CoreContainer init(String solrXmlString, String... subDirs) throws Exception {
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java Fri Apr 4 17:37:58 2014
@@ -50,7 +50,7 @@ public class TestCSVLoader extends SolrT
// if you override setUp or tearDown, you better call
// the super classes version
super.setUp();
- File tempDir = TestUtil.createTempDir("TestCSVLoader");
+ File tempDir = createTempDir("TestCSVLoader");
file = new File(tempDir, "solr_tmp.csv");
filename = file.getPath();
cleanup();
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java Fri Apr 4 17:37:58 2014
@@ -56,7 +56,7 @@ public class TestRemoteStreaming extends
@BeforeClass
public static void beforeTest() throws Exception {
//this one has handleSelect=true which a test here needs
- solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ solrHomeDirectory = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
setupJettyTestHome(solrHomeDirectory, "collection1");
createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
}
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/schema/TestCollationField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/schema/TestCollationField.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/schema/TestCollationField.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/schema/TestCollationField.java Fri Apr 4 17:37:58 2014
@@ -63,7 +63,7 @@ public class TestCollationField extends
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
- File tmpFile = TestUtil.createTempDir("collation1");
+ File tmpFile = createTempDir("collation1");
tmpFile.delete();
tmpFile.mkdir();
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/schema/TestCollationFieldDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/schema/TestCollationFieldDocValues.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/schema/TestCollationFieldDocValues.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/schema/TestCollationFieldDocValues.java Fri Apr 4 17:37:58 2014
@@ -65,7 +65,7 @@ public class TestCollationFieldDocValues
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
- File tmpFile = TestUtil.createTempDir("collation1");
+ File tmpFile = createTempDir("collation1");
tmpFile.delete();
tmpFile.mkdir();
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java Fri Apr 4 17:37:58 2014
@@ -30,7 +30,6 @@ import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.cookie.DateUtils;
-import org.apache.lucene.util.TestUtil;
import org.apache.solr.common.params.CommonParams;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -255,7 +254,7 @@ public class CacheHeaderTest extends Cac
protected File makeFile(String contents, String charset) {
try {
- File f = TestUtil.createTempFile("cachetest_csv", null, initCoreDataDir);
+ File f = new File(initCoreDataDir, "cachetest_csv");
Writer out = new OutputStreamWriter(new FileOutputStream(f), charset);
out.write(contents);
out.close();
Modified: lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java Fri Apr 4 17:37:58 2014
@@ -71,7 +71,7 @@ public class FileBasedSpellCheckerTest e
spellchecker.add(AbstractLuceneSpellChecker.LOCATION, "spellings.txt");
spellchecker.add(AbstractLuceneSpellChecker.FIELD, "teststop");
spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8");
- File indexDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ File indexDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
SolrCore core = h.getCore();
String dictName = checker.init(spellchecker, core);
Modified: lucene/dev/branches/solr5914/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java (original)
+++ lucene/dev/branches/solr5914/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java Fri Apr 4 17:37:58 2014
@@ -76,7 +76,7 @@ public class TestCoreAdmin extends Abstr
public void testConfigSet() throws Exception {
SolrServer server = getSolrAdmin();
- File testDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+ File testDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File newCoreInstanceDir = new File(testDir, "newcore");
Modified: lucene/dev/branches/solr5914/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java (original)
+++ lucene/dev/branches/solr5914/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java Fri Apr 4 17:37:58 2014
@@ -49,7 +49,7 @@ public class ContentStreamTest extends S
{
InputStream is = new SolrResourceLoader(null, null).openResource( "solrj/README" );
assertNotNull( is );
- File file = TestUtil.createTempFile("README", "", createTempDir());
+ File file = new File(createTempDir(), "README");
FileOutputStream os = new FileOutputStream(file);
IOUtils.copy(is, os);
os.close();
Modified: lucene/dev/branches/solr5914/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1584832&r1=1584831&r2=1584832&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/solr5914/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Fri Apr 4 17:37:58 2014
@@ -150,10 +150,7 @@ public abstract class SolrTestCaseJ4 ext
@BeforeClass
@SuppressWarnings("unused")
private static void beforeClass() {
- // Create the root parent folder for all other temporary solr files.
- rootTmpDir = TestUtil.createTempDir();
-
- initCoreDataDir = TestUtil.createTempDir("init-core-data", rootTmpDir);
+ initCoreDataDir = createTempDir("init-core-data");
System.err.println("Creating dataDir: " + initCoreDataDir.getAbsolutePath());
@@ -465,14 +462,6 @@ public abstract class SolrTestCaseJ4 ext
SolrException.ignorePatterns.remove(pattern);
}
- public static File createTempDir() {
- return createTempDir(null);
- }
-
- public static File createTempDir(String prefix) {
- return TestUtil.createTempDir(prefix == null ? "temp" : prefix, rootTmpDir);
- }
-
public static void resetExceptionIgnores() {
SolrException.ignorePatterns = null;
ignoreException("ignore_exception"); // always ignore "ignore_exception"
@@ -533,8 +522,6 @@ public abstract class SolrTestCaseJ4 ext
*/
protected static volatile File initCoreDataDir;
- protected static volatile File rootTmpDir;
-
// hack due to File dataDir
protected static String hdfsDataDir;