From 270dee652171df1a1d67a1d67917a70d2ead99ad Mon Sep 17 00:00:00 2001 From: Steven Rowe Date: Fri, 22 Jul 2011 18:26:28 +0000 Subject: [PATCH] SOLR-2659: Fix ExternalPaths.determineSourceHome() and SolrJettyTestBase.createJetty() to allow Solrj tests to pass. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1149682 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/solr/SolrJettyTestBase.java | 2 +- .../src/java/org/apache/solr/util/ExternalPaths.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java index 608626a7581..cd10c76180e 100755 --- a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java @@ -39,7 +39,7 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4 public static JettySolrRunner createJetty(String solrHome, String configFile, String context) throws Exception { // creates the data dir - initCore(null, null); + initCore(null, null, solrHome); ignoreException("maxWarmingSearchers"); diff --git a/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java b/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java index 316bf93a239..35e41c272fa 100644 --- a/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java +++ b/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java @@ -37,7 +37,17 @@ public class ExternalPaths { static String determineSourceHome() { // ugly, ugly hack to determine the example home without depending on the CWD // this is needed for example/multicore tests which reside outside the classpath - File base = SolrTestCaseJ4.getFile("solr/conf").getAbsoluteFile(); + File file; + try { + file = new File("solr/conf"); + if (!file.exists()) { + file = new File(Thread.currentThread().getContextClassLoader().getResource("solr/conf").toURI()); + } + } catch (Exception e) { + // If there is no "solr/conf" in the classpath, fall back to searching from the current directory. + file = new File("."); + } + File base = file.getAbsoluteFile(); while (!new File(base, "solr/CHANGES.txt").exists()) { base = base.getParentFile(); }