You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by do...@apache.org on 2011/05/22 14:30:01 UTC

svn commit: r1125942 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/ solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java

Author: doronc
Date: Sun May 22 12:30:00 2011
New Revision: 1125942

URL: http://svn.apache.org/viewvc?rev=1125942&view=rev
Log:
SOLR-2500: TestSolrProperties sometimes fails with "no such core: core0" - merge from trunk.

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java

Modified: lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java?rev=1125942&r1=1125941&r2=1125942&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java Sun May 22 12:30:00 2011
@@ -27,7 +27,6 @@ import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrQuery;
@@ -38,6 +37,7 @@ import org.apache.solr.client.solrj.requ
 import org.apache.solr.client.solrj.request.UpdateRequest.ACTION;
 import org.apache.solr.client.solrj.response.CoreAdminResponse;
 import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.FileUtils;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.util.AbstractSolrTestCase;
 import org.junit.After;
@@ -55,6 +55,7 @@ import org.w3c.dom.Node;
 public class TestSolrProperties extends LuceneTestCase {
   protected static Logger log = LoggerFactory.getLogger(TestSolrProperties.class);
   protected CoreContainer cores = null;
+  private File home;
   private File solrXml;
   
   private static final XPathFactory xpathFactory = XPathFactory.newInstance();
@@ -63,19 +64,27 @@ public class TestSolrProperties extends 
     return "solr/shared";
   }
 
-  public String getSolrXml() {
+  public String getOrigSolrXml() {
     return "solr.xml";
   }
 
+  public String getSolrXml() {
+    return "test-solr.xml";
+  }
+  
   @Override
   @Before
   public void setUp() throws Exception {
     super.setUp();
-    File home = SolrTestCaseJ4.getFile(getSolrHome());
+    System.setProperty("solr.solr.home", getSolrHome());
+    
+    home = SolrTestCaseJ4.getFile(getSolrHome());
     System.setProperty("solr.solr.home", home.getAbsolutePath());
 
     log.info("pwd: " + (new File(".")).getAbsolutePath());
-    solrXml = new File(home, "solr.xml");
+    File origSolrXml = new File(home, getOrigSolrXml());
+    solrXml = new File(home, getSolrXml());
+    FileUtils.copyFile(origSolrXml, solrXml);
     cores = new CoreContainer(home.getAbsolutePath(), solrXml);
   }
 
@@ -84,7 +93,7 @@ public class TestSolrProperties extends 
   public void tearDown() throws Exception {
     if (cores != null)
       cores.shutdown();
-    File dataDir = new File(getSolrHome() + "/data");
+    File dataDir = new File(home,"data");
     String skip = System.getProperty("solr.test.leavedatadir");
     if (null != skip && 0 != skip.trim().length()) {
       log.info("NOTE: per solr.test.leavedatadir, dataDir will not be removed: " + dataDir.getAbsolutePath());
@@ -93,8 +102,9 @@ public class TestSolrProperties extends 
         log.warn("!!!! WARNING: best effort to remove " + dataDir.getAbsolutePath() + " FAILED !!!!!");
       }
     }
-    File persistedFile = new File(getSolrHome() + File.separator + "solr-persist.xml");
-    persistedFile.delete();
+    File persistedFile = new File(home,"solr-persist.xml");
+    assertTrue("Failed to delete "+persistedFile, persistedFile.delete());
+    assertTrue("Failed to delete "+solrXml, solrXml.delete());
     super.tearDown();
   }