Apache Solr open-source search software
SOLR-14999: Fixing SolrXmlConfig tests for hostPort.
Houston Putman7e94a56e815f
diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.javaindex 823aa28b336..b222c27dc45 100644--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java@@ -434,7 +434,7 @@ public class SolrXmlConfig {private static CloudConfig fillSolrCloudSection(NamedList<Object> nl, XmlConfigFile config, String defaultZkHost) {- int hostPort = parseInt("hostPort", removeValue(nl, "hostPort"));+ int hostPort = parseInt("hostPort", required("solrcloud", "hostPort", removeValue(nl, "hostPort")));if (hostPort <= 0) {// Default to the port that jetty is listening on, or 8983 if that is not provided.hostPort = parseInt("jetty.port", System.getProperty("jetty.port", "8983"));diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java b/solr/core/src/test/org/apache/solr/core/TestSolrXml.javaindex f45ae271765..4405ddbfe37 100644--- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java+++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java@@ -129,11 +129,12 @@ public class TestSolrXml extends SolrTestCaseJ4 {}public void testExplicitNullGivesDefaults() {+ System.setProperty("jetty.port", "8000");String solrXml = "<solr>" +"<null name=\"maxBooleanClauses\"/>" +"<solrcloud>" +"<str name=\"host\">host</str>" +- "<int name=\"hostPort\">8983</int>" ++ "<int name=\"hostPort\">0</int>" +"<str name=\"hostContext\">solr</str>" +"<null name=\"leaderVoteWait\"/>" +"</solrcloud></solr>";@@ -141,6 +142,7 @@ public class TestSolrXml extends SolrTestCaseJ4 {NodeConfig cfg = SolrXmlConfig.fromString(solrHome, solrXml);assertNull("maxBooleanClauses", cfg.getBooleanQueryMaxClauseCount()); // default is nullassertEquals("leaderVoteWait", 180000, cfg.getCloudConfig().getLeaderVoteWait());+ assertEquals("hostPort", 8000, cfg.getCloudConfig().getSolrHostPort());}public void testIntAsLongBad() {@@ -313,18 +315,25 @@ public class TestSolrXml extends SolrTestCaseJ4 {SolrXmlConfig.fromString(solrHome, solrXml); // return not used, only for validation}- public void testCloudConfigRequiresHost() {+ public void testCloudConfigRequiresHostPort() {expectedException.expect(SolrException.class);- expectedException.expectMessage("solrcloud section missing required entry 'host'");+ expectedException.expectMessage("solrcloud section missing required entry 'hostPort'");SolrXmlConfig.fromString(solrHome, "<solr><solrcloud></solrcloud></solr>");}- public void testCloudConfigRequiresHostPort() {+ public void testCloudConfigDefaultHostPort() {expectedException.expect(SolrException.class);expectedException.expectMessage("solrcloud section missing required entry 'hostPort'");- SolrXmlConfig.fromString(solrHome, "<solr><solrcloud><str name=\"host\">host</str></solrcloud></solr>");+ SolrXmlConfig.fromString(solrHome, "<solr><solrcloud></solrcloud></solr>");+ }++ public void testCloudConfigRequiresHost() {+ expectedException.expect(SolrException.class);+ expectedException.expectMessage("solrcloud section missing required entry 'host'");++ SolrXmlConfig.fromString(solrHome, "<solr><solrcloud><int name=\"hostPort\">8983</int></solrcloud></solr>");}public void testCloudConfigRequiresHostContext() {