SOLR-2011: change all uses of java.io.tmpdir -> TEMP_DIR

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@981650 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-08-02 18:24:32 +00:00
parent cf46248d35
commit b905aba624
9 changed files with 33 additions and 44 deletions

View File

@ -18,6 +18,7 @@ package org.apache.solr.handler.dataimport;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.commons.io.FileUtils; 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.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.request.DirectXmlRequest; import org.apache.solr.client.solrj.request.DirectXmlRequest;
@ -107,12 +108,11 @@ public class TestContentStreamDataSource extends TestCase {
public void setUp() throws Exception { public void setUp() throws Exception {
String home = System.getProperty("java.io.tmpdir") File home = new File(SolrTestCaseJ4.TEMP_DIR,
+ File.separator getClass().getName() + "-" + System.currentTimeMillis());
+ getClass().getName() + "-" + System.currentTimeMillis();
homeDir = new File(home + "inst"); homeDir = new File(home, "inst");
dataDir = new File(homeDir, "data"); dataDir = new File(homeDir, "data");
confDir = new File(homeDir, "conf"); confDir = new File(homeDir, "conf");

View File

@ -116,9 +116,8 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
super.setUp(); super.setUp();
System.setProperty("solr.test.sys.prop1", "propone"); System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo"); System.setProperty("solr.test.sys.prop2", "proptwo");
testDir = new File(System.getProperty("java.io.tmpdir") testDir = new File(TEMP_DIR,
+ System.getProperty("file.separator") getClass().getName() + "-" + System.currentTimeMillis());
+ getClass().getName() + "-" + System.currentTimeMillis());
testDir.mkdirs(); testDir.mkdirs();
} }

View File

@ -101,14 +101,12 @@ public class TestSolrCoreProperties extends AbstractSolrTestCase {
public void setUpMe() throws Exception { public void setUpMe() throws Exception {
String home = System.getProperty("java.io.tmpdir") homeDir = new File(TEMP_DIR,
+ File.separator getClass().getName() + "-" + System.currentTimeMillis());
+ getClass().getName() + "-" + System.currentTimeMillis();
homeDir = new File(home); dataDir = new File(homeDir, "data");
dataDir = new File(home, "data"); confDir = new File(homeDir, "conf");
confDir = new File(home, "conf");
homeDir.mkdirs(); homeDir.mkdirs();

View File

@ -21,6 +21,7 @@ import junit.framework.TestCase;
import junit.framework.Assert; import junit.framework.Assert;
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.io.FileUtils; 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.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.impl.LBHttpSolrServer; import org.apache.solr.client.solrj.impl.LBHttpSolrServer;
@ -188,9 +189,8 @@ public class TestLBHttpSolrServer extends TestCase {
} }
public void setUp() throws Exception { public void setUp() throws Exception {
String home = System.getProperty("java.io.tmpdir") File home = new File(SolrTestCaseJ4.TEMP_DIR,
+ File.separator getClass().getName() + "-" + System.currentTimeMillis());
+ getClass().getName() + "-" + System.currentTimeMillis();
homeDir = new File(home, name); homeDir = new File(home, name);

View File

@ -24,6 +24,7 @@ import java.util.Random;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.mortbay.jetty.Connector; import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server; import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector; import org.mortbay.jetty.bio.SocketConnector;
@ -46,9 +47,8 @@ public class JettyWebappTest extends TestCase
{ {
System.setProperty("solr.solr.home", "../../../example/solr"); System.setProperty("solr.solr.home", "../../../example/solr");
File dataDir = new File(System.getProperty("java.io.tmpdir") File dataDir = new File(SolrTestCaseJ4.TEMP_DIR,
+ System.getProperty("file.separator") getClass().getName() + "-" + System.currentTimeMillis());
+ getClass().getName() + "-" + System.currentTimeMillis());
dataDir.mkdirs(); dataDir.mkdirs();
System.setProperty("solr.data.dir", dataDir.getCanonicalPath()); System.setProperty("solr.data.dir", dataDir.getCanonicalPath());
String path = "../../webapp/web"; String path = "../../webapp/web";

View File

@ -48,9 +48,8 @@ public class TestArbitraryIndexDir extends AbstractSolrTestCase{
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
dataDir = new File(System.getProperty("java.io.tmpdir") dataDir = new File(TEMP_DIR,
+ System.getProperty("file.separator") getClass().getName() + "-" + System.currentTimeMillis() + System.getProperty("file.separator") + "solr"
+ getClass().getName() + "-" + System.currentTimeMillis() + System.getProperty("file.separator") + "solr"
+ System.getProperty("file.separator") + "data"); + System.getProperty("file.separator") + "data");
dataDir.mkdirs(); dataDir.mkdirs();

View File

@ -652,18 +652,17 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
System.setProperty("solr.test.sys.prop1", "propone"); System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo"); System.setProperty("solr.test.sys.prop2", "proptwo");
String home = System.getProperty("java.io.tmpdir") File home = new File(TEMP_DIR,
+ File.separator getClass().getName() + "-" + System.currentTimeMillis());
+ getClass().getName() + "-" + System.currentTimeMillis();
if (null == masterPort) { if (null == masterPort) {
homeDir = new File(home + "master"); homeDir = new File(home, "master");
dataDir = new File(home + "master", "data"); dataDir = new File(homeDir, "data");
confDir = new File(home + "master", "conf"); confDir = new File(homeDir, "conf");
} else { } else {
homeDir = new File(home + "slave"); homeDir = new File(home, "slave");
dataDir = new File(home + "slave", "data"); dataDir = new File(homeDir, "data");
confDir = new File(home + "slave", "conf"); confDir = new File(homeDir, "conf");
} }
homeDir.mkdirs(); homeDir.mkdirs();

View File

@ -70,8 +70,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
spellchecker.add(AbstractLuceneSpellChecker.LOCATION, spelling.getAbsolutePath()); spellchecker.add(AbstractLuceneSpellChecker.LOCATION, spelling.getAbsolutePath());
spellchecker.add(IndexBasedSpellChecker.FIELD, "teststop"); spellchecker.add(IndexBasedSpellChecker.FIELD, "teststop");
spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8"); spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8");
File tmpDir = new File(System.getProperty("java.io.tmpdir")); File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());
File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
indexDir.mkdirs(); indexDir.mkdirs();
spellchecker.add(FileBasedSpellChecker.INDEX_DIR, indexDir.getAbsolutePath()); spellchecker.add(FileBasedSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
SolrCore core = h.getCore(); SolrCore core = h.getCore();
@ -107,8 +106,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
spellchecker.add(AbstractLuceneSpellChecker.LOCATION, spelling.getAbsolutePath()); spellchecker.add(AbstractLuceneSpellChecker.LOCATION, spelling.getAbsolutePath());
spellchecker.add(IndexBasedSpellChecker.FIELD, "teststop"); spellchecker.add(IndexBasedSpellChecker.FIELD, "teststop");
spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8"); spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8");
File tmpDir = new File(System.getProperty("java.io.tmpdir")); File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());
File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
indexDir.mkdirs(); indexDir.mkdirs();
spellchecker.add(FileBasedSpellChecker.INDEX_DIR, indexDir.getAbsolutePath()); spellchecker.add(FileBasedSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
spellchecker.add(FileBasedSpellChecker.FIELD_TYPE, "teststop"); spellchecker.add(FileBasedSpellChecker.FIELD_TYPE, "teststop");

View File

@ -82,8 +82,7 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
NamedList spellchecker = new NamedList(); NamedList spellchecker = new NamedList();
spellchecker.add("classname", IndexBasedSpellChecker.class.getName()); spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
File tmpDir = new File(System.getProperty("java.io.tmpdir")); File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());
File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
indexDir.mkdirs(); indexDir.mkdirs();
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath()); spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
spellchecker.add(IndexBasedSpellChecker.FIELD, "title"); spellchecker.add(IndexBasedSpellChecker.FIELD, "title");
@ -157,8 +156,7 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
NamedList spellchecker = new NamedList(); NamedList spellchecker = new NamedList();
spellchecker.add("classname", IndexBasedSpellChecker.class.getName()); spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
File tmpDir = new File(System.getProperty("java.io.tmpdir")); File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());
File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
indexDir.mkdirs(); indexDir.mkdirs();
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath()); spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
spellchecker.add(IndexBasedSpellChecker.FIELD, "title"); spellchecker.add(IndexBasedSpellChecker.FIELD, "title");
@ -213,8 +211,7 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
NamedList spellchecker = new NamedList(); NamedList spellchecker = new NamedList();
spellchecker.add("classname", IndexBasedSpellChecker.class.getName()); spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
File tmpDir = new File(System.getProperty("java.io.tmpdir")); File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());
File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
indexDir.mkdirs(); indexDir.mkdirs();
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath()); spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
spellchecker.add(IndexBasedSpellChecker.FIELD, "title"); spellchecker.add(IndexBasedSpellChecker.FIELD, "title");
@ -254,10 +251,9 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
NamedList spellchecker = new NamedList(); NamedList spellchecker = new NamedList();
spellchecker.add("classname", IndexBasedSpellChecker.class.getName()); spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
File tmpDir = new File(System.getProperty("java.io.tmpdir")); File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());
File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
//create a standalone index //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); IndexWriter iw = new IndexWriter(FSDirectory.open(altIndexDir), new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
for (int i = 0; i < ALT_DOCS.length; i++) { for (int i = 0; i < ALT_DOCS.length; i++) {
Document doc = new Document(); Document doc = new Document();