Apache Lucene open-source search software
SOLR-2011: change all uses of java.io.tmpdir -> TEMP_DIR
Robert Muirb905aba62414
diff --git a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestContentStreamDataSource.javaindex 32868bbb8f8..f713949b40f 100644--- a/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java+++ b/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java@@ -18,6 +18,7 @@ package org.apache.solr.handler.dataimport;import junit.framework.TestCase;import org.apache.commons.io.FileUtils;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.embedded.JettySolrRunner;import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;import org.apache.solr.client.solrj.request.DirectXmlRequest;@@ -107,12 +108,11 @@ public class TestContentStreamDataSource extends TestCase {public void setUp() throws Exception {- String home = System.getProperty("java.io.tmpdir")- + File.separator- + getClass().getName() + "-" + System.currentTimeMillis();+ File home = new File(SolrTestCaseJ4.TEMP_DIR,+ getClass().getName() + "-" + System.currentTimeMillis());- homeDir = new File(home + "inst");+ homeDir = new File(home, "inst");dataDir = new File(homeDir, "data");confDir = new File(homeDir, "conf");diff --git a/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.javaindex aa74defc0e0..a1864c03721 100644--- a/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java+++ b/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java@@ -116,9 +116,8 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {super.setUp();System.setProperty("solr.test.sys.prop1", "propone");System.setProperty("solr.test.sys.prop2", "proptwo");- testDir = new File(System.getProperty("java.io.tmpdir")- + System.getProperty("file.separator")- + getClass().getName() + "-" + System.currentTimeMillis());+ testDir = new File(TEMP_DIR,+ getClass().getName() + "-" + System.currentTimeMillis());testDir.mkdirs();}diff --git a/solr/src/test/org/apache/solr/TestSolrCoreProperties.java b/solr/src/test/org/apache/solr/TestSolrCoreProperties.javaindex 253816860c2..6cda2ad7e5f 100644--- a/solr/src/test/org/apache/solr/TestSolrCoreProperties.java+++ b/solr/src/test/org/apache/solr/TestSolrCoreProperties.java@@ -101,14 +101,12 @@ public class TestSolrCoreProperties extends AbstractSolrTestCase {public void setUpMe() throws Exception {- String home = System.getProperty("java.io.tmpdir")- + File.separator- + getClass().getName() + "-" + System.currentTimeMillis();+ homeDir = new File(TEMP_DIR,+ getClass().getName() + "-" + System.currentTimeMillis());- homeDir = new File(home);- dataDir = new File(home, "data");- confDir = new File(home, "conf");+ dataDir = new File(homeDir, "data");+ confDir = new File(homeDir, "conf");homeDir.mkdirs();diff --git a/solr/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java b/solr/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.javaindex dfd94b651c9..a2c6097faba 100644--- a/solr/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java+++ b/solr/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java@@ -21,6 +21,7 @@ import junit.framework.TestCase;import junit.framework.Assert;import org.apache.commons.httpclient.HttpClient;import org.apache.commons.io.FileUtils;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.embedded.JettySolrRunner;import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;import org.apache.solr.client.solrj.impl.LBHttpSolrServer;@@ -188,9 +189,8 @@ public class TestLBHttpSolrServer extends TestCase {}public void setUp() throws Exception {- String home = System.getProperty("java.io.tmpdir")- + File.separator- + getClass().getName() + "-" + System.currentTimeMillis();+ File home = new File(SolrTestCaseJ4.TEMP_DIR,+ getClass().getName() + "-" + System.currentTimeMillis());homeDir = new File(home, name);diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java b/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.javaindex 23a2dc85b01..be998bb160b 100644--- a/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java@@ -24,6 +24,7 @@ import java.util.Random;import junit.framework.TestCase;import org.apache.commons.io.IOUtils;+import org.apache.solr.SolrTestCaseJ4;import org.mortbay.jetty.Connector;import org.mortbay.jetty.Server;import org.mortbay.jetty.bio.SocketConnector;@@ -46,9 +47,8 @@ public class JettyWebappTest extends TestCase{System.setProperty("solr.solr.home", "../../../example/solr");- File dataDir = new File(System.getProperty("java.io.tmpdir")- + System.getProperty("file.separator")- + getClass().getName() + "-" + System.currentTimeMillis());+ File dataDir = new File(SolrTestCaseJ4.TEMP_DIR,+ getClass().getName() + "-" + System.currentTimeMillis());dataDir.mkdirs();System.setProperty("solr.data.dir", dataDir.getCanonicalPath());String path = "../../webapp/web";diff --git a/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java b/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.javaindex 0b1c2a844bc..0509c8f4902 100644--- a/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java+++ b/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java@@ -48,9 +48,8 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{public void setUp() throws Exception {super.setUp();- dataDir = new File(System.getProperty("java.io.tmpdir")- + System.getProperty("file.separator")- + getClass().getName() + "-" + System.currentTimeMillis() + System.getProperty("file.separator") + "solr"+ dataDir = new File(TEMP_DIR,+ getClass().getName() + "-" + System.currentTimeMillis() + System.getProperty("file.separator") + "solr"+ System.getProperty("file.separator") + "data");dataDir.mkdirs();diff --git a/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/src/test/org/apache/solr/handler/TestReplicationHandler.javaindex 3a7faad1184..670f7a32d16 100644--- a/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java+++ b/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java@@ -652,18 +652,17 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {System.setProperty("solr.test.sys.prop1", "propone");System.setProperty("solr.test.sys.prop2", "proptwo");- String home = System.getProperty("java.io.tmpdir")- + File.separator- + getClass().getName() + "-" + System.currentTimeMillis();+ File home = new File(TEMP_DIR,+ getClass().getName() + "-" + System.currentTimeMillis());if (null == masterPort) {- homeDir = new File(home + "master");- dataDir = new File(home + "master", "data");- confDir = new File(home + "master", "conf");+ homeDir = new File(home, "master");+ dataDir = new File(homeDir, "data");+ confDir = new File(homeDir, "conf");} else {- homeDir = new File(home + "slave");- dataDir = new File(home + "slave", "data");- confDir = new File(home + "slave", "conf");+ homeDir = new File(home, "slave");+ dataDir = new File(homeDir, "data");+ confDir = new File(homeDir, "conf");}homeDir.mkdirs();diff --git a/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java b/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.javaindex ea133246d33..1b8bb6f4de7 100644--- a/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java+++ b/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java@@ -70,8 +70,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {spellchecker.add(AbstractLuceneSpellChecker.LOCATION, spelling.getAbsolutePath());spellchecker.add(IndexBasedSpellChecker.FIELD, "teststop");spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8");- File tmpDir = new File(System.getProperty("java.io.tmpdir"));- File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());+ File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());indexDir.mkdirs();spellchecker.add(FileBasedSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());SolrCore core = h.getCore();@@ -107,8 +106,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {spellchecker.add(AbstractLuceneSpellChecker.LOCATION, spelling.getAbsolutePath());spellchecker.add(IndexBasedSpellChecker.FIELD, "teststop");spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8");- File tmpDir = new File(System.getProperty("java.io.tmpdir"));- File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());+ File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());indexDir.mkdirs();spellchecker.add(FileBasedSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());spellchecker.add(FileBasedSpellChecker.FIELD_TYPE, "teststop");diff --git a/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java b/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.javaindex dfd58063e97..603a3b66997 100644--- a/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java+++ b/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java@@ -82,8 +82,7 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {NamedList spellchecker = new NamedList();spellchecker.add("classname", IndexBasedSpellChecker.class.getName());- File tmpDir = new File(System.getProperty("java.io.tmpdir"));- File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());+ File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());indexDir.mkdirs();spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());spellchecker.add(IndexBasedSpellChecker.FIELD, "title");@@ -157,8 +156,7 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {NamedList spellchecker = new NamedList();spellchecker.add("classname", IndexBasedSpellChecker.class.getName());- File tmpDir = new File(System.getProperty("java.io.tmpdir"));- File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());+ File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());indexDir.mkdirs();spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());spellchecker.add(IndexBasedSpellChecker.FIELD, "title");@@ -213,8 +211,7 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {NamedList spellchecker = new NamedList();spellchecker.add("classname", IndexBasedSpellChecker.class.getName());- File tmpDir = new File(System.getProperty("java.io.tmpdir"));- File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());+ File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());indexDir.mkdirs();spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());spellchecker.add(IndexBasedSpellChecker.FIELD, "title");@@ -254,10 +251,9 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {NamedList spellchecker = new NamedList();spellchecker.add("classname", IndexBasedSpellChecker.class.getName());- File tmpDir = new File(System.getProperty("java.io.tmpdir"));- File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());+ File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());//create a standalone index- File altIndexDir = new File(tmpDir, "alternateIdx" + new Date().getTime());+ File altIndexDir = new File(TEMP_DIR, "alternateIdx" + new Date().getTime());IndexWriter iw = new IndexWriter(FSDirectory.open(altIndexDir), new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);for (int i = 0; i < ALT_DOCS.length; i++) {Document doc = new Document();