autoprops setup

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@809516 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2009-08-31 09:25:54 +00:00
parent 325f20fc50
commit aad563a397
1 changed files with 47 additions and 52 deletions

View File

@ -28,7 +28,6 @@ import org.apache.commons.io.IOUtils;
import java.io.*;
import java.util.Properties;
import junit.framework.TestCase;
/**
* <p> Test for Loading core properties from a properties file </p>
@ -36,15 +35,13 @@ import junit.framework.TestCase;
* @version $Id$
* @since solr 1.4
*/
public class TestSolrCoreProperties extends AbstractSolrTestCase {
public class TestSolrCoreProperties extends AbstractSolrTestCase {
private static final String CONF_DIR = "." + File.separator + "solr" + File.separator + "conf" + File.separator;
JettySolrRunner solrJetty;
SolrServer client;
@Override
public void setUp() throws Exception {
// System.setProperty("foo.foo1", "f1");
// System.setProperty("foo.foo2", "f2");
setUpMe();
System.setProperty("solr.solr.home", getHomeDir());
System.setProperty("solr.data.dir", getDataDir());
@ -60,7 +57,7 @@ public class TestSolrCoreProperties extends AbstractSolrTestCase {
@Override
public void tearDown() throws Exception {
solrJetty.stop();
AbstractSolrTestCase.recurseDelete(homeDir);
AbstractSolrTestCase.recurseDelete(homeDir);
}
public void testSimple() throws SolrServerException {
@ -71,69 +68,67 @@ public class TestSolrCoreProperties extends AbstractSolrTestCase {
}
File homeDir;
File confDir;
File homeDir;
File confDir;
/**
* if masterPort is null, this instance is a master -- otherwise this instance is a slave, and assumes the master is
* on localhost at the specified port.
*/
/**
* if masterPort is null, this instance is a master -- otherwise this instance is a slave, and assumes the master is
* on localhost at the specified port.
*/
public String getHomeDir() {
return homeDir.toString();
}
public String getHomeDir() {
return homeDir.toString();
}
@Override
public String getSchemaFile() {
return CONF_DIR + "schema-replication1.xml";
}
@Override
public String getSchemaFile() {
return CONF_DIR + "schema-replication1.xml";
}
public String getConfDir() {
return confDir.toString();
}
public String getConfDir() {
return confDir.toString();
}
public String getDataDir() {
return dataDir.toString();
}
public String getDataDir() {
return dataDir.toString();
}
@Override
public String getSolrConfigFile() {
return CONF_DIR + "solrconfig-solcoreproperties.xml";
}
@Override
public String getSolrConfigFile() {
return CONF_DIR + "solrconfig-solcoreproperties.xml";
}
public void setUpMe() throws Exception {
public void setUpMe() throws Exception {
String home = System.getProperty("java.io.tmpdir")
+ File.separator
+ getClass().getName() + "-" + System.currentTimeMillis();
String home = System.getProperty("java.io.tmpdir")
+ File.separator
+ getClass().getName() + "-" + System.currentTimeMillis();
homeDir = new File(home);
dataDir = new File(home, "data");
confDir = new File(home, "conf");
homeDir = new File(home);
dataDir = new File(home, "data");
confDir = new File(home, "conf");
homeDir.mkdirs();
dataDir.mkdirs();
confDir.mkdirs();
homeDir.mkdirs();
dataDir.mkdirs();
confDir.mkdirs();
File f = new File(confDir, "solrconfig.xml");
copyFile(new File(getSolrConfigFile()), f);
File f = new File(confDir, "solrconfig.xml");
copyFile(new File(getSolrConfigFile()), f);
f = new File(confDir, "schema.xml");
copyFile(new File(getSchemaFile()), f);
Properties p = new Properties();
p.setProperty("foo.foo1","f1");
p.setProperty("foo.foo2","f2");
FileOutputStream fos = new FileOutputStream(confDir + File.separator + "solrcore.properties");
p.store(fos,null);
fos.close();
IOUtils.closeQuietly(fos);
}
f = new File(confDir, "schema.xml");
copyFile(new File(getSchemaFile()), f);
Properties p = new Properties();
p.setProperty("foo.foo1", "f1");
p.setProperty("foo.foo2", "f2");
FileOutputStream fos = new FileOutputStream(confDir + File.separator + "solrcore.properties");
p.store(fos, null);
fos.close();
IOUtils.closeQuietly(fos);
}
private void copyFile(File src, File dst) throws IOException {