You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2015/01/20 20:09:20 UTC

svn commit: r1653339 [2/3] - in /lucene/dev/branches/lucene_solr_5_0: ./ solr/ solr/contrib/ solr/contrib/clustering/src/test-files/clustering/solr/ solr/contrib/clustering/src/test-files/clustering/solr/collection1/ solr/contrib/dataimporthandler/src/...

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/TestTolerantSearch.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/TestTolerantSearch.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/TestTolerantSearch.java Tue Jan 20 19:09:18 2015
@@ -1,12 +1,8 @@
 package org.apache.solr;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-
 import org.apache.commons.io.FileUtils;
-import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
 import org.apache.solr.client.solrj.request.CoreAdminRequest;
@@ -21,6 +17,10 @@ import org.apache.solr.response.SolrQuer
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -60,7 +60,7 @@ public class TestTolerantSearch extends
     solrHome = createSolrHome();
     createJetty(solrHome.getAbsolutePath(), null, null);
     String url = jetty.getBaseUrl().toString();
-    collection1 = new HttpSolrClient(url);
+    collection1 = new HttpSolrClient(url + "/collection1");
     collection2 = new HttpSolrClient(url + "/collection2");
     
     String urlCollection1 = jetty.getBaseUrl().toString() + "/" + "collection1";
@@ -69,9 +69,16 @@ public class TestTolerantSearch extends
     shard2 = urlCollection2.replaceAll("https?://", "");
     
     //create second core
-    CoreAdminRequest.Create req = new CoreAdminRequest.Create();
-    req.setCoreName("collection2");
-    collection1.request(req);
+    HttpSolrClient nodeClient = new HttpSolrClient(url);
+    try {
+      CoreAdminRequest.Create req = new CoreAdminRequest.Create();
+      req.setCoreName("collection2");
+      req.setConfigSet("collection1");
+      nodeClient.request(req);
+    }
+    finally {
+      nodeClient.shutdown();
+    }
     
     SolrInputDocument doc = new SolrInputDocument();
     doc.setField("id", "1");

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java Tue Jan 20 19:09:18 2015
@@ -41,6 +41,8 @@ import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Test sync phase that occurs when Leader goes down and a new Leader is
@@ -48,6 +50,8 @@ import org.junit.BeforeClass;
  */
 @Slow
 public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
+
+  private static final Logger logger = LoggerFactory.getLogger(AliasIntegrationTest.class);
   
   @BeforeClass
   public static void beforeSuperClass() throws Exception {
@@ -80,12 +84,14 @@ public class AliasIntegrationTest extend
   
   @Override
   public void doTest() throws Exception {
-    
+
     handle.clear();
     handle.put("timestamp", SKIPVAL);
-    
+
     waitForThingsToLevelOut(30);
 
+    logger.info("### STARTING ACTUAL TEST");
+
     del("*:*");
     
     createCollection("collection2", 2, 1, 10);
@@ -258,6 +264,8 @@ public class AliasIntegrationTest extend
       sawException = true;
     }
     assertTrue(sawException);
+
+    logger.info("### FINISHED ACTUAL TEST");
   }
 
   private void createAlias(String alias, String collections)

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Tue Jan 20 19:09:18 2015
@@ -54,7 +54,6 @@ import org.apache.solr.common.util.StrUt
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.SolrInfoMBean.Category;
-import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.servlet.SolrDispatchFilter;
 import org.apache.solr.update.DirectUpdateHandler2;
 import org.apache.solr.util.DefaultSolrThreadFactory;
@@ -64,10 +63,12 @@ import org.junit.BeforeClass;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 import javax.management.ObjectName;
-
 import java.io.File;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -110,7 +111,6 @@ public class CollectionsAPIDistributedZk
   
   // we randomly use a second config set rather than just one
   private boolean secondConfigSet = random().nextBoolean();
-  private boolean oldStyleSolrXml = false;
   
   @BeforeClass
   public static void beforeThisClass2() throws Exception {
@@ -123,13 +123,7 @@ public class CollectionsAPIDistributedZk
     super.setUp();
     
     useJettyDataDir = false;
-    
-    oldStyleSolrXml = random().nextBoolean();
-    if (oldStyleSolrXml) {
-      System.err.println("Using old style solr.xml");
-    } else {
-      System.err.println("Using new style solr.xml");
-    }
+
     if (secondConfigSet ) {
       String zkHost = zkServer.getZkHost();
       String zkAddress = zkServer.getZkAddress();
@@ -158,12 +152,11 @@ public class CollectionsAPIDistributedZk
     }
     
     System.setProperty("numShards", Integer.toString(sliceCount));
-    System.setProperty("solr.xml.persist", "true");
+
   }
   
   protected String getSolrXml() {
-    // test old style and new style solr.xml
-    return oldStyleSolrXml ? "solr-no-core-old-style.xml" : "solr-no-core.xml";
+    return "solr-no-core.xml";
   }
 
   
@@ -953,28 +946,22 @@ public class CollectionsAPIDistributedZk
     }
   }
 
-  private void checkInstanceDirs(JettySolrRunner jetty) {
+  private void checkInstanceDirs(JettySolrRunner jetty) throws IOException {
     CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter()
         .getFilter()).getCores();
     Collection<SolrCore> theCores = cores.getCores();
     for (SolrCore core : theCores) {
-      if (!oldStyleSolrXml) {
-        // look for core props file
-        assertTrue("Could not find expected core.properties file",
-            new File((String) core.getStatistics().get("instanceDir"),
-                "core.properties").exists());
-      }
 
-      try {
-        assertEquals(
-           new File(SolrResourceLoader.normalizeDir(jetty.getSolrHome() + File.separator
-                + core.getName())).getCanonicalPath(),
-            new File(SolrResourceLoader.normalizeDir((String) core.getStatistics().get(
-                "instanceDir"))).getCanonicalPath());
-      } catch (IOException e) {
-        log.error("Failed to get canonical path", e);
-        fail("Failed to get canonical path");
-      }
+      // look for core props file
+      assertTrue("Could not find expected core.properties file",
+          new File((String) core.getStatistics().get("instanceDir"),
+              "core.properties").exists());
+
+      Path expected = Paths.get(jetty.getSolrHome()).toAbsolutePath().resolve("cores").resolve(core.getName());
+      Path reported = Paths.get((String) core.getStatistics().get("instanceDir"));
+
+      assertTrue("Expected: " + expected + "\nFrom core stats: " + reported, Files.isSameFile(expected, reported));
+
     }
   }
 

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java Tue Jan 20 19:09:18 2015
@@ -23,6 +23,7 @@ import org.apache.solr.common.cloud.Solr
 import org.apache.solr.common.cloud.ZkNodeProps;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.CoreDescriptor;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -146,8 +147,7 @@ public class LeaderElectionIntegrationTe
     ports.add(port);
     CoreContainer container = new CoreContainer();
     container.load();
