diff --git a/solr/core/src/test/org/apache/solr/cli/ZkSubcommandsTest.java b/solr/core/src/test/org/apache/solr/cli/ZkSubcommandsTest.java index b3a82f029a8f..14c286862b02 100644 --- a/solr/core/src/test/org/apache/solr/cli/ZkSubcommandsTest.java +++ b/solr/core/src/test/org/apache/solr/cli/ZkSubcommandsTest.java @@ -49,17 +49,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -// 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 ZkSubcommandsTest extends SolrTestCaseJ4 { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); protected ZkTestServer zkServer; - protected Path zkDir; - - private String solrHome; - private SolrZkClient zkClient; private PrintStream originalSystemOut; @@ -78,14 +72,12 @@ public void setUp() throws Exception { log.info("####SETUP_START {}", getTestName()); } - Path exampleHome = legacyExampleCollection1SolrHome(); - - Path tmpDir = createTempDir(); - solrHome = exampleHome.toString(); + String solrHome = createTempDir().toString(); + System.setProperty("solr.home", solrHome); originalSystemOut = System.out; - zkDir = tmpDir.resolve("zookeeper/server1/data"); + Path zkDir = createTempDir().resolve("zookeeper/server1/data"); log.info("ZooKeeper dataDir:{}", zkDir); zkServer = new ZkTestServer(zkDir); zkServer.run(); @@ -138,7 +130,6 @@ public void testPut() throws Exception { @Test public void testPutCompressed() throws Exception { // test put compressed - System.setProperty("solr.home", solrHome); System.setProperty("minStateByteLenForCompression", "0"); String data = "my data"; @@ -240,7 +231,6 @@ public void testPutFileWithoutSlash() throws Exception { @Test public void testPutFileCompressed() throws Exception { // test put file compressed - System.setProperty("solr.home", solrHome); System.setProperty("minStateByteLenForCompression", "0"); String[] args = @@ -459,7 +449,6 @@ public void testGet() throws Exception { @Test public void testGetCompressed() throws Exception { - System.setProperty("solr.home", solrHome); System.setProperty("minStateByteLenForCompression", "0"); String getNode = "/getNode"; diff --git a/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java index 0e67cf69b10e..a22f78431373 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java @@ -16,6 +16,8 @@ */ package org.apache.solr.handler.admin; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import java.io.IOException; import java.io.InputStream; import java.util.Set; @@ -32,12 +34,14 @@ import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.ContentStreamBase; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.NamedList; import org.apache.solr.core.SolrCore; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.request.SolrRequestHandler; import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.SolrJettyTestRule; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -48,8 +52,13 @@ public class ShowFileRequestHandlerTest extends SolrTestCaseJ4 { @BeforeClass public static void beforeTest() throws Exception { - initCore("solrconfig.xml", "schema.xml"); - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir()); + solrTestRule + .newCollection("collection1") + .withConfigSet(ExternalPaths.DEFAULT_CONFIGSET) + .create(); } private GenericSolrRequest createShowFileRequest(SolrParams params) { @@ -66,19 +75,17 @@ public void test404ViaHttp() { } public void test404Locally() { - // we need to test that executing the handler directly does not - // throw an exception, just sets the exception on the response. - - // bypass TestHarness since it will throw any exception found in the - // response. - SolrCore core = h.getCore(); - SolrQueryResponse rsp = new SolrQueryResponse(); - core.execute(core.getRequestHandler("/admin/file"), req("file", "does-not-exist-404.txt"), rsp); - assertNotNull("no exception in response", rsp.getException()); - assertTrue( - "wrong type of exception: " + rsp.getException().getClass(), - rsp.getException() instanceof SolrException); - assertEquals(404, ((SolrException) rsp.getException()).code()); + try (SolrCore core = solrTestRule.getCoreContainer().getCore("collection1")) { + SolrQueryResponse rsp = new SolrQueryResponse(); + SolrQueryRequest req = + new SolrQueryRequestBase(core, params("file", "does-not-exist-404.txt")); + core.execute(core.getRequestHandler("/admin/file"), req, rsp); + assertNotNull("no exception in response", rsp.getException()); + assertTrue( + "wrong type of exception: " + rsp.getException().getClass(), + rsp.getException() instanceof SolrException); + assertEquals(404, ((SolrException) rsp.getException()).code()); + } } public void testDirList() throws SolrServerException, IOException { @@ -119,26 +126,17 @@ public Set getContentTypes() { } public void testContentTypeHtmlBecomesTextPlain() { - SolrRequestHandler handler = h.getCore().getRequestHandler("/admin/file"); - SolrQueryRequest req = - new SolrQueryRequestBase( - h.getCore(), params("file", "schema.xml", "contentType", "text/html")); - SolrQueryResponse rsp = new SolrQueryResponse(); - handler.handleRequest(req, rsp); - ContentStreamBase.FileStream content = - (ContentStreamBase.FileStream) rsp.getValues().get("content"); - assertEquals("text/plain", content.getContentType()); - } - - public void testContentTypeHtmlDefault() { - SolrRequestHandler handler = h.getCore().getRequestHandler("/admin/file"); - SolrQueryRequest req = new SolrQueryRequestBase(h.getCore(), params("file", "example.html")); - SolrQueryResponse rsp = new SolrQueryResponse(); - handler.handleRequest(req, rsp); - ContentStreamBase.FileStream content = - (ContentStreamBase.FileStream) rsp.getValues().get("content"); - // System attempts to guess content type, but will only return XML, JSON, CSV, never HTML - assertEquals("application/xml", content.getContentType()); + try (SolrCore core = solrTestRule.getCoreContainer().getCore("collection1")) { + SolrRequestHandler handler = core.getRequestHandler("/admin/file"); + SolrQueryRequest req = + new SolrQueryRequestBase( + core, params("file", "managed-schema.xml", "contentType", "text/html")); + SolrQueryResponse rsp = new SolrQueryResponse(); + handler.handleRequest(req, rsp); + ContentStreamBase.FileStream content = + (ContentStreamBase.FileStream) rsp.getValues().get("content"); + assertEquals("text/plain", content.getContentType()); + } } public void testIllegalContentType() throws SolrServerException, IOException { diff --git a/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/ConcurrentUpdateJettySolrClientBadInputTest.java b/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/ConcurrentUpdateJettySolrClientBadInputTest.java index 9e1137119b49..1c78cbc6463a 100644 --- a/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/ConcurrentUpdateJettySolrClientBadInputTest.java +++ b/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/ConcurrentUpdateJettySolrClientBadInputTest.java @@ -17,11 +17,13 @@ package org.apache.solr.client.solrj.jetty; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import java.util.ArrayList; import java.util.List; -import java.util.Properties; import org.apache.solr.SolrTestCaseJ4; -import org.apache.solr.embedded.JettyConfig; +import org.apache.solr.common.util.EnvUtils; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.SolrJettyTestRule; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -39,8 +41,13 @@ public class ConcurrentUpdateJettySolrClientBadInputTest extends SolrTestCaseJ4 @BeforeClass public static void beforeTest() throws Exception { - solrTestRule.startSolr( - legacyExampleCollection1SolrHome(), new Properties(), JettyConfig.builder().build()); + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir()); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } @Test diff --git a/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientCompatibilityTest.java b/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientCompatibilityTest.java index 918ef1247f8c..b5aafdee9ba9 100644 --- a/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientCompatibilityTest.java +++ b/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientCompatibilityTest.java @@ -17,13 +17,17 @@ package org.apache.solr.client.solrj.jetty; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import java.util.Properties; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.client.solrj.RemoteSolrException; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.request.SolrQuery; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.embedded.JettyConfig; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.LogLevel; import org.apache.solr.util.ServletFixtures.DebugServlet; import org.apache.solr.util.SolrJettyTestRule; @@ -56,7 +60,13 @@ public void testConnectToOldNodesUsingHttp1() throws Exception { .withServlet(new ServletHolder(DebugServlet.class), "/debug/*") .useOnlyHttp1(true) .build(); - solrTestRule.startSolr(legacyExampleCollection1SolrHome(), new Properties(), jettyConfig); + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir(), new Properties(), jettyConfig); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); try (var client = new HttpJettySolrClient.Builder(solrTestRule.getBaseUrl() + "/debug/foo") @@ -79,7 +89,13 @@ public void testConnectToNewNodesUsingHttp1() throws Exception { .withServlet(new ServletHolder(DebugServlet.class), "/debug/*") .useOnlyHttp1(false) .build(); - solrTestRule.startSolr(legacyExampleCollection1SolrHome(), new Properties(), jettyConfig); + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir(), new Properties(), jettyConfig); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); try (var client = new HttpJettySolrClient.Builder(solrTestRule.getBaseUrl() + "/debug/foo") @@ -105,7 +121,14 @@ public void testConnectToOldNodesUsingHttp2() throws Exception { .withServlet(new ServletHolder(DebugServlet.class), "/debug/*") .useOnlyHttp1(true) .build(); - solrTestRule.startSolr(legacyExampleCollection1SolrHome(), new Properties(), jettyConfig); + + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir(), new Properties(), jettyConfig); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); System.clearProperty("solr.http1"); try (var client = diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryHttp2Test.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryHttp2Test.java index 8dc258df5bcf..a9a2e8ad868e 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryHttp2Test.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryHttp2Test.java @@ -22,7 +22,6 @@ import org.apache.solr.client.solrj.jetty.HttpJettySolrClient; import org.apache.solr.client.solrj.request.JavaBinRequestWriter; import org.apache.solr.client.solrj.response.JavaBinResponseParser; -import org.junit.BeforeClass; /** * A subclass of SolrExampleTests that explicitly uses the HTTP2 client and the binary codec for @@ -31,15 +30,10 @@ @SolrTestCaseJ4.SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776") public class SolrExampleBinaryHttp2Test extends SolrExampleTests { - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } - @Override public SolrClient createNewSolrClient() { - return new HttpJettySolrClient.Builder(getBaseUrl()) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + return new HttpJettySolrClient.Builder(solrTestRule.getBaseUrl()) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .withConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS) .withRequestWriter(new JavaBinRequestWriter()) // where the magic happens diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java index ce47301c2270..102a2beda125 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java @@ -20,7 +20,6 @@ import org.apache.solr.client.solrj.apache.HttpSolrClient; import org.apache.solr.client.solrj.request.JavaBinRequestWriter; import org.apache.solr.client.solrj.response.JavaBinResponseParser; -import org.junit.BeforeClass; /** * A subclass of SolrExampleTests that explicitly uses the HTTP1 client and the binary codec for @@ -28,15 +27,11 @@ */ @SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776") public class SolrExampleBinaryTest extends SolrExampleTests { - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } @Override public SolrClient createNewSolrClient() { - return new HttpSolrClient.Builder(getBaseUrl()) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + return new HttpSolrClient.Builder(solrTestRule.getBaseUrl()) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .allowMultiPartPost(random().nextBoolean()) .withRequestWriter(new JavaBinRequestWriter()) .withResponseParser(new JavaBinResponseParser()) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleCborTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleCborTest.java index b281a4557ce5..59031c28b7ee 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleCborTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleCborTest.java @@ -36,7 +36,6 @@ import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.util.NamedList; -import org.junit.BeforeClass; import org.junit.Ignore; /** @@ -45,15 +44,11 @@ * converts them from Map to NamedList */ public class SolrExampleCborTest extends SolrExampleTests { - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } @Override public SolrClient createNewSolrClient() { - return new HttpSolrClient.Builder(getBaseUrl()) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + return new HttpSolrClient.Builder(solrTestRule.getBaseUrl()) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .allowMultiPartPost(random().nextBoolean()) .withRequestWriter(cborRequestWriter()) .withResponseParser(cborResponseParser()) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java index bb3c7df68049..b1b37ffea995 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java @@ -17,6 +17,7 @@ package org.apache.solr.client.solrj; import static org.apache.solr.common.params.UpdateParams.ASSUME_CONTENT_TYPE; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.StringContains.containsString; @@ -75,10 +76,12 @@ import org.apache.solr.common.params.FacetParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.ContentStreamBase; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.Pair; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.RTimer; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.noggit.JSONParser; import org.slf4j.Logger; @@ -95,12 +98,15 @@ public abstract class SolrExampleTests extends SolrExampleTestsBase { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - @Before - public void emptyCollection() throws Exception { - SolrClient client = getSolrClient(); - // delete everything! - client.deleteByQuery("*:*"); - client.commit(); + @BeforeClass + public static void beforeTest() throws Exception { + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir()); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } @Test @@ -108,8 +114,7 @@ public void emptyCollection() throws Exception { // ant -Dtestcase=SolrExampleBinaryTest -Dtests.method=testQueryPerf -Dtests.monster=true test public void testQueryPerf() throws Exception { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); - client.commit(); + ArrayList docs = new ArrayList<>(); int id = 0; docs.add( @@ -306,9 +311,6 @@ public void testQueryPerf() throws Exception { public void testExampleConfig() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - // Now add something... SolrInputDocument doc = new SolrInputDocument(); String docID = "1112211111"; @@ -434,7 +436,7 @@ public void testExampleConfig() throws Exception { if (solrTestRule.getJetty() != null) { // check system wide system handler + "/admin/info/system" - String url = getBaseUrl(); + String url = solrTestRule.getBaseUrl(); try (SolrClient adminClient = getHttpSolrClient(url)) { SolrQuery q = new SolrQuery(); q.set("qt", CommonParams.SYSTEM_INFO_PATH); @@ -451,9 +453,6 @@ public void testExampleConfig() throws Exception { public void testAddRetrieve() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - // Now add something... SolrInputDocument doc1 = new SolrInputDocument(); doc1.addField("id", "id1"); @@ -499,10 +498,6 @@ public void testAddRetrieve() throws Exception { public void testFailOnVersionConflicts() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - client.request(new UpdateRequest().add("id", "id1", "name", "doc1.v1")); client.commit(); @@ -546,10 +541,6 @@ public void testFailOnVersionConflicts() throws Exception { public void testGetEmptyResults() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - // Add two docs SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "id1"); @@ -573,11 +564,6 @@ public void testGetEmptyResults() throws Exception { public void testMatchAllPaging() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - if (random().nextBoolean()) { - client.commit(); - } // Add eleven docs List docs = new ArrayList<>(); final int docsTotal = CommonParams.ROWS_DEFAULT + 1; @@ -768,9 +754,6 @@ public void testErrorHandling() throws Exception { public void testAugmentFields() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - // Now add something... SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "111"); @@ -823,9 +806,6 @@ public void testRawFields() throws Exception { String rawXml = "this is "; SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - // Now add something... SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "111"); @@ -911,8 +891,6 @@ public void testRawFields() throws Exception { @Test public void testUpdateRequestWithParameters() throws Exception { try (SolrClient client = createNewSolrClient()) { - client.deleteByQuery("*:*"); - client.commit(); SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "id1"); @@ -936,8 +914,7 @@ public void testUpdateRequestWithParameters() throws Exception { @Test public void testContentStreamRequest() throws Exception { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); // delete everything! - client.commit(); + QueryResponse rsp = client.query(new SolrQuery("*:*")); assertEquals(0, rsp.getResults().getNumFound()); @@ -985,8 +962,7 @@ public void close() throws IOException { @Test public void testStreamingRequest() throws Exception { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); // delete everything! - client.commit(); + QueryResponse rsp = client.query(new SolrQuery("*:*")); assertEquals(0, rsp.getResults().getNumFound()); NamedList result = @@ -1001,8 +977,7 @@ public void testStreamingRequest() throws Exception { @Test public void testMultiContentWriterRequest() throws Exception { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); // delete everything! - client.commit(); + QueryResponse rsp = client.query(new SolrQuery("*:*")); assertEquals(0, rsp.getResults().getNumFound()); @@ -1032,8 +1007,7 @@ private ByteBuffer getFileContent(String name) throws IOException { @Test public void testMultiContentStreamRequest() throws Exception { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); // delete everything! - client.commit(); + QueryResponse rsp = client.query(new SolrQuery("*:*")); assertEquals(0, rsp.getResults().getNumFound()); @@ -1055,9 +1029,6 @@ public void testMultiContentStreamRequest() throws Exception { public void testLukeHandler() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - SolrInputDocument[] doc = new SolrInputDocument[5]; for (int i = 0; i < doc.length; i++) { doc[i] = new SolrInputDocument(); @@ -1085,11 +1056,6 @@ public void testLukeHandler() throws Exception { public void testStatistics() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - assertNumFound("*:*", 0); // make sure it got in - String f = "val_i"; int i = 0; // 0 1 2 3 4 5 6 7 8 9 @@ -1193,11 +1159,6 @@ public void testStatistics() throws Exception { public void testPingHandler() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - assertNumFound("*:*", 0); // make sure it got in - // should be ok client.ping(); } @@ -1206,11 +1167,6 @@ public void testPingHandler() throws Exception { public void testFaceting() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - assertNumFound("*:*", 0); // make sure it got in - ArrayList docs = new ArrayList<>(10); for (int i = 1; i <= 10; i++) { SolrInputDocument doc = new SolrInputDocument(); @@ -1279,11 +1235,6 @@ public void testPivotFacets() throws Exception { public void testPivotFacetsStats() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - assertNumFound("*:*", 0); // make sure it got in - int id = 1; ArrayList docs = new ArrayList<>(); docs.add( @@ -1569,11 +1520,6 @@ public void testPivotFacetsStats() throws Exception { public void testPivotFacetsStatsNotSupported() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - assertNumFound("*:*", 0); // make sure it got in - // results of this test should be the same regardless of whether any docs in index if (random().nextBoolean()) { client.add( @@ -1636,11 +1582,6 @@ public void testPivotFacetsStatsNotSupported() throws Exception { public void testPivotFacetsQueries() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - assertNumFound("*:*", 0); // make sure it got in - int id = 1; ArrayList docs = new ArrayList<>(); docs.add( @@ -1802,11 +1743,6 @@ public void testPivotFacetsQueries() throws Exception { public void testPivotFacetsRanges() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - assertNumFound("*:*", 0); // make sure it got in - int id = 1; ArrayList docs = new ArrayList<>(); docs.add( @@ -2102,8 +2038,6 @@ public void testPivotFacetsMissing() throws Exception { private void doPivotFacetTest(boolean missing) throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! client.commit(); assertNumFound("*:*", 0); // make sure it got in @@ -2335,8 +2269,6 @@ public static SolrInputDocument makeTestDoc(Object... kvp) { @Test public void testChineseDefaults() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! client.commit(); assertNumFound("*:*", 0); // make sure it got in @@ -2360,9 +2292,6 @@ public void testChineseDefaults() throws Exception { public void testRealtimeGet() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - // Now add something... SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "DOCID"); @@ -2399,8 +2328,7 @@ public void testUpdateField() throws Exception { // Use a simple float field. "price"->"price_c" has problems: SOLR-15357 & SOLR-15358 final String field = "price_f"; SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); - client.commit(); + SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "unique"); doc.addField("name", "gadget"); @@ -2577,8 +2505,6 @@ public void testQueryWithParams() throws SolrServerException, IOException { @Test public void testChildDocTransformer() throws IOException, SolrServerException { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); - client.commit(); int numRootDocs = TestUtil.nextInt(random(), 10, 100); int maxDepth = TestUtil.nextInt(random(), 2, 5); @@ -2752,7 +2678,6 @@ public void testChildDocTransformer() throws IOException, SolrServerException { @Test public void testExpandComponent() throws IOException, SolrServerException { SolrClient server = getSolrClient(); - server.deleteByQuery("*:*"); ArrayList docs = new ArrayList<>(); docs.add( @@ -2902,7 +2827,7 @@ public void testFieldGlobbing() throws Exception { @Test public void testMoreLikeThis() throws Exception { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); + for (int i = 0; i < 20; i++) { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "testMoreLikeThis" + i); @@ -3013,7 +2938,6 @@ private SolrInputDocument genNestedDocuments( public void testAddChildToChildFreeDoc() throws IOException, SolrServerException, IllegalArgumentException, SecurityException { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); SolrInputDocument docToUpdate = new SolrInputDocument(); docToUpdate.addField("id", "p0"); @@ -3055,7 +2979,6 @@ public void testAddChildToChildFreeDoc() public void testDeleteParentDoc() throws IOException, SolrServerException, IllegalArgumentException, SecurityException { SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); SolrInputDocument docToDelete = new SolrInputDocument(); docToDelete.addField("id", "p0"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java index efb1119763e1..8d41ab9ce224 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java @@ -34,6 +34,7 @@ import org.apache.solr.common.util.TimeSource; import org.apache.solr.util.SolrJettyTestRule; import org.apache.solr.util.TimeOut; +import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; @@ -43,6 +44,14 @@ public abstract class SolrExampleTestsBase extends SolrTestCaseJ4 { private SolrClient client; + @Before + public void emptyCollection() throws Exception { + SolrClient client = getSolrClient(); + // delete everything! + client.deleteByQuery("*:*"); + client.commit(); + } + @Override public void tearDown() throws Exception { if (client != null) { @@ -69,26 +78,15 @@ protected SolrClient getSolrClient() { * options. */ public SolrClient createNewSolrClient() { - return SolrTestCaseJ4.getHttpSolrClient(solrTestRule.getBaseUrl(), DEFAULT_TEST_CORENAME); - } - - protected static String getCoreUrl() { - return solrTestRule.getBaseUrl() + "/" + DEFAULT_TEST_CORENAME; - } - - protected static String getBaseUrl() { - return solrTestRule.getBaseUrl(); + return SolrTestCaseJ4.getHttpSolrClient( + solrTestRule.getBaseUrl(), DEFAULT_TEST_COLLECTION_NAME); } - // Backward compatibility methods for existing subclasses - /** query the example */ @Test public void testCommitWithinOnAdd() throws Exception { - // make sure it is empty... SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); // delete everything! - client.commit(); + QueryResponse rsp = client.query(new SolrQuery("*:*")); assertEquals(0, rsp.getResults().getNumFound()); @@ -160,10 +158,8 @@ public void testCommitWithinOnAdd() throws Exception { @Test public void testCommitWithinOnDelete() throws Exception { - // make sure it is empty... SolrClient client = getSolrClient(); - client.deleteByQuery("*:*"); // delete everything! - client.commit(); + QueryResponse rsp = client.query(new SolrQuery("*:*")); assertEquals(0, rsp.getResults().getNumFound()); @@ -207,9 +203,6 @@ public void testCommitWithinOnDelete() throws Exception { public void testAddDelete() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - SolrInputDocument[] doc = new SolrInputDocument[3]; for (int i = 0; i < 3; i++) { doc[i] = new SolrInputDocument(); @@ -254,10 +247,6 @@ public void testAddDelete() throws Exception { @Test public void testStreamingRequest() throws Exception { SolrClient client = getSolrClient(); - // Empty the database... - client.deleteByQuery("*:*"); // delete everything! - client.commit(); - assertNumFound("*:*", 0); // make sure it got in // Add some docs to the index UpdateRequest req = new UpdateRequest(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java index 902fc5f4681d..1b0efddca917 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java @@ -20,7 +20,6 @@ import org.apache.solr.client.solrj.apache.HttpSolrClient; import org.apache.solr.client.solrj.request.XMLRequestWriter; import org.apache.solr.client.solrj.response.XMLResponseParser; -import org.junit.BeforeClass; /** * A subclass of SolrExampleTests that explicitly uses the HTTP1 client and the xml codec for @@ -28,15 +27,11 @@ */ @SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776") public class SolrExampleXMLTest extends SolrExampleTests { - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } @Override public SolrClient createNewSolrClient() { - return new HttpSolrClient.Builder(getBaseUrl()) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + return new HttpSolrClient.Builder(solrTestRule.getBaseUrl()) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .allowMultiPartPost(random().nextBoolean()) .withRequestWriter(new XMLRequestWriter()) .withResponseParser(new XMLResponseParser()) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java index 6b6aefc99393..94565fc756b9 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java @@ -80,7 +80,8 @@ public void testArbitraryJsonIndexing() throws Exception { // two docs, one with uniqueKey, another without it String json = "{\"id\":\"abc1\", \"name\": \"name1\"} {\"name\" : \"name2\"}"; HttpClient httpClient = getHttpClient(); - HttpPost post = new HttpPost(getCoreUrl() + "/update/json/docs"); + HttpPost post = + new HttpPost(solrTestRule.getBaseUrl() + "/" + DEFAULT_TEST_CORENAME + "/update/json/docs"); post.setHeader("Content-Type", "application/json"); post.setEntity( new InputStreamEntity(new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)), -1)); @@ -108,7 +109,8 @@ public void testFieldMutating() throws Exception { + "{\"p.q\" : \"name\"}" + "{\"a&b\" : \"name\"}"; HttpClient httpClient = getHttpClient(); - HttpPost post = new HttpPost(getCoreUrl() + "/update/json/docs"); + HttpPost post = + new HttpPost(solrTestRule.getBaseUrl() + "/" + DEFAULT_TEST_CORENAME + "/update/json/docs"); post.setHeader("Content-Type", "application/json"); post.setEntity( new InputStreamEntity(new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)), -1)); @@ -128,8 +130,8 @@ public void testFieldMutating() throws Exception { @Override public SolrClient createNewSolrClient() { HttpSolrClient.Builder httpSolrClientBuilder = - new HttpSolrClient.Builder(getBaseUrl()) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + new HttpSolrClient.Builder(solrTestRule.getBaseUrl()) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .allowMultiPartPost(random().nextBoolean()); if (random().nextBoolean()) { httpSolrClientBuilder diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServer.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/EmbeddedSolrServerTest.java similarity index 79% rename from solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServer.java rename to solr/solrj/src/test/org/apache/solr/client/solrj/embedded/EmbeddedSolrServerTest.java index f23bb602a221..3266a71ff0e1 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServer.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/EmbeddedSolrServerTest.java @@ -21,12 +21,18 @@ import static org.mockito.Mockito.verify; import java.io.IOException; -import org.apache.solr.SolrTestCase; import org.apache.solr.SolrTestCaseJ4; +import org.apache.solr.client.solrj.SolrClient; +import org.apache.solr.client.solrj.SolrExampleTests; import org.apache.solr.core.CoreContainer; import org.junit.BeforeClass; -public class TestEmbeddedSolrServer extends SolrTestCase { +/** + * Tests {@link EmbeddedSolrServer}. Use of {@link SolrExampleTests} is rather thorough. + * + * @since solr 1.3 + */ +public class EmbeddedSolrServerTest extends SolrExampleTests { @BeforeClass public static void beforeClass() { @@ -45,4 +51,9 @@ public void testClose() throws IOException { // CoreContainer passed in that it propagates the shutdown, but honestly tons of // tests would fail, so we're covered. } + + @Override + public SolrClient createNewSolrClient() { + return new EmbeddedSolrServer(solrTestRule.getCoreContainer(), DEFAULT_TEST_CORENAME); + } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java index f2f4e5efc192..25d21e010013 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java @@ -49,7 +49,7 @@ public class JettyWebappTest extends SolrTestCaseJ4 { @Override public void setUp() throws Exception { super.setUp(); - System.setProperty("solr.solr.home", legacyExampleCollection1SolrHome().toString()); + System.setProperty("solr.solr.home", createTempDir().toString()); System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong())); System.setProperty("solr.tests.doContainerStreamCloseAssert", "false"); 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.java deleted file mode 100644 index 79b24092a0e3..000000000000 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.client.solrj.embedded; - -import org.apache.solr.client.solrj.SolrExampleTests; -import org.junit.BeforeClass; - -/** - * This runs SolrServer test using - * - * @since solr 1.3 - */ -public class SolrExampleEmbeddedTest extends SolrExampleTests { - - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } -} diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java index 071b9ee7ffb2..a35cda753111 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java @@ -36,7 +36,6 @@ import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrInputDocument; -import org.junit.BeforeClass; import org.junit.Test; /** @@ -46,11 +45,6 @@ @SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776") public class SolrExampleJettyTest extends SolrExampleTests { - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } - @Test public void testBadSetup() { String url = "http" + (isSSLMode() ? "s" : "") + "://127.0.0.1/?core=xxx"; @@ -69,7 +63,9 @@ public void testArbitraryJsonIndexing() throws Exception { // two docs, one with uniqueKey, another without it String json = "{\"id\":\"abc1\", \"name\": \"name1\"} {\"name\" : \"name2\"}"; - HttpPost post = new HttpPost(getRandomizedUpdateUri(getCoreUrl())); + HttpPost post = + new HttpPost( + getRandomizedUpdateUri(solrTestRule.getBaseUrl() + "/" + DEFAULT_TEST_CORENAME)); post.setHeader("Content-Type", "application/json"); post.setEntity( new InputStreamEntity( diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java index b564e131a3c0..d735eac50038 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java @@ -36,7 +36,7 @@ public class SolrExampleStreamingBinaryHttp2Test extends SolrExampleStreamingHtt @Override public SolrClient createNewSolrClient() { - String url = getBaseUrl(); + String url = solrTestRule.getBaseUrl(); // smaller queue size hits locks more often var solrClient = new HttpJettySolrClient.Builder() diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java index d40277393310..3a66dc2c7bc3 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java @@ -36,7 +36,7 @@ public class SolrExampleStreamingBinaryTest extends SolrExampleStreamingTest { public SolrClient createNewSolrClient() { SolrClient client = - new ErrorTrackingConcurrentUpdateSolrClient.Builder(getBaseUrl()) + new ErrorTrackingConcurrentUpdateSolrClient.Builder(solrTestRule.getBaseUrl()) .withDefaultCollection(DEFAULT_TEST_CORENAME) .withQueueSize(2) .withThreadCount(5) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingHttp2Test.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingHttp2Test.java index bac599266ad8..2139c3cb2c33 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingHttp2Test.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingHttp2Test.java @@ -30,7 +30,6 @@ import org.apache.solr.client.solrj.request.XMLRequestWriter; import org.apache.solr.client.solrj.response.XMLResponseParser; import org.apache.solr.common.SolrInputDocument; -import org.junit.BeforeClass; /** * A subclass of SolrExampleTests that explicitly uses the HTTP2 client and the streaming update @@ -38,14 +37,9 @@ */ public class SolrExampleStreamingHttp2Test extends SolrExampleTests { - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } - @Override public SolrClient createNewSolrClient() { - String url = getBaseUrl(); + String url = solrTestRule.getBaseUrl(); // smaller queue size hits locks more often var solrClient = new HttpJettySolrClient.Builder() @@ -54,7 +48,7 @@ public SolrClient createNewSolrClient() { .build(); var concurrentClient = new ErrorTrackingConcurrentUpdateSolrClient.Builder(url, solrClient) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .withQueueSize(2) .withThreadCount(5) .build(); @@ -64,11 +58,11 @@ public SolrClient createNewSolrClient() { public void testWaitOptions() throws Exception { // SOLR-3903 final List failures = new ArrayList<>(); - final String serverUrl = getBaseUrl(); + final String serverUrl = solrTestRule.getBaseUrl(); try (var http2Client = new HttpJettySolrClient.Builder().build(); var concurrentClient = new FailureRecordingConcurrentUpdateSolrClient.Builder(serverUrl, http2Client) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .withQueueSize(2) .withThreadCount(2) .build()) { diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java index a662c444c463..0625ab905919 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java @@ -28,7 +28,6 @@ import org.apache.solr.client.solrj.request.XMLRequestWriter; import org.apache.solr.client.solrj.response.XMLResponseParser; import org.apache.solr.common.SolrInputDocument; -import org.junit.BeforeClass; /** * A subclass of SolrExampleTests that explicitly uses the HTTP1 client and the streaming update @@ -36,16 +35,11 @@ */ public class SolrExampleStreamingTest extends SolrExampleTests { - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } - @Override public SolrClient createNewSolrClient() { // smaller queue size hits locks more often - return new ErrorTrackingConcurrentUpdateSolrClient.Builder(getBaseUrl()) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + return new ErrorTrackingConcurrentUpdateSolrClient.Builder(solrTestRule.getBaseUrl()) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .withQueueSize(2) .withThreadCount(5) .withResponseParser(new XMLResponseParser()) @@ -57,7 +51,7 @@ public void testWaitOptions() throws Exception { // SOLR-3903 // TODO these failures are not the same as recorded by the client final List failures = new ArrayList<>(); - final String serverUrl = getCoreUrl(); + final String serverUrl = solrTestRule.getBaseUrl() + "/" + DEFAULT_TEST_CORENAME; try (ConcurrentUpdateSolrClient concurrentClient = new FailureRecordingConcurrentUpdateSolrClient.Builder(serverUrl) .withQueueSize(2) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleXMLHttp2Test.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleXMLHttp2Test.java index 3afeb5b3f84b..ebfcc0360466 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleXMLHttp2Test.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleXMLHttp2Test.java @@ -23,24 +23,19 @@ import org.apache.solr.client.solrj.jetty.HttpJettySolrClient; import org.apache.solr.client.solrj.request.XMLRequestWriter; import org.apache.solr.client.solrj.response.XMLResponseParser; -import org.junit.BeforeClass; /** * A subclass of SolrExampleTests that explicitly uses the HTTP2 client and the xml codec for * communication. */ public class SolrExampleXMLHttp2Test extends SolrExampleTests { - @BeforeClass - public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); - } @Override public SolrClient createNewSolrClient() { var client = - new HttpJettySolrClient.Builder(getBaseUrl()) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + new HttpJettySolrClient.Builder(solrTestRule.getBaseUrl()) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .withConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS) .withRequestWriter(new XMLRequestWriter()) .withResponseParser(new XMLResponseParser()) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTestBase.java index c52e7dd33cda..4c2eca633c94 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTestBase.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTestBase.java @@ -17,6 +17,8 @@ package org.apache.solr.client.solrj.impl; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; @@ -44,9 +46,11 @@ import org.apache.solr.client.solrj.request.SolrQuery; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.common.SolrInputDocument; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.SolrNamedThreadFactory; import org.apache.solr.embedded.JettyConfig; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.SolrJettyTestRule; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.junit.AfterClass; @@ -191,7 +195,14 @@ public void run() { public static void beforeTest() throws Exception { JettyConfig jettyConfig = JettyConfig.builder().withServlet(new ServletHolder(TestServlet.class), "/cuss/*").build(); - solrTestRule.startSolr(legacyExampleCollection1SolrHome(), new Properties(), jettyConfig); + + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir(), new Properties(), jettyConfig); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } @AfterClass diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java index d9f6680c70ba..5efd56e69c19 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java @@ -17,6 +17,7 @@ package org.apache.solr.client.solrj.impl; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; import static org.hamcrest.CoreMatchers.instanceOf; import java.io.IOException; @@ -52,8 +53,10 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.MapSolrParams; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.NamedList; import org.apache.solr.embedded.JettyConfig; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.ServletFixtures.DebugServlet; import org.apache.solr.util.ServletFixtures.RedirectServlet; import org.apache.solr.util.ServletFixtures.SlowServlet; @@ -67,7 +70,7 @@ public abstract class HttpSolrClientTestBase extends SolrTestCaseJ4 { @ClassRule public static SolrJettyTestRule solrTestRule = new SolrJettyTestRule(); - protected static final String DEFAULT_COLLECTION = DEFAULT_TEST_CORENAME; + protected static final String DEFAULT_COLLECTION = DEFAULT_TEST_COLLECTION_NAME; protected static final String SLOW_SERVLET_PATH = "/slow"; protected static final String SLOW_SERVLET_REGEX = SLOW_SERVLET_PATH + "/*"; protected static final String DEBUG_SERVLET_PATH = "/debug"; @@ -76,7 +79,6 @@ public abstract class HttpSolrClientTestBase extends SolrTestCaseJ4 { protected static final String REDIRECT_SERVLET_REGEX = REDIRECT_SERVLET_PATH + "/*"; protected static final String SLOW_STREAM_SERVLET_PATH = "/slowStream"; protected static final String SLOW_STREAM_SERVLET_REGEX = SLOW_STREAM_SERVLET_PATH + "/*"; - protected static final String COLLECTION_1 = "collection1"; // example chars that must be URI encoded - non-ASCII and curly quote protected static final String MUST_ENCODE = "\u1234\u007B"; @@ -90,7 +92,14 @@ public static void beforeTest() throws Exception { .withServlet(new ServletHolder(SlowStreamServlet.class), SLOW_STREAM_SERVLET_REGEX) .withSSLConfig(sslConfig.buildServerSSLConfig()) .build(); - solrTestRule.startSolr(legacyExampleCollection1SolrHome(), new Properties(), jettyConfig); + + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir(), new Properties(), jettyConfig); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } @Override diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/InputStreamResponseParserTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/InputStreamResponseParserTest.java index 6734b53d6a57..3332e82aa1ce 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/InputStreamResponseParserTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/InputStreamResponseParserTest.java @@ -16,6 +16,8 @@ */ package org.apache.solr.client.solrj.response; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -29,7 +31,9 @@ import org.apache.solr.client.solrj.request.SolrQuery; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrInputDocument; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.NamedList; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.SolrJettyTestRule; import org.junit.Before; import org.junit.BeforeClass; @@ -47,7 +51,13 @@ private static InputStream getResponse() { @BeforeClass public static void beforeTest() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir()); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } @Before 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.java index 98c1bae3bd88..cf66ac7a63f7 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 @@ -16,6 +16,8 @@ */ package org.apache.solr.client.solrj.response; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import java.io.IOException; import java.util.List; import java.util.Map; @@ -27,6 +29,8 @@ import org.apache.solr.client.solrj.request.SolrQuery; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.util.EnvUtils; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.SolrJettyTestRule; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -39,7 +43,13 @@ public class TestSuggesterResponse extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir()); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } static String field = "cat"; @@ -139,7 +149,7 @@ private SolrClient createSuggestSolrClient() { random().nextBoolean() ? new JavaBinResponseParser() : new XMLResponseParser(); return new HttpSolrClient.Builder() .withBaseSolrUrl(solrTestRule.getBaseUrl()) - .withDefaultCollection(DEFAULT_TEST_CORENAME) + .withDefaultCollection(DEFAULT_TEST_COLLECTION_NAME) .withResponseParser(randomParser) .build(); } diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index b3f4e939c477..fb1ce4bd3b72 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -27,7 +27,6 @@ import java.io.OutputStreamWriter; import java.io.StringReader; import java.io.StringWriter; -import java.io.UncheckedIOException; import java.io.Writer; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -74,8 +73,6 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.tests.analysis.MockTokenizer; -import org.apache.lucene.tests.mockfile.FilterPath; -import org.apache.lucene.tests.util.LuceneTestCase; import org.apache.lucene.tests.util.LuceneTestCase.SuppressFileSystems; import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.Constants; @@ -132,9 +129,7 @@ import org.apache.solr.update.processor.DistributedZkUpdateProcessor; import org.apache.solr.update.processor.UpdateRequestProcessor; import org.apache.solr.util.BaseTestHarness; -import org.apache.solr.util.DirectoryUtil; import org.apache.solr.util.ErrorLogMuter; -import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.RandomizeSSL; import org.apache.solr.util.RandomizeSSL.SSLRandomizer; import org.apache.solr.util.RefCounted; @@ -2279,40 +2274,6 @@ public static void copySolrHomeToTemp(Path dstRoot, String collection) throws IO Files.copy(top.resolve("synonyms.txt"), subHome.resolve("synonyms.txt")); } - /** Creates a temp solr home using sample_techproducts_configs. Returns the home path. */ - @Deprecated // Instead use a basic config + whatever is needed or default config - public static Path legacyExampleCollection1SolrHome() { - Path sourceHome = ExternalPaths.SOURCE_HOME; - if (sourceHome == null) - throw new IllegalStateException( - "No source home! Cannot create the legacy example solr home directory."); - - try { - Path tempSolrHome = FilterPath.unwrap(LuceneTestCase.createTempDir()); - Path serverSolr = tempSolrHome.resolve(sourceHome).resolve("server").resolve("solr"); - - Path sourceConfig = serverSolr.resolve("configsets").resolve("sample_techproducts_configs"); - Path collection1Dir = tempSolrHome.resolve("collection1"); - - DirectoryUtil.copyDirectoryContents( - sourceConfig.resolve("conf"), collection1Dir.resolve("conf")); - - Properties props = new Properties(); - props.setProperty("name", "collection1"); - try (Writer writer = - new OutputStreamWriter( - Files.newOutputStream(collection1Dir.resolve("core.properties")), - StandardCharsets.UTF_8)) { - props.store(writer, null); - } - return tempSolrHome; - } catch (RuntimeException e) { - throw e; - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - public boolean compareSolrDocument(Object expected, Object actual) { if (!(expected instanceof SolrDocument solrDocument1) diff --git a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/BasicHttpSolrClientTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/BasicHttpSolrClientTest.java index c2b87f704196..77b8174c4565 100644 --- a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/BasicHttpSolrClientTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/BasicHttpSolrClientTest.java @@ -16,6 +16,8 @@ */ package org.apache.solr.client.solrj.apache; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import java.io.IOException; import java.io.InputStream; import java.lang.invoke.MethodHandles; @@ -65,8 +67,10 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.ModifiableSolrParams; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.NamedList; import org.apache.solr.embedded.JettyConfig; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.ServletFixtures.DebugServlet; import org.apache.solr.util.ServletFixtures.RedirectServlet; import org.apache.solr.util.ServletFixtures.SlowServlet; @@ -95,7 +99,13 @@ public static void beforeTest() throws Exception { .withServlet(new ServletHolder(DebugServlet.class), "/debug/*") .withServlet(new ServletHolder(SlowStreamServlet.class), "/slowStream/*") .build(); - solrTestRule.startSolr(legacyExampleCollection1SolrHome(), new Properties(), jettyConfig); + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir(), new Properties(), jettyConfig); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } @Test diff --git a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBadInputTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBadInputTest.java index 51202442729d..8fec38bf3188 100644 --- a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBadInputTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBadInputTest.java @@ -17,12 +17,14 @@ package org.apache.solr.client.solrj.apache; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import java.util.ArrayList; import java.util.List; -import java.util.Properties; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.embedded.JettyConfig; +import org.apache.solr.common.util.EnvUtils; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.SolrJettyTestRule; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -40,8 +42,13 @@ public class ConcurrentUpdateSolrClientBadInputTest extends SolrTestCaseJ4 { @BeforeClass public static void beforeTest() throws Exception { - solrTestRule.startSolr( - legacyExampleCollection1SolrHome(), new Properties(), JettyConfig.builder().build()); + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir()); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } @Test diff --git a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientTest.java index dc0755ef5af6..48dc85a8d034 100644 --- a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientTest.java @@ -16,6 +16,8 @@ */ package org.apache.solr.client.solrj.apache; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; @@ -39,9 +41,11 @@ import org.apache.solr.client.solrj.request.SolrQuery; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.common.SolrInputDocument; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.SolrNamedThreadFactory; import org.apache.solr.embedded.JettyConfig; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.SolrJettyTestRule; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.junit.BeforeClass; @@ -135,7 +139,14 @@ public void update( public static void beforeTest() throws Exception { JettyConfig jettyConfig = JettyConfig.builder().withServlet(new ServletHolder(TestServlet.class), "/cuss/*").build(); - solrTestRule.startSolr(legacyExampleCollection1SolrHome(), new Properties(), jettyConfig); + + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir(), new Properties(), jettyConfig); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); } @Test diff --git a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/HttpSolrClientConPoolTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/HttpSolrClientConPoolTest.java index c1ac4215f985..cbce7fe26cfb 100644 --- a/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/HttpSolrClientConPoolTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/HttpSolrClientConPoolTest.java @@ -16,6 +16,8 @@ */ package org.apache.solr.client.solrj.apache; +import static org.apache.solr.core.CoreContainer.ALLOW_PATHS_SYSPROP; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -32,8 +34,10 @@ import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.ModifiableSolrParams; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.SolrNamedThreadFactory; +import org.apache.solr.util.ExternalPaths; import org.apache.solr.util.SolrJettyTestRule; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -46,11 +50,23 @@ public class HttpSolrClientConPoolTest extends SolrTestCaseJ4 { private static String barUrl; // second Jetty URL @BeforeClass - public static void beforeTest() { - solrTestRule.startSolr(legacyExampleCollection1SolrHome()); + public static void beforeTest() throws SolrServerException, IOException { + EnvUtils.setProperty( + ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); + solrTestRule.startSolr(createTempDir()); + solrTestRule + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); + fooUrl = solrTestRule.getBaseUrl(); - secondJetty.startSolr(legacyExampleCollection1SolrHome()); + secondJetty.startSolr(createTempDir()); + secondJetty + .newCollection(DEFAULT_TEST_COLLECTION_NAME) + .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET) + .create(); + barUrl = secondJetty.getBaseUrl(); }