Skip to content

Commit e2f9a50

Browse files
authored
SolrClientTestRule usage conformance (#4217)
* startSolr don't specify temp dir * newCollection don't specify collection1 * getSolrClient don't specify collection1 * withConfigSet use Path if possible org.apache.solr.SolrTestCaseJ4.getFile should return an absolute file to reduce ambiguity
1 parent c8cf0db commit e2f9a50

34 files changed

Lines changed: 81 additions & 140 deletions

solr/core/src/test/org/apache/solr/TestTolerantSearch.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ private static Path createSolrHome() throws Exception {
7070
@BeforeClass
7171
public static void createThings() throws Exception {
7272
systemSetPropertyEnableUrlAllowList(false);
73-
Path solrHome = createSolrHome();
74-
solrTestRule.startSolr(solrHome);
73+
solrTestRule.startSolr(createSolrHome());
7574

7675
collection1 = solrTestRule.getSolrClient("collection1");
7776

solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class TestHttpRequestId extends SolrTestCaseJ4 {
4848

4949
@BeforeClass
5050
public static void beforeTest() throws Exception {
51-
solrTestRule.startSolr(createTempDir());
51+
solrTestRule.startSolr();
5252
}
5353

5454
@Test

solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ public class ShowFileRequestHandlerTest extends SolrTestCaseJ4 {
5454
public static void beforeTest() throws Exception {
5555
EnvUtils.setProperty(
5656
ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString());
57-
solrTestRule.startSolr(createTempDir());
58-
solrTestRule
59-
.newCollection("collection1")
60-
.withConfigSet(ExternalPaths.DEFAULT_CONFIGSET)
61-
.create();
57+
solrTestRule.startSolr();
58+
solrTestRule.newCollection().withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();
6259
}
6360

6461
private GenericSolrRequest createShowFileRequest(SolrParams params) {

solr/core/src/test/org/apache/solr/handler/admin/api/RenameCoreAPITest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ public class RenameCoreAPITest extends SolrTestCaseJ4 {
5050
public static void beforeTest() throws Exception {
5151
EnvUtils.setProperty(
5252
ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString());
53-
solrTestRule.startSolr(createTempDir());
54-
solrTestRule
55-
.newCollection(DEFAULT_TEST_CORENAME)
56-
.withConfigSet(ExternalPaths.DEFAULT_CONFIGSET)
57-
.create();
53+
solrTestRule.startSolr();
54+
solrTestRule.newCollection().withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();
5855
}
5956

6057
@Test

solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void createThings() throws Exception {
5959
systemSetPropertyEnableUrlAllowList(false);
6060
EnvUtils.setProperty(
6161
ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString());
62-
solrTestRule.startSolr(createTempDir());
62+
solrTestRule.startSolr();
6363

6464
solrTestRule
6565
.newCollection("collection1")

solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class JvmMetricsTest extends SolrTestCaseJ4 {
5454
@BeforeClass
5555
public static void beforeTest() throws Exception {
5656
System.setProperty("solr.metrics.jvm.enabled", "true");
57-
solrTestRule.startSolr(createTempDir());
57+
solrTestRule.startSolr();
5858
}
5959

6060
@Test

solr/core/src/test/org/apache/solr/response/TestErrorResponseStackTrace.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.commons.codec.CharEncoding;
2525
import org.apache.http.client.methods.CloseableHttpResponse;
2626
import org.apache.http.client.methods.HttpGet;
27-
import org.apache.lucene.tests.util.LuceneTestCase;
2827
import org.apache.solr.SolrTestCaseJ4;
2928
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
3029
import org.apache.solr.client.solrj.RemoteSolrException;
@@ -67,7 +66,7 @@ public static void setupSolrHome() throws Exception {
6766
+ " </requestHandler>\n"
6867
+ "</config>"));
6968

70-
solrTestRule.startSolr(LuceneTestCase.createTempDir());
69+
solrTestRule.startSolr();
7170
solrTestRule.newCollection().withConfigSet(configSet).create();
7271
}
7372

solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.HashSet;
2727
import java.util.List;
2828
import java.util.Set;
29-
import org.apache.lucene.tests.util.LuceneTestCase;
3029
import org.apache.solr.SolrTestCaseJ4;
3130
import org.apache.solr.client.solrj.SolrClient;
3231
import org.apache.solr.client.solrj.request.MetricsRequest;
@@ -51,7 +50,7 @@ public class TestPrometheusResponseWriter extends SolrTestCaseJ4 {
5150
public static void beforeClass() throws Exception {
5251
EnvUtils.setProperty(
5352
ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString());
54-
solrTestRule.startSolr(LuceneTestCase.createTempDir());
53+
solrTestRule.startSolr();
5554
solrTestRule.newCollection("core1").withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();
5655
solrTestRule.newCollection("core2").withConfigSet(ExternalPaths.DEFAULT_CONFIGSET).create();
5756

solr/core/src/test/org/apache/solr/search/TestDocValuesIteratorCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected void before() throws Throwable {
5050
// existence of multiple segments; if the merge policy happens to combine into a single
5151
// segment, no OrdinalMap will be built, throwing off our tests
5252
systemSetPropertySolrTestsMergePolicyFactory(NoMergePolicyFactory.class.getName());
53-
startSolr(LuceneTestCase.createTempDir());
53+
startSolr();
5454
}
5555
};
5656

solr/core/src/test/org/apache/solr/search/json/TestJsonRequestWithEdismaxDefType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class TestJsonRequestWithEdismaxDefType extends SolrTestCaseJ4 {
3232
@ClassRule public static final SolrClientTestRule solrTestRule = new EmbeddedSolrServerTestRule();
3333

3434
public void test() throws Exception {
35-
solrTestRule.startSolr(LuceneTestCase.createTempDir());
35+
solrTestRule.startSolr();
3636

3737
Path configSet = LuceneTestCase.createTempDir();
3838
SolrTestCaseJ4.copyMinConf(configSet);

0 commit comments

Comments
 (0)