-    assertTrue("Container " + port + " has no cores!", container.getCores()
-        .size() > 0);
+    container.create(new CoreDescriptor(container, "collection1", "collection1", "collection", "collection1"));
     containerMap.put(port, container);
     System.clearProperty("solr.solr.home");
     System.clearProperty("hostPort");

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java Tue Jan 20 19:09:18 2015
@@ -17,14 +17,6 @@ package org.apache.solr.cloud;
  * limitations under the License.
  */
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.List;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.filefilter.RegexFileFilter;
@@ -44,6 +36,14 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.List;
+
 // TODO: This test would be a lot faster if it used a solrhome with fewer config
 // files - there are a lot of them to upload
 public class ZkCLITest extends SolrTestCaseJ4 {
@@ -78,19 +78,10 @@ public class ZkCLITest extends SolrTestC
     log.info("####SETUP_START " + getTestName());
 
     String exampleHome = SolrJettyTestBase.legacyExampleCollection1SolrHome();
-    
-    boolean useNewSolrXml = random().nextBoolean();
+
     File tmpDir = createTempDir().toFile();
-    if (useNewSolrXml) {
-      solrHome = exampleHome;
-    } else {
-      File tmpSolrHome = new File(tmpDir, "tmp-solr-home");
-      FileUtils.copyDirectory(new File(exampleHome), tmpSolrHome);
-      FileUtils.copyFile(getFile("old-solr-example/solr.xml"), new File(tmpSolrHome, "solr.xml"));
-      solrHome = tmpSolrHome.getAbsolutePath();
-    }
-    
-    
+    solrHome = exampleHome;
+
     zkDir = tmpDir.getAbsolutePath() + File.separator
         + "zookeeper/server1/data";
     log.info("ZooKeeper dataDir:" + zkDir);

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java Tue Jan 20 19:09:18 2015
@@ -17,12 +17,6 @@ package org.apache.solr.cloud;
  * the License.
  */
 
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.solr.SolrJettyTestBase;
 import org.apache.solr.SolrTestCaseJ4;
@@ -33,6 +27,7 @@ import org.apache.solr.core.ConfigSolr;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.CoresLocator;
+import org.apache.solr.core.PluginInfo;
 import org.apache.solr.handler.admin.CoreAdminHandler;
 import org.apache.solr.handler.component.HttpShardHandlerFactory;
 import org.apache.solr.update.UpdateShardHandler;
@@ -41,6 +36,12 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @Slow
 public class ZkControllerTest extends SolrTestCaseJ4 {
 
@@ -321,7 +322,7 @@ public class ZkControllerTest extends So
     
     @Override
     public ConfigSolr getConfig() {
-      return new ConfigSolr() {
+      return new ConfigSolr(null, null) {
 
         @Override
         public CoresLocator getCoresLocator() {
@@ -329,25 +330,22 @@ public class ZkControllerTest extends So
         }
 
         @Override
-        protected String getShardHandlerFactoryConfigPath() {
-          throw new UnsupportedOperationException();
+        public PluginInfo getShardHandlerFactoryPluginInfo() {
+          return null;
         }
 
         @Override
-        public boolean isPersistent() {
-          throw new UnsupportedOperationException();
-        }};
+        protected String getProperty(CfgProp key) {
+          return null;
+        }
+
+      };
     }
     
     @Override
     public UpdateShardHandler getUpdateShardHandler() {
       return new UpdateShardHandler(null);
     }
-    
-    @Override
-    public String getAdminPath() {
-      return "/admin/cores";
-    }
 
   }
 }

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java Tue Jan 20 19:09:18 2015
@@ -105,47 +105,41 @@ public class OpenCloseCoreStressTest ext
 
   @Test
   public void test5Seconds() throws Exception {
-    doStress(5, random().nextBoolean());
+    doStress(5);
   }
   
   @Test
   @Nightly
   public void test15SecondsOld() throws Exception {
-    doStress(15, true);
+    doStress(15);
   }
 
   @Test
   @Nightly
   public void test15SecondsNew() throws Exception {
-    doStress(15, false);
+    doStress(15);
   }
 
   @Test
   @Nightly
   public void test10MinutesOld() throws Exception {
-    doStress(300, true);
+    doStress(300);
   }
 
   @Test
   @Nightly
   public void test10MinutesNew() throws Exception {
-    doStress(300, false);
+    doStress(300);
   }
 
   @Test
   @Weekly
-  public void test1HourOld() throws Exception {
-    doStress(1800, true);
+  public void test1Hour() throws Exception {
+    doStress(1800);
   }
-
-  @Test
-  @Weekly
-  public void test1HourNew() throws Exception {
-    doStress(1800, false);
-  }
-
-
+  
   private void buildClients() throws Exception {
+
     jetty.start();
     url = buildUrl(jetty.getLocalPort(), "/solr/");
 
@@ -169,8 +163,8 @@ public class OpenCloseCoreStressTest ext
   }
 
   // Unless things go _really_ well, stop after you have the directories set up.
-  private void doStress(int secondsToRun, boolean oldStyle) throws Exception {
-    makeCores(solrHomeDirectory, oldStyle);
+  private void doStress(int secondsToRun) throws Exception {
+    makeCores(solrHomeDirectory);
 
     //MUST start the server after the cores are made.
     buildClients();
@@ -213,25 +207,22 @@ public class OpenCloseCoreStressTest ext
     }
   }
 
-  private void makeCores(File home, boolean oldStyle) throws Exception {
+  private void makeCores(File home) throws Exception {
     File testSrcRoot = new File(SolrTestCaseJ4.TEST_HOME());
     String srcSolrXml = "solr-stress-new.xml";
 
-    if (oldStyle) {
-      srcSolrXml = "solr-stress-old.xml";
-    }
     FileUtils.copyFile(new File(testSrcRoot, srcSolrXml), new File(home, "solr.xml"));
 
     // create directories in groups of 100 until you have enough.
     for (int idx = 0; idx < numCores; ++idx) {
       String coreName = String.format(Locale.ROOT, "%05d_core", idx);
-      makeCore(new File(home, coreName), testSrcRoot, oldStyle);
+      makeCore(new File(home, coreName), testSrcRoot);
       coreCounts.put(coreName, 0L);
       coreNames.add(coreName);
     }
   }
 
-  private void makeCore(File coreDir, File testSrcRoot, boolean oldStyle) throws IOException {
+  private void makeCore(File coreDir, File testSrcRoot) throws IOException {
     File conf = new File(coreDir, "conf");
 
     if (!conf.mkdirs()) log.warn("mkdirs returned false in makeCore... ignoring");
@@ -244,9 +235,7 @@ public class OpenCloseCoreStressTest ext
     FileUtils.copyFile(new File(testConf, "solrconfig.snippet.randomindexconfig.xml"),
         new File(conf, "solrconfig.snippet.randomindexconfig.xml"));
 
-    if (!oldStyle) {
-      FileUtils.copyFile(new File(testSrcRoot, "conf/core.properties"), new File(coreDir, "core.properties"));
-    }
+    FileUtils.copyFile(new File(testSrcRoot, "conf/core.properties"), new File(coreDir, "core.properties"));
 
   }
 

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java Tue Jan 20 19:09:18 2015
@@ -51,35 +51,6 @@ public class SolrCoreTest extends SolrTe
     deleteCore();
     super.tearDown();
   }
-  
-  @Test
-  public void testRemoveThenAddDefaultCore() throws Exception {
-    final CoreContainer cores = h.getCoreContainer();
-    SolrCore core = cores.getCore("");
-
-    assertEquals(COLLECTION1, cores.getDefaultCoreName());
-    
-    cores.unload("");
-    core.close();
-
-    CoreDescriptor cd = new CoreDescriptor(cores, COLLECTION1, "collection1",
-                                            CoreDescriptor.CORE_DATADIR, createTempDir("dataDir2").toFile().getAbsolutePath());
-    
-    cores.create(cd);
-    
-    assertEquals(COLLECTION1, cores.getDefaultCoreName());
-    
-    // so we should be able to get a core with collection1
-    core = cores.getCore(COLLECTION1);
-    assertNotNull(core);
-    core.close();
-    
-    // and with ""
-    core = cores.getCore("");
-    assertNotNull(core);
-    
-    core.close();
-  }
 
   @Test
   public void testRequestHandlerRegistry() {
@@ -100,7 +71,7 @@ public class SolrCoreTest extends SolrTe
   @Test
   public void testClose() throws Exception {
     final CoreContainer cores = h.getCoreContainer();
-    SolrCore core = cores.getCore("");
+    SolrCore core = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
 
     ClosingRequestHandler handler1 = new ClosingRequestHandler();
     handler1.inform( core );
@@ -120,7 +91,7 @@ public class SolrCoreTest extends SolrTe
     assertTrue("Refcount != 1", core.getOpenCount() == 1);
     
     final CoreContainer cores = h.getCoreContainer();
-    SolrCore c1 = cores.getCore("");
+    SolrCore c1 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
     assertTrue("Refcount != 2", core.getOpenCount() == 2);
 
     ClosingRequestHandler handler1 = new ClosingRequestHandler();
@@ -131,12 +102,12 @@ public class SolrCoreTest extends SolrTe
     assertNull( old ); // should not be anything...
     assertEquals( core.getRequestHandlers().get( path ), handler1 );
    
-    SolrCore c2 = cores.getCore("");
+    SolrCore c2 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
     c1.close();
     assertTrue("Refcount < 1", core.getOpenCount() >= 1);
     assertTrue("Handler is closed", handler1.closed == false);
     
-    c1 = cores.getCore("");
+    c1 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
     assertTrue("Refcount < 2", core.getOpenCount() >= 2);
     assertTrue("Handler is closed", handler1.closed == false);
     
@@ -184,7 +155,7 @@ public class SolrCoreTest extends SolrTe
           try {
             for (int l = 0; l < LOOP; ++l) {
               r += 1;
-              core = cores.getCore("");
+              core = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
               // sprinkle concurrency hinting...
               yield(l);
               assertTrue("Refcount < 1", core.getOpenCount() >= 1);              

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestConfigSets.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestConfigSets.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestConfigSets.java Tue Jan 20 19:09:18 2015
@@ -46,7 +46,7 @@ public class TestConfigSets extends Solr
     System.setProperty("configsets", configSetsBaseDir);
 
     SolrResourceLoader loader = new SolrResourceLoader(testDirectory.getAbsolutePath());
-    CoreContainer container = new CoreContainer(loader, ConfigSolr.fromString(loader, solrxml));
+    CoreContainer container = new CoreContainer(ConfigSolr.fromString(loader, solrxml));
     container.load();
 
     return container;
@@ -115,12 +115,12 @@ public class TestConfigSets extends Solr
     System.setProperty("configsets", csd);
 
     SolrResourceLoader loader = new SolrResourceLoader(testDirectory.getAbsolutePath());
-    CoreContainer container = new CoreContainer(loader, ConfigSolr.fromString(loader, solrxml));
+    CoreContainer container = new CoreContainer(ConfigSolr.fromString(loader, solrxml));
     container.load();
 
     // We initially don't have a /get handler defined
     SolrCore core = container.create(new CoreDescriptor(container, "core1", testDirectory + "/core", "configSet", "configset-2"));
-    assertThat("No /get handler should be defined in the initial configuration",
+    assertThat("No /dump handler should be defined in the initial configuration",
         core.getRequestHandler("/dump"), is(nullValue()));
 
     // Now copy in a config with a /get handler and reload
@@ -129,7 +129,7 @@ public class TestConfigSets extends Solr
     container.reload("core1");
 
     core = container.getCore("core1");
-    assertThat("A /get handler should be defined in the reloaded configuration",
+    assertThat("A /dump handler should be defined in the reloaded configuration",
         core.getRequestHandler("/dump"), is(notNullValue()));
     core.close();
 

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java Tue Jan 20 19:09:18 2015
@@ -18,6 +18,7 @@
 package org.apache.solr.core;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.IOUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.handler.admin.CollectionsHandler;
@@ -26,19 +27,18 @@ import org.apache.solr.handler.admin.Inf
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
 
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
+import java.util.regex.Pattern;
 
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
@@ -55,7 +55,7 @@ public class TestCoreContainer extends S
   @BeforeClass
   public static void beforeClass() throws Exception {
     oldSolrHome = System.getProperty(SOLR_HOME_PROP);
-    initCore("solrconfig.xml", "schema.xml");
+    System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
   }
 
   @AfterClass
@@ -67,16 +67,14 @@ public class TestCoreContainer extends S
     }
   }
 
-  private File solrHomeDirectory;
-
-  private CoreContainer init(String dirName) throws Exception {
-
-    solrHomeDirectory = createTempDir(dirName).toFile();
-
-    FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME()), solrHomeDirectory);
-    System.out.println("Using solrconfig from " + new File(SolrTestCaseJ4.TEST_HOME()).getAbsolutePath());
+  private CoreContainer init(String xml) throws Exception {
+    Path solrHomeDirectory = createTempDir();
+    return init(solrHomeDirectory, xml);
+  }
 
-    CoreContainer ret = new CoreContainer(solrHomeDirectory.getAbsolutePath());
+  private CoreContainer init(Path homeDirectory, String xml) throws Exception {
+    SolrResourceLoader loader = new SolrResourceLoader(homeDirectory.toString());
+    CoreContainer ret = new CoreContainer(ConfigSolr.fromString(loader, xml));
     ret.load();
     return ret;
   }
@@ -84,12 +82,14 @@ public class TestCoreContainer extends S
   @Test
   public void testShareSchema() throws Exception {
     System.setProperty("shareSchema", "true");
-    final CoreContainer cores = init("_shareSchema");
+
+    CoreContainer cores = init(CONFIGSETS_SOLR_XML);
+
     try {
-      CoreDescriptor descriptor1 = new CoreDescriptor(cores, "core1", "./collection1");
+      CoreDescriptor descriptor1 = new CoreDescriptor(cores, "core1", "./collection1", "configSet", "minimal");
       SolrCore core1 = cores.create(descriptor1);
       
-      CoreDescriptor descriptor2 = new CoreDescriptor(cores, "core2", "./collection1");
+      CoreDescriptor descriptor2 = new CoreDescriptor(cores, "core2", "./collection1", "configSet", "minimal");
       SolrCore core2 = cores.create(descriptor2);
       
       assertSame(core1.getLatestSchema(), core2.getLatestSchema());
@@ -102,12 +102,14 @@ public class TestCoreContainer extends S
 
   @Test
   public void testReloadSequential() throws Exception {
-    final CoreContainer cc = init("_reloadSequential");
+    final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
+    CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
+    cc.create(descriptor1);
     try {
-      cc.reload("collection1");
-      cc.reload("collection1");
-      cc.reload("collection1");
-      cc.reload("collection1");
+      cc.reload("core1");
+      cc.reload("core1");
+      cc.reload("core1");
+      cc.reload("core1");
 
     } finally {
       cc.shutdown();
@@ -116,63 +118,52 @@ public class TestCoreContainer extends S
 
   @Test
   public void testReloadThreaded() throws Exception {
-    final CoreContainer cc = init("_reloadThreaded");
-
-      class TestThread extends Thread {
-        @Override
-        public void run() {
-          cc.reload("collection1");
-        }
+    final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
+    CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
+    cc.create(descriptor1);
+
+    class TestThread extends Thread {
+      @Override
+      public void run() {
+        cc.reload("core1");
       }
+    }
 
-      List<Thread> threads = new ArrayList<>();
-      int numThreads = 4;
-      for (int i = 0; i < numThreads; i++) {
-        threads.add(new TestThread());
-      }
+    List<Thread> threads = new ArrayList<>();
+    int numThreads = 4;
+    for (int i = 0; i < numThreads; i++) {
+      threads.add(new TestThread());
+    }
 
-      for (Thread thread : threads) {
-        thread.start();
-      }
+    for (Thread thread : threads) {
+      thread.start();
+    }
 
-      for (Thread thread : threads) {
-        thread.join();
+    for (Thread thread : threads) {
+      thread.join();
     }
 
     cc.shutdown();
 
   }
 
+  @Test
+  public void testNoCores() throws Exception {
 
+    CoreContainer cores = init(CONFIGSETS_SOLR_XML);
 
-  @Test
-  public void testNoCores() throws IOException, ParserConfigurationException, SAXException {
-    //create solrHome
-    File solrHomeDirectory = createTempDir().toFile();
-    
-    boolean oldSolrXml = random().nextBoolean();
-    
-    SetUpHome(solrHomeDirectory, oldSolrXml ? EMPTY_SOLR_XML : EMPTY_SOLR_XML2);
-    CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
-    cores.load();
     try {
       //assert zero cores
       assertEquals("There should not be cores", 0, cores.getCores().size());
       
-      FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME(), "collection1"), solrHomeDirectory);
       //add a new core
-      CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", solrHomeDirectory.getAbsolutePath());
+      CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", "collection1", CoreDescriptor.CORE_CONFIGSET, "minimal");
       SolrCore newCore = cores.create(coreDescriptor);
 
       //assert one registered core
 
       assertEquals("There core registered", 1, cores.getCores().size());
 
-      if (oldSolrXml) {
-        assertXmlFile(new File(solrHomeDirectory, "solr.xml"),
-            "/solr/cores[@transientCacheSize='32']");
-      }
-
       cores.unload("core1");
       //assert cero cores
       assertEquals("There should not be cores", 0, cores.getCores().size());
@@ -193,27 +184,14 @@ public class TestCoreContainer extends S
   }
 
   @Test
-  public void testLogWatcherEnabledByDefault() {
-    assertNotNull(h.getCoreContainer().getLogging());
-  }
-  
-  private void SetUpHome(File solrHomeDirectory, String xmlFile) throws IOException {
-    if (solrHomeDirectory.exists()) {
-      FileUtils.deleteDirectory(solrHomeDirectory);
-    }
-    assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs());
-    try {
-      File solrXmlFile = new File(solrHomeDirectory, "solr.xml");
-      BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(solrXmlFile), StandardCharsets.UTF_8));
-      out.write(xmlFile);
-      out.close();
-    } catch (IOException e) {
-      FileUtils.deleteDirectory(solrHomeDirectory);
-      throw e;
+  public void testLogWatcherEnabledByDefault() throws Exception {
+    CoreContainer cc = init("<solr></solr>");
+    try {
+      assertNotNull(cc.getLogging());
+    }
+    finally {
+      cc.shutdown();
     }
-
-    //init
-    System.setProperty(SOLR_HOME_PROP, solrHomeDirectory.getAbsolutePath());
   }
 
   @Test
@@ -221,13 +199,12 @@ public class TestCoreContainer extends S
 
     MockCoresLocator cl = new MockCoresLocator();
 
-    solrHomeDirectory = createTempDir("_deleteBadCores").toFile();
-    SolrResourceLoader resourceLoader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
-    File instanceDir = new File(solrHomeDirectory, "_deleteBadCores");
+    SolrResourceLoader resourceLoader = new SolrResourceLoader(createTempDir().toString());
+
     System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
 
-    final CoreContainer cc = new CoreContainer(resourceLoader, ConfigSolr.fromString(resourceLoader, EMPTY_SOLR_XML2), cl);
-    CoreDescriptor badcore = new CoreDescriptor(cc, "badcore", instanceDir.getAbsolutePath(), "configSet", "nosuchconfigset");
+    final CoreContainer cc = new CoreContainer(ConfigSolr.fromString(resourceLoader, CONFIGSETS_SOLR_XML), cl);
+    CoreDescriptor badcore = new CoreDescriptor(cc, "badcore", "badcore", "configSet", "nosuchconfigset");
     cl.add(badcore);
 
     try {
@@ -238,7 +215,7 @@ public class TestCoreContainer extends S
       assertThat(cc.getCoreInitFailures().size(), is(0));
 
       // can we create the core now with a good config?
-      SolrCore core = cc.create(new CoreDescriptor(cc, "badcore", instanceDir.getAbsolutePath(), "configSet", "minimal"));
+      SolrCore core = cc.create(new CoreDescriptor(cc, "badcore", "badcore", "configSet", "minimal"));
       assertThat(core, not(nullValue()));
 
     }
@@ -249,13 +226,13 @@ public class TestCoreContainer extends S
 
   @Test
   public void testClassLoaderHierarchy() throws Exception {
-    final CoreContainer cc = init("_classLoaderHierarchy");
+    final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
     try {
       ClassLoader sharedLoader = cc.loader.getClassLoader();
       ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
       assertSame(contextLoader, sharedLoader.getParent());
 
-      CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1");
+      CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
       SolrCore core1 = cc.create(descriptor1);
       ClassLoader coreLoader = core1.getResourceLoader().getClassLoader();
       assertSame(sharedLoader, coreLoader.getParent());
@@ -267,9 +244,9 @@ public class TestCoreContainer extends S
 
   @Test
   public void testSharedLib() throws Exception {
-    File tmpRoot = createTempDir("testSharedLib").toFile();
+    Path tmpRoot = createTempDir("testSharedLib");
 
-    File lib = new File(tmpRoot, "lib");
+    File lib = new File(tmpRoot.toFile(), "lib");
     lib.mkdirs();
 
     JarOutputStream jar1 = new JarOutputStream(new FileOutputStream(new File(lib, "jar1.jar")));
@@ -277,7 +254,7 @@ public class TestCoreContainer extends S
     jar1.closeEntry();
     jar1.close();
 
-    File customLib = new File(tmpRoot, "customLib");
+    File customLib = new File(tmpRoot.toFile(), "customLib");
     customLib.mkdirs();
 
     JarOutputStream jar2 = new JarOutputStream(new FileOutputStream(new File(customLib, "jar2.jar")));
@@ -285,41 +262,32 @@ public class TestCoreContainer extends S
     jar2.closeEntry();
     jar2.close();
 
-    FileUtils.writeStringToFile(new File(tmpRoot, "default-lib-solr.xml"), "<solr><cores/></solr>", "UTF-8");
-    FileUtils.writeStringToFile(new File(tmpRoot, "explicit-lib-solr.xml"), "<solr sharedLib=\"lib\"><cores/></solr>", "UTF-8");
-    FileUtils.writeStringToFile(new File(tmpRoot, "custom-lib-solr.xml"), "<solr sharedLib=\"customLib\"><cores/></solr>", "UTF-8");
-
-    final CoreContainer cc1 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "default-lib-solr.xml"));
+    final CoreContainer cc1 = init(tmpRoot, "<solr></solr>");
     try {
       cc1.loader.openResource("defaultSharedLibFile").close();
     } finally {
       cc1.shutdown();
     }
 
-    final CoreContainer cc2 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "explicit-lib-solr.xml"));
+    final CoreContainer cc2 = init(tmpRoot, "<solr><str name=\"sharedLib\">lib</str></solr>");
     try {
       cc2.loader.openResource("defaultSharedLibFile").close();
     } finally {
       cc2.shutdown();
     }
 
-    final CoreContainer cc3 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "custom-lib-solr.xml"));
+    final CoreContainer cc3 = init(tmpRoot, "<solr><str name=\"sharedLib\">customLib</str></solr>");
     try {
       cc3.loader.openResource("customSharedLibFile").close();
     } finally {
       cc3.shutdown();
     }
   }
-  
-  private static final String EMPTY_SOLR_XML ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
-      "<solr persistent=\"false\">\n" +
-      "  <cores adminPath=\"/admin/cores\" transientCacheSize=\"32\" >\n" +
-      "  </cores>\n" +
-      "</solr>";
-  
-  private static final String EMPTY_SOLR_XML2 ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+
+  private static final String CONFIGSETS_SOLR_XML ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
       "<solr>\n" +
-      "<str name=\"configSetBaseDir\">${configsets:configsets}</str>" +
+      "<str name=\"configSetBaseDir\">${configsets:configsets}</str>\n" +
+      "<str name=\"shareSchema\">${shareSchema:false}</str>\n" +
       "</solr>";
 
   private static final String CUSTOM_HANDLERS_SOLR_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
@@ -350,12 +318,7 @@ public class TestCoreContainer extends S
   @Test
   public void testCustomHandlers() throws Exception {
 
-    solrHomeDirectory = createTempDir("_customHandlers").toFile();
-    SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
-
-    ConfigSolr config = ConfigSolr.fromString(loader, CUSTOM_HANDLERS_SOLR_XML);
-
-    CoreContainer cc = new CoreContainer(loader, config);
+    CoreContainer cc = init(CUSTOM_HANDLERS_SOLR_XML);
     try {
       cc.load();
       assertThat(cc.getCollectionsHandler(), is(instanceOf(CustomCollectionsHandler.class)));
@@ -406,4 +369,262 @@ public class TestCoreContainer extends S
       return cores;
     }
   }
+
+  @Test
+  public void testCoreInitFailuresFromEmptyContainer() throws Exception {
+    // reused state
+    Map<String,CoreContainer.CoreLoadFailure> failures = null;
+    Collection<String> cores = null;
+    Exception fail = null;
+
+    // ----
+    // init the CoreContainer
+    CoreContainer cc = init(CONFIGSETS_SOLR_XML);
+
+    // check that we have the cores we expect
+    cores = cc.getCoreNames();
+    assertNotNull("core names is null", cores);
+    assertEquals("wrong number of cores", 0, cores.size());
+
+    // check that we have the failures we expect
+    failures = cc.getCoreInitFailures();
+    assertNotNull("core failures is a null map", failures);
+    assertEquals("wrong number of core failures", 0, failures.size());
+
+    // -----
+    // try to add a collection with a path that doesn't exist
+    final CoreDescriptor bogus = new CoreDescriptor(cc, "bogus", "bogus_path");
+    try {
+      ignoreException(Pattern.quote("bogus_path"));
+      cc.create(bogus);
+      fail("bogus inst dir failed to trigger exception from create");
+    } catch (SolrException e) {
+      assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
+          0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
+
+    }
+
+    // check that we have the cores we expect
+    cores = cc.getCoreNames();
+    assertNotNull("core names is null", cores);
+    assertEquals("wrong number of cores", 0, cores.size());
+
+    // check that we have the failures we expect
+    failures = cc.getCoreInitFailures();
+    assertNotNull("core failures is a null map", failures);
+    assertEquals("wrong number of core failures", 1, failures.size());
+    fail = failures.get("bogus").exception;
+    assertNotNull("null failure for test core", fail);
+    assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
+        0 < fail.getCause().getMessage().indexOf("bogus_path"));
+
+    // check that we get null accessing a non-existent core
+    assertNull(cc.getCore("does_not_exist"));
+    // check that we get a 500 accessing the core with an init failure
+    try {
+      SolrCore c = cc.getCore("bogus");
+      fail("Failed to get Exception on accessing core with init failure");
+    } catch (SolrException ex) {
+      assertEquals(500, ex.code());
+      // double wrapped
+      String cause = ex.getCause().getCause().getMessage();
+      assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
+          0 < cause.indexOf("bogus_path"));
+
+    }
+
+    cc.shutdown();
+  }
+
+  @Test
+  public void testCoreInitFailuresOnReload() throws Exception {
+
+    // reused state
+    Map<String,CoreContainer.CoreLoadFailure> failures = null;
+    Collection<String> cores = null;
+    Exception fail = null;
+
+    // -----
+    // init the  CoreContainer with the mix of ok/bad cores
+    MockCoresLocator cl = new MockCoresLocator();
+
+    SolrResourceLoader resourceLoader = new SolrResourceLoader(createTempDir().toString());
+
+    System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
+
+    final CoreContainer cc = new CoreContainer(ConfigSolr.fromString(resourceLoader, CONFIGSETS_SOLR_XML), cl);
+    cl.add(new CoreDescriptor(cc, "col_ok", "col_ok", "configSet", "minimal"));
+    cl.add(new CoreDescriptor(cc, "col_bad", "col_bad", "configSet", "bad-mergepolicy"));
+    cc.load();
+
+    // check that we have the cores we expect
+    cores = cc.getCoreNames();
+    assertNotNull("core names is null", cores);
+    assertEquals("wrong number of cores", 1, cores.size());
+    assertTrue("col_ok not found", cores.contains("col_ok"));
+
+    // check that we have the failures we expect
+    failures = cc.getCoreInitFailures();
+    assertNotNull("core failures is a null map", failures);
+    assertEquals("wrong number of core failures", 1, failures.size());
+    fail = failures.get("col_bad").exception;
+    assertNotNull("null failure for test core", fail);
+    assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
+        0 < fail.getMessage().indexOf("DummyMergePolicy"));
+
+    // check that we get null accessing a non-existent core
+    assertNull(cc.getCore("does_not_exist"));
+    // check that we get a 500 accessing the core with an init failure
+    try {
+      SolrCore c = cc.getCore("col_bad");
+      fail("Failed to get Exception on accessing core with init failure");
+    } catch (SolrException ex) {
+      assertEquals(500, ex.code());
+      // double wrapped
+      String cause = ex.getCause().getCause().getMessage();
+      assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
+          0 < cause.indexOf("DummyMergePolicy"));
+    }
+
+    // -----
+    // "fix" the bad collection
+    FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
+        FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"));
+    FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
+        FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "schema.xml"));
+    final CoreDescriptor fixed = new CoreDescriptor(cc, "col_bad", "col_bad");
+    cc.create(fixed);
+
+    // check that we have the cores we expect
+    cores = cc.getCoreNames();
+    assertNotNull("core names is null", cores);
+    assertEquals("wrong number of cores", 2, cores.size());
+    assertTrue("col_ok not found", cores.contains("col_ok"));
+    assertTrue("col_bad not found", cores.contains("col_bad"));
+
+    // check that we have the failures we expect
+    failures = cc.getCoreInitFailures();
+    assertNotNull("core failures is a null map", failures);
+    assertEquals("wrong number of core failures", 0, failures.size());
+
+
+    // -----
+    // try to add a collection with a path that doesn't exist
+    final CoreDescriptor bogus = new CoreDescriptor(cc, "bogus", "bogus_path");
+    try {
+      ignoreException(Pattern.quote("bogus_path"));
+      cc.create(bogus);
+      fail("bogus inst dir failed to trigger exception from create");
+    } catch (SolrException e) {
+      assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
+          0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
+
+    }
+
+    // check that we have the cores we expect
+    cores = cc.getCoreNames();
+    assertNotNull("core names is null", cores);
+    assertEquals("wrong number of cores", 2, cores.size());
+    assertTrue("col_ok not found", cores.contains("col_ok"));
+    assertTrue("col_bad not found", cores.contains("col_bad"));
+
+    // check that we have the failures we expect
+    failures = cc.getCoreInitFailures();
+    assertNotNull("core failures is a null map", failures);
+    assertEquals("wrong number of core failures", 1, failures.size());
+    fail = failures.get("bogus").exception;
+    assertNotNull("null failure for test core", fail);
+    assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
+        0 < fail.getCause().getMessage().indexOf("bogus_path"));
+
+    // check that we get null accessing a non-existent core
+    assertNull(cc.getCore("does_not_exist"));
+    // check that we get a 500 accessing the core with an init failure
+    try {
+      SolrCore c = cc.getCore("bogus");
+      fail("Failed to get Exception on accessing core with init failure");
+    } catch (SolrException ex) {
+      assertEquals(500, ex.code());
+      // double wrapped
+      String cause = ex.getCause().getCause().getMessage();
+      assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
+          0 < cause.indexOf("bogus_path"));
+    }
+
+    // -----
+    // break col_bad's config and try to RELOAD to add failure
+
+    final long col_bad_old_start = getCoreStartTime(cc, "col_bad");
+
+    FileUtils.write
+        (FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"),
+            "This is giberish, not valid XML <",
+            IOUtils.UTF_8);
+
+    try {
+      ignoreException(Pattern.quote("SAX"));
+      cc.reload("col_bad");
+      fail("corrupt solrconfig.xml failed to trigger exception from reload");
+    } catch (SolrException e) {
+      Throwable rootException = getWrappedException(e);
+      assertTrue("We're supposed to have a wrapped SAXParserException here, but we don't",
+          rootException instanceof SAXParseException);
+      SAXParseException se = (SAXParseException) rootException;
+      assertTrue("reload exception doesn't refer to slrconfig.xml " + se.getSystemId(),
+          0 < se.getSystemId().indexOf("solrconfig.xml"));
+
+    }
+
+    assertEquals("Failed core reload should not have changed start time",
+        col_bad_old_start, getCoreStartTime(cc, "col_bad"));
+
+    // check that we have the cores we expect
+    cores = cc.getCoreNames();
+    assertNotNull("core names is null", cores);
+    assertEquals("wrong number of cores", 2, cores.size());
+    assertTrue("col_ok not found", cores.contains("col_ok"));
+    assertTrue("col_bad not found", cores.contains("col_bad"));
+
+    // check that we have the failures we expect
+    failures = cc.getCoreInitFailures();
+    assertNotNull("core failures is a null map", failures);
+    assertEquals("wrong number of core failures", 2, failures.size());
+    Throwable ex = getWrappedException(failures.get("col_bad").exception);
+    assertNotNull("null failure for test core", ex);
+    assertTrue("init failure isn't SAXParseException",
+        ex instanceof SAXParseException);
+    SAXParseException saxEx = (SAXParseException) ex;
+    assertTrue("init failure doesn't mention problem: " + saxEx.toString(), saxEx.getSystemId().contains("solrconfig.xml"));
+
+    // ----
+    // fix col_bad's config (again) and RELOAD to fix failure
+    FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
+        FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"));
+    cc.reload("col_bad");
+
+    assertTrue("Core reload should have changed start time",
+        col_bad_old_start < getCoreStartTime(cc, "col_bad"));
+
+
+    // check that we have the cores we expect
+    cores = cc.getCoreNames();
+    assertNotNull("core names is null", cores);
+    assertEquals("wrong number of cores", 2, cores.size());
+    assertTrue("col_ok not found", cores.contains("col_ok"));
+    assertTrue("col_bad not found", cores.contains("col_bad"));
+
+    // check that we have the failures we expect
+    failures = cc.getCoreInitFailures();
+    assertNotNull("core failures is a null map", failures);
+    assertEquals("wrong number of core failures", 1, failures.size());
+
+    cc.shutdown();
+
+  }
+
+  private long getCoreStartTime(final CoreContainer cc, final String name) {
+    try (SolrCore tmp = cc.getCore(name)) {
+      return tmp.getStartTime();
+    }
+  }
 }

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java Tue Jan 20 19:09:18 2015
@@ -140,8 +140,6 @@ public class TestCoreDiscovery extends S
 
     CoreContainer cc = init();
     try {
-      assertEquals(ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME,
-                   cc.getDefaultCoreName());
 
       TestLazyCores.checkInCores(cc, "core1");
       TestLazyCores.checkNotInCores(cc, "lazy1", "core2", "collection1");

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java Tue Jan 20 19:09:18 2015
@@ -1,7 +1,6 @@
 package org.apache.solr.core;
 
 import org.apache.solr.SolrTestCaseJ4;
-import java.io.File;
 import org.junit.Test;
 
 /*
@@ -22,17 +21,16 @@ import org.junit.Test;
  */
 public class TestImplicitCoreProperties extends SolrTestCaseJ4 {
 
-  public static final String SOLRXML =
-      "<solr><cores><core name=\"collection1\" instanceDir=\"collection1\" config=\"solrconfig-implicitproperties.xml\"/></cores></solr>";
-
   @Test
   public void testImplicitPropertiesAreSubstitutedInSolrConfig() {
 
-    CoreContainer cc = createCoreContainer(TEST_HOME(), SOLRXML);
+    CoreContainer cc
+        = createCoreContainer("collection1", "data", "solrconfig-implicitproperties.xml", "schema.xml");
+    
     try {
       assertQ(req("q", "*:*")
               , "//str[@name='dummy1'][.='collection1']"
-              , "//str[@name='dummy2'][.='data"+File.separator+"']"
+              , "//str[@name='dummy2'][.='data']"
               , "//str[@name='dummy3'][.='solrconfig-implicitproperties.xml']"
               , "//str[@name='dummy4'][.='schema.xml']"
               , "//str[@name='dummy5'][.='false']"

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestLazyCores.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestLazyCores.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestLazyCores.java Tue Jan 20 19:09:18 2015
@@ -17,9 +17,10 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
-import org.apache.commons.lang.StringUtils;
+import com.google.common.collect.ImmutableList;
 import org.apache.commons.codec.Charsets;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.CoreAdminParams;
@@ -31,9 +32,7 @@ import org.apache.solr.response.SolrQuer
 import org.apache.solr.update.AddUpdateCommand;
 import org.apache.solr.update.CommitUpdateCommand;
 import org.apache.solr.update.UpdateHandler;
-import org.apache.solr.util.TestHarness;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.apache.solr.util.ReadOnlyCoresLocator;
 import org.junit.Test;
 
 import java.io.File;
@@ -48,18 +47,7 @@ import java.util.regex.Pattern;
 
 public class TestLazyCores extends SolrTestCaseJ4 {
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    initCore("solrconfig-minimal.xml", "schema-tiny.xml");
-  }
-
   private File solrHomeDirectory;
-  
-  @Before
-  @Override
-  public void setUp() throws Exception {
-    super.setUp();
-  }
 
   private CoreContainer init() throws Exception {
     solrHomeDirectory = createTempDir().toFile();
@@ -69,17 +57,7 @@ public class TestLazyCores extends SolrT
     }
 
     SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
-
-    File solrXml = new File(solrHomeDirectory, "solr.xml");
-    FileUtils.write(solrXml, LOTS_SOLR_XML, Charsets.UTF_8.toString());
-    ConfigSolrXmlOld config = (ConfigSolrXmlOld) ConfigSolr.fromFile(loader, solrXml);
-
-    CoresLocator locator = new SolrXMLCoresLocator.NonPersistingLocator(LOTS_SOLR_XML, config);
-
-
-    final CoreContainer cores = new CoreContainer(loader, config, locator);
-    cores.load();
-    return cores;
+    return createCoreContainer(new LazyCoreTestConfig(loader));
   }
   
   @Test
@@ -172,14 +150,16 @@ public class TestLazyCores extends SolrT
 
       // Now just insure that the normal searching on "collection1" finds _0_ on the same query that found _2_ above.
       // Use of makeReq above and req below is tricky, very tricky.
+      SolrCore collection1 = cc.getCore("collection1");
       assertQ("test raw query",
-          req("q", "{!raw f=v_t}hello", "wt", "xml")
+          makeReq(collection1, "q", "{!raw f=v_t}hello", "wt", "xml")
           , "//result[@numFound='0']"
       );
 
       checkInCores(cc, "collectionLazy4");
 
       core4.close();
+      collection1.close();
     } finally {
       cc.shutdown();
     }
@@ -411,72 +391,6 @@ public class TestLazyCores extends SolrT
     }
   }
 
-
-  //Make sure persisting not-loaded lazy cores is done. See SOLR-4347
-
-  @Test
-  public void testPersistence() throws Exception {
-    final CoreContainer cc = init();
-    try {
-      copyMinConf(new File(solrHomeDirectory, "core1"));
-      copyMinConf(new File(solrHomeDirectory, "core2"));
-      copyMinConf(new File(solrHomeDirectory, "core3"));
-      copyMinConf(new File(solrHomeDirectory, "core4"));
-
-      final CoreDescriptor cd1 = buildCoreDescriptor(cc, "core1", "./core1")
-          .isTransient(true).loadOnStartup(true).build();
-      final CoreDescriptor cd2 = buildCoreDescriptor(cc, "core2", "./core2")
-          .isTransient(true).loadOnStartup(false).build();
-      final CoreDescriptor cd3 = buildCoreDescriptor(cc, "core3", "./core3")
-          .isTransient(false).loadOnStartup(true).build();
-      final CoreDescriptor cd4 = buildCoreDescriptor(cc, "core4", "./core4")
-          .isTransient(false).loadOnStartup(false).build();
-
-
-      SolrCore core1 = cc.create(cd1);
-      SolrCore core2 = cc.create(cd2);
-      SolrCore core3 = cc.create(cd3);
-      SolrCore core4 = cc.create(cd4);
-
-      SolrXMLCoresLocator.NonPersistingLocator locator =
-          (SolrXMLCoresLocator.NonPersistingLocator) cc.getCoresLocator();
-
-      TestHarness.validateXPath(locator.xml,
-          "/solr/cores/core[@name='collection1']",
-          "/solr/cores/core[@name='collectionLazy2']",
-          "/solr/cores/core[@name='collectionLazy3']",
-          "/solr/cores/core[@name='collectionLazy4']",
-          "/solr/cores/core[@name='collectionLazy5']",
-          "/solr/cores/core[@name='collectionLazy6']",
-          "/solr/cores/core[@name='collectionLazy7']",
-          "/solr/cores/core[@name='collectionLazy8']",
-          "/solr/cores/core[@name='collectionLazy9']",
-          "/solr/cores/core[@name='core1']",
-          "/solr/cores/core[@name='core2']",
-          "/solr/cores/core[@name='core3']",
-          "/solr/cores/core[@name='core4']",
-          "13=count(/solr/cores/core)");
-
-      removeOne(cc, "collectionLazy2");
-      removeOne(cc, "collectionLazy3");
-      removeOne(cc, "collectionLazy4");
-      removeOne(cc, "collectionLazy5");
-      removeOne(cc, "collectionLazy6");
-      removeOne(cc, "collectionLazy7");
-      removeOne(cc, "core1");
-      removeOne(cc, "core2");
-      removeOne(cc, "core3");
-      removeOne(cc, "core4");
-
-      // now test that unloading a core means the core is not persisted
-      TestHarness.validateXPath(locator.xml, "3=count(/solr/cores/core)");
-
-    } finally {
-      cc.shutdown();
-    }
-  }
-
-
   // Test that transient cores
   // 1> produce errors as appropriate when the config or schema files are foo'd
   // 2> "self heal". That is, if the problem is corrected can the core be reloaded and used?
@@ -627,12 +541,8 @@ public class TestLazyCores extends SolrT
     SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
     ConfigSolrXml config = (ConfigSolrXml) ConfigSolr.fromFile(loader, solrXml);
 
-    CoresLocator locator = new CorePropertiesLocator(solrHomeDirectory.getAbsolutePath());
-
     // OK this should succeed, but at the end we should have recorded a series of errors.
-    final CoreContainer cores = new CoreContainer(loader, config, locator);
-    cores.load();
-    return cores;
+    return createCoreContainer(config);
   }
 
   // We want to see that the core "heals itself" if an un-corrupted file is written to the directory.
