Start version 3.0

* Upgrade to Jakarta EE
* Upgrade to Spring Integration 6.0
* Use Testcontainers instead of direct Localstack
This commit is contained in:
Artem Bilan
2022-03-30 16:19:40 -04:00
parent 055307e7ba
commit 620b741ba8
14 changed files with 115 additions and 343 deletions

View File

@@ -1,45 +0,0 @@
/*
* Copyright 2019 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.
* 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 org.springframework.integration.aws;
import cloud.localstack.docker.annotation.IHostNameResolver;
import com.amazonaws.SDKGlobalConfiguration;
/**
* An {@link IHostNameResolver} implementation for {@value EnvironmentHostNameResolver#DOCKER_HOST_NAME}
* environment variable to resolve for Local Stack Docker instance.
* Also this class places an {@value SDKGlobalConfiguration#AWS_CBOR_DISABLE_SYSTEM_PROPERTY}
* system property to disable CBOR for services requests.
*
* @author Artem Bilan
*
* @since 2.3
*/
public class EnvironmentHostNameResolver implements IHostNameResolver {
public static final String DOCKER_HOST_NAME = "DOCKER_HOST_NAME";
static {
System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
}
@Override
public String getHostName() {
return System.getenv(DOCKER_HOST_NAME);
}
}

View File

