Apache Solr open-source search software
SolrClientTestRule usage conformance (#4217)
David Smileye2f9a5057c7a
diff --git a/solr/core/src/test/org/apache/solr/TestTolerantSearch.java b/solr/core/src/test/org/apache/solr/TestTolerantSearch.javaindex 5c5b5b63470..1c3e23aa613 100644--- a/solr/core/src/test/org/apache/solr/TestTolerantSearch.java+++ b/solr/core/src/test/org/apache/solr/TestTolerantSearch.java@@ -70,8 +70,7 @@ public class TestTolerantSearch extends SolrTestCaseJ4 {@BeforeClasspublic static void createThings() throws Exception {systemSetPropertyEnableUrlAllowList(false);- Path solrHome = createSolrHome();- solrTestRule.startSolr(solrHome);+ solrTestRule.startSolr(createSolrHome());collection1 = solrTestRule.getSolrClient("collection1");diff --git a/solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.java b/solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.javaindex fc560425209..ef0f486fa30 100644--- a/solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.java+++ b/solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.java@@ -48,7 +48,7 @@ public class TestHttpRequestId extends SolrTestCaseJ4 {@BeforeClasspublic static void beforeTest() throws Exception {- solrTestRule.startSolr(createTempDir());+ solrTestRule.startSolr();}@Testdiff --git a/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.javaindex a22f7843137..69f3108ba8a 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@@ -54,11 +54,8 @@ public class ShowFileRequestHandlerTest extends SolrTestCaseJ4 {public static void beforeTest() throws Exception {EnvUtils.setProperty(ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString());- solrTestRule.startSolr(createTempDir());- solrTestRule- .newCollection("collection1")- .withConfigSet(ExternalPaths.DEFAULT_CONFIGSET)- .create();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();}private GenericSolrRequest createShowFileRequest(SolrParams params) {diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/RenameCoreAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/RenameCoreAPITest.javaindex b999e2b8cf5..d62d9bf4dd6 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/api/RenameCoreAPITest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/RenameCoreAPITest.java@@ -50,11 +50,8 @@ public class RenameCoreAPITest extends SolrTestCaseJ4 {public static void beforeTest() throws Exception {EnvUtils.setProperty(ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString());- solrTestRule.startSolr(createTempDir());- solrTestRule- .newCollection(DEFAULT_TEST_CORENAME)- .withConfigSet(ExternalPaths.DEFAULT_CONFIGSET)- .create();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();}@Testdiff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.javaindex 0295bd6a5eb..5953a970cd0 100644--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java@@ -59,7 +59,7 @@ public class DistributedDebugComponentTest extends SolrTestCaseJ4 {systemSetPropertyEnableUrlAllowList(false);EnvUtils.setProperty(ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString());- solrTestRule.startSolr(createTempDir());+ solrTestRule.startSolr();solrTestRule.newCollection("collection1")diff --git a/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java b/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.javaindex ca2a8f4b007..f099ba7d1d3 100644--- a/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java+++ b/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java@@ -54,7 +54,7 @@ public class JvmMetricsTest extends SolrTestCaseJ4 {@BeforeClasspublic static void beforeTest() throws Exception {System.setProperty("solr.metrics.jvm.enabled", "true");- solrTestRule.startSolr(createTempDir());+ solrTestRule.startSolr();}@Testdiff --git a/solr/core/src/test/org/apache/solr/response/TestErrorResponseStackTrace.java b/solr/core/src/test/org/apache/solr/response/TestErrorResponseStackTrace.javaindex cda8bbf8130..21e08e162c3 100644--- a/solr/core/src/test/org/apache/solr/response/TestErrorResponseStackTrace.java+++ b/solr/core/src/test/org/apache/solr/response/TestErrorResponseStackTrace.java@@ -24,7 +24,6 @@ import java.nio.file.Path;import org.apache.commons.codec.CharEncoding;import org.apache.http.client.methods.CloseableHttpResponse;import org.apache.http.client.methods.HttpGet;-import org.apache.lucene.tests.util.LuceneTestCase;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;import org.apache.solr.client.solrj.RemoteSolrException;@@ -67,7 +66,7 @@ public class TestErrorResponseStackTrace extends SolrTestCaseJ4 {+ " </requestHandler>\n"+ "</config>"));- solrTestRule.startSolr(LuceneTestCase.createTempDir());+ solrTestRule.startSolr();solrTestRule.newCollection().withConfigSet(configSet).create();}diff --git a/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java b/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.javaindex a8250a1ba3a..f229b01ac67 100644--- a/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java+++ b/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java@@ -26,7 +26,6 @@ import java.util.Arrays;import java.util.HashSet;import java.util.List;import java.util.Set;-import org.apache.lucene.tests.util.LuceneTestCase;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.request.MetricsRequest;@@ -51,7 +50,7 @@ public class TestPrometheusResponseWriter extends SolrTestCaseJ4 {public static void beforeClass() throws Exception {EnvUtils.setProperty(ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString());- solrTestRule.startSolr(LuceneTestCase.createTempDir());+ solrTestRule.startSolr();solrTestRule.newCollection("core1").withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();solrTestRule.newCollection("core2").withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();diff --git a/solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.java b/solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.javaindex 48016588de3..e71090e0efc 100644--- a/solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.java+++ b/solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.java@@ -50,7 +50,7 @@ public class TestDocValuesIteratorCache extends SolrTestCaseJ4 {// existence of multiple segments; if the merge policy happens to combine into a single// segment, no OrdinalMap will be built, throwing off our testssystemSetPropertySolrTestsMergePolicyFactory(NoMergePolicyFactory.class.getName());- startSolr(LuceneTestCase.createTempDir());+ startSolr();}};diff --git a/solr/core/src/test/org/apache/solr/search/json/TestJsonRequestWithEdismaxDefType.java b/solr/core/src/test/org/apache/solr/search/json/TestJsonRequestWithEdismaxDefType.javaindex 1339d1d64b2..806c57f72c8 100644--- a/solr/core/src/test/org/apache/solr/search/json/TestJsonRequestWithEdismaxDefType.java+++ b/solr/core/src/test/org/apache/solr/search/json/TestJsonRequestWithEdismaxDefType.java@@ -32,7 +32,7 @@ public class TestJsonRequestWithEdismaxDefType extends SolrTestCaseJ4 {@ClassRule public static final SolrClientTestRule solrTestRule = new EmbeddedSolrServerTestRule();public void test() throws Exception {- solrTestRule.startSolr(LuceneTestCase.createTempDir());+ solrTestRule.startSolr();Path configSet = LuceneTestCase.createTempDir();SolrTestCaseJ4.copyMinConf(configSet);diff --git a/solr/core/src/test/org/apache/solr/servlet/HideStackTraceTest.java b/solr/core/src/test/org/apache/solr/servlet/HideStackTraceTest.javaindex 2caca8ee68b..0a0986292be 100644--- a/solr/core/src/test/org/apache/solr/servlet/HideStackTraceTest.java+++ b/solr/core/src/test/org/apache/solr/servlet/HideStackTraceTest.java@@ -24,7 +24,6 @@ import java.nio.file.Path;import org.apache.http.client.methods.CloseableHttpResponse;import org.apache.http.client.methods.HttpGet;import org.apache.http.util.EntityUtils;-import org.apache.lucene.tests.util.LuceneTestCase;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;import org.apache.solr.client.solrj.apache.HttpClientUtil;@@ -66,7 +65,7 @@ public class HideStackTraceTest extends SolrTestCaseJ4 {+ " </requestHandler>\n"+ "</config>"));- solrTestRule.startSolr(LuceneTestCase.createTempDir());+ solrTestRule.startSolr();solrTestRule.newCollection().withConfigSet(configSet).create();}diff --git a/solr/core/src/test/org/apache/solr/update/CustomTLogDirTest.java b/solr/core/src/test/org/apache/solr/update/CustomTLogDirTest.javaindex 03bc0503924..334b8c3525f 100644--- a/solr/core/src/test/org/apache/solr/update/CustomTLogDirTest.java+++ b/solr/core/src/test/org/apache/solr/update/CustomTLogDirTest.java@@ -39,7 +39,7 @@ public class CustomTLogDirTest extends SolrTestCaseJ4 {@Overrideprotected void before() {System.setProperty("solr.directoryFactory", "solr.NRTCachingDirectoryFactory");- solrTestRule.startSolr(LuceneTestCase.createTempDir());+ solrTestRule.startSolr();}};diff --git a/solr/core/src/test/org/apache/solr/update/RootFieldTest.java b/solr/core/src/test/org/apache/solr/update/RootFieldTest.javaindex d5ca7c66076..1487e9ec9dd 100644--- a/solr/core/src/test/org/apache/solr/update/RootFieldTest.java+++ b/solr/core/src/test/org/apache/solr/update/RootFieldTest.java@@ -61,7 +61,11 @@ public class RootFieldTest extends SolrTestCase {String schema = useRootSchema ? "schema15.xml" : "schema-rest.xml";SolrTestCaseJ4.newRandomConfig();- solrTestRule.newCollection().withConfigSet("../collection1").withSchemaFile(schema).create();+ solrTestRule+ .newCollection()+ .withConfigSet(SolrTestCaseJ4.TEST_COLL1_CONF())+ .withSchemaFile(schema)+ .create();}@Testdiff --git a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.javaindex dfd1ac8980e..2852df097ec 100644--- a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java+++ b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java@@ -16,6 +16,7 @@*/package org.apache.solr.update.processor;+import static org.apache.solr.SolrTestCaseJ4.TEST_COLL1_CONF;import static org.apache.solr.SolrTestCaseJ4.sdoc;import static org.hamcrest.CoreMatchers.hasItems;import static org.hamcrest.CoreMatchers.not;@@ -55,7 +56,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends SolrTestCaSystem.setProperty("solr.index.updatelog.enabled", "true");SolrTestCaseJ4.newRandomConfig();- solrTestRule.newCollection().withConfigSet("../collection1").create();+ solrTestRule.newCollection().withConfigSet(TEST_COLL1_CONF()).create();}@Beforediff --git a/solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandlerNonCloud.java b/solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandlerNonCloud.javaindex 8bb82fd41b0..cae84b3a3a9 100644--- a/solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandlerNonCloud.java+++ b/solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandlerNonCloud.java@@ -47,8 +47,7 @@ public class TestSQLHandlerNonCloud extends SolrTestCaseJ4 {@BeforeClasspublic static void beforeClass() throws Exception {- Path solrHome = createSolrHome();- solrTestRule.startSolr(solrHome);+ solrTestRule.startSolr(createSolrHome());}@Testdiff --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.javaindex 1c78cbc6463..a01a522f02c 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@@ -43,11 +43,8 @@ public class ConcurrentUpdateJettySolrClientBadInputTest extends SolrTestCaseJ4public 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();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Testdiff --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.javaindex b5aafdee9ba..82b3fd8e83a 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@@ -63,10 +63,7 @@ public class HttpJettySolrClientCompatibilityTest extends SolrTestCaseJ4 {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();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();try (var client =new HttpJettySolrClient.Builder(solrTestRule.getBaseUrl() + "/debug/foo")@@ -92,10 +89,7 @@ public class HttpJettySolrClientCompatibilityTest extends SolrTestCaseJ4 {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();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();try (var client =new HttpJettySolrClient.Builder(solrTestRule.getBaseUrl() + "/debug/foo")@@ -125,10 +119,7 @@ public class HttpJettySolrClientCompatibilityTest extends SolrTestCaseJ4 {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();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();System.clearProperty("solr.http1");try (var client =diff --git a/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientProxyTest.java b/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientProxyTest.javaindex 20d44bc107d..7b4f85ba7fe 100644--- a/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientProxyTest.java+++ b/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientProxyTest.java@@ -51,7 +51,7 @@ public class HttpJettySolrClientProxyTest extends SolrTestCaseJ4 {ALLOW_PATHS_SYSPROP,ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); // Needed for configset locationsolrTestRule.enableProxy();- solrTestRule.startSolr(createTempDir());+ solrTestRule.startSolr();// Actually only need extremely minimal configSet but just use the defaultsolrTestRule.newCollection()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.javaindex 4f7c4029e12..4b0a1f286be 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@@ -103,11 +103,8 @@ public abstract class SolrExampleTests extends SolrExampleTestsBase {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();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Testdiff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java b/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.javaindex 85dd1c8266d..d64b999560b 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java@@ -51,11 +51,8 @@ public class TestBatchUpdate extends SolrTestCaseJ4 {EnvUtils.setProperty(ALLOW_PATHS_SYSPROP,ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); // Needed for configset location- solrTestRule.startSolr(createTempDir());- solrTestRule- .newCollection("collection1")- .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET)- .create();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}static final int numdocs = 1000;diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java b/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.javaindex 2a5ca071267..023874d77dd 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java@@ -66,11 +66,8 @@ public class TestSolrJErrorHandling extends SolrTestCaseJ4 {EnvUtils.setProperty(ALLOW_PATHS_SYSPROP,ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); // Needed for configset location- solrTestRule.startSolr(createTempDir());- solrTestRule- .newCollection("collection1")- .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET)- .create();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Overridediff --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.javaindex 4c2eca633c9..3ccb0f39011 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@@ -199,10 +199,7 @@ public abstract class ConcurrentUpdateSolrClientTestBase extends SolrTestCaseJ4EnvUtils.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();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@AfterClassdiff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientBadInputTest.javaindex 8eaa9feb82a..c80338e412b 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientBadInputTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientBadInputTest.java@@ -45,11 +45,8 @@ public class HttpSolrClientBadInputTest extends SolrTestCaseJ4 {EnvUtils.setProperty(ALLOW_PATHS_SYSPROP,ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); // Needed for configset location- solrTestRule.startSolr(createTempDir());- solrTestRule- .newCollection("collection1")- .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET)- .create();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Testdiff --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.javaindex 73d6d19ccfe..b9d76b80133 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@@ -97,10 +97,7 @@ public abstract class HttpSolrClientTestBase extends SolrTestCaseJ4 {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();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Overridediff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientBadInputTest.javaindex 647f912b11d..e82dcb1ca9f 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientBadInputTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientBadInputTest.java@@ -44,11 +44,8 @@ public class LBHttpSolrClientBadInputTest extends SolrTestCaseJ4 {EnvUtils.setProperty(ALLOW_PATHS_SYSPROP,ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); // Needed for configset location- solrTestRule.startSolr(createTempDir());- solrTestRule- .newCollection("collection1")- .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET)- .create();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Testdiff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.javaindex c1efae5ef56..721a9492539 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java@@ -16,6 +16,7 @@*/package org.apache.solr.client.solrj.request;+import java.nio.file.Path;import org.apache.solr.SolrTestCase;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.response.SolrPingResponse;@@ -35,10 +36,11 @@ public class SolrPingTest extends SolrTestCase {@BeforeClasspublic static void beforeClass() throws Exception {- solrTestRule.startSolr(SolrTestCaseJ4.getFile("solrj/solr"));+ Path solrHome = SolrTestCaseJ4.getFile("solrj/solr");+ solrTestRule.startSolr(solrHome);SolrTestCaseJ4.newRandomConfig();- solrTestRule.newCollection().withConfigSet("../collection1").create();+ solrTestRule.newCollection().withConfigSet(solrHome.resolve("collection1")).create();}@Beforediff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/json/DirectJsonQueryRequestFacetingEmbeddedTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/json/DirectJsonQueryRequestFacetingEmbeddedTest.javaindex 488dd83f41c..0717ab90c7d 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/json/DirectJsonQueryRequestFacetingEmbeddedTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/json/DirectJsonQueryRequestFacetingEmbeddedTest.java@@ -20,7 +20,6 @@ package org.apache.solr.client.solrj.request.json;import static org.apache.solr.SolrTestCaseJ4.getFile;import java.util.List;-import org.apache.lucene.tests.util.LuceneTestCase;import org.apache.solr.SolrTestCase;import org.apache.solr.SolrTestCaseJ4.SuppressSSL;import org.apache.solr.client.solrj.SolrClient;@@ -43,7 +42,6 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {@ClassRulepublic static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();- private static final String COLLECTION_NAME = "collection1";private static final int NUM_TECHPRODUCTS_DOCS = 32;private static final int NUM_IN_STOCK = 17;private static final int NUM_ELECTRONICS = 12;@@ -56,17 +54,14 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {@BeforeClasspublic static void beforeClass() throws Exception {- solrTestRule.startSolr(LuceneTestCase.createTempDir());+ solrTestRule.startSolr();- solrTestRule- .newCollection(COLLECTION_NAME)- .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET)- .create();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();- SolrClient client = solrTestRule.getSolrClient(COLLECTION_NAME);+ SolrClient client = solrTestRule.getSolrClient();ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");- up.setParam("collection", COLLECTION_NAME);+ up.setParam("collection", client.getDefaultCollection());up.addFile(getFile("solrj/techproducts.xml"), "application/xml");up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);UpdateResponse updateResponse = up.process(client);@@ -90,7 +85,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -125,7 +120,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -163,7 +158,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -204,7 +199,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -239,7 +234,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -260,7 +255,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -286,7 +281,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -324,7 +319,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -364,7 +359,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -403,7 +398,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -434,7 +429,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {" }","}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_TECHPRODUCTS_DOCS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -466,7 +461,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_ELECTRONICS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -497,7 +492,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_ELECTRONICS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -527,7 +522,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_ELECTRONICS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -557,7 +552,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_ELECTRONICS, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();@@ -594,7 +589,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends SolrTestCase {"}");final DirectJsonQueryRequest request = new DirectJsonQueryRequest(jsonBody);- QueryResponse response = request.process(solrTestRule.getSolrClient(), COLLECTION_NAME);+ QueryResponse response = request.process(solrTestRule.getSolrClient());assertExpectedDocumentsFoundAndReturned(response, NUM_IN_STOCK, 10);final NestableJsonFacet topLevelFacetData = response.getJsonFacetingResponse();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.javaindex 3332e82aa1c..984d19864d4 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@@ -53,11 +53,8 @@ public class InputStreamResponseParserTest extends SolrTestCaseJ4 {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();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Beforediff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSuggesterResponse.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSuggesterResponse.javaindex cf66ac7a63f..d159bcc5328 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@@ -45,11 +45,8 @@ public class TestSuggesterResponse extends SolrTestCaseJ4 {public static void beforeClass() 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();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}static String field = "cat";diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.javaindex 3a4cbe2532a..3ff7e74aaa2 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java@@ -2114,6 +2114,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {* using {@code this.getClass()}.*/public static Path getFile(String name) {+ // see if it's a classpath resourcefinal URL url =SolrTestCaseJ4.class.getClassLoader()@@ -2128,10 +2129,13 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {+ name);}}++ // see if it's a file path resourcefinal Path file = Path.of(name);if (Files.exists(file)) {- return file;+ return file.toAbsolutePath(); // absolute to reduce ambiguity}+throw new RuntimeException("Cannot find resource in classpath or in file-system (relative to CWD): "+ file.toAbsolutePath());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.javaindex 6e5320ae7ae..c7367bab551 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@@ -103,10 +103,7 @@ public class BasicHttpSolrClientTest extends SolrTestCaseJ4 {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();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Testdiff --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.javaindex 8fec38bf318..9522bb62e48 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@@ -44,11 +44,8 @@ public class ConcurrentUpdateSolrClientBadInputTest extends SolrTestCaseJ4 {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();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Testdiff --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.javaindex 48dc85a8d03..804580f6c2b 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@@ -143,10 +143,7 @@ public class ConcurrentUpdateSolrClientTest extends SolrTestCaseJ4 {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();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();}@Testdiff --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.javaindex cbce7fe26cf..1bd221afad7 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@@ -53,19 +53,13 @@ public class HttpSolrClientConPoolTest extends SolrTestCaseJ4 {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();+ solrTestRule.startSolr();+ solrTestRule.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();fooUrl = solrTestRule.getBaseUrl();- secondJetty.startSolr(createTempDir());- secondJetty- .newCollection(DEFAULT_TEST_COLLECTION_NAME)- .withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET)- .create();+ secondJetty.startSolr();+ secondJetty.newCollection().withConfigSet(ExternalPaths.TECHPRODUCTS_CONFIGSET).create();barUrl = secondJetty.getBaseUrl();}