@@ -669,9 +579,6 @@ public class TestLazyCores extends SolrT
     }
   }
 
-  private void removeOne(CoreContainer cc, String coreName) {
-    cc.unload(coreName);
-  }
   public static void checkNotInCores(CoreContainer cc, String... nameCheck) {
     Collection<String> names = cc.getCoreNames();
     for (String name : nameCheck) {
@@ -712,26 +619,51 @@ public class TestLazyCores extends SolrT
     return StringUtils.join(args, File.separator);
   }
 
-  private final static String LOTS_SOLR_XML = " <solr persistent=\"false\"> " +
-      "<cores adminPath=\"/admin/cores\" defaultCoreName=\"collectionLazy2\" transientCacheSize=\"4\">  " +
-      "<core name=\"collection1\" instanceDir=\"collection1\"  /> " +
+  public static class LazyCoreTestConfig extends ConfigSolr {
 
-      "<core name=\"collectionLazy2\" instanceDir=\"collection2\" transient=\"true\" loadOnStartup=\"true\"   /> " +
-
-      "<core name=\"collectionLazy3\" instanceDir=\"collection3\" transient=\"on\" loadOnStartup=\"false\"    /> " +
-
-      "<core name=\"collectionLazy4\" instanceDir=\"collection4\" transient=\"false\" loadOnStartup=\"false\" /> " +
-
-      "<core name=\"collectionLazy5\" instanceDir=\"collection5\" transient=\"false\" loadOnStartup=\"true\" /> " +
-
-      "<core name=\"collectionLazy6\" instanceDir=\"collection6\" transient=\"true\" loadOnStartup=\"false\" /> " +
-
-      "<core name=\"collectionLazy7\" instanceDir=\"collection7\" transient=\"true\" loadOnStartup=\"false\" /> " +
-
-      "<core name=\"collectionLazy8\" instanceDir=\"collection8\" transient=\"true\" loadOnStartup=\"false\" /> " +
+    public LazyCoreTestConfig(SolrResourceLoader loader) {
+      super(loader, null);
+    }
 
-      "<core name=\"collectionLazy9\" instanceDir=\"collection9\" transient=\"true\" loadOnStartup=\"false\" /> " +
+    static CoreDescriptor makeCoreDescriptor(CoreContainer cc, String coreName, String instanceDir, String isTransient, String loadOnStartup) {
+      return new CoreDescriptor(cc, coreName, instanceDir,
+          CoreDescriptor.CORE_TRANSIENT, isTransient,
+          CoreDescriptor.CORE_LOADONSTARTUP, loadOnStartup);
+    }
+
+    @Override
+    public CoresLocator getCoresLocator() {
+      return new ReadOnlyCoresLocator() {
+        @Override
+        public List<CoreDescriptor> discover(CoreContainer cc) {
+          return ImmutableList.of(
+              new CoreDescriptor(cc, "collection1", "collection1"),
+              makeCoreDescriptor(cc, "collectionLazy2", "collection2", "true", "true"),
+              makeCoreDescriptor(cc, "collectionLazy3", "collection3", "on", "false"),
+              makeCoreDescriptor(cc, "collectionLazy4", "collection4", "false", "false"),
+              makeCoreDescriptor(cc, "collectionLazy5", "collection5", "false", "true"),
+              makeCoreDescriptor(cc, "collectionLazy6", "collection6", "true", "false"),
+              makeCoreDescriptor(cc, "collectionLazy7", "collection7", "true", "false"),
+              makeCoreDescriptor(cc, "collectionLazy8", "collection8", "true", "false"),
+              makeCoreDescriptor(cc, "collectionLazy9", "collection9", "true", "false")
+          );
+        }
+      };
+    }
+
+    @Override
+    public PluginInfo getShardHandlerFactoryPluginInfo() {
+      return null;
+    }
+
+    @Override
+    protected String getProperty(CfgProp key) {
+      switch (key) {
+        case SOLR_TRANSIENTCACHESIZE:
+          return "4";
+      }
+      return null;
+    }
+  }
 
-      "</cores> " +
-      "</solr>";
 }

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java Tue Jan 20 19:09:18 2015
@@ -38,13 +38,4 @@ public class TestShardHandlerFactory ext
     cc.shutdown();
   }
 
