From f5b31d2495ac90cc16e80f54be992912cad83218 Mon Sep 17 00:00:00 2001 From: abilan Date: Tue, 29 Nov 2022 16:02:47 -0500 Subject: [PATCH] Upgrade to the latest dependencies Fix compatibility and deprecations --- build.gradle | 16 +++++++-------- .../SqsMessageDrivenChannelAdapter.java | 6 ++++-- .../aws/LocalstackContainerTest.java | 20 +++++++++++++++---- .../SqsMessageDrivenChannelAdapterTests.java | 4 ++-- .../aws/kinesis/KplKclIntegrationTests.java | 4 ++-- .../outbound/KinesisMessageHandlerTests.java | 6 +++--- .../KinesisProducingMessageHandlerTests.java | 6 +++--- .../aws/outbound/S3MessageHandlerTests.java | 4 ++-- .../aws/outbound/SnsMessageHandlerTests.java | 8 ++++---- 9 files changed, 44 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index 4a833b3..d2ac8ad 100644 --- a/build.gradle +++ b/build.gradle @@ -26,18 +26,18 @@ repositories { } ext { - assertjVersion = '3.22.0' + assertjVersion = '3.23.1' awaitilityVersion = '4.2.0' dynamodbLockClientVersion = '1.1.0' jacksonVersion = '2.13.3' - junitVersion = '5.8.2' - servletApiVersion = '5.0.0' - log4jVersion = '2.17.2' + junitVersion = '5.9.1' + servletApiVersion = '6.0.0' + log4jVersion = '2.19.0' springCloudAwsVersion = '2.4.2' - springIntegrationVersion = '6.0.0-M3' + springIntegrationVersion = '6.0.0' kinesisClientVersion = '1.14.8' - kinesisProducerVersion = '0.14.12' - testcontainersVersion = '1.17.1' + kinesisProducerVersion = '0.14.13' + testcontainersVersion = '1.17.6' idPrefix = 'aws' @@ -98,7 +98,7 @@ jacoco { checkstyle { configDirectory.set(rootProject.file('src/checkstyle')) - toolVersion = '10.2' + toolVersion = '10.4' } dependencies { diff --git a/src/main/java/org/springframework/integration/aws/inbound/SqsMessageDrivenChannelAdapter.java b/src/main/java/org/springframework/integration/aws/inbound/SqsMessageDrivenChannelAdapter.java index 69bd577..3fb1ba6 100644 --- a/src/main/java/org/springframework/integration/aws/inbound/SqsMessageDrivenChannelAdapter.java +++ b/src/main/java/org/springframework/integration/aws/inbound/SqsMessageDrivenChannelAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -51,6 +51,7 @@ import io.awspring.cloud.messaging.listener.SqsMessageDeletionPolicy; * * @author Artem Bilan * @author Patrick Fitzsimons + * * @see SimpleMessageListenerContainerFactory * @see SimpleMessageListenerContainer * @see QueueMessageHandler @@ -59,7 +60,8 @@ import io.awspring.cloud.messaging.listener.SqsMessageDeletionPolicy; @IntegrationManagedResource public class SqsMessageDrivenChannelAdapter extends MessageProducerSupport implements DisposableBean { - private final SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory = new SimpleMessageListenerContainerFactory(); + private final SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory = + new SimpleMessageListenerContainerFactory(); private final String[] queues; diff --git a/src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java b/src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java index 1275c60..ac1c20e 100644 --- a/src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java +++ b/src/test/java/org/springframework/integration/aws/LocalstackContainerTest.java @@ -21,6 +21,9 @@ import org.testcontainers.containers.localstack.LocalStackContainer; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; +import com.amazonaws.auth.AWSCredentialsProvider; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.services.cloudwatch.AmazonCloudWatch; import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; @@ -37,7 +40,6 @@ import com.amazonaws.services.kinesis.AmazonKinesisAsyncClientBuilder; * started only once per JVM, therefore the target Docker container is reused automatically. * * @author Artem Bilan - * * @since 3.0 */ @Testcontainers(disabledWithoutDocker = true) @@ -45,7 +47,7 @@ public interface LocalstackContainerTest { LocalStackContainer LOCAL_STACK_CONTAINER = new LocalStackContainer( - DockerImageName.parse("localstack/localstack:0.14.2")) + DockerImageName.parse("localstack/localstack:1.2.0")) .withServices( LocalStackContainer.Service.DYNAMODB, LocalStackContainer.Service.KINESIS, @@ -68,11 +70,21 @@ public interface LocalstackContainerTest { return applyAwsClientOptions(AmazonCloudWatchClientBuilder.standard(), LocalStackContainer.Service.CLOUDWATCH); } + static AWSCredentialsProvider credentialsProvider() { + return new AWSStaticCredentialsProvider( + new BasicAWSCredentials( + LOCAL_STACK_CONTAINER.getAccessKey(), + LOCAL_STACK_CONTAINER.getSecretKey())); + } + private static , T> T applyAwsClientOptions(B clientBuilder, LocalStackContainer.Service serviceToBuild) { - return clientBuilder.withEndpointConfiguration(LOCAL_STACK_CONTAINER.getEndpointConfiguration(serviceToBuild)) - .withCredentials(LOCAL_STACK_CONTAINER.getDefaultCredentialsProvider()) + return clientBuilder.withEndpointConfiguration( + new AwsClientBuilder.EndpointConfiguration( + LOCAL_STACK_CONTAINER.getEndpointOverride(serviceToBuild).toString(), + LOCAL_STACK_CONTAINER.getRegion())) + .withCredentials(credentialsProvider()) .build(); } diff --git a/src/test/java/org/springframework/integration/aws/inbound/SqsMessageDrivenChannelAdapterTests.java b/src/test/java/org/springframework/integration/aws/inbound/SqsMessageDrivenChannelAdapterTests.java index 6b6258f..9f1e2d5 100644 --- a/src/test/java/org/springframework/integration/aws/inbound/SqsMessageDrivenChannelAdapterTests.java +++ b/src/test/java/org/springframework/integration/aws/inbound/SqsMessageDrivenChannelAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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. @@ -105,7 +105,7 @@ public class SqsMessageDrivenChannelAdapterTests { assertThatThrownBy( () -> this.controlBusInput.send(new GenericMessage<>("@sqsMessageDrivenChannelAdapter.start('foo')"))) .hasCauseExactlyInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Queue with name 'foo' does not exist"); + .hasStackTraceContaining("Queue with name 'foo' does not exist"); assertThat(this.sqsMessageDrivenChannelAdapter.getQueues()).isEqualTo(new String[] {"testQueue"}); } diff --git a/src/test/java/org/springframework/integration/aws/kinesis/KplKclIntegrationTests.java b/src/test/java/org/springframework/integration/aws/kinesis/KplKclIntegrationTests.java index 6fc3b75..918e9d6 100644 --- a/src/test/java/org/springframework/integration/aws/kinesis/KplKclIntegrationTests.java +++ b/src/test/java/org/springframework/integration/aws/kinesis/KplKclIntegrationTests.java @@ -151,7 +151,7 @@ public class KplKclIntegrationTests implements LocalstackContainerTest { LocalstackContainerTest.LOCAL_STACK_CONTAINER.getEndpointOverride(LocalStackContainer.Service.CLOUDWATCH); return new KinesisProducerConfiguration() - .setCredentialsProvider(LocalstackContainerTest.LOCAL_STACK_CONTAINER.getDefaultCredentialsProvider()) + .setCredentialsProvider(LocalstackContainerTest.credentialsProvider()) .setRegion(LocalstackContainerTest.LOCAL_STACK_CONTAINER.getRegion()) .setKinesisEndpoint(kinesisUri.getHost()) .setKinesisPort(kinesisUri.getPort()) @@ -175,7 +175,7 @@ public class KplKclIntegrationTests implements LocalstackContainerTest { KclMessageDrivenChannelAdapter adapter = new KclMessageDrivenChannelAdapter( TEST_STREAM, AMAZON_KINESIS, CLOUD_WATCH, DYNAMO_DB, - LocalstackContainerTest.LOCAL_STACK_CONTAINER.getDefaultCredentialsProvider()); + LocalstackContainerTest.credentialsProvider()); adapter.setOutputChannel(kinesisReceiveChannel()); adapter.setErrorChannel(errorChannel()); adapter.setErrorMessageStrategy(new KinesisMessageHeaderErrorMessageStrategy()); diff --git a/src/test/java/org/springframework/integration/aws/outbound/KinesisMessageHandlerTests.java b/src/test/java/org/springframework/integration/aws/outbound/KinesisMessageHandlerTests.java index f81105c..37d915b 100644 --- a/src/test/java/org/springframework/integration/aws/outbound/KinesisMessageHandlerTests.java +++ b/src/test/java/org/springframework/integration/aws/outbound/KinesisMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2022 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. @@ -86,14 +86,14 @@ public class KinesisMessageHandlerTests { assertThatExceptionOfType(MessageHandlingException.class) .isThrownBy(() -> this.kinesisSendChannel.send(message)) .withCauseInstanceOf(IllegalStateException.class) - .withMessageContaining("'stream' must not be null for sending a Kinesis record"); + .withStackTraceContaining("'stream' must not be null for sending a Kinesis record"); this.kinesisMessageHandler.setStream("foo"); assertThatExceptionOfType(MessageHandlingException.class) .isThrownBy(() -> this.kinesisSendChannel.send(message)) .withCauseInstanceOf(IllegalStateException.class) - .withMessageContaining("'partitionKey' must not be null for sending a Kinesis record"); + .withStackTraceContaining("'partitionKey' must not be null for sending a Kinesis record"); Message message2 = MessageBuilder.fromMessage(message).setHeader(AwsHeaders.PARTITION_KEY, "fooKey") .setHeader(AwsHeaders.SEQUENCE_NUMBER, "10").setHeader("foo", "bar").build(); diff --git a/src/test/java/org/springframework/integration/aws/outbound/KinesisProducingMessageHandlerTests.java b/src/test/java/org/springframework/integration/aws/outbound/KinesisProducingMessageHandlerTests.java index 4bf1190..712c496 100644 --- a/src/test/java/org/springframework/integration/aws/outbound/KinesisProducingMessageHandlerTests.java +++ b/src/test/java/org/springframework/integration/aws/outbound/KinesisProducingMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2022 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. @@ -86,14 +86,14 @@ public class KinesisProducingMessageHandlerTests { assertThatExceptionOfType(MessageHandlingException.class) .isThrownBy(() -> this.kinesisSendChannel.send(message)) .withCauseInstanceOf(IllegalStateException.class) - .withMessageContaining("'stream' must not be null for sending a Kinesis record"); + .withStackTraceContaining("'stream' must not be null for sending a Kinesis record"); this.kinesisMessageHandler.setStream("foo"); assertThatExceptionOfType(MessageHandlingException.class) .isThrownBy(() -> this.kinesisSendChannel.send(message)) .withCauseInstanceOf(IllegalStateException.class) - .withMessageContaining("'partitionKey' must not be null for sending a Kinesis record"); + .withStackTraceContaining("'partitionKey' must not be null for sending a Kinesis record"); Message message2 = MessageBuilder.fromMessage(message).setHeader(AwsHeaders.PARTITION_KEY, "fooKey") .setHeader(AwsHeaders.SEQUENCE_NUMBER, "10").build(); diff --git a/src/test/java/org/springframework/integration/aws/outbound/S3MessageHandlerTests.java b/src/test/java/org/springframework/integration/aws/outbound/S3MessageHandlerTests.java index f9b5c57..cbab354 100644 --- a/src/test/java/org/springframework/integration/aws/outbound/S3MessageHandlerTests.java +++ b/src/test/java/org/springframework/integration/aws/outbound/S3MessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2022 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. @@ -200,7 +200,7 @@ public class S3MessageHandlerTests { assertThatThrownBy(() -> this.s3SendChannel.send(message)) .hasCauseExactlyInstanceOf(IllegalStateException.class) - .hasMessageContaining("Specify a 'keyExpression' for non-java.io.File payloads"); + .hasStackTraceContaining("Specify a 'keyExpression' for non-java.io.File payloads"); this.s3MessageHandler.setKeyExpression(actualKeyExpression); diff --git a/src/test/java/org/springframework/integration/aws/outbound/SnsMessageHandlerTests.java b/src/test/java/org/springframework/integration/aws/outbound/SnsMessageHandlerTests.java index 4d5df0b..96141f5 100644 --- a/src/test/java/org/springframework/integration/aws/outbound/SnsMessageHandlerTests.java +++ b/src/test/java/org/springframework/integration/aws/outbound/SnsMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2022 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. @@ -23,6 +23,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import java.util.Map; +import java.util.concurrent.CompletableFuture; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -43,7 +44,6 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.PollableChannel; -import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @@ -60,7 +60,7 @@ import com.amazonaws.services.sns.model.PublishResult; @DirtiesContext public class SnsMessageHandlerTests { - private static SpelExpressionParser PARSER = new SpelExpressionParser(); + private static final SpelExpressionParser PARSER = new SpelExpressionParser(); @Autowired private MessageChannel sendToSnsChannel; @@ -120,7 +120,7 @@ public class SnsMessageHandlerTests { PublishResult publishResult = new PublishResult().withMessageId("111"); AsyncHandler asyncHandler = invocation.getArgument(1); asyncHandler.onSuccess(invocation.getArgument(0), publishResult); - return new AsyncResult<>(publishResult); + return CompletableFuture.completedFuture(publishResult); }).given(mock).publishAsync(any(PublishRequest.class), any(AsyncHandler.class)); return mock;