Skip to content

Apache Lucene open-source search software

Use preferably sysprop "temptDir" also in backwards tests.

Uwe Schindler6e4c79b21989
diff --git a/lucene/backwards/src/test/org/apache/lucene/index/TestFieldsReader.java b/lucene/backwards/src/test/org/apache/lucene/index/TestFieldsReader.java
index ef8876040f4..c3b0b933c6a 100644
--- a/lucene/backwards/src/test/org/apache/lucene/index/TestFieldsReader.java
+++ b/lucene/backwards/src/test/org/apache/lucene/index/TestFieldsReader.java
@@ -384,9 +384,9 @@ public class TestFieldsReader extends LuceneTestCase {
// LUCENE-1262
public void testExceptions() throws Throwable {
- String tempDir = System.getProperty("java.io.tmpdir");
+ String tempDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
if (tempDir == null)
- throw new IOException("java.io.tmpdir undefined, cannot run test");
+ throw new IOException("System property tempDir undefined, cannot run test");
File indexDir = new File(tempDir, "testfieldswriterexceptions");
try {
diff --git a/lucene/backwards/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java b/lucene/backwards/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
index 556c98618de..f7735711651 100644
--- a/lucene/backwards/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
+++ b/lucene/backwards/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
@@ -81,10 +81,9 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
*/
public void testNorms() throws IOException {
// tmp dir
- String tempDir = System.getProperty("java.io.tmpdir");
- if (tempDir == null) {
- throw new IOException("java.io.tmpdir undefined, cannot run test");
- }
+ String tempDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
+ if (tempDir == null)
+ throw new IOException("System property tempDir undefined, cannot run test");
// test with a single index: index1
File indexDir1 = new File(tempDir, "lucenetestindex1");
diff --git a/lucene/backwards/src/test/org/apache/lucene/index/TestIndexReaderReopen.java b/lucene/backwards/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
index 8cbef684814..56d97826f8f 100644
--- a/lucene/backwards/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
+++ b/lucene/backwards/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
@@ -1095,9 +1095,9 @@ public class TestIndexReaderReopen extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- String tempDir = System.getProperty("java.io.tmpdir");
+ String tempDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
if (tempDir == null)
- throw new IOException("java.io.tmpdir undefined, cannot run test");
+ throw new IOException("System property tempDir undefined, cannot run test");
indexDir = new File(tempDir, "IndexReaderReopen");
}
diff --git a/lucene/backwards/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java b/lucene/backwards/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
index 79cf68cb47f..f7734e55ead 100644
--- a/lucene/backwards/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
+++ b/lucene/backwards/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
@@ -39,8 +39,10 @@ public class TestIndexWriterLockRelease extends LuceneTestCase {
public void setUp() throws Exception {
super.setUp();
if (this.__test_dir == null) {
- String tmp_dir = System.getProperty("java.io.tmpdir", "tmp");
- this.__test_dir = new File(tmp_dir, "testIndexWriter");
+ String tempDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
+ if (tempDir == null)
+ throw new IOException("System property tempDir undefined, cannot run test");
+ this.__test_dir = new File(tempDir, "testIndexWriter");
if (this.__test_dir.exists()) {
throw new IOException("test directory \"" + this.__test_dir.getPath() + "\" already exists (please remove by hand)");
diff --git a/lucene/backwards/src/test/org/apache/lucene/store/TestRAMDirectory.java b/lucene/backwards/src/test/org/apache/lucene/store/TestRAMDirectory.java
index 25cbceb85fd..4e09aa1b3bd 100644
--- a/lucene/backwards/src/test/org/apache/lucene/store/TestRAMDirectory.java
+++ b/lucene/backwards/src/test/org/apache/lucene/store/TestRAMDirectory.java
@@ -49,9 +49,9 @@ public class TestRAMDirectory extends LuceneTestCase {
@Override
public void setUp () throws Exception {
super.setUp();
- String tempDir = System.getProperty("java.io.tmpdir");
+ String tempDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
if (tempDir == null)
- throw new IOException("java.io.tmpdir undefined, cannot run test");
+ throw new IOException("System property tempDir undefined, cannot run test");
indexDir = new File(tempDir, "RAMDirIndex");
Directory dir = FSDirectory.open(indexDir);
diff --git a/lucene/backwards/src/test/org/apache/lucene/util/_TestUtil.java b/lucene/backwards/src/test/org/apache/lucene/util/_TestUtil.java
index ada8c30476a..4e435079113 100644
--- a/lucene/backwards/src/test/org/apache/lucene/util/_TestUtil.java
+++ b/lucene/backwards/src/test/org/apache/lucene/util/_TestUtil.java
@@ -33,9 +33,9 @@ public class _TestUtil {
/** Returns temp dir, containing String arg in its name;
* does not create the directory. */
public static File getTempDir(String desc) {
- String tempDir = System.getProperty("java.io.tmpdir");
+ String tempDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
if (tempDir == null)
- throw new RuntimeException("java.io.tmpdir undefined, cannot run test");
+ throw new RuntimeException("System property tempDir undefined, cannot run test");
return new File(tempDir, desc + "." + new Random().nextLong());
}