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:
43
README.md
43
README.md
@@ -470,26 +470,6 @@ The implementation is based on a simple table with `KEY` and `VALUE` attributes,
|
||||
By default, the `SpringIntegrationMetadataStore` table is used, and it is created during `DynamoDbMetaDataStore` initialization if that doesn't exist yet.
|
||||
The `DynamoDbMetadataStore` can be used for the `KinesisMessageDrivenChannelAdapter` as a cloud-based `cehckpointStore`.
|
||||
|
||||
For testing application with the `DynamoDbMetadataStore` you can use [Dynalite][] NPM module.
|
||||
What you need in your application is to configure DynamoDB client properly:
|
||||
|
||||
````java
|
||||
String url = "http://localhost:" + this.port;
|
||||
|
||||
this.amazonDynamoDB = AmazonDynamoDBAsyncClientBuilder.standard()
|
||||
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", "")))
|
||||
.withClientConfiguration(
|
||||
new ClientConfiguration()
|
||||
.withMaxErrorRetry(0)
|
||||
.withConnectionTimeout(1000))
|
||||
.withEndpointConfiguration(
|
||||
new AwsClientBuilder.EndpointConfiguration(url, Regions.DEFAULT_REGION.getName()))
|
||||
.build();
|
||||
````
|
||||
|
||||
where you should specify the port on which you have ran the Dynalite service.
|
||||
Also, you can use for you testing purpose a [Local Stack][] library.
|
||||
|
||||
Starting with _version 2.0_, the `DynamoDbMetadataStore` can be configured with the `timeToLive` option to enable the [DynamoDB TTL][] feature.
|
||||
The `TTL` attribute is added to each item with the value based on the sum of current time and provided `timeToLive` in seconds.
|
||||
If the provided `timeToLive` value is non-positive, the TTL functionality is disabled on the table.
|
||||
@@ -608,29 +588,6 @@ public MessageHandler kinesisMessageHandler(AmazonKinesis amazonKinesis,
|
||||
Starting with _version 2.0_, the `KinesisMessageHandler` can be configured with the `OutboundMessageMapper` to embed message headers into the record data alongside with the payload.
|
||||
See `EmbeddedJsonHeadersMessageMapper` implementation for more information.
|
||||
|
||||
For testing application with the Kinesis Channel Adapters you can use [Kinesalite][] NPM module.
|
||||
What you need in your application is to configure Kinesis client properly:
|
||||
|
||||
````java
|
||||
String url = "http://localhost:" + this.port;
|
||||
|
||||
// See https://github.com/mhart/kinesalite#cbor-protocol-issues-with-the-java-sdk
|
||||
System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
|
||||
|
||||
this.amazonKinesis = AmazonKinesisAsyncClientBuilder.standard()
|
||||
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", "")))
|
||||
.withClientConfiguration(
|
||||
new ClientConfiguration()
|
||||
.withMaxErrorRetry(0)
|
||||
.withConnectionTimeout(1000))
|
||||
.withEndpointConfiguration(
|
||||
new AwsClientBuilder.EndpointConfiguration(url, Regions.DEFAULT_REGION.getName()))
|
||||
.build();
|
||||
````
|
||||
|
||||
where you should specify the port on which you have ran the Kinesalite service.
|
||||
Also, you can use for you testing purpose a [Local Stack][] library.
|
||||
|
||||
Also, the `KplMessageHandler` is provided for performing streams consumption by [Kinesis Producer Library][].
|
||||
|
||||
## Lock Registry for Amazon DynamoDB
|
||||
|
||||
17
build.gradle
17
build.gradle
@@ -31,13 +31,13 @@ ext {
|
||||
dynamodbLockClientVersion = '1.1.0'
|
||||
jacksonVersion = '2.13.2'
|
||||
junitVersion = '5.8.2'
|
||||
servletApiVersion = '4.0.1'
|
||||
localstackVersion = '0.2.20'
|
||||
servletApiVersion = '5.0.0'
|
||||
log4jVersion = '2.17.2'
|
||||
springCloudAwsVersion = '2.4.0'
|
||||
springIntegrationVersion = '5.5.11-SNAPSHOT'
|
||||
springIntegrationVersion = '6.0.0-SNAPSHOT'
|
||||
kinesisClientVersion = '1.14.8'
|
||||
kinesisProducerVersion = '0.14.12'
|
||||
testcontainersVersion = '1.16.3'
|
||||
|
||||
idPrefix = 'aws'
|
||||
|
||||
@@ -56,8 +56,7 @@ ext.javadocLinks = [
|
||||
] as String[]
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
options.release = 17
|
||||
}
|
||||
|
||||
java {
|
||||
@@ -89,6 +88,7 @@ dependencyManagement {
|
||||
mavenBom "org.springframework.integration:spring-integration-bom:$springIntegrationVersion"
|
||||
mavenBom "com.fasterxml.jackson:jackson-bom:$jacksonVersion"
|
||||
mavenBom "org.junit:junit-bom:$junitVersion"
|
||||
mavenBom "org.testcontainers:testcontainers-bom:$testcontainersVersion"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ jacoco {
|
||||
|
||||
checkstyle {
|
||||
configDirectory.set(rootProject.file('src/checkstyle'))
|
||||
toolVersion = '9.3'
|
||||
toolVersion = '10.1'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -117,19 +117,20 @@ dependencies {
|
||||
optionalApi 'com.amazonaws:aws-java-sdk-dynamodb'
|
||||
optionalApi "com.amazonaws:dynamodb-lock-client:$dynamodbLockClientVersion"
|
||||
|
||||
optionalApi "javax.servlet:javax.servlet-api:$servletApiVersion"
|
||||
optionalApi "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
|
||||
|
||||
testImplementation ('org.springframework.integration:spring-integration-test') {
|
||||
exclude group: 'junit'
|
||||
}
|
||||
|
||||
testImplementation "org.assertj:assertj-core:$assertjVersion"
|
||||
testImplementation "cloud.localstack:localstack-utils:$localstackVersion"
|
||||
|
||||
testImplementation ("org.awaitility:awaitility:$awaitilityVersion") {
|
||||
exclude group: 'org.hamcrest'
|
||||
}
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api'
|
||||
testImplementation 'org.testcontainers:junit-jupiter'
|
||||
testImplementation 'org.testcontainers:localstack'
|
||||
|
||||
testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
|
||||
testRuntimeOnly "org.apache.logging.log4j:log4j-jcl:$log4jVersion"
|
||||
|
||||
@@ -1 +1 @@
|
||||
version=2.5.2-SNAPSHOT
|
||||
version=3.0.0-SNAPSHOT
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user