Skip to content

Commit f37f263

Browse files
committed
Move Solr tests to JUnit Jupiter (#10766)
1 parent 69b3689 commit f37f263

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

modules/solr/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ dependencies {
55
// TODO use JDK's HTTP client and/or Apache HttpClient5
66
shaded 'com.squareup.okhttp3:okhttp:5.1.0'
77

8+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0'
9+
10+
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
11+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.13.4'
812
testImplementation 'org.apache.solr:solr-solrj:8.11.4'
913
testImplementation 'org.assertj:assertj-core:3.27.3'
1014
}
@@ -14,3 +18,7 @@ tasks.japicmp {
1418
"org.testcontainers.containers.SolrContainer"
1519
]
1620
}
21+
22+
test {
23+
useJUnitPlatform()
24+
}

modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,33 @@
44
import org.apache.solr.client.solrj.SolrServerException;
55
import org.apache.solr.client.solrj.impl.Http2SolrClient;
66
import org.apache.solr.client.solrj.response.SolrPingResponse;
7-
import org.junit.After;
8-
import org.junit.Test;
9-
import org.junit.runner.RunWith;
10-
import org.junit.runners.Parameterized;
7+
import org.junit.jupiter.api.AfterEach;
8+
import org.junit.jupiter.params.ParameterizedTest;
9+
import org.junit.jupiter.params.provider.MethodSource;
1110

1211
import java.io.IOException;
1312

1413
import static org.assertj.core.api.Assertions.assertThat;
1514

16-
@RunWith(Parameterized.class)
1715
public class SolrContainerTest {
1816

19-
@Parameterized.Parameters(name = "{0}")
17+
private SolrClient client = null;
18+
2019
public static String[] getVersionsToTest() {
2120
return new String[] { "solr:8.11.4", "solr:9.8.0" };
2221
}
2322

24-
@Parameterized.Parameter
25-
public String solrImage;
26-
27-
private SolrClient client = null;
28-
29-
@After
30-
public void stopRestClient() throws IOException {
23+
@AfterEach
24+
void stopRestClient() throws IOException {
3125
if (client != null) {
3226
client.close();
3327
client = null;
3428
}
3529
}
3630

37-
@Test
38-
public void solrCloudTest() throws IOException, SolrServerException {
31+
@ParameterizedTest
32+
@MethodSource("getVersionsToTest")
33+
void solrCloudTest(String solrImage) throws IOException, SolrServerException {
3934
try (SolrContainer container = new SolrContainer(solrImage)) {
4035
container.start();
4136
SolrPingResponse response = getClient(container).ping("dummy");
@@ -44,8 +39,9 @@ public void solrCloudTest() throws IOException, SolrServerException {
4439
}
4540
}
4641

47-
@Test
48-
public void solrStandaloneTest() throws IOException, SolrServerException {
42+
@ParameterizedTest
43+
@MethodSource("getVersionsToTest")
44+
void solrStandaloneTest(String solrImage) throws IOException, SolrServerException {
4945
try (SolrContainer container = new SolrContainer(solrImage).withZookeeper(false)) {
5046
container.start();
5147
SolrPingResponse response = getClient(container).ping("dummy");
@@ -54,8 +50,9 @@ public void solrStandaloneTest() throws IOException, SolrServerException {
5450
}
5551
}
5652

57-
@Test
58-
public void solrCloudPingTest() throws IOException, SolrServerException {
53+
@ParameterizedTest
54+
@MethodSource("getVersionsToTest")
55+
void solrCloudPingTest(String solrImage) throws IOException, SolrServerException {
5956
// solrContainerUsage {
6057
// Create the solr container.
6158
SolrContainer container = new SolrContainer(solrImage);

0 commit comments

Comments
 (0)