-  public void testOldXML() throws Exception {
-    CoreContainer cc = CoreContainer.createAndLoad(TEST_HOME(), new File(TEST_HOME(), "solr-shardhandler-old.xml"));
-    ShardHandlerFactory factory = cc.getShardHandlerFactory();
-    assertTrue(factory instanceof MockShardHandlerFactory);
-    NamedList args = ((MockShardHandlerFactory)factory).args;
-    assertEquals("myMagicRequiredValue", args.get("myMagicRequiredParameter"));
-    factory.close();
-    cc.shutdown();
-  }
 }

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java Tue Jan 20 19:09:18 2015
@@ -18,30 +18,10 @@ package org.apache.solr.core;
  */
 
 
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.nio.charset.StandardCharsets;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
-
 import com.google.common.collect.ImmutableList;
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.common.cloud.DocCollection;
-import org.apache.solr.common.cloud.Replica;
-import org.apache.solr.common.cloud.Slice;
-import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.handler.TestBlobHandler;
 import org.apache.solr.handler.TestSolrConfigHandlerConcurrent;
 import org.apache.solr.util.RestTestBase;
 import org.apache.solr.util.RestTestHarness;
@@ -54,6 +34,19 @@ import org.restlet.ext.servlet.ServerSer
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
+
 import static org.apache.solr.core.ConfigOverlay.getObjectByPath;
 import static org.apache.solr.handler.TestBlobHandler.getAsString;
 

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestSolrXml.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestSolrXml.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/core/TestSolrXml.java Tue Jan 20 19:09:18 2015
@@ -88,8 +88,6 @@ public class TestSolrXml extends SolrTes
     assertEquals("trans cache size", 66, cfg.getTransientCacheSize());
     assertEquals("zk client timeout", 77, cfg.getZkClientTimeout());
     assertEquals("zk host", "testZkHost", cfg.getZkHost());
