GH-907 - Upgrade to Spring Boot 3.4 snapshots.
Tweak test containers setup for dynamic properties to adapt to Boot 3.4's new behavior [0]. [0] https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.4.0-RC1-Release-Notes#dynamic-properties-with-testcontainers
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -43,7 +43,7 @@
|
||||
<jmolecules-bom.version>2023.1.7</jmolecules-bom.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>3.4.0-M3</spring-boot.version>
|
||||
<spring-boot.version>3.4.0-SNAPSHOT</spring-boot.version>
|
||||
<spring-framework.version>6.2.0-RC3</spring-framework.version> <!-- For Javadoc links only -->
|
||||
<spring-cloud-aws-bom.version>3.1.1</spring-cloud-aws-bom.version>
|
||||
<testcontainers.version>1.17.6</testcontainers.version>
|
||||
|
||||
@@ -28,14 +28,13 @@ import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.modulith.events.ApplicationModuleListener;
|
||||
import org.springframework.modulith.events.Externalized;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertyRegistrar;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.testcontainers.containers.localstack.LocalStackContainer;
|
||||
import org.testcontainers.utility.DockerImageName;
|
||||
@@ -57,16 +56,20 @@ class SnsEventPublicationIntegrationTests {
|
||||
static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
LocalStackContainer localStackContainer(@Qualifier("dynamicPropertyRegistry") DynamicPropertyRegistry registry) {
|
||||
LocalStackContainer localStackContainer() {
|
||||
return new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"));
|
||||
}
|
||||
|
||||
var localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"));
|
||||
@Bean
|
||||
DynamicPropertyRegistrar localstackDynamicProperties(LocalStackContainer localstack) {
|
||||
|
||||
registry.add("spring.cloud.aws.endpoint", localstack::getEndpoint);
|
||||
registry.add("spring.cloud.aws.credentials.access-key", localstack::getAccessKey);
|
||||
registry.add("spring.cloud.aws.credentials.secret-key", localstack::getSecretKey);
|
||||
registry.add("spring.cloud.aws.region.static", localstack::getRegion);
|
||||
return registry -> {
|
||||
|
||||
return localstack;
|
||||
registry.add("spring.cloud.aws.endpoint", localstack::getEndpoint);
|
||||
registry.add("spring.cloud.aws.credentials.access-key", localstack::getAccessKey);
|
||||
registry.add("spring.cloud.aws.credentials.secret-key", localstack::getSecretKey);
|
||||
registry.add("spring.cloud.aws.region.static", localstack::getRegion);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -27,14 +27,13 @@ import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.modulith.events.ApplicationModuleListener;
|
||||
import org.springframework.modulith.events.Externalized;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertyRegistrar;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.testcontainers.containers.localstack.LocalStackContainer;
|
||||
import org.testcontainers.utility.DockerImageName;
|
||||
@@ -56,16 +55,20 @@ class SqsEventPublicationIntegrationTests {
|
||||
static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
LocalStackContainer localStackContainer(@Qualifier("dynamicPropertyRegistry") DynamicPropertyRegistry registry) {
|
||||
LocalStackContainer localStackContainer() {
|
||||
return new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"));
|
||||
}
|
||||
|
||||
var localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"));
|
||||
@Bean
|
||||
DynamicPropertyRegistrar localStackDynamicProperties(LocalStackContainer localstack) {
|
||||
|
||||
registry.add("spring.cloud.aws.endpoint", localstack::getEndpoint);
|
||||
registry.add("spring.cloud.aws.credentials.access-key", localstack::getAccessKey);
|
||||
registry.add("spring.cloud.aws.credentials.secret-key", localstack::getSecretKey);
|
||||
registry.add("spring.cloud.aws.region.static", localstack::getRegion);
|
||||
return registry -> {
|
||||
|
||||
return localstack;
|
||||
registry.add("spring.cloud.aws.endpoint", localstack::getEndpoint);
|
||||
registry.add("spring.cloud.aws.credentials.access-key", localstack::getAccessKey);
|
||||
registry.add("spring.cloud.aws.credentials.secret-key", localstack::getSecretKey);
|
||||
registry.add("spring.cloud.aws.region.static", localstack::getRegion);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.4.0-M3</version>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user