-
Notifications
You must be signed in to change notification settings - Fork 914
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1415 from eddumelendez
* pr/1415-2: Add ActiveMQ module when ActiveMQ/Artemis and Testcontainers are selected Closes gh-1415
- Loading branch information
Showing
10 changed files
with
194 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...pring/start/site/extension/dependency/activemq/ArtemisProjectGenerationConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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. | ||
* 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 io.spring.start.site.extension.dependency.activemq; | ||
|
||
import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion; | ||
import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; | ||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration; | ||
import io.spring.start.site.container.ComposeFileCustomizer; | ||
import io.spring.start.site.container.DockerServiceResolver; | ||
import io.spring.start.site.container.ServiceConnections.ServiceConnection; | ||
import io.spring.start.site.container.ServiceConnectionsCustomizer; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
|
||
/** | ||
* Configuration for generation of projects that depend on ActiveMQ Artemis. | ||
* | ||
* @author Eddú Meléndez | ||
*/ | ||
@ProjectGenerationConfiguration | ||
@ConditionalOnRequestedDependency("artemis") | ||
public class ArtemisProjectGenerationConfiguration { | ||
|
||
private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.activemq.ArtemisContainer"; | ||
|
||
@Bean | ||
@ConditionalOnPlatformVersion("3.3.0-M2") | ||
@ConditionalOnRequestedDependency("testcontainers") | ||
ServiceConnectionsCustomizer artemisServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { | ||
return (serviceConnections) -> serviceResolver.doWith("artemis", (service) -> serviceConnections | ||
.addServiceConnection(ServiceConnection.ofContainer("artemis", service, TESTCONTAINERS_CLASS_NAME, false))); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnPlatformVersion("3.3.0-M2") | ||
@ConditionalOnRequestedDependency("docker-compose") | ||
ComposeFileCustomizer artemisComposeFileCustomizer(DockerServiceResolver serviceResolver) { | ||
return (composeFile) -> serviceResolver.doWith("artemis", | ||
(service) -> composeFile.services().add("artemis", service)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
.../start/site/extension/dependency/activemq/ArtemisProjectGenerationConfigurationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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. | ||
* 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 io.spring.start.site.extension.dependency.activemq; | ||
|
||
import io.spring.initializr.generator.test.project.ProjectStructure; | ||
import io.spring.initializr.web.project.ProjectRequest; | ||
import io.spring.start.site.extension.AbstractExtensionTests; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.core.io.ClassPathResource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Tests for {@link ArtemisProjectGenerationConfiguration}. | ||
* | ||
* @author Eddú Meléndez | ||
*/ | ||
class ArtemisProjectGenerationConfigurationTests extends AbstractExtensionTests { | ||
|
||
@Test | ||
void dockerComposeWhenDockerComposeIsNotSelectedDoesNotCreateService() { | ||
ProjectRequest request = createProjectRequest("web", "artemis"); | ||
request.setBootVersion("3.3.0-M2"); | ||
ProjectStructure structure = generateProject(request); | ||
assertThat(structure.getProjectDirectory().resolve("compose.yaml")).doesNotExist(); | ||
} | ||
|
||
@Test | ||
void dockerComposeWhenIncompatibleSpringBootVersionDoesNotCreateService() { | ||
ProjectRequest request = createProjectRequest("docker-compose", "artemis"); | ||
request.setBootVersion("3.1.1"); | ||
assertThat(composeFile(request)).doesNotContain("artemis"); | ||
} | ||
|
||
@Test | ||
void dockerComposeCreatesAppropriateService() { | ||
ProjectRequest request = createProjectRequest("docker-compose", "artemis"); | ||
request.setBootVersion("3.3.0-M2"); | ||
assertThat(composeFile(request)).hasSameContentAs(new ClassPathResource("compose/artemis.yaml")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
services: | ||
activemq: | ||
image: 'apache/activemq-classic:latest' | ||
ports: | ||
- '61616' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
services: | ||
artemis: | ||
image: 'apache/activemq-artemis:latest' | ||
ports: | ||
- '61616' |