You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2013/04/22 21:50:07 UTC

svn commit: r1470681 [2/2] - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/cloud/ solr/core/src/java/org/apache/solr/core/ solr/core/src/java/org/apache/solr/util/ solr/core/src/test/org/apache/solr/core/ sol...

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestSolrXml.java?rev=1470681&r1=1470680&r2=1470681&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestSolrXml.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestSolrXml.java Mon Apr 22 19:50:06 2013
@@ -20,9 +20,11 @@ package org.apache.solr.core;
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.junit.Test;
+import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 import javax.xml.parsers.ParserConfigurationException;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -38,7 +40,14 @@ public class TestSolrXml extends SolrTes
     FileUtils.copyFile(new File(testSrcRoot, "solr-50-all.xml"), new File(solrHome, "solr.xml"));
     try {
       InputStream is = new FileInputStream(new File(solrHome, "solr.xml"));
-      ConfigSolr cfg = new ConfigSolrXml(new SolrResourceLoader("solr/collection1"), null, is, null, false, null);
+      Config config = new Config(new SolrResourceLoader("solr/collection1"), null, new InputSource(is), null, false);
+      boolean oldStyle = (config.getNode("solr/cores", false) != null);
+      ConfigSolr cfg;
+      if (oldStyle) {
+        cfg = new ConfigSolrXmlOld(config, cc);
+      } else {
+        cfg = new ConfigSolrXml(config, cc);
+      }
 
       assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_ADMINHANDLER, null), "testAdminHandler");
       assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_CORELOADTHREADS, 0), 11);
@@ -90,7 +99,14 @@ public class TestSolrXml extends SolrTes
     FileUtils.copyFile(new File(testSrcRoot, "solr-50-all.xml"), new File(solrHome, "solr.xml"));
     try {
       InputStream is = new FileInputStream(new File(solrHome, "solr.xml"));
-      ConfigSolr cfg = new ConfigSolrXml(new SolrResourceLoader("solr/collection1"), null, is, null, false, null);
+      Config config = new Config(new SolrResourceLoader("solr/collection1"), null, new InputSource(is), null, false);
+      boolean oldStyle = (config.getNode("solr/cores", false) != null);
+      ConfigSolr cfg;
+      if (oldStyle) {
+        cfg = new ConfigSolrXmlOld(config, cc);
+      } else {
+        cfg = new ConfigSolrXml(config, cc);
+      }
       assertEquals("Did not find expected value", cfg.get(ConfigSolr.CfgProp.SOLR_COREROOTDIRECTORY, null), "myCoreRoot");
       assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_HOSTPORT, 0), 8888);
       assertEquals("Did not find expected value", cfg.getInt(ConfigSolr.CfgProp.SOLR_SHARDHANDLERFACTORY_CONNTIMEOUT, 0), 200);

Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java?rev=1470681&r1=1470680&r2=1470681&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java (original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java Mon Apr 22 19:50:06 2013
@@ -20,6 +20,8 @@ package org.apache.solr.util;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.Config;
+import org.apache.solr.core.ConfigSolrXmlOld;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.CoreContainer;
@@ -39,13 +41,18 @@ import org.apache.solr.schema.IndexSchem
 import org.apache.solr.schema.IndexSchemaFactory;
 import org.apache.solr.servlet.DirectSolrConnection;
 import org.apache.solr.common.util.NamedList.NamedListEntry;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.xml.parsers.ParserConfigurationException;
+
 
 /**
  * This class provides a simple harness that may be useful when
@@ -171,15 +178,27 @@ public class TestHarness extends BaseTes
     }
     @Override
     public CoreContainer initialize() {
-      CoreContainer container = new CoreContainer(new SolrResourceLoader(SolrResourceLoader.locateSolrHome())) {
-        {
-          hostPort = System.getProperty("hostPort");
-          hostContext = "solr";
-          defaultCoreName = CoreContainer.DEFAULT_DEFAULT_CORE_NAME;
-          initShardHandler();
-          initZooKeeper(System.getProperty("zkHost"), 10000);
-        }
-      };
+      CoreContainer container;
+      try {
+        container = new CoreContainer(new SolrResourceLoader(SolrResourceLoader.locateSolrHome())) {
+          {
+            hostPort = System.getProperty("hostPort");
+            hostContext = "solr";
+            defaultCoreName = CoreContainer.DEFAULT_DEFAULT_CORE_NAME;
+            initShardHandler();
+            initZooKeeper(System.getProperty("zkHost"), 10000);
+            ByteArrayInputStream is = new ByteArrayInputStream(ConfigSolrXmlOld.DEF_SOLR_XML.getBytes("UTF-8"));
+            Config config = new Config(loader, null, new InputSource(is), null, false);
+            cfg = new ConfigSolrXmlOld(config, this);
+          }
+        };
+      } catch (ParserConfigurationException e) {
+        throw new RuntimeException(e);
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      } catch (SAXException e) {
+        throw new RuntimeException(e);
+      }
       LogWatcher<?> logging = new JulWatcher("test");
       logging.registerListener(new ListenerConfig(), container);
       container.setLogging(logging);