mirror of https://github.com/apache/lucene.git
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:
parent
707085a12b
commit
201c6447ea
|
@ -907,6 +907,7 @@ public class CoreContainer
|
||||||
writeAttribute(w, "adminPath",adminPath);
|
writeAttribute(w, "adminPath",adminPath);
|
||||||
if(adminHandler != null) writeAttribute(w, "adminHandler",adminHandler);
|
if(adminHandler != null) writeAttribute(w, "adminHandler",adminHandler);
|
||||||
if(shareSchema) writeAttribute(w, "shareSchema","true");
|
if(shareSchema) writeAttribute(w, "shareSchema","true");
|
||||||
|
if(!defaultCoreName.equals("")) writeAttribute(w, "defaultCoreName",defaultCoreName);
|
||||||
w.write(">\n");
|
w.write(">\n");
|
||||||
|
|
||||||
synchronized(cores) {
|
synchronized(cores) {
|
||||||
|
|
|
@ -17,7 +17,15 @@
|
||||||
|
|
||||||
package org.apache.solr.client.solrj.embedded;
|
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.lucene.util.LuceneTestCase;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
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.core.CoreContainer;
|
||||||
import org.apache.solr.util.AbstractSolrTestCase;
|
import org.apache.solr.util.AbstractSolrTestCase;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -48,6 +54,9 @@ import org.slf4j.LoggerFactory;
|
||||||
public class TestSolrProperties extends LuceneTestCase {
|
public class TestSolrProperties extends LuceneTestCase {
|
||||||
protected static Logger log = LoggerFactory.getLogger(TestSolrProperties.class);
|
protected static Logger log = LoggerFactory.getLogger(TestSolrProperties.class);
|
||||||
protected CoreContainer cores = null;
|
protected CoreContainer cores = null;
|
||||||
|
private File solrXml;
|
||||||
|
|
||||||
|
private static final XPathFactory xpathFactory = XPathFactory.newInstance();
|
||||||
|
|
||||||
public String getSolrHome() {
|
public String getSolrHome() {
|
||||||
return "solr/shared";
|
return "solr/shared";
|
||||||
|
@ -64,8 +73,8 @@ public class TestSolrProperties extends LuceneTestCase {
|
||||||
|
|
||||||
log.info("pwd: " + (new File(".")).getAbsolutePath());
|
log.info("pwd: " + (new File(".")).getAbsolutePath());
|
||||||
File home = new File(getSolrHome());
|
File home = new File(getSolrHome());
|
||||||
File f = new File(home, "solr.xml");
|
solrXml = new File(home, "solr.xml");
|
||||||
cores = new CoreContainer(getSolrHome(), f);
|
cores = new CoreContainer(getSolrHome(), solrXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -175,5 +184,22 @@ public class TestSolrProperties extends LuceneTestCase {
|
||||||
assertTrue("should have more recent time: " + after + "," + before, after > before);
|
assertTrue("should have more recent time: " + after + "," + before, after > before);
|
||||||
|
|
||||||
mcr = CoreAdminRequest.persist("solr-persist.xml", coreadmin);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
adminPath: RequestHandler path to manage cores.
|
adminPath: RequestHandler path to manage cores.
|
||||||
If 'null' (or absent), cores will not be manageable via REST
|
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="./">
|
<core name="core0" instanceDir="./">
|
||||||
<property name="version" value="3.5"/>
|
<property name="version" value="3.5"/>
|
||||||
<property name="l10n" value="EN"/>
|
<property name="l10n" value="EN"/>
|
||||||
|
|
Loading…
Reference in New Issue