Skip to content

Commit

Permalink
Add ActiveMQ Classic support for Docker Compose and Testcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez committed Feb 21, 2024
1 parent 60d0d1f commit 6c138c8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class SimpleDockerServiceResolver implements DockerServiceResolver {
public SimpleDockerServiceResolver() {
this.dockerServices = new HashMap<>();
this.dockerServices.put("activeMQ", activeMQ());
this.dockerServices.put("activeMQClassic", activeMQClassic());
this.dockerServices.put("artemis", artemis());
this.dockerServices.put("cassandra", cassandra());
this.dockerServices.put("elasticsearch", elasticsearch());
Expand All @@ -59,6 +60,13 @@ private static DockerService activeMQ() {
.build();
}

private static DockerService activeMQClassic() {
return DockerService.withImageAndTag("apache/activemq-classic")
.website("https://hub.docker.com/r/apache/activemq-classic")
.ports(61616)
.build();
}

private static DockerService artemis() {
return DockerService.withImageAndTag("apache/activemq-artemis")
.website("https://hub.docker.com/r/apache/activemq-classic")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
Expand Down Expand Up @@ -35,8 +35,10 @@
@ConditionalOnRequestedDependency("activemq")
public class ActiveMQProjectGenerationConfiguration {

private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.activemq.ActiveMQContainer";

@Bean
@ConditionalOnPlatformVersion("3.2.0-M1")
@ConditionalOnPlatformVersion("[3.2.0-M1,3.3.0-M2)")
@ConditionalOnRequestedDependency("testcontainers")
ServiceConnectionsCustomizer activeMQServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) {
return (serviceConnections) -> serviceResolver.doWith("activeMQ", (service) -> serviceConnections
Expand All @@ -45,10 +47,26 @@ ServiceConnectionsCustomizer activeMQServiceConnectionsCustomizer(DockerServiceR

@Bean
@ConditionalOnPlatformVersion("3.2.0-M1")
@ConditionalOnRequestedDependency("testcontainers")
ServiceConnectionsCustomizer activeMQClassicServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) {
return (serviceConnections) -> serviceResolver.doWith("activeMQClassic", (service) -> serviceConnections
.addServiceConnection(ServiceConnection.ofContainer("activemq", service, TESTCONTAINERS_CLASS_NAME)));
}

@Bean
@ConditionalOnPlatformVersion("[3.2.0-M1,3.3.0-M2)")
@ConditionalOnRequestedDependency("docker-compose")
ComposeFileCustomizer activeMQComposeFileCustomizer(DockerServiceResolver serviceResolver) {
return (composeFile) -> serviceResolver.doWith("activeMQ",
(service) -> composeFile.services().add("activemq", service));
}

@Bean
@ConditionalOnPlatformVersion("3.3.0-M2")
@ConditionalOnRequestedDependency("docker-compose")
ComposeFileCustomizer activeMQClassicComposeFileCustomizer(DockerServiceResolver serviceResolver) {
return (composeFile) -> serviceResolver.doWith("activeMQClassic",
(service) -> composeFile.services().add("activemq", service));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
Expand Down Expand Up @@ -29,6 +29,7 @@
* Tests for {@link ActiveMQProjectGenerationConfiguration}.
*
* @author Stephane Nicoll
* @author Eddú Meléndez
*/
class ActiveMQProjectGenerationConfigurationTests extends AbstractExtensionTests {

Expand All @@ -54,4 +55,11 @@ void dockerComposeCreatesAppropriateService() {
assertThat(composeFile(request)).hasSameContentAs(new ClassPathResource("compose/activemq.yaml"));
}

@Test
void dockerComposeCreatesAppropriateServiceWithVersion33() {
ProjectRequest request = createProjectRequest("docker-compose", "activemq");
request.setBootVersion("3.3.0-M2");
assertThat(composeFile(request)).hasSameContentAs(new ClassPathResource("compose/activemq-classic.yaml"));
}

}
5 changes: 5 additions & 0 deletions start-site/src/test/resources/compose/activemq-classic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
activemq:
image: 'apache/activemq-classic:latest'
ports:
- '61616'

0 comments on commit 6c138c8

Please sign in to comment.