From 2e273395942da4a28a25ad79cb4bb1ab2d61cfc2 Mon Sep 17 00:00:00 2001 From: abilan Date: Thu, 8 Jun 2023 10:53:12 -0400 Subject: [PATCH] Use edge endpoint for Localstack services * Upgrade to Testcontainers `1.18.3` * Simplify `LocalstackContainerTest` to rely on the `LocalStackContainer.getEndpoint()` for all the AWS services requested --- build.gradle | 2 +- .../aws/LocalstackContainerTest.java | 20 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index a5ab23a..9856b0d 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ ext { springIntegrationVersion = '6.0.5' kinesisClientVersion = '2.5.0' kinesisProducerVersion = '0.15.7' - testcontainersVersion = '1.18.2' + testcontainersVersion = '1.18.3' idPrefix = 'aws' diff --git a/src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java b/src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java index 2189b8b..b2ae916 100644 --- a/src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java +++ b/src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java @@ -56,28 +56,27 @@ public interface LocalstackContainerTest { } static DynamoDbAsyncClient dynamoDbClient() { - return applyAwsClientOptions(DynamoDbAsyncClient.builder(), LocalStackContainer.Service.DYNAMODB); + return applyAwsClientOptions(DynamoDbAsyncClient.builder()); } static KinesisAsyncClient kinesisClient() { - return applyAwsClientOptions(KinesisAsyncClient.builder(), LocalStackContainer.Service.KINESIS); + return applyAwsClientOptions(KinesisAsyncClient.builder()); } static CloudWatchAsyncClient cloudWatchClient() { - return applyAwsClientOptions(CloudWatchAsyncClient.builder(), LocalStackContainer.Service.CLOUDWATCH); + return applyAwsClientOptions(CloudWatchAsyncClient.builder()); } static S3AsyncClient s3AsyncClient() { - return applyAwsClientOptions(S3AsyncClient.builder(), LocalStackContainer.Service.S3); + return applyAwsClientOptions(S3AsyncClient.builder()); } static S3Client s3Client() { - return applyAwsClientOptions(S3Client.builder().httpClient(ApacheHttpClient.create()), - LocalStackContainer.Service.S3); + return applyAwsClientOptions(S3Client.builder().httpClient(ApacheHttpClient.create())); } static SqsAsyncClient sqsClient() { - return applyAwsClientOptions(SqsAsyncClient.builder(), LocalStackContainer.Service.SQS); + return applyAwsClientOptions(SqsAsyncClient.builder()); } static AwsCredentialsProvider credentialsProvider() { @@ -85,13 +84,12 @@ public interface LocalstackContainerTest { AwsBasicCredentials.create(LOCAL_STACK_CONTAINER.getAccessKey(), LOCAL_STACK_CONTAINER.getSecretKey())); } - private static , T> T applyAwsClientOptions(B clientBuilder, - LocalStackContainer.Service serviceToBuild) { - + private static , T> T applyAwsClientOptions(B clientBuilder) { return clientBuilder .region(Region.of(LOCAL_STACK_CONTAINER.getRegion())) .credentialsProvider(credentialsProvider()) - .endpointOverride(LOCAL_STACK_CONTAINER.getEndpointOverride(serviceToBuild)) + .endpointOverride(LOCAL_STACK_CONTAINER.getEndpoint()) .build(); } + }