Merge branch '3.5.x' into 4.0.x

Closes gh-49866
This commit is contained in:
Moritz Halbritter
2026-04-02 10:46:26 +02:00
11 changed files with 128 additions and 12 deletions
@@ -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"
@@ -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 {
@@ -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");
}
}
@@ -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;
@@ -4,5 +4,5 @@ services:
ports:
- '61616'
environment:
ACTIVEMQ_USERNAME: 'root'
ACTIVEMQ_PASSWORD: 'secret'
ACTIVEMQ_CONNECTION_USER: 'root'
ACTIVEMQ_CONNECTION_PASSWORD: 'secret'
@@ -0,0 +1,8 @@
services:
activemq:
image: '{imageName}'
ports:
- '61616'
environment:
ACTIVEMQ_USERNAME: 'root'
ACTIVEMQ_PASSWORD: 'secret'
@@ -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
@@ -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;
@@ -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);
}
}
@@ -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);
}
}
@@ -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.