Apache Lucene open-source search software
SOLR-13539: Introduce EmbeddedSolrServerTestBase
Jason Gerlowski319cb005d314
diff --git a/solr/core/src/test/org/apache/solr/update/RootFieldTest.java b/solr/core/src/test/org/apache/solr/update/RootFieldTest.javaindex 7c0ad2b858f..8015d19d604 100644--- a/solr/core/src/test/org/apache/solr/update/RootFieldTest.java+++ b/solr/core/src/test/org/apache/solr/update/RootFieldTest.java@@ -17,7 +17,7 @@package org.apache.solr.update;-import org.apache.solr.SolrJettyTestBase;+import org.apache.solr.EmbeddedSolrServerTestBase;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.common.SolrDocument;@@ -32,7 +32,7 @@ import org.junit.rules.ExpectedException;import static org.hamcrest.CoreMatchers.is;-public class RootFieldTest extends SolrJettyTestBase {+public class RootFieldTest extends EmbeddedSolrServerTestBase {private static boolean useRootSchema;private static final String MESSAGE = "Update handler should create and process _root_ field " +"unless there is no such a field in schema";diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/GetByIdTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/GetByIdTest.javaindex 6085a08c5dd..3078a0a0560 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/GetByIdTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/GetByIdTest.java@@ -18,7 +18,7 @@ package org.apache.solr.client.solrj;import java.util.Arrays;-import org.apache.solr.SolrJettyTestBase;+import org.apache.solr.EmbeddedSolrServerTestBase;import org.apache.solr.common.SolrDocument;import org.apache.solr.common.SolrDocumentList;import org.apache.solr.common.params.CommonParams;@@ -27,13 +27,13 @@ import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;-public class GetByIdTest extends SolrJettyTestBase {-+public class GetByIdTest extends EmbeddedSolrServerTestBase {+@BeforeClasspublic static void beforeClass() throws Exception {initCore();}-+@Before@Overridepublic void setUp() throws Exception {@@ -43,39 +43,39 @@ public class GetByIdTest extends SolrJettyTestBase {sdoc("id", "1", "term_s", "Microsoft", "term2_s", "MSFT"),sdoc("id", "2", "term_s", "Apple", "term2_s", "AAPL"),sdoc("id", "3", "term_s", "Yahoo", "term2_s", "YHOO")));-+getSolrClient().commit(true, true);}-+@Testpublic void testGetId() throws Exception {SolrDocument rsp = getSolrClient().getById("0");assertNull(rsp);-+rsp = getSolrClient().getById("1");assertEquals("1", rsp.get("id"));assertEquals("Microsoft", rsp.get("term_s"));assertEquals("MSFT", rsp.get("term2_s"));- rsp = getSolrClient().getById("2");+ rsp = getSolrClient().getById("2");assertEquals("2", rsp.get("id"));assertEquals("Apple", rsp.get("term_s"));assertEquals("AAPL", rsp.get("term2_s"));}-+@Testpublic void testGetIdWithParams() throws Exception {final SolrParams ID_FL_ONLY = params(CommonParams.FL, "id");-+SolrDocument rsp = getSolrClient().getById("0", ID_FL_ONLY);assertNull(rsp);-+rsp = getSolrClient().getById("1", ID_FL_ONLY);assertEquals("1", rsp.get("id"));assertNull("This field should have been removed from the response.", rsp.get("term_s"));assertNull("This field should have been removed from the response.", rsp.get("term2_s"));- rsp = getSolrClient().getById("2", ID_FL_ONLY);+ rsp = getSolrClient().getById("2", ID_FL_ONLY);assertEquals("2", rsp.get("id"));assertNull("This field should have been removed from the response.", rsp.get("term_s"));assertNull("This field should have been removed from the response.", rsp.get("term2_s"));@@ -88,25 +88,25 @@ public class GetByIdTest extends SolrJettyTestBase {assertEquals("1", rsp.get(0).get("id"));assertEquals("Microsoft", rsp.get(0).get("term_s"));assertEquals("MSFT", rsp.get(0).get("term2_s"));-+assertEquals("2", rsp.get(1).get("id"));assertEquals("Apple", rsp.get(1).get("term_s"));assertEquals("AAPL", rsp.get(1).get("term2_s"));-+assertEquals("3", rsp.get(2).get("id"));assertEquals("Yahoo", rsp.get(2).get("term_s"));assertEquals("YHOO", rsp.get(2).get("term2_s"));}-+@Testpublic void testGetIdsWithParams() throws Exception {SolrDocumentList rsp = getSolrClient().getById(Arrays.asList("0", "1", "2"), params(CommonParams.FL, "id"));assertEquals(2, rsp.getNumFound());-+assertEquals("1", rsp.get(0).get("id"));assertNull("This field should have been removed from the response.", rsp.get(0).get("term_s"));assertNull("This field should have been removed from the response.", rsp.get(0).get("term2_s"));-+assertEquals("2", rsp.get(1).get("id"));assertNull("This field should have been removed from the response.", rsp.get(1).get("term_s"));assertNull("This field should have been removed from the response.", rsp.get(1).get("term2_s"));diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.javaindex 8f43c3314c5..eb1dbc53c12 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java@@ -16,7 +16,12 @@*/package org.apache.solr.client.solrj;-import org.apache.solr.SolrJettyTestBase;+import java.io.IOException;+import java.lang.invoke.MethodHandles;+import java.util.ArrayList;+import java.util.List;++import org.apache.solr.EmbeddedSolrServerTestBase;import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.client.solrj.response.UpdateResponse;@@ -25,16 +30,11 @@ import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import java.io.IOException;-import java.lang.invoke.MethodHandles;-import java.util.ArrayList;-import java.util.List;-/**** @since solr 1.3*/-public abstract class LargeVolumeTestBase extends SolrJettyTestBase+public abstract class LargeVolumeTestBase extends EmbeddedSolrServerTestBase{private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.javaindex 5b5bd111b69..3323dd0958f 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java@@ -27,6 +27,6 @@ import org.junit.BeforeClass;public class LargeVolumeBinaryJettyTest extends LargeVolumeTestBase {@BeforeClasspublic static void beforeTest() throws Exception {- createAndStartJetty(legacyExampleCollection1SolrHome());+ initCore();}}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.javaindex e7cb58f4d1f..9c172da0a61 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java@@ -24,6 +24,6 @@ import org.junit.BeforeClass;public class LargeVolumeJettyTest extends LargeVolumeTestBase {@BeforeClasspublic static void beforeTest() throws Exception {- createAndStartJetty(legacyExampleCollection1SolrHome());+ initCore();}}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.javaindex b4d89d4f015..05d871710a6 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java@@ -29,6 +29,6 @@ public class SolrExampleEmbeddedTest extends SolrExampleTests {@BeforeClasspublic static void beforeTest() throws Exception {- initCore();+ createAndStartJetty(legacyExampleCollection1SolrHome());}}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.javaindex e65049b8439..388cc78d6b4 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java@@ -16,10 +16,10 @@*/package org.apache.solr.client.solrj.request;-import junit.framework.Assert;+import java.io.File;import org.apache.commons.io.FileUtils;-import org.apache.solr.SolrJettyTestBase;+import org.apache.solr.EmbeddedSolrServerTestBase;import org.apache.solr.client.solrj.response.SolrPingResponse;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;@@ -27,12 +27,12 @@ import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;-import java.io.File;+import junit.framework.Assert;/*** Test SolrPing in Solrj*/-public class SolrPingTest extends SolrJettyTestBase {+public class SolrPingTest extends EmbeddedSolrServerTestBase {@BeforeClasspublic static void beforeClass() throws Exception {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.javaindex 681588949a3..57d6a73df2b 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java@@ -15,31 +15,33 @@* limitations under the License.*/package org.apache.solr.client.solrj.response;+import java.util.List;-import junit.framework.Assert;-import org.apache.solr.SolrJettyTestBase;+import org.apache.solr.EmbeddedSolrServerTestBase;import org.apache.solr.client.solrj.SolrQuery;-import org.apache.solr.common.SolrInputDocument;import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.response.TermsResponse.Term;+import org.apache.solr.common.SolrInputDocument;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;+import junit.framework.Assert;+/*** Test for TermComponent's response in Solrj*/-public class TermsResponseTest extends SolrJettyTestBase {-+public class TermsResponseTest extends EmbeddedSolrServerTestBase {+@BeforeClass- public static void beforeTest() throws Exception {+ public static void beforeClass() throws Exception {initCore();}-+@Before@Override- public void setUp() throws Exception{+ public void setUp() throws Exception {super.setUp();clearIndex();assertU(commit());@@ -62,7 +64,7 @@ public class TermsResponseTest extends SolrJettyTestBase {query.setTermsPrefix("s");query.addTermsField("terms_s");query.setTermsMinCount(1);-+QueryRequest request = new QueryRequest(query);List<Term> terms = request.process(getSolrClient()).getTermsResponse().getTerms("terms_s");diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.javaindex 443091b5849..8ffdefef34e 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java@@ -15,8 +15,10 @@* limitations under the License.*/package org.apache.solr.client.solrj.response;-import junit.framework.Assert;-import org.apache.solr.SolrJettyTestBase;++import java.util.List;++import org.apache.solr.EmbeddedSolrServerTestBase;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.response.SpellCheckResponse.Collation;@@ -27,7 +29,7 @@ import org.apache.solr.common.params.SpellingParams;import org.junit.BeforeClass;import org.junit.Test;-import java.util.List;+import junit.framework.Assert;/*** Test for SpellCheckComponent's response in Solrj@@ -35,12 +37,13 @@ import java.util.List;** @since solr 1.3*/-public class TestSpellCheckResponse extends SolrJettyTestBase {+public class TestSpellCheckResponse extends EmbeddedSolrServerTestBase {+@BeforeClass- public static void beforeTest() throws Exception {+ public static void beforeClass() throws Exception {initCore();}-+static String field = "name";@Test@@ -101,7 +104,7 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {// Hmmm... the API for SpellCheckResponse could be nicer:response.getSuggestions().get(0).getAlternatives().get(0);}-+@Testpublic void testSpellCheckCollationResponse() throws Exception {getSolrClient();@@ -128,7 +131,7 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {doc.setField("name", "fat of homer");client.add(doc);client.commit(true, true);-+//Test Backwards CompatibilitySolrQuery query = new SolrQuery("name:(+fauth +home +loane)");query.set(CommonParams.QT, "/spell");@@ -139,15 +142,15 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {SpellCheckResponse response = request.process(client).getSpellCheckResponse();response = request.process(client).getSpellCheckResponse();assertTrue("name:(+faith +hope +loaves)".equals(response.getCollatedResult()));-+//Test Expanded Collation Resultsquery.set(SpellingParams.SPELLCHECK_COLLATE_EXTENDED_RESULTS, true);query.set(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, 10);- query.set(SpellingParams.SPELLCHECK_MAX_COLLATIONS, 2);+ query.set(SpellingParams.SPELLCHECK_MAX_COLLATIONS, 2);request = new QueryRequest(query);response = request.process(client).getSpellCheckResponse();assertTrue("name:(+faith +hope +love)".equals(response.getCollatedResult()) || "name:(+faith +hope +loaves)".equals(response.getCollatedResult()));-+List<Collation> collations = response.getCollatedResults();assertEquals(2, collations.size());for(Collation collation : collations)@@ -174,7 +177,7 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {}}}-+query.set(SpellingParams.SPELLCHECK_COLLATE_EXTENDED_RESULTS, false);response = request.process(client).getSpellCheckResponse();{@@ -182,12 +185,12 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {assertEquals(2, collations.size());String collation1 = collations.get(0).getCollationQueryString();String collation2 = collations.get(1).getCollationQueryString();- assertFalse(collation1 + " equals " + collation2,+ assertFalse(collation1 + " equals " + collation2,collation1.equals(collation2));for(Collation collation : collations) {assertTrue("name:(+faith +hope +love)".equals(collation.getCollationQueryString()) || "name:(+faith +hope +loaves)".equals(collation.getCollationQueryString()));- }+ }}-+}}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSuggesterResponse.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSuggesterResponse.javaindex 0b3cf2ce1bd..5eb28ec5866 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSuggesterResponse.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSuggesterResponse.java@@ -15,11 +15,12 @@* limitations under the License.*/package org.apache.solr.client.solrj.response;+import java.io.IOException;import java.util.List;import java.util.Map;-import org.apache.solr.SolrJettyTestBase;+import org.apache.solr.EmbeddedSolrServerTestBase;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.request.QueryRequest;@@ -32,9 +33,10 @@ import org.junit.Test;* Test for SuggesterComponent's response in Solrj**/-public class TestSuggesterResponse extends SolrJettyTestBase {+public class TestSuggesterResponse extends EmbeddedSolrServerTestBase {+@BeforeClass- public static void beforeTest() throws Exception {+ public static void beforeClass() throws Exception {initCore();}diff --git a/solr/test-framework/src/java/org/apache/solr/EmbeddedSolrServerTestBase.java b/solr/test-framework/src/java/org/apache/solr/EmbeddedSolrServerTestBase.javanew file mode 100644index 00000000000..8df8dea8ebf--- /dev/null+++ b/solr/test-framework/src/java/org/apache/solr/EmbeddedSolrServerTestBase.java@@ -0,0 +1,160 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr;++import java.io.ByteArrayOutputStream;+import java.io.File;+import java.io.FileInputStream;+import java.io.FileOutputStream;+import java.io.IOException;+import java.io.OutputStream;+import java.io.OutputStreamWriter;+import java.io.Writer;+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.List;+import java.util.Properties;++import org.apache.commons.io.FileUtils;+import org.apache.lucene.util.LuceneTestCase;+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;+import org.apache.solr.common.util.ContentStream;+import org.apache.solr.common.util.ContentStreamBase;+import org.apache.solr.common.util.ContentStreamBase.ByteArrayStream;+import org.apache.solr.util.ExternalPaths;+import org.junit.After;+import org.junit.AfterClass;++import com.google.common.io.ByteStreams;++abstract public class EmbeddedSolrServerTestBase extends SolrTestCaseJ4 {++ protected static final String DEFAULT_CORE_NAME = "collection1";++ public static EmbeddedSolrServer client = null;++ @After+ public synchronized void afterClass() throws Exception {+ if (client != null) client.close();+ client = null;+ }++ @AfterClass+ public static void afterEmbeddedSolrServerTestBase() throws Exception {++ }++ public synchronized EmbeddedSolrServer getSolrClient() {+ if (client == null) {+ client = createNewSolrClient();+ }+ return client;+ }++ /**+ * Create a new solr client. Subclasses should override for other options.+ */+ public EmbeddedSolrServer createNewSolrClient() {+ return new EmbeddedSolrServer(h.getCoreContainer(), DEFAULT_CORE_NAME) {+ @Override+ public void close() {+ // do not close core container+ }+ };+ }++ public void upload(final String collection, final ContentStream... contents) {+ final Path base = Paths.get(getSolrClient().getCoreContainer().getSolrHome(), collection);+ writeTo(base, contents);+ }++ private void writeTo(final Path base, final ContentStream... contents) {+ try {+ if (!Files.exists(base)) {+ Files.createDirectories(base);+ }++ for (final ContentStream content : contents) {+ final File file = new File(base.toFile(), content.getName());+ file.getParentFile().mkdirs();++ try (OutputStream os = new FileOutputStream(file)) {+ ByteStreams.copy(content.getStream(), os);+ }+ }+ } catch (final IOException e) {+ throw new RuntimeException(e);+ }+ }++ public Collection<ContentStream> download(final String collection, final String... names) {+ final Path base = Paths.get(getSolrClient().getCoreContainer().getSolrHome(), collection);+ final List<ContentStream> result = new ArrayList<>();++ if (Files.exists(base)) {+ for (final String name : names) {+ final File file = new File(base.toFile(), name);+ if (file.exists() && file.canRead()) {+ try {+ final ByteArrayOutputStream os = new ByteArrayOutputStream();+ ByteStreams.copy(new FileInputStream(file), os);+ final ByteArrayStream stream = new ContentStreamBase.ByteArrayStream(os.toByteArray(), name);+ result.add(stream);+ } catch (final IOException e) {+ throw new RuntimeException(e);+ }+ }+ }+ }++ return result;+ }++ public static void initCore() throws Exception {+ final String home = legacyExampleCollection1SolrHome();+ final String config = home + "/" + DEFAULT_CORE_NAME + "/conf/solrconfig.xml";+ final String schema = home + "/" + DEFAULT_CORE_NAME + "/conf/schema.xml";+ initCore(config, schema, home);+ }++ public static String legacyExampleCollection1SolrHome() throws IOException {+ final String sourceHome = ExternalPaths.SOURCE_HOME;+ if (sourceHome == null)+ throw new IllegalStateException("No source home! Cannot create the legacy example solr home directory.");++ final File tempSolrHome = LuceneTestCase.createTempDir().toFile();+ FileUtils.copyFileToDirectory(new File(sourceHome, "server/solr/solr.xml"), tempSolrHome);+ final File collectionDir = new File(tempSolrHome, DEFAULT_CORE_NAME);+ FileUtils.forceMkdir(collectionDir);+ final File configSetDir = new File(sourceHome, "server/solr/configsets/sample_techproducts_configs/conf");+ FileUtils.copyDirectoryToDirectory(configSetDir, collectionDir);++ final Properties props = new Properties();+ props.setProperty("name", DEFAULT_CORE_NAME);++ try (Writer writer = new OutputStreamWriter(FileUtils.openOutputStream(new File(collectionDir, "core.properties")),+ "UTF-8");) {+ props.store(writer, null);+ }++ return tempSolrHome.getAbsolutePath();+ }++}diff --git a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.javaindex db415a20e29..6dcccb4c099 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java@@ -16,10 +16,16 @@*/package org.apache.solr;+import java.io.File;+import java.io.OutputStreamWriter;+import java.lang.invoke.MethodHandles;+import java.nio.file.Path;+import java.util.Properties;+import java.util.SortedMap;+import org.apache.commons.io.FileUtils;import org.apache.lucene.util.LuceneTestCase;import org.apache.solr.client.solrj.SolrClient;-import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;import org.apache.solr.client.solrj.embedded.JettyConfig;import org.apache.solr.client.solrj.embedded.JettySolrRunner;import org.apache.solr.client.solrj.impl.HttpSolrClient;@@ -31,16 +37,9 @@ import org.junit.BeforeClass;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import java.io.File;-import java.io.OutputStreamWriter;-import java.lang.invoke.MethodHandles;import java.nio.charset.StandardCharsets;-import java.nio.file.Path;-import java.util.Properties;-import java.util.SortedMap;--abstract public class SolrJettyTestBase extends SolrTestCaseJ4+abstract public class SolrJettyTestBase extends SolrTestCaseJ4{private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());@@ -55,8 +54,8 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4public static String context;public static JettySolrRunner createAndStartJetty(String solrHome, String configFile, String schemaFile, String context,- boolean stopAtShutdown, SortedMap<ServletHolder,String> extraServlets)- throws Exception {+ boolean stopAtShutdown, SortedMap<ServletHolder,String> extraServlets)+ throws Exception {// creates the data dircontext = context==null ? "/solr" : context;@@ -132,7 +131,6 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4}}-public synchronized SolrClient getSolrClient() {if (client == null) {client = createNewSolrClient();@@ -147,23 +145,13 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4* Subclasses should override for other options.*/public SolrClient createNewSolrClient() {- if (jetty != null) {- try {- // setup the client...- String url = jetty.getBaseUrl().toString() + "/" + "collection1";- HttpSolrClient client = getHttpSolrClient(url, DEFAULT_CONNECTION_TIMEOUT);- return client;- }- catch( Exception ex ) {- throw new RuntimeException( ex );- }- } else {- return new EmbeddedSolrServer( h.getCoreContainer(), "collection1" ) {- @Override- public void close() {- // do not close core container- }- };+ try {+ // setup the client...+ final String url = jetty.getBaseUrl().toString() + "/" + "collection1";+ final HttpSolrClient client = getHttpSolrClient(url, DEFAULT_CONNECTION_TIMEOUT);+ return client;+ } catch (final Exception ex) {+ throw new RuntimeException(ex);}}@@ -179,13 +167,6 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4}}- public static void initCore() throws Exception {- String exampleHome = legacyExampleCollection1SolrHome();- String exampleConfig = exampleHome+"/collection1/conf/solrconfig.xml";- String exampleSchema = exampleHome+"/collection1/conf/schema.xml";- initCore(exampleConfig, exampleSchema, exampleHome);- }-public static String legacyExampleCollection1SolrHome() {String sourceHome = ExternalPaths.SOURCE_HOME;if (sourceHome == null)@@ -226,5 +207,4 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4return legacyExampleSolrHome;}-}