@@ -1,113 +0,0 @@
/*
* Copyright 2019-2020 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.
* 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 org.springframework.integration.aws;
import static cloud.localstack.Constants.DEFAULT_REGION;
import java.util.function.Supplier;
import cloud.localstack.Localstack;
import cloud.localstack.awssdkv1.TestUtils;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.client.builder.AwsAsyncClientBuilder;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync;
import com.amazonaws.services.cloudwatch.AmazonCloudWatchAsyncClientBuilder;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClientBuilder;
import com.amazonaws.services.kinesis.AmazonKinesisAsync;
import com.amazonaws.services.kinesis.AmazonKinesisAsyncClientBuilder;
/**
* An utility class for providing AWS {@code async} clients based on the Local Stack Docker instance.
* In addition it provides SSL-based async clients.
*
*
* @author Artem Bilan
*
* @since 2.3
*/
public final class ExtendedDockerTestUtils {
public static AmazonKinesisAsync getClientKinesisAsync() {
return doGetClientKinesisAsync(false);
}
public static AmazonKinesisAsync getClientKinesisAsyncSsl() {
return doGetClientKinesisAsync(true);
}
private static AmazonKinesisAsync doGetClientKinesisAsync(boolean ssl) {
AmazonKinesisAsyncClientBuilder amazonKinesisAsyncClientBuilder =
AmazonKinesisAsyncClientBuilder.standard()
.withEndpointConfiguration(
createEndpointConfiguration(Localstack.INSTANCE::getEndpointKinesis, ssl));
return applyConfigurationAndBuild(amazonKinesisAsyncClientBuilder);
}
public static AmazonDynamoDBAsync getClientDynamoDbAsync() {
return doClientDynamoDbAsync(false);
}
public static AmazonDynamoDBAsync getClientDynamoDbAsyncSsl() {
return doClientDynamoDbAsync(true);
}
private static AmazonDynamoDBAsync doClientDynamoDbAsync(boolean ssl) {
AmazonDynamoDBAsyncClientBuilder dynamoDBAsyncClientBuilder =
AmazonDynamoDBAsyncClientBuilder.standard()
.withEndpointConfiguration(
createEndpointConfiguration(Localstack.INSTANCE::getEndpointDynamoDB, ssl));
return applyConfigurationAndBuild(dynamoDBAsyncClientBuilder);
}
public static AmazonCloudWatchAsync getClientCloudWatchAsync() {
return doClientCloudWatchAsync(false);
}
public static AmazonCloudWatchAsync getClientCloudWatchAsyncSsl() {
return doClientCloudWatchAsync(true);
}
private static AmazonCloudWatchAsync doClientCloudWatchAsync(boolean ssl) {
AmazonCloudWatchAsyncClientBuilder cloudWatchAsyncClientBuilder =
AmazonCloudWatchAsyncClientBuilder.standard()
.withEndpointConfiguration(
createEndpointConfiguration(Localstack.INSTANCE::getEndpointCloudWatch, ssl));
return applyConfigurationAndBuild(cloudWatchAsyncClientBuilder);
}
private static AwsClientBuilder.EndpointConfiguration createEndpointConfiguration(Supplier<String> supplier,
boolean ssl) {
String serviceEndpoint = supplier.get();
if (ssl) {
serviceEndpoint = serviceEndpoint.replaceFirst("http", "https");
}
return new AwsClientBuilder.EndpointConfiguration(serviceEndpoint, DEFAULT_REGION);
}
private static <T, C extends AwsAsyncClientBuilder<C, T>> T applyConfigurationAndBuild(C builder) {
return builder.withCredentials(TestUtils.getCredentialsProvider())
.withClientConfiguration(new ClientConfiguration().withMaxErrorRetry(0).withConnectionTimeout(1000))
.build();
}
private ExtendedDockerTestUtils() {
}
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2019 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.
* 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 org.springframework.integration.aws;
import java.util.Collections;
import java.util.Map;
import cloud.localstack.docker.annotation.IEnvironmentVariableProvider;
import com.amazonaws.SDKGlobalConfiguration;
/**
* An {@link IEnvironmentVariableProvider} implementation to provide a {@code USE_SSL}
* environment variable for docker to start a Local Stack in TLS mode.
* Also this class populates a {@value SDKGlobalConfiguration#DISABLE_CERT_CHECKING_SYSTEM_PROPERTY}
* system property to disable SSL certificates validation.
*
* @author Artem Bilan
*
* @since 2.3
*/
public class LocalStackSslEnvironmentProvider implements IEnvironmentVariableProvider {
static {
System.setProperty(SDKGlobalConfiguration.DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "true");
}
@Override
public Map<String, String> getEnvironmentVariables() {
return Collections.singletonMap("USE_SSL", "true");
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright 2021-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.
* 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 org.springframework.integration.aws;
import org.testcontainers.containers.localstack.LocalStackContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.cloudwatch.AmazonCloudWatch;
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClientBuilder;
import com.amazonaws.services.kinesis.AmazonKinesisAsync;
import com.amazonaws.services.kinesis.AmazonKinesisAsyncClientBuilder;
/**
*
* @author Artem Bilan
*
* @since 5.5.5
*/
@Testcontainers(disabledWithoutDocker = true)
public interface LocalstackContainerTest {
@Container
LocalStackContainer localStack =
new LocalStackContainer(DockerImageName.parse("localstack/localstack"))
.withServices(
LocalStackContainer.Service.DYNAMODB,
LocalStackContainer.Service.KINESIS,
LocalStackContainer.Service.CLOUDWATCH)
.withReuse(true);
static AmazonDynamoDBAsync dynamoDbClient() {
return applyAwsClientOptions(AmazonDynamoDBAsyncClientBuilder.standard(), LocalStackContainer.Service.DYNAMODB);
}
static AmazonKinesisAsync kinesisClient() {
return applyAwsClientOptions(AmazonKinesisAsyncClientBuilder.standard(), LocalStackContainer.Service.KINESIS);
}
static AmazonCloudWatch cloudWatchClient() {
return applyAwsClientOptions(AmazonCloudWatchClientBuilder.standard(), LocalStackContainer.Service.CLOUDWATCH);
}
private static <B extends AwsClientBuilder<B, T>, T> T applyAwsClientOptions(B clientBuilder,
LocalStackContainer.Service serviceToBuild) {
return clientBuilder.withEndpointConfiguration(localStack.getEndpointConfiguration(serviceToBuild))
.withCredentials(localStack.getDefaultCredentialsProvider())
.build();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 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.
@@ -26,10 +26,6 @@ import java.util.Set;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,8 +33,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.aws.EnvironmentHostNameResolver;
import org.springframework.integration.aws.ExtendedDockerTestUtils;
import org.springframework.integration.aws.LocalstackContainerTest;
import org.springframework.integration.aws.inbound.kinesis.KinesisMessageDrivenChannelAdapter;
import org.springframework.integration.aws.inbound.kinesis.KinesisMessageHeaderErrorMessageStrategy;
import org.springframework.integration.aws.outbound.KinesisMessageHandler;
@@ -60,8 +55,6 @@ import org.springframework.messaging.support.ErrorMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import com.amazonaws.services.kinesis.AmazonKinesisAsync;
/**
@@ -69,15 +62,9 @@ import com.amazonaws.services.kinesis.AmazonKinesisAsync;
*
* @since 1.1
*/
@DisabledOnOs(OS.LINUX)
@SpringJUnitConfig
@EnabledIfEnvironmentVariable(named = EnvironmentHostNameResolver.DOCKER_HOST_NAME, matches = ".+")
@ExtendWith(LocalstackDockerExtension.class)
@LocalstackDockerProperties(
hostNameResolver = EnvironmentHostNameResolver.class,
services = "kinesis")
@DirtiesContext
public class KinesisIntegrationTests {
public class KinesisIntegrationTests implements LocalstackContainerTest {
private static final String TEST_STREAM = "TestStream";
@@ -94,7 +81,7 @@ public class KinesisIntegrationTests {
@BeforeAll
static void setup() {
AMAZON_KINESIS_ASYNC = ExtendedDockerTestUtils.getClientKinesisAsync();
AMAZON_KINESIS_ASYNC = LocalstackContainerTest.kinesisClient();
AMAZON_KINESIS_ASYNC.createStream(TEST_STREAM, 1);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 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.
@@ -25,19 +25,17 @@ import java.util.Date;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.testcontainers.containers.localstack.LocalStackContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.aws.EnvironmentHostNameResolver;
import org.springframework.integration.aws.ExtendedDockerTestUtils;
import org.springframework.integration.aws.LocalStackSslEnvironmentProvider;
import org.springframework.integration.aws.LocalstackContainerTest;
import org.springframework.integration.aws.inbound.kinesis.KclMessageDrivenChannelAdapter;
import org.springframework.integration.aws.inbound.kinesis.KinesisMessageHeaderErrorMessageStrategy;
import org.springframework.integration.aws.outbound.KplMessageHandler;
@@ -56,10 +54,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import cloud.localstack.Constants;
import cloud.localstack.Localstack;
import cloud.localstack.awssdkv1.TestUtils;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import com.amazonaws.services.cloudwatch.AmazonCloudWatch;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.kinesis.AmazonKinesis;
@@ -72,16 +67,10 @@ import com.amazonaws.services.kinesis.producer.KinesisProducerConfiguration;
*
* @since 1.1
*/
@Disabled
@DisabledOnOs(OS.WINDOWS)
@SpringJUnitConfig
@EnabledIfEnvironmentVariable(named = EnvironmentHostNameResolver.DOCKER_HOST_NAME, matches = ".+")
@ExtendWith(LocalstackDockerExtension.class)
@LocalstackDockerProperties(
hostNameResolver = EnvironmentHostNameResolver.class,
environmentVariableProvider = LocalStackSslEnvironmentProvider.class,
services = { "kinesis", "dynamodb", "cloudwatch" })
@DirtiesContext
public class KplKclIntegrationTests {
public class KplKclIntegrationTests implements LocalstackContainerTest {
private static final String TEST_STREAM = "TestStream";
@@ -102,9 +91,9 @@ public class KplKclIntegrationTests {
@BeforeAll
static void setup() {
AMAZON_KINESIS = ExtendedDockerTestUtils.getClientKinesisAsyncSsl();
DYNAMO_DB = ExtendedDockerTestUtils.getClientDynamoDbAsyncSsl();
CLOUD_WATCH = ExtendedDockerTestUtils.getClientCloudWatchAsyncSsl();
AMAZON_KINESIS = LocalstackContainerTest.kinesisClient();
DYNAMO_DB = LocalstackContainerTest.dynamoDbClient();
CLOUD_WATCH = LocalstackContainerTest.cloudWatchClient();
AMAZON_KINESIS.createStream(TEST_STREAM, 1);
}
@@ -152,8 +141,10 @@ public class KplKclIntegrationTests {
@Bean
public KinesisProducerConfiguration kinesisProducerConfiguration() throws URISyntaxException {
URI kinesisUri = new URI(Localstack.INSTANCE.getEndpointKinesis());
URI cloudWatchUri = new URI(Localstack.INSTANCE.getEndpointCloudWatch());
URI kinesisUri =
LocalstackContainerTest.localStack.getEndpointOverride(LocalStackContainer.Service.KINESIS);
URI cloudWatchUri =
LocalstackContainerTest.localStack.getEndpointOverride(LocalStackContainer.Service.CLOUDWATCH);
return new KinesisProducerConfiguration()
.setCredentialsProvider(TestUtils.getCredentialsProvider())
.setRegion(Constants.DEFAULT_REGION)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-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.
@@ -27,11 +27,8 @@ import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.integration.aws.EnvironmentHostNameResolver;
import org.springframework.integration.aws.ExtendedDockerTestUtils;
import org.springframework.integration.aws.LocalstackContainerTest;
import org.springframework.integration.aws.lock.DynamoDbLockRegistry;
import org.springframework.integration.leader.Context;
import org.springframework.integration.leader.DefaultCandidate;
@@ -39,8 +36,6 @@ import org.springframework.integration.leader.event.LeaderEventPublisher;
import org.springframework.integration.support.leader.LockRegistryLeaderInitiator;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync;
import com.amazonaws.services.dynamodbv2.model.DescribeTableRequest;
import com.amazonaws.waiters.FixedDelayStrategy;
@@ -54,19 +49,13 @@ import com.amazonaws.waiters.WaiterParameters;
*
* @since 2.0
*/
@EnabledIfEnvironmentVariable(named = EnvironmentHostNameResolver.DOCKER_HOST_NAME, matches = ".+")
@ExtendWith(LocalstackDockerExtension.class)
@LocalstackDockerProperties(
hostNameResolver = EnvironmentHostNameResolver.class,
services = "dynamodb")
class DynamoDbLockRegistryLeaderInitiatorTests {
class DynamoDbLockRegistryLeaderInitiatorTests implements LocalstackContainerTest {
private static AmazonDynamoDBAsync DYNAMO_DB;
@BeforeAll
static void init() {
DYNAMO_DB = ExtendedDockerTestUtils.getClientDynamoDbAsync();
DYNAMO_DB = LocalstackContainerTest.dynamoDbClient();
try {
DYNAMO_DB.deleteTableAsync(DynamoDbLockRegistry.DEFAULT_TABLE_NAME);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2020 the original author or authors.
* Copyright 2020-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.
@@ -44,6 +44,7 @@ import com.amazonaws.services.dynamodbv2.model.TableStatus;
* @since 2.3.5
*/
class DynamoDbLockRegistryBuildTableTests {
private static final String TEST_TABLE
= "testLockRegistry" + DynamoDbLockRegistryBuildTableTests.class.getSimpleName();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-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.
@@ -28,22 +28,17 @@ import java.util.concurrent.locks.Lock;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.integration.aws.EnvironmentHostNameResolver;
import org.springframework.integration.aws.ExtendedDockerTestUtils;
import org.springframework.integration.aws.LocalstackContainerTest;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync;
import com.amazonaws.services.dynamodbv2.model.DescribeTableRequest;
import com.amazonaws.waiters.FixedDelayStrategy;
@@ -58,13 +53,8 @@ import com.amazonaws.waiters.WaiterParameters;
* @since 2.0
*/
@SpringJUnitConfig
@EnabledIfEnvironmentVariable(named = EnvironmentHostNameResolver.DOCKER_HOST_NAME, matches = ".+")
@ExtendWith(LocalstackDockerExtension.class)
@LocalstackDockerProperties(
hostNameResolver = EnvironmentHostNameResolver.class,
services = "dynamodb")
@DirtiesContext
public class DynamoDbLockRegistryTests {
public class DynamoDbLockRegistryTests implements LocalstackContainerTest {
private static AmazonDynamoDBAsync DYNAMO_DB;
@@ -75,8 +65,7 @@ public class DynamoDbLockRegistryTests {
@BeforeAll
static void setup() {
DYNAMO_DB = ExtendedDockerTestUtils.getClientDynamoDbAsync();
DYNAMO_DB = LocalstackContainerTest.dynamoDbClient();
try {
DYNAMO_DB.deleteTableAsync(DynamoDbLockRegistry.DEFAULT_TABLE_NAME);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2020 the original author or authors.
* Copyright 2020-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.
@@ -38,6 +38,7 @@ import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException;
* @since 2.3.5
*/
class DynamoDbMetadataStoreBuildTableTests {
private static final String TEST_TABLE
= "testMetadataStore" + DynamoDbMetadataStoreBuildTableTests.class.getSimpleName();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 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.
@@ -24,15 +24,10 @@ import java.util.concurrent.CountDownLatch;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.integration.aws.EnvironmentHostNameResolver;
import org.springframework.integration.aws.ExtendedDockerTestUtils;
import org.springframework.integration.aws.LocalstackContainerTest;
import org.springframework.integration.test.util.TestUtils;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.amazonaws.services.dynamodbv2.model.DescribeTableRequest;
@@ -47,12 +42,7 @@ import com.amazonaws.waiters.WaiterParameters;
*
* @since 1.1
*/
@EnabledIfEnvironmentVariable(named = EnvironmentHostNameResolver.DOCKER_HOST_NAME, matches = ".+")
@ExtendWith(LocalstackDockerExtension.class)
@LocalstackDockerProperties(
hostNameResolver = EnvironmentHostNameResolver.class,
services = "dynamodb")
class DynamoDbMetadataStoreTests {
class DynamoDbMetadataStoreTests implements LocalstackContainerTest {
private static final String TEST_TABLE = "testMetadataStore";
@@ -66,8 +56,7 @@ class DynamoDbMetadataStoreTests {
@BeforeAll
static void setup() {
DYNAMO_DB = ExtendedDockerTestUtils.getClientDynamoDbAsync();
DYNAMO_DB = LocalstackContainerTest.dynamoDbClient();
try {
DYNAMO_DB.deleteTableAsync(TEST_TABLE);