diff --git a/aws-dynamodb-project/pom.xml b/aws-dynamodb-project/pom.xml index 3fb15011..d55f5742 100644 --- a/aws-dynamodb-project/pom.xml +++ b/aws-dynamodb-project/pom.xml @@ -94,11 +94,6 @@ spring-boot-starter-test test - - org.springframework.boot - spring-boot-testcontainers - test - io.awspring.cloud spring-cloud-aws-testcontainers @@ -109,11 +104,6 @@ junit-jupiter test - - org.testcontainers - localstack - test - diff --git a/aws-ses-project/pom.xml b/aws-ses-project/pom.xml index 465a35e8..1f87a978 100644 --- a/aws-ses-project/pom.xml +++ b/aws-ses-project/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.2.4 + 3.3.0-M3 com.example.awsspring @@ -19,7 +19,7 @@ UTF-8 21 - 3.1.1 + 3.2.0-M1 2.4.0 ${project.build.directory}/test-results @@ -98,13 +98,13 @@ test - org.testcontainers - junit-jupiter + io.awspring.cloud + spring-cloud-aws-testcontainers test org.testcontainers - localstack + junit-jupiter test @@ -222,7 +222,7 @@ - 1.18.1 + 1.19.2 diff --git a/aws-ses-project/src/test/java/com/example/awsspring/TestSESApplication.java b/aws-ses-project/src/test/java/com/example/awsspring/TestSESApplication.java new file mode 100644 index 00000000..cee6b50c --- /dev/null +++ b/aws-ses-project/src/test/java/com/example/awsspring/TestSESApplication.java @@ -0,0 +1,31 @@ +package com.example.awsspring; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.context.annotation.Bean; +import org.testcontainers.containers.localstack.LocalStackContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.utility.DockerImageName; + +@Slf4j +@TestConfiguration(proxyBeanMethods = false) +public class TestSESApplication { + + @Bean + @ServiceConnection + LocalStackContainer localStackContainer() { + LocalStackContainer localStackContainer = + new LocalStackContainer( + DockerImageName.parse("localstack/localstack").withTag("3.3.0")); + localStackContainer.start(); + Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log); + localStackContainer.followOutput(logConsumer); + return localStackContainer; + } + + public static void main(String[] args) { + SpringApplication.from(SESApplication::main).with(TestSESApplication.class).run(args); + } +} diff --git a/aws-ses-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java b/aws-ses-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java index b9e80eea..3c23e08b 100644 --- a/aws-ses-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java +++ b/aws-ses-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java @@ -3,6 +3,7 @@ import static com.example.awsspring.utils.AppConstants.PROFILE_TEST; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; +import com.example.awsspring.TestSESApplication; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -11,9 +12,9 @@ import org.springframework.test.web.servlet.MockMvc; @ActiveProfiles({PROFILE_TEST}) -@SpringBootTest(webEnvironment = RANDOM_PORT) +@SpringBootTest(webEnvironment = RANDOM_PORT, classes = TestSESApplication.class) @AutoConfigureMockMvc -public abstract class AbstractIntegrationTest extends LocalStackConfig { +public abstract class AbstractIntegrationTest { @Autowired protected MockMvc mockMvc; diff --git a/aws-ses-project/src/test/java/com/example/awsspring/common/LocalStackConfig.java b/aws-ses-project/src/test/java/com/example/awsspring/common/LocalStackConfig.java deleted file mode 100644 index bb8e916a..00000000 --- a/aws-ses-project/src/test/java/com/example/awsspring/common/LocalStackConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.example.awsspring.common; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; -import org.testcontainers.containers.localstack.LocalStackContainer; -import org.testcontainers.containers.output.Slf4jLogConsumer; -import org.testcontainers.utility.DockerImageName; - -@Slf4j -public class LocalStackConfig { - - static final LocalStackContainer localStackContainer = - new LocalStackContainer( - DockerImageName.parse("localstack/localstack").withTag("3.3.0")); - - static { - localStackContainer.start(); - Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log); - localStackContainer.followOutput(logConsumer); - } - - @DynamicPropertySource - static void setDynamicProperties(DynamicPropertyRegistry dynamicPropertyRegistry) { - dynamicPropertyRegistry.add( - "spring.cloud.aws.credentials.access-key", localStackContainer::getAccessKey); - dynamicPropertyRegistry.add( - "spring.cloud.aws.credentials.secret-key", localStackContainer::getSecretKey); - dynamicPropertyRegistry.add( - "spring.cloud.aws.region.static", localStackContainer::getRegion); - dynamicPropertyRegistry.add( - "spring.cloud.aws.endpoint", () -> localStackContainer.getEndpoint().toString()); - } -} diff --git a/aws-sns-project/pom.xml b/aws-sns-project/pom.xml index 209f3ea7..741f6abf 100644 --- a/aws-sns-project/pom.xml +++ b/aws-sns-project/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 3.2.4 + 3.3.0-M3 com.learning.awssns @@ -21,7 +21,7 @@ UTF-8 21 - 3.1.1 + 3.2.0-M1 2.4.0 ${project.build.directory}/test-results @@ -84,8 +84,8 @@ test - org.springframework.boot - spring-boot-testcontainers + io.awspring.cloud + spring-cloud-aws-testcontainers test @@ -93,11 +93,6 @@ junit-jupiter test - - org.testcontainers - localstack - test - @@ -326,4 +321,25 @@ + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + diff --git a/aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java b/aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java index 3be0e43b..d67f1da8 100644 --- a/aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java +++ b/aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java @@ -1,6 +1,7 @@ package com.learning.awssns.common; import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.context.annotation.Bean; import org.springframework.test.context.DynamicPropertyRegistry; import org.testcontainers.containers.localstack.LocalStackContainer; @@ -10,13 +11,9 @@ public class ContainersConfig { @Bean + @ServiceConnection LocalStackContainer localstackContainer(DynamicPropertyRegistry registry) { - LocalStackContainer localStackContainer = new LocalStackContainer( + return new LocalStackContainer( DockerImageName.parse("localstack/localstack").withTag("3.3.0")); - registry.add("spring.cloud.aws.credentials.access-key", localStackContainer::getAccessKey); - registry.add("spring.cloud.aws.credentials.secret-key", localStackContainer::getSecretKey); - registry.add("spring.cloud.aws.region.static", localStackContainer::getRegion); - registry.add("spring.cloud.aws.endpoint", localStackContainer::getEndpoint); - return localStackContainer; } } diff --git a/aws-sqs-project/pom.xml b/aws-sqs-project/pom.xml index f0b01f95..4a428b30 100644 --- a/aws-sqs-project/pom.xml +++ b/aws-sqs-project/pom.xml @@ -116,11 +116,6 @@ spring-boot-starter-test test - - org.springframework.boot - spring-boot-testcontainers - test - io.awspring.cloud spring-cloud-aws-testcontainers @@ -136,11 +131,6 @@ postgresql test - - org.testcontainers - localstack - test - @@ -341,7 +331,7 @@ - 1.18.1 + 1.19.2