From 56dbe84cb43c1b7db479704bc70913136d621373 Mon Sep 17 00:00:00 2001 From: Chris Bono Date: Mon, 6 Feb 2023 15:02:32 -0600 Subject: [PATCH] Remove duplicate PulsarTestContainerSupport (#316) Also: * Re-order (alpha) test dependencies --- spring-pulsar-reactive/build.gradle | 5 +- .../core/PulsarTestContainerSupport.java | 64 ------------------- .../core/ReactivePulsarTemplateTests.java | 2 +- ...vePulsarMessageListenerContainerTests.java | 4 +- .../listener/ReactivePulsarListenerTests.java | 2 +- .../build.gradle | 3 +- spring-pulsar/build.gradle | 8 ++- 7 files changed, 14 insertions(+), 74 deletions(-) delete mode 100644 spring-pulsar-reactive/src/test/java/org/springframework/pulsar/core/PulsarTestContainerSupport.java diff --git a/spring-pulsar-reactive/build.gradle b/spring-pulsar-reactive/build.gradle index d0408e1a..4064543f 100644 --- a/spring-pulsar-reactive/build.gradle +++ b/spring-pulsar-reactive/build.gradle @@ -16,13 +16,14 @@ dependencies { optional 'com.jayway.jsonpath:json-path' optional 'io.projectreactor:reactor-core' - testImplementation 'org.junit.jupiter:junit-jupiter' - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + testImplementation project(':spring-pulsar-test') testRuntimeOnly 'ch.qos.logback:logback-classic' testImplementation 'io.projectreactor:reactor-test' testImplementation 'org.assertj:assertj-core' testImplementation 'org.awaitility:awaitility' testImplementation 'org.hamcrest:hamcrest' + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' testImplementation 'org.mockito:mockito-junit-jupiter' testImplementation 'org.springframework:spring-test' testImplementation 'org.testcontainers:junit-jupiter' diff --git a/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/core/PulsarTestContainerSupport.java b/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/core/PulsarTestContainerSupport.java deleted file mode 100644 index 2198b8da..00000000 --- a/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/core/PulsarTestContainerSupport.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2022 the original author or authors. - * - * Licensed 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 - * - * https://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.springframework.pulsar.core; - -import java.util.Locale; - -import org.junit.jupiter.api.BeforeAll; -import org.testcontainers.containers.PulsarContainer; -import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; - -/** - * Provides a static {@link PulsarContainer} that can be shared across test classes. - * - * @author Chris Bono - */ -@Testcontainers(disabledWithoutDocker = true) -public interface PulsarTestContainerSupport { - - PulsarContainer PULSAR_CONTAINER = new PulsarContainer( - isRunningOnMacM1() ? getMacM1PulsarImage() : getStandardPulsarImage()); - - @BeforeAll - static void startContainer() { - PULSAR_CONTAINER.start(); - } - - static String getPulsarBrokerUrl() { - return PULSAR_CONTAINER.getPulsarBrokerUrl(); - } - - static String getHttpServiceUrl() { - return PULSAR_CONTAINER.getHttpServiceUrl(); - } - - private static boolean isRunningOnMacM1() { - String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); - String osArchitecture = System.getProperty("os.arch").toLowerCase(Locale.ENGLISH); - return osName.contains("mac") && osArchitecture.equals("aarch64"); - } - - private static DockerImageName getStandardPulsarImage() { - return DockerImageName.parse("apachepulsar/pulsar:2.10.3"); - } - - private static DockerImageName getMacM1PulsarImage() { - return DockerImageName.parse("kezhenxu94/pulsar").asCompatibleSubstituteFor("apachepulsar/pulsar"); - } - -} diff --git a/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/core/ReactivePulsarTemplateTests.java b/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/core/ReactivePulsarTemplateTests.java index 6a3ddd4b..a40ba121 100644 --- a/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/core/ReactivePulsarTemplateTests.java +++ b/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/core/ReactivePulsarTemplateTests.java @@ -44,7 +44,7 @@ import org.junit.jupiter.params.provider.ValueSource; import org.springframework.pulsar.core.DefaultSchemaResolver; import org.springframework.pulsar.core.DefaultTopicResolver; -import org.springframework.pulsar.core.PulsarTestContainerSupport; +import org.springframework.pulsar.test.support.PulsarTestContainerSupport; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/DefaultReactivePulsarMessageListenerContainerTests.java b/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/DefaultReactivePulsarMessageListenerContainerTests.java index 5c987fb2..43f3a0f9 100644 --- a/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/DefaultReactivePulsarMessageListenerContainerTests.java +++ b/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/DefaultReactivePulsarMessageListenerContainerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,10 +39,10 @@ import org.apache.pulsar.reactive.client.api.ReactivePulsarClient; import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; -import org.springframework.pulsar.core.PulsarTestContainerSupport; import org.springframework.pulsar.reactive.core.DefaultReactivePulsarConsumerFactory; import org.springframework.pulsar.reactive.core.DefaultReactivePulsarSenderFactory; import org.springframework.pulsar.reactive.core.ReactivePulsarTemplate; +import org.springframework.pulsar.test.support.PulsarTestContainerSupport; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/ReactivePulsarListenerTests.java b/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/ReactivePulsarListenerTests.java index 91d4e06e..ef9e2230 100644 --- a/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/ReactivePulsarListenerTests.java +++ b/spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/ReactivePulsarListenerTests.java @@ -65,7 +65,6 @@ import org.springframework.pulsar.core.DefaultTopicResolver; import org.springframework.pulsar.core.PulsarAdministration; import org.springframework.pulsar.core.PulsarProducerFactory; import org.springframework.pulsar.core.PulsarTemplate; -import org.springframework.pulsar.core.PulsarTestContainerSupport; import org.springframework.pulsar.core.PulsarTopic; import org.springframework.pulsar.core.SchemaResolver; import org.springframework.pulsar.core.TopicResolver; @@ -79,6 +78,7 @@ import org.springframework.pulsar.reactive.core.ReactiveMessageConsumerBuilderCu import org.springframework.pulsar.reactive.core.ReactivePulsarConsumerFactory; import org.springframework.pulsar.reactive.listener.ReactivePulsarListenerTests.SchemaCustomMappingsTestCases.SchemaCustomMappingsTestConfig.User2; import org.springframework.pulsar.support.PulsarHeaders; +import org.springframework.pulsar.test.support.PulsarTestContainerSupport; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; diff --git a/spring-pulsar-spring-boot-autoconfigure/build.gradle b/spring-pulsar-spring-boot-autoconfigure/build.gradle index 084863df..28554825 100644 --- a/spring-pulsar-spring-boot-autoconfigure/build.gradle +++ b/spring-pulsar-spring-boot-autoconfigure/build.gradle @@ -16,13 +16,14 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter' implementation 'com.google.code.findbugs:jsr305' + testImplementation project(':spring-pulsar-test') testRuntimeOnly 'org.apache.logging.log4j:log4j-core' testRuntimeOnly 'org.apache.logging.log4j:log4j-jcl' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.testcontainers:junit-jupiter' testImplementation 'org.testcontainers:pulsar' - testImplementation project(':spring-pulsar-test') + // used by PulsarFunctionTests testImplementation 'org.testcontainers:rabbitmq' testImplementation 'org.springframework.boot:spring-boot-starter-amqp' diff --git a/spring-pulsar/build.gradle b/spring-pulsar/build.gradle index 5c051586..c8b61d8c 100644 --- a/spring-pulsar/build.gradle +++ b/spring-pulsar/build.gradle @@ -22,8 +22,8 @@ dependencies { optional 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' optional 'com.fasterxml.jackson.datatype:jackson-datatype-joda' optional 'com.jayway.jsonpath:json-path' - testImplementation 'org.junit.jupiter:junit-jupiter' - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + testImplementation project(':spring-pulsar-test') testRuntimeOnly 'ch.qos.logback:logback-classic' testImplementation 'io.micrometer:micrometer-observation-test' testImplementation 'io.micrometer:micrometer-tracing-bridge-brave' @@ -32,10 +32,12 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.awaitility:awaitility' testImplementation 'org.hamcrest:hamcrest' + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' testImplementation 'org.mockito:mockito-junit-jupiter' testImplementation 'org.springframework:spring-test' testImplementation 'org.springframework.boot:spring-boot-test' - testImplementation project(':spring-pulsar-test') + } test {