diff --git a/subprojects/micronaut-amazon-awssdk-integration-testing/micronaut-amazon-awssdk-integration-testing.gradle b/subprojects/micronaut-amazon-awssdk-integration-testing/micronaut-amazon-awssdk-integration-testing.gradle index 1849ffc93..9921109f5 100644 --- a/subprojects/micronaut-amazon-awssdk-integration-testing/micronaut-amazon-awssdk-integration-testing.gradle +++ b/subprojects/micronaut-amazon-awssdk-integration-testing/micronaut-amazon-awssdk-integration-testing.gradle @@ -17,8 +17,9 @@ */ dependencies { api group: 'org.testcontainers', name: 'localstack', version: testcontainersVersion - implementation 'com.amazonaws:aws-java-sdk-core' - implementation "software.amazon.awssdk:netty-nio-client:$kinesisClientV2Version" + + compileOnly 'com.amazonaws:aws-java-sdk-core' + compileOnly "software.amazon.awssdk:netty-nio-client:$kinesisClientV2Version" compileOnly project(':micronaut-amazon-awssdk-cloudwatch') compileOnly project(':micronaut-amazon-awssdk-cloudwatchlogs') diff --git a/subprojects/micronaut-amazon-awssdk-integration-testing/src/main/java/com/agorapulse/micronaut/amazon/awssdk/itest/localstack/LocalstackContainerHolderFactory.java b/subprojects/micronaut-amazon-awssdk-integration-testing/src/main/java/com/agorapulse/micronaut/amazon/awssdk/itest/localstack/LocalstackContainerHolderFactory.java index a30231759..e98e1df79 100644 --- a/subprojects/micronaut-amazon-awssdk-integration-testing/src/main/java/com/agorapulse/micronaut/amazon/awssdk/itest/localstack/LocalstackContainerHolderFactory.java +++ b/subprojects/micronaut-amazon-awssdk-integration-testing/src/main/java/com/agorapulse/micronaut/amazon/awssdk/itest/localstack/LocalstackContainerHolderFactory.java @@ -23,11 +23,6 @@ import io.micronaut.context.annotation.Primary; import io.micronaut.context.annotation.Replaces; import io.micronaut.context.annotation.Requires; -import software.amazon.awssdk.http.Protocol; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.async.SdkAsyncHttpClient; -import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; -import software.amazon.awssdk.utils.AttributeMap; import jakarta.inject.Singleton; import java.util.List; @@ -47,22 +42,4 @@ public LocalstackContainerHolder localstackContainerHolder( return new LocalstackContainerHolder(configuration, overrides); } - @Primary - @Singleton - @Bean(preDestroy = "close") - public SdkAsyncHttpClient client() { - return NettyNioAsyncHttpClient - .builder() - .protocol(Protocol.HTTP1_1) - .buildWithDefaults( - AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE - ) - .build() - ); - } - } diff --git a/subprojects/micronaut-amazon-awssdk-integration-testing/src/main/java/com/agorapulse/micronaut/amazon/awssdk/itest/localstack/v2/SdkAsyncClientFactory.java b/subprojects/micronaut-amazon-awssdk-integration-testing/src/main/java/com/agorapulse/micronaut/amazon/awssdk/itest/localstack/v2/SdkAsyncClientFactory.java new file mode 100644 index 000000000..ce5440c8c --- /dev/null +++ b/subprojects/micronaut-amazon-awssdk-integration-testing/src/main/java/com/agorapulse/micronaut/amazon/awssdk/itest/localstack/v2/SdkAsyncClientFactory.java @@ -0,0 +1,56 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright 2018-2024 Agorapulse. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.agorapulse.micronaut.amazon.awssdk.itest.localstack.v2; + +import com.agorapulse.micronaut.amazon.awssdk.core.AwsConfiguration; +import io.micronaut.context.annotation.Bean; +import io.micronaut.context.annotation.Factory; +import io.micronaut.context.annotation.Primary; +import io.micronaut.context.annotation.Replaces; +import io.micronaut.context.annotation.Requires; +import jakarta.inject.Singleton; +import software.amazon.awssdk.http.Protocol; +import software.amazon.awssdk.http.SdkHttpConfigurationOption; +import software.amazon.awssdk.http.async.SdkAsyncHttpClient; +import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; +import software.amazon.awssdk.utils.AttributeMap; + +@Factory +@Replaces(AwsConfiguration.class) +@Requires(missingProperty = "localstack.disabled", classes = NettyNioAsyncHttpClient.class) +public class SdkAsyncClientFactory { + + @Primary + @Singleton + @Bean(preDestroy = "close") + public SdkAsyncHttpClient client() { + return NettyNioAsyncHttpClient + .builder() + .protocol(Protocol.HTTP1_1) + .buildWithDefaults( + AttributeMap + .builder() + .put( + SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, + Boolean.TRUE + ) + .build() + ); + } + +}