This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_10x by this push:
new 3054503f680 SOLR-15788: Remove the use of
legacyExampleCollection1SolrHome() in test setup (#4147)
3054503f680 is described below
commit 3054503f680d4478751242d61455b637c23d20ac
Author: Eric Pugh <[email protected]>
AuthorDate: Mon Feb 23 09:04:30 2026 -0500
SOLR-15788: Remove the use of legacyExampleCollection1SolrHome() in test
setup (#4147)
Co-authored-by: David Smiley <[email protected]>
(cherry picked from commit f80dc744c83197aefcfa7010c33371989fba1b37)
---
.../org/apache/solr/cli/ZkSubcommandsTest.java | 17 +--
.../handler/admin/ShowFileRequestHandlerTest.java | 68 ++++++------
...oncurrentUpdateJettySolrClientBadInputTest.java | 15 ++-
.../HttpJettySolrClientCompatibilityTest.java | 29 ++++-
.../client/solrj/SolrExampleBinaryHttp2Test.java | 10 +-
.../solr/client/solrj/SolrExampleBinaryTest.java | 9 +-
.../solr/client/solrj/SolrExampleCborTest.java | 9 +-
.../apache/solr/client/solrj/SolrExampleTests.java | 119 ++++-----------------
.../solr/client/solrj/SolrExampleTestsBase.java | 37 +++----
.../solr/client/solrj/SolrExampleXMLTest.java | 9 +-
.../client/solrj/SolrSchemalessExampleTest.java | 10 +-
...SolrServer.java => EmbeddedSolrServerTest.java} | 15 ++-
.../client/solrj/embedded/JettyWebappTest.java | 2 +-
.../solrj/embedded/SolrExampleEmbeddedTest.java | 33 ------
.../solrj/embedded/SolrExampleJettyTest.java | 10 +-
.../SolrExampleStreamingBinaryHttp2Test.java | 2 +-
.../embedded/SolrExampleStreamingBinaryTest.java | 2 +-
.../embedded/SolrExampleStreamingHttp2Test.java | 14 +--
.../solrj/embedded/SolrExampleStreamingTest.java | 12 +--
.../solrj/embedded/SolrExampleXMLHttp2Test.java | 9 +-
.../impl/ConcurrentUpdateSolrClientTestBase.java | 13 ++-
.../client/solrj/impl/HttpSolrClientTestBase.java | 15 ++-
.../response/InputStreamResponseParserTest.java | 12 ++-
.../solrj/response/TestSuggesterResponse.java | 14 ++-
.../src/java/org/apache/solr/SolrTestCaseJ4.java | 39 -------
.../solrj/apache/BasicHttpSolrClientTest.java | 12 ++-
.../ConcurrentUpdateSolrClientBadInputTest.java | 15 ++-
.../apache/ConcurrentUpdateSolrClientTest.java | 13 ++-
.../solrj/apache/HttpSolrClientConPoolTest.java | 22 +++-
29 files changed, 249 insertions(+), 337 deletions(-)
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 b3a82f029a8..14c286862b0 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.junit.Test;
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 class ZkSubcommandsTest extends SolrTestCaseJ4 {
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 class ZkSubcommandsTest extends SolrTestCaseJ4 {
@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 class ZkSubcommandsTest extends SolrTestCaseJ4 {
@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 class ZkSubcommandsTest extends SolrTestCaseJ4 {
@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 0e67cf69b10..a22f7843137 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.SolrException;
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 class ShowFileRequestHandlerTest extends
SolrTestCaseJ4 {
}
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 class ShowFileRequestHandlerTest extends
SolrTestCaseJ4 {
}
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 9e1137119b4..1c78cbc6463 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 918ef1247f8..b5aafdee9ba 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 class HttpJettySolrClientCompatibilityTest extends
SolrTestCaseJ4 {
.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 class HttpJettySolrClientCompatibilityTest extends
SolrTestCaseJ4 {
.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 class HttpJettySolrClientCompatibilityTest extends
SolrTestCaseJ4 {
.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 8dc258df5bc..a9a2e8ad868 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.SolrTestCaseJ4;
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 @@ import org.junit.BeforeClass;
@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 ce47301c227..102a2beda12 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.SolrTestCaseJ4.SuppressSSL;
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 @@ import org.junit.BeforeClass;
*/
@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 b281a4557ce..59031c28b7e 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.SolrDocument;
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 @@ import org.junit.Ignore;
* 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 bb3c7df6804..b1b37ffea99 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.CommonParams;
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 @@ import org.slf4j.LoggerFactory;
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
// ant -Dtestcase=SolrExampleBinaryTest -Dtests.method=testQueryPerf
-Dtests.monster=true test
public void testQueryPerf() throws Exception {
SolrClient client = getSolrClient();
- client.deleteByQuery("*:*");
- client.commit();
+
ArrayList<SolrInputDocument> docs = new ArrayList<>();
int id = 0;
docs.add(
@@ -306,9 +311,6 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
public void testMatchAllPaging() throws Exception {
SolrClient client = getSolrClient();
- // Empty the database...
- client.deleteByQuery("*:*"); // delete everything!
- if (random().nextBoolean()) {
- client.commit();
- }
// Add eleven docs
List<SolrInputDocument> docs = new ArrayList<>();
final int docsTotal = CommonParams.ROWS_DEFAULT + 1;
@@ -768,9 +754,6 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
String rawXml = "<hello>this is <some/><xml/></hello>";
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
@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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
@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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
@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<Object> result =
@@ -1001,8 +977,7 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
@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 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
@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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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<SolrInputDocument> docs = new ArrayList<>(10);
for (int i = 1; i <= 10; i++) {
SolrInputDocument doc = new SolrInputDocument();
@@ -1279,11 +1235,6 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
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<SolrInputDocument> docs = new ArrayList<>();
docs.add(
@@ -1569,11 +1520,6 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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<SolrInputDocument> docs = new ArrayList<>();
docs.add(
@@ -1802,11 +1743,6 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
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<SolrInputDocument> docs = new ArrayList<>();
docs.add(
@@ -2102,8 +2038,6 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
@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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
// 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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
@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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
@Test
public void testExpandComponent() throws IOException, SolrServerException {
SolrClient server = getSolrClient();
- server.deleteByQuery("*:*");
ArrayList<SolrInputDocument> docs = new ArrayList<>();
docs.add(
@@ -2902,7 +2827,7 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
@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 @@ public abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 abstract class SolrExampleTests extends
SolrExampleTestsBase {
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 efb1119763e..8d41ab9ce22 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.params.CommonParams;
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 @@ public abstract class SolrExampleTestsBase extends
SolrTestCaseJ4 {
* 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 abstract class SolrExampleTestsBase extends
SolrTestCaseJ4 {
@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 abstract class SolrExampleTestsBase extends
SolrTestCaseJ4 {
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 abstract class SolrExampleTestsBase extends
SolrTestCaseJ4 {
@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 902fc5f4681..1b0efddca91 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.SolrTestCaseJ4.SuppressSSL;
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 @@ import org.junit.BeforeClass;
*/
@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 6b6aefc9939..94565fc756b 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 class SolrSchemalessExampleTest extends
SolrExampleTestsBase {
// 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 class SolrSchemalessExampleTest extends
SolrExampleTestsBase {
+ "{\"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 class SolrSchemalessExampleTest extends
SolrExampleTestsBase {
@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 f23bb602a22..3266a71ff0e 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.never;
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 class TestEmbeddedSolrServer extends SolrTestCase {
// 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 f2f4e5efc19..25d21e01001 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 79b24092a0e..00000000000
---
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 071b9ee7ffb..a35cda75311 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.request.SolrQuery;
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 @@ import org.junit.Test;
@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 class SolrExampleJettyTest extends SolrExampleTests {
// 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 b564e131a3c..d735eac5003 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 d4027739331..3a66dc2c7bc 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 bac599266ad..2139c3cb2c3 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.UpdateRequest;
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 @@ import org.junit.BeforeClass;
*/
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 class SolrExampleStreamingHttp2Test extends
SolrExampleTests {
.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 class SolrExampleStreamingHttp2Test extends
SolrExampleTests {
public void testWaitOptions() throws Exception {
// SOLR-3903
final List<Throwable> 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 a662c444c46..0625ab90591 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.UpdateRequest;
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 @@ import org.junit.BeforeClass;
*/
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 class SolrExampleStreamingTest extends
SolrExampleTests {
// SOLR-3903
// TODO these failures are not the same as recorded by the client
final List<Throwable> 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 3afeb5b3f84..ebfcc036046 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.SolrExampleTests;
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 c52e7dd33cd..4c2eca633c9 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.JavaBinUpdateRequestCodec;
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 abstract class ConcurrentUpdateSolrClientTestBase
extends SolrTestCaseJ4
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 d9f6680c70b..5efd56e69c1 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.SolrException;
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 abstract class HttpSolrClientTestBase extends
SolrTestCaseJ4 {
.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 6734b53d6a5..3332e82aa1c 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.QueryRequest;
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 @@ public class InputStreamResponseParserTest extends
SolrTestCaseJ4 {
@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 98c1bae3bd8..cf66ac7a63f 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.QueryRequest;
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 @@ public class TestSuggesterResponse extends SolrTestCaseJ4 {
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 b3f4e939c47..fb1ce4bd3b7 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.IOException;
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.http.client.HttpClient;
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.DistributedUpdateProcessor.DistribPhase;
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 abstract class SolrTestCaseJ4 extends
SolrTestCase {
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 c2b87f70419..77b8174c456 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.SolrException.ErrorCode;
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 class BasicHttpSolrClientTest extends SolrTestCaseJ4 {
.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 51202442729..8fec38bf318 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 dc0755ef5af..48dc85a8d03 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.JavaBinUpdateRequestCodec;
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 class ConcurrentUpdateSolrClientTest extends
SolrTestCaseJ4 {
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 c1ac4215f98..cbce7fe26cf 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.SolrQuery;
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();
}