From 8ea4ac75f1df8aeeb1633efeb5eff699f9fbbdb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Wilmsmann?= Date: Thu, 8 Oct 2020 00:13:33 +0200 Subject: [PATCH] Fixed integration test and local tests with Testcontainers on macOS (see https://github.com/testcontainers/testcontainers-java/issues/3166 ) --- application/build.gradle | 2 +- application/src/main/java/dev/aws101/config/AwsConfig.java | 5 +++++ application/src/test/java/dev/aws101/AwsTestConfig.java | 3 +++ application/src/test/resources/application.yml | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/application/build.gradle b/application/build.gradle index 38d57aec..f44b02bc 100644 --- a/application/build.gradle +++ b/application/build.gradle @@ -42,7 +42,7 @@ dependencies { testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } - def testcontainersVersion = '1.14.3' + def testcontainersVersion = '1.15.0-rc2' testCompile('org.testcontainers:localstack:' + testcontainersVersion) testCompile('org.testcontainers:junit-jupiter:' + testcontainersVersion) } diff --git a/application/src/main/java/dev/aws101/config/AwsConfig.java b/application/src/main/java/dev/aws101/config/AwsConfig.java index 280000af..26316fbd 100644 --- a/application/src/main/java/dev/aws101/config/AwsConfig.java +++ b/application/src/main/java/dev/aws101/config/AwsConfig.java @@ -50,6 +50,11 @@ public NotificationMessagingTemplate notificationMessagingTemplate(AmazonSNS ama } @Bean + @ConditionalOnProperty( + value = "custom.local-sns-enabled", + havingValue = "false", + matchIfMissing = true + ) public AmazonSNS amazonSNS(AWSCredentialsProvider awsCredentialsProvider) { AwsClientBuilder.EndpointConfiguration endpointConfiguration = null; if (endpoint != null) { diff --git a/application/src/test/java/dev/aws101/AwsTestConfig.java b/application/src/test/java/dev/aws101/AwsTestConfig.java index 47668f1f..a0cd2ee1 100644 --- a/application/src/test/java/dev/aws101/AwsTestConfig.java +++ b/application/src/test/java/dev/aws101/AwsTestConfig.java @@ -6,6 +6,7 @@ import com.amazonaws.services.sqs.AmazonSQSAsyncClientBuilder; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; import static dev.aws101.TodoApplicationTests.localStack; import static org.testcontainers.containers.localstack.LocalStackContainer.Service.SNS; @@ -15,6 +16,7 @@ public class AwsTestConfig { @Bean + @Primary public AmazonSQSAsync amazonSQS() { return AmazonSQSAsyncClientBuilder.standard() .withCredentials(localStack.getDefaultCredentialsProvider()) @@ -23,6 +25,7 @@ public AmazonSQSAsync amazonSQS() { } @Bean + @Primary public AmazonSNS amazonSNS() { return AmazonSNSClientBuilder .standard() diff --git a/application/src/test/resources/application.yml b/application/src/test/resources/application.yml index 6f83f638..39452592 100644 --- a/application/src/test/resources/application.yml +++ b/application/src/test/resources/application.yml @@ -24,5 +24,10 @@ spring: usernameAttribute: username custom: + security: + enabled: false sharing-queue: test-todo-sharing updates-topic: test-todo-updates + websocket-url: ws://localhost:8080/websocket + external-url: ${EXTERNAL_URL:#{null}} + local-sns-enabled: true