diff --git a/modules/solr/build.gradle b/modules/solr/build.gradle index d2cdc0083eb..30fc1d9b833 100644 --- a/modules/solr/build.gradle +++ b/modules/solr/build.gradle @@ -5,6 +5,10 @@ dependencies { // TODO use JDK's HTTP client and/or Apache HttpClient5 shaded 'com.squareup.okhttp3:okhttp:5.1.0' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.13.4' testImplementation 'org.apache.solr:solr-solrj:8.11.4' testImplementation 'org.assertj:assertj-core:3.27.3' } @@ -14,3 +18,7 @@ tasks.japicmp { "org.testcontainers.containers.SolrContainer" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java b/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java index f678155b3c1..0e463d11111 100644 --- a/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java +++ b/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java @@ -4,38 +4,33 @@ import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.Http2SolrClient; import org.apache.solr.client.solrj.response.SolrPingResponse; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import java.io.IOException; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class SolrContainerTest { - @Parameterized.Parameters(name = "{0}") + private SolrClient client = null; + public static String[] getVersionsToTest() { return new String[] { "solr:8.11.4", "solr:9.8.0" }; } - @Parameterized.Parameter - public String solrImage; - - private SolrClient client = null; - - @After - public void stopRestClient() throws IOException { + @AfterEach + void stopRestClient() throws IOException { if (client != null) { client.close(); client = null; } } - @Test - public void solrCloudTest() throws IOException, SolrServerException { + @ParameterizedTest + @MethodSource("getVersionsToTest") + void solrCloudTest(String solrImage) throws IOException, SolrServerException { try (SolrContainer container = new SolrContainer(solrImage)) { container.start(); SolrPingResponse response = getClient(container).ping("dummy"); @@ -44,8 +39,9 @@ public void solrCloudTest() throws IOException, SolrServerException { } } - @Test - public void solrStandaloneTest() throws IOException, SolrServerException { + @ParameterizedTest + @MethodSource("getVersionsToTest") + void solrStandaloneTest(String solrImage) throws IOException, SolrServerException { try (SolrContainer container = new SolrContainer(solrImage).withZookeeper(false)) { container.start(); SolrPingResponse response = getClient(container).ping("dummy"); @@ -54,8 +50,9 @@ public void solrStandaloneTest() throws IOException, SolrServerException { } } - @Test - public void solrCloudPingTest() throws IOException, SolrServerException { + @ParameterizedTest + @MethodSource("getVersionsToTest") + void solrCloudPingTest(String solrImage) throws IOException, SolrServerException { // solrContainerUsage { // Create the solr container. SolrContainer container = new SolrContainer(solrImage);