diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/dev-services.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/dev-services.adoc index 1d14e8ef905..20b063a2715 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/dev-services.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/dev-services.adoc @@ -84,7 +84,7 @@ The following service connections are currently supported: | Connection Details | Matched on | javadoc:org.springframework.boot.activemq.autoconfigure.ActiveMQConnectionDetails[] -| Containers named "symptoma/activemq" or "apache/activemq-classic" +| Containers named "symptoma/activemq", "apache/activemq-classic" or "apache/activemq" | javadoc:org.springframework.boot.artemis.autoconfigure.ArtemisConnectionDetails[] | Containers named "apache/activemq-artemis" diff --git a/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/docker/compose/ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests.java b/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/docker/compose/ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests.java index b522fbec6b3..a55b1b37b33 100644 --- a/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/docker/compose/ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests.java +++ b/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/docker/compose/ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests.java @@ -25,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * Integration tests for {@link ActiveMQDockerComposeConnectionDetailsFactory}. * - * @author Stephane Nicoll + * @author Moritz Halbritter */ class ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests { diff --git a/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/docker/compose/ActiveMQSymptomaDockerComposeConnectionDetailsFactoryIntegrationTests.java b/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/docker/compose/ActiveMQSymptomaDockerComposeConnectionDetailsFactoryIntegrationTests.java new file mode 100644 index 00000000000..afb382d7346 --- /dev/null +++ b/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/docker/compose/ActiveMQSymptomaDockerComposeConnectionDetailsFactoryIntegrationTests.java @@ -0,0 +1,39 @@ +/* + * Copyright 2012-present 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.boot.activemq.docker.compose; + +import org.springframework.boot.activemq.autoconfigure.ActiveMQConnectionDetails; +import org.springframework.boot.docker.compose.service.connection.test.DockerComposeTest; +import org.springframework.boot.testsupport.container.TestImage; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration tests for {@link ActiveMQDockerComposeConnectionDetailsFactory}. + * + * @author Stephane Nicoll + */ +class ActiveMQSymptomaDockerComposeConnectionDetailsFactoryIntegrationTests { + + @DockerComposeTest(composeFile = "activemq-symptoma-compose.yaml", image = TestImage.ACTIVE_MQ_SYMPTOMA) + void runCreatesConnectionDetails(ActiveMQConnectionDetails connectionDetails) { + assertThat(connectionDetails.getBrokerUrl()).isNotNull().startsWith("tcp://"); + assertThat(connectionDetails.getUser()).isEqualTo("root"); + assertThat(connectionDetails.getPassword()).isEqualTo("secret"); + } + +} diff --git a/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/testcontainers/ActiveMQClassicContainerConnectionDetailsFactoryIntegrationTests.java b/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/testcontainers/ActiveMQClassicContainerConnectionDetailsFactoryIntegrationTests.java index 2395383fd43..1f7f707bd6e 100644 --- a/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/testcontainers/ActiveMQClassicContainerConnectionDetailsFactoryIntegrationTests.java +++ b/module/spring-boot-activemq/src/dockerTest/java/org/springframework/boot/activemq/testcontainers/ActiveMQClassicContainerConnectionDetailsFactoryIntegrationTests.java @@ -22,7 +22,6 @@ import java.util.List; import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; -import org.testcontainers.activemq.ActiveMQContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -31,6 +30,7 @@ import org.springframework.boot.activemq.autoconfigure.ActiveMQAutoConfiguration import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.jms.autoconfigure.JmsAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.boot.testsupport.container.ActiveMQClassicContainer; import org.springframework.boot.testsupport.container.TestImage; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -51,7 +51,7 @@ class ActiveMQClassicContainerConnectionDetailsFactoryIntegrationTests { @Container @ServiceConnection - static final ActiveMQContainer activemq = TestImage.container(ActiveMQContainer.class); + static final ActiveMQClassicContainer activemq = TestImage.container(ActiveMQClassicContainer.class); @Autowired private JmsClient jmsClient; diff --git a/module/spring-boot-activemq/src/dockerTest/resources/org/springframework/boot/activemq/docker/compose/activemq-compose.yaml b/module/spring-boot-activemq/src/dockerTest/resources/org/springframework/boot/activemq/docker/compose/activemq-compose.yaml index 9ae6911655e..2bdef98e5aa 100644 --- a/module/spring-boot-activemq/src/dockerTest/resources/org/springframework/boot/activemq/docker/compose/activemq-compose.yaml +++ b/module/spring-boot-activemq/src/dockerTest/resources/org/springframework/boot/activemq/docker/compose/activemq-compose.yaml @@ -4,5 +4,5 @@ services: ports: - '61616' environment: - ACTIVEMQ_USERNAME: 'root' - ACTIVEMQ_PASSWORD: 'secret' + ACTIVEMQ_CONNECTION_USER: 'root' + ACTIVEMQ_CONNECTION_PASSWORD: 'secret' diff --git a/module/spring-boot-activemq/src/dockerTest/resources/org/springframework/boot/activemq/docker/compose/activemq-symptoma-compose.yaml b/module/spring-boot-activemq/src/dockerTest/resources/org/springframework/boot/activemq/docker/compose/activemq-symptoma-compose.yaml new file mode 100644 index 00000000000..9ae6911655e --- /dev/null +++ b/module/spring-boot-activemq/src/dockerTest/resources/org/springframework/boot/activemq/docker/compose/activemq-symptoma-compose.yaml @@ -0,0 +1,8 @@ +services: + activemq: + image: '{imageName}' + ports: + - '61616' + environment: + ACTIVEMQ_USERNAME: 'root' + ACTIVEMQ_PASSWORD: 'secret' diff --git a/module/spring-boot-activemq/src/main/java/org/springframework/boot/activemq/docker/compose/ActiveMQClassicDockerComposeConnectionDetailsFactory.java b/module/spring-boot-activemq/src/main/java/org/springframework/boot/activemq/docker/compose/ActiveMQClassicDockerComposeConnectionDetailsFactory.java index 9d7e2684a51..92b99e06cd3 100644 --- a/module/spring-boot-activemq/src/main/java/org/springframework/boot/activemq/docker/compose/ActiveMQClassicDockerComposeConnectionDetailsFactory.java +++ b/module/spring-boot-activemq/src/main/java/org/springframework/boot/activemq/docker/compose/ActiveMQClassicDockerComposeConnectionDetailsFactory.java @@ -36,7 +36,7 @@ class ActiveMQClassicDockerComposeConnectionDetailsFactory private static final int ACTIVEMQ_PORT = 61616; protected ActiveMQClassicDockerComposeConnectionDetailsFactory() { - super("apache/activemq-classic"); + super(new String[] { "apache/activemq-classic", "apache/activemq" }); } @Override diff --git a/smoke-test/spring-boot-smoke-test-activemq/src/dockerTest/java/smoketest/activemq/SampleActiveMqTests.java b/smoke-test/spring-boot-smoke-test-activemq/src/dockerTest/java/smoketest/activemq/SampleActiveMqTests.java index e88d9f1f6f6..f2e600e1d85 100644 --- a/smoke-test/spring-boot-smoke-test-activemq/src/dockerTest/java/smoketest/activemq/SampleActiveMqTests.java +++ b/smoke-test/spring-boot-smoke-test-activemq/src/dockerTest/java/smoketest/activemq/SampleActiveMqTests.java @@ -21,7 +21,6 @@ import java.time.Duration; import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.testcontainers.activemq.ActiveMQContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -30,6 +29,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.boot.testsupport.container.ActiveMQClassicContainer; import org.springframework.boot.testsupport.container.TestImage; import static org.assertj.core.api.Assertions.assertThat; @@ -47,7 +47,7 @@ class SampleActiveMqTests { @Container @ServiceConnection - private static final ActiveMQContainer container = TestImage.container(ActiveMQContainer.class); + private static final ActiveMQClassicContainer container = TestImage.container(ActiveMQClassicContainer.class); @Autowired private Producer producer; diff --git a/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/ActiveMQClassicContainer.java b/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/ActiveMQClassicContainer.java new file mode 100644 index 00000000000..563b4b69bd1 --- /dev/null +++ b/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/ActiveMQClassicContainer.java @@ -0,0 +1,33 @@ +/* + * Copyright 2012-present 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.boot.testsupport.container; + +import org.testcontainers.activemq.ActiveMQContainer; +import org.testcontainers.utility.DockerImageName; + +/** + * An {@link ActiveMQContainer} for ActiveMQ classic. + * + * @author Moritz Halbritter + */ +public final class ActiveMQClassicContainer extends ActiveMQContainer { + + public ActiveMQClassicContainer(DockerImageName dockerImageName) { + super(dockerImageName); + } + +} diff --git a/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/ActiveMQContainer.java b/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/ActiveMQContainer.java new file mode 100644 index 00000000000..28c8bf4915a --- /dev/null +++ b/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/ActiveMQContainer.java @@ -0,0 +1,32 @@ +/* + * Copyright 2012-present 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.boot.testsupport.container; + +import org.testcontainers.utility.DockerImageName; + +/** + * An {@link org.testcontainers.activemq.ActiveMQContainer} for ActiveMQ. + * + * @author Moritz Halbritter + */ +public final class ActiveMQContainer extends org.testcontainers.activemq.ActiveMQContainer { + + public ActiveMQContainer(DockerImageName dockerImageName) { + super(dockerImageName); + } + +} diff --git a/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/TestImage.java b/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/TestImage.java index e64fc32615c..3b2bf29eab3 100644 --- a/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/TestImage.java +++ b/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/TestImage.java @@ -25,7 +25,6 @@ import java.util.function.Supplier; import com.redis.testcontainers.RedisContainer; import com.redis.testcontainers.RedisStackContainer; -import org.testcontainers.activemq.ActiveMQContainer; import org.testcontainers.activemq.ArtemisContainer; import org.testcontainers.cassandra.CassandraContainer; import org.testcontainers.containers.Container; @@ -61,15 +60,20 @@ import org.springframework.util.Assert; */ public enum TestImage { + /** + * A container image suitable for testing ActiveMQ made by Symptoma. + */ + ACTIVE_MQ_SYMPTOMA("symptoma/activemq", "5.18.3", () -> SymptomaActiveMQContainer.class), + /** * A container image suitable for testing ActiveMQ. */ - ACTIVE_MQ("symptoma/activemq", "5.18.3", () -> SymptomaActiveMQContainer.class), + ACTIVE_MQ("apache/activemq", "6.2.1", () -> ActiveMQContainer.class), /** * A container image suitable for testing ActiveMQ classic. */ - ACTIVE_MQ_CLASSIC("apache/activemq-classic", "5.18.3", () -> ActiveMQContainer.class), + ACTIVE_MQ_CLASSIC("apache/activemq-classic", "5.18.3", () -> ActiveMQClassicContainer.class), /** * A container image suitable for testing Apache Kafka.