-    assertEquals("persistent", true, cfg.isPersistent());
-    assertEquals("core admin path", ConfigSolr.DEFAULT_CORE_ADMIN_PATH, cfg.getAdminPath());
   }
 
   // Test  a few property substitutions that happen to be in solr-50-all.xml.

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Tue Jan 20 19:09:18 2015
@@ -68,6 +68,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
+import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
@@ -153,7 +154,7 @@ public class TestReplicationHandler exte
   private static SolrClient createNewSolrClient(int port) {
     try {
       // setup the client...
-      HttpSolrClient client = new HttpSolrClient(buildUrl(port));
+      HttpSolrClient client = new HttpSolrClient(buildUrl(port) + "/" + DEFAULT_TEST_CORENAME);
       client.setConnectionTimeout(15000);
       client.setSoTimeout(60000);
       client.setDefaultMaxConnectionsPerHost(100);
@@ -261,18 +262,27 @@ public class TestReplicationHandler exte
   }
   
   private NamedList<Object> reloadCore(SolrClient s, String core) throws Exception {
-    
+
     ModifiableSolrParams params = new ModifiableSolrParams();
     params.set("action","reload");
     params.set("core", core);
     params.set("qt","/admin/cores");
     QueryRequest req = new QueryRequest(params);
 
-    NamedList<Object> res = s.request(req);
-
-    assertNotNull("null response from server", res);
+    HttpSolrClient adminClient = adminClient(s);
+    try {
+      NamedList<Object> res = adminClient.request(req);
+      assertNotNull("null response from server", res);
+      return res;
+    }
+    finally {
+      adminClient.shutdown();
+    }
+  }
 
-    return res;
+  private HttpSolrClient adminClient(SolrClient client) {
+    String adminUrl = ((HttpSolrClient)client).getBaseURL().replace("/collection1", "");
+    return new HttpSolrClient(adminUrl);
   }
 
   @Test
@@ -449,7 +459,7 @@ public class TestReplicationHandler exte
   //jetty servers.
   private void invokeReplicationCommand(int pJettyPort, String pCommand) throws IOException
   {
-    String masterUrl = buildUrl(pJettyPort) + "/replication?command=" + pCommand;
+    String masterUrl = buildUrl(pJettyPort) + "/" + DEFAULT_TEST_CORENAME + "/replication?command=" + pCommand;
     URL u = new URL(masterUrl);
     InputStream stream = u.openStream();
     stream.close();
@@ -608,8 +618,8 @@ public class TestReplicationHandler exte
     assertEquals(nDocs, masterQueryResult.getNumFound());
 
     // snappull
-    String masterUrl = buildUrl(slaveJetty.getLocalPort()) + "/replication?command=fetchindex&masterUrl=";
-    masterUrl += buildUrl(masterJetty.getLocalPort()) + "/replication";
+    String masterUrl = buildUrl(slaveJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME + "/replication?command=fetchindex&masterUrl=";
+    masterUrl += buildUrl(masterJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME + "/replication";
     URL url = new URL(masterUrl);
     InputStream stream = url.openStream();
     stream.close();
@@ -962,8 +972,10 @@ public class TestReplicationHandler exte
     URL url;
     InputStream stream;
     masterUrl = buildUrl(to.getLocalPort())
+        + "/" + DEFAULT_TEST_CORENAME
         + "/replication?wait=true&command=fetchindex&masterUrl="
-        + buildUrl(from.getLocalPort()) + "/replication";
+        + buildUrl(from.getLocalPort())
+        + "/" + DEFAULT_TEST_CORENAME + "/replication";
     url = new URL(masterUrl);
     stream = url.openStream();
     stream.close();
@@ -1391,34 +1403,40 @@ public class TestReplicationHandler exte
     final long sleepInterval = 200;
     long timeSlept = 0;
 
-    SolrParams p = params("action","status", "core", "collection1");
-    while (timeSlept < timeout) {
-      QueryRequest req = new QueryRequest(p);
-      req.setPath("/admin/cores");
-      try {
-        NamedList data = client.request(req);
-        for (String k : new String[] {"status","collection1"}) {
-          Object o = data.get(k);
-          assertNotNull("core status rsp missing key: " + k, o);
-          data = (NamedList) o;
-        }
-        Date startTime = (Date) data.get("startTime");
-        assertNotNull("core has null startTime", startTime);
-        if (null == min || startTime.after(min)) {
-          return startTime;
+    HttpSolrClient adminClient = adminClient(client);
+    try {
+      SolrParams p = params("action", "status", "core", "collection1");
+      while (timeSlept < timeout) {
+        QueryRequest req = new QueryRequest(p);
+        req.setPath("/admin/cores");
+        try {
+          NamedList data = adminClient.request(req);
+          for (String k : new String[]{"status", "collection1"}) {
+            Object o = data.get(k);
+            assertNotNull("core status rsp missing key: " + k, o);
+            data = (NamedList) o;
+          }
+          Date startTime = (Date) data.get("startTime");
+          assertNotNull("core has null startTime", startTime);
+          if (null == min || startTime.after(min)) {
+            return startTime;
+          }
+        } catch (SolrException e) {
+          // workarround for SOLR-4668
+          if (500 != e.code()) {
+            throw e;
+          } // else server possibly from the core reload in progress...
         }
-      } catch (SolrException e) {
-        // workarround for SOLR-4668
-        if (500 != e.code()) {
-          throw e;
-        } // else server possibly from the core reload in progress...
-      }
 
-      timeSlept += sleepInterval;
-      Thread.sleep(sleepInterval);
+        timeSlept += sleepInterval;
+        Thread.sleep(sleepInterval);
+      }
+      fail("timed out waiting for collection1 startAt time to exceed: " + min);
+      return min; // compilation neccessity
+    }
+    finally {
+      adminClient.shutdown();
     }
-    fail("timed out waiting for collection1 startAt time to exceed: " + min);
-    return min; // compilation neccessity
   }
   
   private static String buildUrl(int port) {
@@ -1476,6 +1494,11 @@ public class TestReplicationHandler exte
       System.setProperty("solr.test.sys.prop1", "propone");
       System.setProperty("solr.test.sys.prop2", "proptwo");
 
+      Properties props = new Properties();
+      props.setProperty("name", "collection1");
+
+      writeCoreProperties(homeDir.toPath().resolve("collection1"), props, "TestReplicationHandler");
+
       dataDir = new File(homeDir + "/collection1", "data");
       confDir = new File(homeDir + "/collection1", "conf");
 

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java Tue Jan 20 19:09:18 2015
@@ -73,7 +73,7 @@ public class TestReplicationHandlerBacku
   private static SolrClient createNewSolrClient(int port) {
     try {
       // setup the client...
-      HttpSolrClient client = new HttpSolrClient(buildUrl(port, context));
+      HttpSolrClient client = new HttpSolrClient(buildUrl(port, context) + "/" + DEFAULT_TEST_CORENAME);
       client.setConnectionTimeout(15000);
       client.setSoTimeout(60000);
       client.setDefaultMaxConnectionsPerHost(100);
@@ -260,7 +260,7 @@ public class TestReplicationHandlerBacku
     }
 
     public void fetchStatus() throws IOException {
-      String masterUrl = buildUrl(masterJetty.getLocalPort(), "/solr") + "/replication?command=" + ReplicationHandler.CMD_DETAILS;
+      String masterUrl = buildUrl(masterJetty.getLocalPort(), "/solr") + "/" + DEFAULT_TEST_CORENAME + "/replication?command=" + ReplicationHandler.CMD_DETAILS;
       URL url;
       InputStream stream = null;
       try {
@@ -309,10 +309,10 @@ public class TestReplicationHandlerBacku
     public void runCommand() {
       String masterUrl = null;
       if(backupName != null) {
-        masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/replication?command=" + cmd +
+        masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME + "/replication?command=" + cmd +
             "&name=" +  backupName;
       } else {
-        masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/replication?command=" + cmd +
+        masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME + "/replication?command=" + cmd +
             (addNumberToKeepInRequest ? "&" + backupKeepParamName + "=1" : "");
       }
 
@@ -343,7 +343,7 @@ public class TestReplicationHandlerBacku
     }
 
     public boolean fetchStatus() throws IOException {
-      String masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/replication?command=" + ReplicationHandler.CMD_DETAILS;
+      String masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME + "/replication?command=" + ReplicationHandler.CMD_DETAILS;
       URL url;
       InputStream stream = null;
       try {

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java Tue Jan 20 19:09:18 2015
@@ -31,7 +31,6 @@ import org.apache.solr.common.util.Named
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.SolrCore;
-import org.apache.solr.core.SolrXMLCoresLocator;
 import org.apache.solr.response.SolrQueryResponse;
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -73,8 +72,6 @@ public class CoreAdminHandlerTest extend
         new File(subHome, "solrconfig.snippet.randomindexconfig.xml"));
 
     final CoreContainer cores = h.getCoreContainer();
-    SolrXMLCoresLocator.NonPersistingLocator locator
-        = (SolrXMLCoresLocator.NonPersistingLocator) cores.getCoresLocator();
 
     final CoreAdminHandler admin = new CoreAdminHandler(cores);
 
@@ -98,15 +95,6 @@ public class CoreAdminHandlerTest extend
             resp);
     assertNull("Exception on create", resp.getException());
 
-    // First assert that these values are persisted.
-    h.validateXPath
-        (locator.xml
-            ,"/solr/cores/core[@name='" + getCoreName() + "' and @instanceDir='${INSTDIR_TEST}']"
-            ,"/solr/cores/core[@name='" + getCoreName() + "' and @dataDir='${DATA_TEST}']"
-            ,"/solr/cores/core[@name='" + getCoreName() + "' and @schema='${SCHEMA_TEST}']"
-            ,"/solr/cores/core[@name='" + getCoreName() + "' and @config='${CONFIG_TEST}']"
-        );
-
     // Now assert that certain values are properly dereferenced in the process of creating the core, see
     // SOLR-4982.
 

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java Tue Jan 20 19:09:18 2015
@@ -65,7 +65,8 @@ public class DistributedDebugComponentTe
     solrHome = createSolrHome();
     createJetty(solrHome.getAbsolutePath(), null, null);
     String url = jetty.getBaseUrl().toString();
-    collection1 = new HttpSolrClient(url);
+
+    collection1 = new HttpSolrClient(url + "/collection1");
     collection2 = new HttpSolrClient(url + "/collection2");
     
     String urlCollection1 = jetty.getBaseUrl().toString() + "/" + "collection1";
@@ -74,9 +75,16 @@ public class DistributedDebugComponentTe
     shard2 = urlCollection2.replaceAll("https?://", "");
     
     //create second core
-    CoreAdminRequest.Create req = new CoreAdminRequest.Create();
-    req.setCoreName("collection2");
-    collection1.request(req);
+    HttpSolrClient nodeClient = new HttpSolrClient(url);
+    try {
+      CoreAdminRequest.Create req = new CoreAdminRequest.Create();
+      req.setCoreName("collection2");
+      req.setConfigSet("collection1");
+      nodeClient.request(req);
+    }
+    finally {
+      nodeClient.shutdown();
+    }
     
     SolrInputDocument doc = new SolrInputDocument();
     doc.setField("id", "1");

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java Tue Jan 20 19:09:18 2015
@@ -21,6 +21,8 @@ import org.eclipse.jetty.servlet.Servlet
 import org.junit.BeforeClass;
 import org.restlet.ext.servlet.ServerServlet;
 
+import java.nio.file.Path;
+import java.util.Properties;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
@@ -42,11 +44,25 @@ abstract public class SolrRestletTestBas
    */
   @BeforeClass
   public static void init() throws Exception {
+
+    Path tempDir = createTempDir();
+    Path coresDir = tempDir.resolve("cores");
+
+    System.setProperty("coreRootDirectory", coresDir.toString());
+    System.setProperty("configSetBaseDir", TEST_HOME());
+
     final SortedMap<ServletHolder,String> extraServlets = new TreeMap<>();
     final ServletHolder solrSchemaRestApi = new ServletHolder("SolrSchemaRestApi", ServerServlet.class);
     solrSchemaRestApi.setInitParameter("org.restlet.application", "org.apache.solr.rest.SolrSchemaRestApi");
     extraServlets.put(solrSchemaRestApi, "/schema/*");  // '/schema/*' matches '/schema', '/schema/', and '/schema/whatever...'
 
+    Properties props = new Properties();
+    props.setProperty("name", DEFAULT_TEST_CORENAME);
+    props.setProperty("config", "solrconfig.xml");
+    props.setProperty("schema", "schema-rest.xml");
+    props.setProperty("configSet", "collection1");
+
+    writeCoreProperties(coresDir.resolve("core"), props, "SolrRestletTestBase");
     createJettyAndHarness(TEST_HOME(), "solrconfig.xml", "schema-rest.xml", "/solr", true, extraServlets);
   }
 }

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaDynamicFieldResource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaDynamicFieldResource.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaDynamicFieldResource.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaDynamicFieldResource.java Tue Jan 20 19:09:18 2015
@@ -16,11 +16,6 @@ package org.apache.solr.rest.schema;
  * limitations under the License.
  */
 
-import java.io.File;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.regex.Pattern;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.util.RestTestBase;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -29,6 +24,11 @@ import org.junit.Before;
 import org.junit.Test;
 import org.restlet.ext.servlet.ServerServlet;
 
+import java.io.File;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.regex.Pattern;
+
 public class TestManagedSchemaDynamicFieldResource extends RestTestBase {
 
   private static File tmpSolrHome;

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaFieldResource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaFieldResource.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaFieldResource.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/rest/schema/TestManagedSchemaFieldResource.java Tue Jan 20 19:09:18 2015
@@ -16,11 +16,6 @@ package org.apache.solr.rest.schema;
  * limitations under the License.
  */
 
-import java.io.File;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.regex.Pattern;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.util.RestTestBase;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -29,6 +24,11 @@ import org.junit.Before;
 import org.junit.Test;
 import org.restlet.ext.servlet.ServerServlet;
 
+import java.io.File;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.regex.Pattern;
+
 public class TestManagedSchemaFieldResource extends RestTestBase {
 
   private static File tmpSolrHome;

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java?rev=1653339&r1=1653338&r2=1653339&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java Tue Jan 20 19:09:18 2015
@@ -17,10 +17,7 @@
 
 package org.apache.solr.schema;
 
-import java.io.File;
-import java.nio.ByteBuffer;
-import java.util.List;
-
+import com.google.common.base.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.SolrJettyTestBase;
 import org.apache.solr.SolrTestCaseJ4;
@@ -34,6 +31,14 @@ import org.apache.solr.common.SolrDocume
 import org.apache.solr.common.SolrInputDocument;
 import org.junit.BeforeClass;
 
+import java.io.File;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.ByteBuffer;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.Properties;
+
 @SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
 public class TestBinaryField extends SolrJettyTestBase {
 
@@ -60,6 +65,12 @@ public class TestBinaryField extends Sol
     FileUtils.copyFile(new File(src_dir, "solrconfig.snippet.randomindexconfig.xml"), 
                        new File(confDir, "solrconfig.snippet.randomindexconfig.xml"));
 
+    try (Writer w = new OutputStreamWriter(Files.newOutputStream(collDir.toPath().resolve("core.properties")), Charsets.UTF_8)) {
+      Properties coreProps = new Properties();
+      coreProps.put("name", "collection1");
+      coreProps.store(w, "");
+    }
+
     createJetty(homeDir.getAbsolutePath(), null, null);
   }