SOLR-2127: When using the defaultCoreName attribute, after performing a swap, solr.xml no longer contains the defaultCoreName attribute, and the core which was dafult is now renamed to ""

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1025547 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2010-10-20 13:24:00 +00:00
parent 707085a12b
commit 201c6447ea
3 changed files with 35 additions and 8 deletions

View File

@ -907,6 +907,7 @@ public class CoreContainer
writeAttribute(w, "adminPath",adminPath);
if(adminHandler != null) writeAttribute(w, "adminHandler",adminHandler);
if(shareSchema) writeAttribute(w, "shareSchema","true");
if(!defaultCoreName.equals("")) writeAttribute(w, "defaultCoreName",defaultCoreName);
w.write(">\n");
synchronized(cores) {

View File

@ -17,7 +17,15 @@
package org.apache.solr.client.solrj.embedded;
import static junit.framework.Assert.assertEquals;
import java.io.File;
import java.io.FileInputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4;
@ -32,14 +40,12 @@ import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.After;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
/**
* @version $Id$
@ -48,6 +54,9 @@ import org.slf4j.LoggerFactory;
public class TestSolrProperties extends LuceneTestCase {
protected static Logger log = LoggerFactory.getLogger(TestSolrProperties.class);
protected CoreContainer cores = null;
private File solrXml;
private static final XPathFactory xpathFactory = XPathFactory.newInstance();
public String getSolrHome() {
return "solr/shared";
@ -64,8 +73,8 @@ public class TestSolrProperties extends LuceneTestCase {
log.info("pwd: " + (new File(".")).getAbsolutePath());
File home = new File(getSolrHome());
File f = new File(home, "solr.xml");
cores = new CoreContainer(getSolrHome(), f);
solrXml = new File(home, "solr.xml");
cores = new CoreContainer(getSolrHome(), solrXml);
}
@After
@ -175,5 +184,22 @@ public class TestSolrProperties extends LuceneTestCase {
assertTrue("should have more recent time: " + after + "," + before, after > before);
mcr = CoreAdminRequest.persist("solr-persist.xml", coreadmin);
// System.out.println(IOUtils.toString(new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"))));
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
FileInputStream fis = new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"));
try {
Document document = builder.parse(fis);
assertTrue(exists("/solr/cores[@defaultCoreName='core0']", document));
} finally {
fis.close();
}
}
public static boolean exists(String xpathStr, Node node)
throws XPathExpressionException {
XPath xpath = xpathFactory.newXPath();
return (Boolean) xpath.evaluate(xpathStr, node, XPathConstants.BOOLEAN);
}
}

View File

@ -30,7 +30,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via REST
-->
<cores adminPath="/admin/cores">
<cores adminPath="/admin/cores" defaultCoreName="core0">
<core name="core0" instanceDir="./">
<property name="version" value="3.5"/>
<property name="l10n" value="EN"/>