This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new be2e163 Migrates the camel-aws2-sqs integration tests to the shared
test infra (#4484)
be2e163 is described below
commit be2e16347e93a0d2663db53938e2c016f41dc53f
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Oct 20 17:57:37 2020 +0200
Migrates the camel-aws2-sqs integration tests to the shared test infra
(#4484)
---
components/camel-aws2-sqs/README.md | 36 ++++++++++
components/camel-aws2-sqs/pom.xml | 76 ++++++++++++++++++++--
.../integration/SqsComponentIntegrationTest.java | 30 +++++++--
.../SqsConsumerMessageIntegrationTest.java | 38 +++++++++--
.../SqsProducerBatchSendFifoIntegrationTest.java | 39 +++++++++--
.../SqsProducerBatchSendIntegrationTest.java | 36 ++++++++--
.../SqsProducerDeleteMessageIntegrationTest.java | 45 ++++++++++---
.../aws2/sqs/integration/TestSqsConfiguration.java | 44 +++++++++++++
.../aws2/sqs/localstack/Aws2SQSBaseTest.java | 55 ++++------------
.../sqs/localstack/SqsComponentLocalstackTest.java | 3 +-
.../SqsConsumerMessageLocalstackTest.java | 4 +-
.../SqsProducerBatchSendFifoLocalstackTest.java | 7 +-
.../SqsProducerBatchSendLocalstackTest.java | 4 +-
.../SqsProducerDeleteMessageLocalstackTest.java | 6 +-
.../test/infra/aws2/clients/AWSSDKClientUtils.java | 7 +-
.../SystemPropertiesAWSCredentialsProvider.java | 27 ++++++++
.../test/infra/aws2/common/TestAWSCredentials.java | 43 ++++++++++++
.../aws2/common/TestAWSCredentialsProvider.java | 32 ---------
.../aws2/services/AWSLocalContainerService.java | 21 +++---
.../test/infra/aws2/services/AWSRemoteService.java | 6 +-
.../aws2/services/AWSSQSLocalContainerService.java | 3 -
21 files changed, 421 insertions(+), 141 deletions(-)
diff --git a/components/camel-aws2-sqs/README.md
b/components/camel-aws2-sqs/README.md
new file mode 100644
index 0000000..80489b5
--- /dev/null
+++ b/components/camel-aws2-sqs/README.md
@@ -0,0 +1,36 @@
+# AWS SQS component for SDK v2
+
+# Running the tests
+
+This component contains integration tests that can be executed against a
LocalStack instance, or an actual AWS
+instance. The build determines the execution or not of the integration tests
automatically by checking the `DOCKER_HOST`
+environment variable or by the presence of the local unix socket. If either of
the conditions is true , then the build
+will try to execute the integration test.
+
+*Note*: the `DOCKER_HOST` variable is usually the address of the local unix
socket `unix:///var/run/docker.sock`.
+
+It is possible to run the tests on a remote docker server by overwriting the
value of the DOCKER_HOST variable:
+
+
+```
+DOCKER_HOST=tcp://myhost:2375 mvn clean verify
+```
+
+# Force running the integration tests
+
+Should you need to force the execution of the integration tests, despite the
value of the DOCKER_HOST variable, you can
+do so by enabling the `aws2-sqs-tests-docker-env` profile:
+
+
+```
+mvn -Paws2-sqs-tests-docker-env clean test verify
+```
+
+# Running the tests against AWS
+
+You can define the `aws-service.instance.type`, `aws.access.key` and
`aws.secret.key` to switch the test execution from
+using LocalStack and, instead, using AWS:
+
+```
+mvn -Paws2-sqs-tests-docker-env -Daws-service.instance.type=remote
-Daws.access.key=you-access-key -Daws.secret.key=you-secret-key clean test
verify
+```
\ No newline at end of file
diff --git a/components/camel-aws2-sqs/pom.xml
b/components/camel-aws2-sqs/pom.xml
index 04fac9f..c8aeabc 100644
--- a/components/camel-aws2-sqs/pom.xml
+++ b/components/camel-aws2-sqs/pom.xml
@@ -51,6 +51,32 @@
<version>${aws-java-sdk2-version}</version>
</dependency>
+ <!-- test infra -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-aws-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-aws-v2</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+
<!-- for testing -->
<dependency>
<groupId>org.apache.camel</groupId>
@@ -67,11 +93,6 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-testcontainers-junit5</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<profiles>
@@ -111,6 +132,28 @@
</systemPropertyVariables>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipTests}</skipTests>
+ <reuseForks>true</reuseForks>
+ <systemPropertyVariables>
+
<visibleassertions.silence>true</visibleassertions.silence>
+ </systemPropertyVariables>
+ <includes>
+ <include>**/*IntegrationTest.java</include>
+ </includes>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</profile>
@@ -134,6 +177,29 @@
</systemPropertyVariables>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipTests}</skipTests>
+ <reuseForks>true</reuseForks>
+ <systemPropertyVariables>
+
<visibleassertions.silence>true</visibleassertions.silence>
+ </systemPropertyVariables>
+ <includes>
+ <include>**/*IntegrationTest.java</include>
+ </includes>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
</profile>
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsComponentIntegrationTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsComponentIntegrationTest.java
index 27b7a0c..64f969c 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsComponentIntegrationTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsComponentIntegrationTest.java
@@ -24,18 +24,28 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.aws2.sqs.Sqs2Constants;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.aws.common.services.AWSService;
+import
org.apache.camel.test.infra.aws2.common.SystemPropertiesAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.common.TestAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
+import org.apache.camel.test.infra.common.SharedNameGenerator;
+import org.apache.camel.test.infra.common.TestEntityNameGenerator;
import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.services.sqs.SqsClient;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class SqsComponentIntegrationTest extends CamelTestSupport {
- private String accessKey = "xxx";
- private String secretKey = "yyy";
+ @RegisterExtension
+ public static AWSService<SqsClient> service =
AWSServiceFactory.createSQSService();
+
+ @RegisterExtension
+ public static SharedNameGenerator sharedNameGenerator = new
TestEntityNameGenerator();
@EndpointInject("direct:start")
private ProducerTemplate template;
@@ -93,13 +103,19 @@ public class SqsComponentIntegrationTest extends
CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ TestAWSCredentialsProvider credentialsProvider = new
SystemPropertiesAWSCredentialsProvider();
+ AwsCredentials credentials = credentialsProvider.resolveCredentials();
+
final String sqsEndpointUri = String
-
.format("aws2-sqs://MyNewCamelQueue?accessKey=%s&secretKey=%s&messageRetentionPeriod=%s&maximumMessageSize=%s&visibilityTimeout=%s&policy=%s",
- accessKey, secretKey,
+
.format("aws2-sqs://%s?accessKey=%s&secretKey=%s&messageRetentionPeriod=%s&maximumMessageSize=%s&visibilityTimeout=%s&policy=%s&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
"1209600", "65536", "60",
"%7B%22Version%22%3A%222008-10-17%22%2C%22Id%22%3A%22%2F195004372649%2FMyNewCamelQueue%2FSQSDefaultPolicy%22%2C%22"
+
"Statement%22%3A%5B%7B%22Sid%22%3A%22Queue1ReceiveMessage%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22AWS%22%3A%22*%22%7D%2C%22"
- +
"Action%22%3A%22SQS%3AReceiveMessage%22%2C%22Resource%22%3A%22%2F195004372649%2FMyNewCamelQueue%22%7D%5D%7D");
+ +
"Action%22%3A%22SQS%3AReceiveMessage%22%2C%22Resource%22%3A%22%2F195004372649%2FMyNewCamelQueue%22%7D%5D%7D",
+ "#class:" + TestSqsConfiguration.class.getName());
return new RouteBuilder() {
@Override
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsConsumerMessageIntegrationTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsConsumerMessageIntegrationTest.java
index 37a600d..d552842 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsConsumerMessageIntegrationTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsConsumerMessageIntegrationTest.java
@@ -23,13 +23,26 @@ import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.aws.common.services.AWSService;
+import
org.apache.camel.test.infra.aws2.common.SystemPropertiesAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.common.TestAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
+import org.apache.camel.test.infra.common.SharedNameGenerator;
+import org.apache.camel.test.infra.common.TestEntityNameGenerator;
import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.services.sqs.SqsClient;
-@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class SqsConsumerMessageIntegrationTest extends CamelTestSupport {
+ @RegisterExtension
+ public static AWSService<SqsClient> service =
AWSServiceFactory.createSQSService();
+
+ @RegisterExtension
+ public static SharedNameGenerator sharedNameGenerator = new
TestEntityNameGenerator();
+
@EndpointInject("direct:start")
private ProducerTemplate template;
@@ -57,18 +70,29 @@ public class SqsConsumerMessageIntegrationTest extends
CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ TestAWSCredentialsProvider credentialsProvider = new
SystemPropertiesAWSCredentialsProvider();
+ AwsCredentials credentials = credentialsProvider.resolveCredentials();
+
final String sqsEndpointUri
- =
String.format("aws2-sqs://camel-1?accessKey=RAW(xxxx)&secretKey=RAW(xxxx)®ion=eu-west-1");
+ =
String.format("aws2-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" + TestSqsConfiguration.class.getName());
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").startupOrder(2).to(sqsEndpointUri);
-
from("aws2-sqs://camel-1?accessKey=RAW(xxxx)&secretKey=RAW(xxxx)®ion=eu-west-1&deleteAfterRead=false&deleteIfFiltered=true")
- .startupOrder(1)
- .filter(simple("${body} !=
'ignore'")).log("${body}").log("${header.CamelAwsSqsReceiptHandle}")
- .to("mock:result");
+
fromF("aws2-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&deleteAfterRead=false&deleteIfFiltered=true&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" + TestSqsConfiguration.class.getName())
+ .startupOrder(1)
+ .filter(simple("${body} !=
'ignore'")).log("${body}").log("${header.CamelAwsSqsReceiptHandle}")
+ .to("mock:result");
}
};
}
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendFifoIntegrationTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendFifoIntegrationTest.java
index cf56cd3..be06431 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendFifoIntegrationTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendFifoIntegrationTest.java
@@ -27,13 +27,26 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.aws2.sqs.Sqs2Constants;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.aws.common.services.AWSService;
+import
org.apache.camel.test.infra.aws2.common.SystemPropertiesAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.common.TestAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
+import org.apache.camel.test.infra.common.SharedNameGenerator;
+import org.apache.camel.test.infra.common.TestEntityNameGenerator;
import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.services.sqs.SqsClient;
-@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class SqsProducerBatchSendFifoIntegrationTest extends CamelTestSupport {
+ @RegisterExtension
+ public static AWSService<SqsClient> service =
AWSServiceFactory.createSQSService();
+
+ @RegisterExtension
+ public static SharedNameGenerator sharedNameGenerator = new
TestEntityNameGenerator();
+
@EndpointInject("direct:start")
private ProducerTemplate template;
@@ -61,9 +74,17 @@ public class SqsProducerBatchSendFifoIntegrationTest extends
CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ TestAWSCredentialsProvider credentialsProvider = new
SystemPropertiesAWSCredentialsProvider();
+ AwsCredentials credentials = credentialsProvider.resolveCredentials();
+
final String sqsEndpointUri = String.format(
-
"aws2-sqs://camel-1.fifo?accessKey=RAW(xxx)&secretKey=RAW(xxx)®ion=eu-west-1&messageGroupIdStrategy=useExchangeId"
- +
"&messageDeduplicationIdStrategy=useContentBasedDeduplication");
+
"aws2-sqs://%s.fifo?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&messageGroupIdStrategy=useExchangeId"
+ +
"&messageDeduplicationIdStrategy=useContentBasedDeduplication"
+ + "&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" + TestSqsConfiguration.class.getName());
return new RouteBuilder() {
@Override
@@ -71,8 +92,14 @@ public class SqsProducerBatchSendFifoIntegrationTest extends
CamelTestSupport {
from("direct:start").startupOrder(2).setHeader(Sqs2Constants.SQS_OPERATION,
constant("sendBatchMessage"))
.to(sqsEndpointUri);
-
from("aws2-sqs://camel-1.fifo?accessKey=RAW(xxx)&secretKey=RAW(xxxx)®ion=eu-west-1&deleteAfterRead=false")
- .startupOrder(1).log("${body}").to("mock:result");
+
fromF("aws2-sqs://%s.fifo?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&deleteAfterRead=false&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" + TestSqsConfiguration.class.getName())
+ .startupOrder(1)
+ .log("${body}")
+ .to("mock:result");
}
};
}
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendIntegrationTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendIntegrationTest.java
index 939969e..02c12cd 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendIntegrationTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerBatchSendIntegrationTest.java
@@ -27,13 +27,26 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.aws2.sqs.Sqs2Constants;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.aws.common.services.AWSService;
+import
org.apache.camel.test.infra.aws2.common.SystemPropertiesAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.common.TestAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
+import org.apache.camel.test.infra.common.SharedNameGenerator;
+import org.apache.camel.test.infra.common.TestEntityNameGenerator;
import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.services.sqs.SqsClient;
-@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class SqsProducerBatchSendIntegrationTest extends CamelTestSupport {
+ @RegisterExtension
+ public static AWSService<SqsClient> service =
AWSServiceFactory.createSQSService();
+
+ @RegisterExtension
+ public static SharedNameGenerator sharedNameGenerator = new
TestEntityNameGenerator();
+
@EndpointInject("direct:start")
private ProducerTemplate template;
@@ -61,8 +74,15 @@ public class SqsProducerBatchSendIntegrationTest extends
CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ TestAWSCredentialsProvider credentialsProvider = new
SystemPropertiesAWSCredentialsProvider();
+ AwsCredentials credentials = credentialsProvider.resolveCredentials();
+
final String sqsEndpointUri
- =
String.format("aws2-sqs://camel-1?accessKey=RAW(xxx)&secretKey=RAW(xxx)®ion=eu-west-1");
+ =
String.format("aws2-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" + TestSqsConfiguration.class.getName());
return new RouteBuilder() {
@Override
@@ -70,8 +90,14 @@ public class SqsProducerBatchSendIntegrationTest extends
CamelTestSupport {
from("direct:start").startupOrder(2).setHeader(Sqs2Constants.SQS_OPERATION,
constant("sendBatchMessage"))
.to(sqsEndpointUri);
-
from("aws2-sqs://camel-1?accessKey=RAW(xxx)&secretKey=RAW(xxx)®ion=eu-west-1&deleteAfterRead=true")
- .startupOrder(1).log("${body}").to("mock:result");
+
fromF("aws2-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&deleteAfterRead=true&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" + TestSqsConfiguration.class.getName())
+ .startupOrder(1)
+ .log("${body}")
+ .to("mock:result");
}
};
}
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerDeleteMessageIntegrationTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerDeleteMessageIntegrationTest.java
index bc2043f..1851c53 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerDeleteMessageIntegrationTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/SqsProducerDeleteMessageIntegrationTest.java
@@ -23,13 +23,26 @@ import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.aws.common.services.AWSService;
+import
org.apache.camel.test.infra.aws2.common.SystemPropertiesAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.common.TestAWSCredentialsProvider;
+import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
+import org.apache.camel.test.infra.common.SharedNameGenerator;
+import org.apache.camel.test.infra.common.TestEntityNameGenerator;
import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.services.sqs.SqsClient;
-@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class SqsProducerDeleteMessageIntegrationTest extends CamelTestSupport {
+ @RegisterExtension
+ public static AWSService<SqsClient> service =
AWSServiceFactory.createSQSService();
+
+ @RegisterExtension
+ public static SharedNameGenerator sharedNameGenerator = new
TestEntityNameGenerator();
+
@EndpointInject("direct:start")
private ProducerTemplate template;
@@ -51,19 +64,35 @@ public class SqsProducerDeleteMessageIntegrationTest
extends CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ TestAWSCredentialsProvider credentialsProvider = new
SystemPropertiesAWSCredentialsProvider();
+ AwsCredentials credentials = credentialsProvider.resolveCredentials();
+
final String sqsEndpointUri
- =
String.format("aws2-sqs://camel-1?accessKey=RAW(xxx)&secretKey=RAW(xxx)®ion=eu-west-1");
+ =
String.format("aws2-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" + TestSqsConfiguration.class.getName());
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").startupOrder(2).to(sqsEndpointUri);
-
from("aws2-sqs://camel-1?accessKey=RAW(xxx)&secretKey=RAW(xxx)®ion=eu-west-1&deleteAfterRead=false")
- .startupOrder(1).log("${body}")
-
.to("aws2-sqs://camel-1?accessKey=RAW(xxx)&secretKey=RAW(xxx)®ion=eu-west-1&operation=deleteMessage")
- .log("${body}")
-
.log("${header.CamelAwsSqsReceiptHandle}").to("mock:result");
+
fromF("aws2-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&deleteAfterRead=false&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" + TestSqsConfiguration.class.getName())
+ .startupOrder(1)
+ .log("${body}")
+
.toF("aws2-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)®ion=eu-west-1&operation=deleteMessage&configuration=%s",
+ sharedNameGenerator.getName(),
+ credentials.accessKeyId(),
+ credentials.secretAccessKey(),
+ "#class:" +
TestSqsConfiguration.class.getName())
+ .log("${body}")
+
.log("${header.CamelAwsSqsReceiptHandle}").to("mock:result");
}
};
}
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/TestSqsConfiguration.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/TestSqsConfiguration.java
new file mode 100644
index 0000000..9f70bc5
--- /dev/null
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/integration/TestSqsConfiguration.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.camel.component.aws2.sqs.integration;
+
+import org.apache.camel.component.aws2.sqs.Sqs2Configuration;
+import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
+import org.apache.camel.test.infra.common.SharedNameGenerator;
+import org.apache.camel.test.infra.common.SharedNameRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.services.sqs.SqsClient;
+
+public class TestSqsConfiguration extends Sqs2Configuration {
+ private static final Logger LOG =
LoggerFactory.getLogger(TestSqsConfiguration.class);
+ private final SqsClient sqsClient = AWSSDKClientUtils.newSQSClient();
+
+ public TestSqsConfiguration() {
+ SharedNameGenerator sharedNameGenerator =
SharedNameRegistry.getInstance().getSharedNameGenerator();
+
+ String name = sharedNameGenerator.getName();
+ LOG.debug("Using the following shared resource name for the test: {}",
name);
+ setQueueName(name);
+ }
+
+ @Override
+ public SqsClient getAmazonSQSClient() {
+ return sqsClient;
+ }
+}
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/Aws2SQSBaseTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/Aws2SQSBaseTest.java
index 9e12731..b92f504 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/Aws2SQSBaseTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/Aws2SQSBaseTest.java
@@ -16,61 +16,32 @@
*/
package org.apache.camel.component.aws2.sqs.localstack;
-import java.net.URI;
-
import org.apache.camel.CamelContext;
import org.apache.camel.component.aws2.sqs.Sqs2Component;
-import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport;
-import org.apache.camel.test.testcontainers.junit5.Wait;
+import org.apache.camel.test.infra.aws.common.services.AWSService;
+import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
+import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
+import org.apache.camel.test.infra.common.SharedNameGenerator;
+import org.apache.camel.test.infra.common.TestEntityNameGenerator;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.TestInstance;
-import org.testcontainers.containers.GenericContainer;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.regions.Region;
+import org.junit.jupiter.api.extension.RegisterExtension;
import software.amazon.awssdk.services.sqs.SqsClient;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public class Aws2SQSBaseTest extends ContainerAwareTestSupport {
+public class Aws2SQSBaseTest extends CamelTestSupport {
- public static final String CONTAINER_IMAGE =
"localstack/localstack:0.11.6";
- public static final String CONTAINER_NAME = "sqs";
+ @RegisterExtension
+ public static AWSService<SqsClient> service =
AWSServiceFactory.createSQSService();
- @Override
- protected GenericContainer<?> createContainer() {
- return localstackContainer();
- }
-
- public static GenericContainer localstackContainer() {
- return new GenericContainer(CONTAINER_IMAGE)
- .withNetworkAliases(CONTAINER_NAME)
- .withEnv("SERVICES", "sqs")
- .withExposedPorts(4566)
- .waitingFor(Wait.forListeningPort())
- .waitingFor(Wait.forLogMessageContaining("Ready.", 1));
- }
-
- public String getS3Url() {
- return String.format(
- "%s:%d",
- getContainerHost(CONTAINER_NAME),
- getContainerPort(CONTAINER_NAME, 4566));
- }
-
- public SqsClient getSQSClient() {
- SqsClient sqsClient = SqsClient
- .builder()
- .endpointOverride(URI.create("http://" + getS3Url()))
-
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxx",
"yyy")))
- .region(Region.EU_WEST_1)
- .build();
- return sqsClient;
- }
+ @RegisterExtension
+ public static SharedNameGenerator sharedNameGenerator = new
TestEntityNameGenerator();
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
Sqs2Component sqs = context.getComponent("aws2-sqs",
Sqs2Component.class);
- sqs.getConfiguration().setAmazonSQSClient(getSQSClient());
+
sqs.getConfiguration().setAmazonSQSClient(AWSSDKClientUtils.newSQSClient());
return context;
}
}
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsComponentLocalstackTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsComponentLocalstackTest.java
index 698c687..eebb2e4 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsComponentLocalstackTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsComponentLocalstackTest.java
@@ -88,7 +88,8 @@ public class SqsComponentLocalstackTest extends
Aws2SQSBaseTest {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
final String sqsEndpointUri = String
-
.format("aws2-sqs://MyNewCamelQueue?messageRetentionPeriod=%s&maximumMessageSize=%s&visibilityTimeout=%s&policy=%s",
+
.format("aws2-sqs://%s?messageRetentionPeriod=%s&maximumMessageSize=%s&visibilityTimeout=%s&policy=%s",
+ sharedNameGenerator.getName(),
"1209600", "65536", "60",
"%7B%22Version%22%3A%222008-10-17%22%2C%22Id%22%3A%22%2F195004372649%2FMyNewCamelQueue%2FSQSDefaultPolicy%22%2C%22"
+
"Statement%22%3A%5B%7B%22Sid%22%3A%22Queue1ReceiveMessage%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22AWS%22%3A%22*%22%7D%2C%22"
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsConsumerMessageLocalstackTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsConsumerMessageLocalstackTest.java
index ff1c0d0..e761ca1 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsConsumerMessageLocalstackTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsConsumerMessageLocalstackTest.java
@@ -58,9 +58,9 @@ public class SqsConsumerMessageLocalstackTest extends
Aws2SQSBaseTest {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:start").startupOrder(2).to("aws2-sqs://camel-1");
+ from("direct:start").startupOrder(2).toF("aws2-sqs://%s",
sharedNameGenerator.getName());
-
from("aws2-sqs://camel-1?deleteAfterRead=false&deleteIfFiltered=true")
+
fromF("aws2-sqs://%s?deleteAfterRead=false&deleteIfFiltered=true",
sharedNameGenerator.getName())
.startupOrder(1)
.filter(simple("${body} !=
'ignore'")).log("${body}").log("${header.CamelAwsSqsReceiptHandle}")
.to("mock:result");
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerBatchSendFifoLocalstackTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerBatchSendFifoLocalstackTest.java
index 8df58ed..767af64 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerBatchSendFifoLocalstackTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerBatchSendFifoLocalstackTest.java
@@ -55,8 +55,9 @@ public class SqsProducerBatchSendFifoLocalstackTest extends
Aws2SQSBaseTest {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
final String sqsEndpointUri = String.format(
- "aws2-sqs://camel-1.fifo?messageGroupIdStrategy=useExchangeId"
- +
"&messageDeduplicationIdStrategy=useContentBasedDeduplication");
+ "aws2-sqs://%s.fifo?messageGroupIdStrategy=useExchangeId"
+ +
"&messageDeduplicationIdStrategy=useContentBasedDeduplication",
+ sharedNameGenerator.getName());
return new RouteBuilder() {
@Override
@@ -64,7 +65,7 @@ public class SqsProducerBatchSendFifoLocalstackTest extends
Aws2SQSBaseTest {
from("direct:start").startupOrder(2).setHeader(Sqs2Constants.SQS_OPERATION,
constant("sendBatchMessage"))
.to(sqsEndpointUri);
- from("aws2-sqs://camel-1.fifo?deleteAfterRead=false")
+ fromF("aws2-sqs://%s.fifo?deleteAfterRead=false",
sharedNameGenerator.getName())
.startupOrder(1).log("${body}").to("mock:result");
}
};
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerBatchSendLocalstackTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerBatchSendLocalstackTest.java
index a0fbb91..9aab850 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerBatchSendLocalstackTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerBatchSendLocalstackTest.java
@@ -63,9 +63,9 @@ public class SqsProducerBatchSendLocalstackTest extends
Aws2SQSBaseTest {
@Override
public void configure() throws Exception {
from("direct:start").startupOrder(2).setHeader(Sqs2Constants.SQS_OPERATION,
constant("sendBatchMessage"))
- .to("aws2-sqs://camel-1");
+ .toF("aws2-sqs://%s", sharedNameGenerator.getName());
- from("aws2-sqs://camel-1?deleteAfterRead=true")
+ fromF("aws2-sqs://%s?deleteAfterRead=true",
sharedNameGenerator.getName())
.startupOrder(1).log("${body}").to("mock:result");
}
};
diff --git
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerDeleteMessageLocalstackTest.java
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerDeleteMessageLocalstackTest.java
index 1d72e73..31602a3 100644
---
a/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerDeleteMessageLocalstackTest.java
+++
b/components/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/localstack/SqsProducerDeleteMessageLocalstackTest.java
@@ -52,11 +52,11 @@ public class SqsProducerDeleteMessageLocalstackTest extends
Aws2SQSBaseTest {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:start").startupOrder(2).to("aws2-sqs://camel-1");
+ from("direct:start").startupOrder(2).toF("aws2-sqs://%s",
sharedNameGenerator.getName());
- from("aws2-sqs://camel-1?deleteAfterRead=false")
+ fromF("aws2-sqs://%s?deleteAfterRead=false",
sharedNameGenerator.getName())
.startupOrder(1).log("${body}")
- .to("aws2-sqs://camel-1?operation=deleteMessage")
+ .toF("aws2-sqs://%s?operation=deleteMessage",
sharedNameGenerator.getName())
.log("${body}")
.log("${header.CamelAwsSqsReceiptHandle}").to("mock:result");
}
diff --git
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/clients/AWSSDKClientUtils.java
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/clients/AWSSDKClientUtils.java
index a6961bb..0bdc4e0 100644
---
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/clients/AWSSDKClientUtils.java
+++
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/clients/AWSSDKClientUtils.java
@@ -21,6 +21,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import org.apache.camel.test.infra.aws.common.AWSConfigs;
+import
org.apache.camel.test.infra.aws2.common.SystemPropertiesAWSCredentialsProvider;
import org.apache.camel.test.infra.aws2.common.TestAWSCredentialsProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,7 +77,7 @@ public final class AWSSDKClientUtils {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.CONTAINER_LOCAL_DEFAULT_PROVIDER);
} else {
-
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.SYSTEM_PROPERTY_PROVIDER);
+ clientBuilder.credentialsProvider(new
SystemPropertiesAWSCredentialsProvider());
}
return clientBuilder.build();
@@ -101,7 +102,7 @@ public final class AWSSDKClientUtils {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.CONTAINER_LOCAL_DEFAULT_PROVIDER);
} else {
-
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.SYSTEM_PROPERTY_PROVIDER);
+ clientBuilder.credentialsProvider(new
SystemPropertiesAWSCredentialsProvider());
}
return clientBuilder.build();
@@ -125,7 +126,7 @@ public final class AWSSDKClientUtils {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.CONTAINER_LOCAL_DEFAULT_PROVIDER);
} else {
-
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.SYSTEM_PROPERTY_PROVIDER);
+ clientBuilder.credentialsProvider(new
SystemPropertiesAWSCredentialsProvider());
}
return clientBuilder.build();
diff --git
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/SystemPropertiesAWSCredentialsProvider.java
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/SystemPropertiesAWSCredentialsProvider.java
new file mode 100644
index 0000000..d2ad248
--- /dev/null
+++
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/SystemPropertiesAWSCredentialsProvider.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.camel.test.infra.aws2.common;
+
+import org.apache.camel.test.infra.aws.common.AWSConfigs;
+
+public class SystemPropertiesAWSCredentialsProvider extends
TestAWSCredentialsProvider {
+
+ public SystemPropertiesAWSCredentialsProvider() {
+ super(System.getProperty(AWSConfigs.ACCESS_KEY),
System.getProperty(AWSConfigs.SECRET_KEY));
+ }
+}
diff --git
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/TestAWSCredentials.java
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/TestAWSCredentials.java
new file mode 100644
index 0000000..dccc8c6
--- /dev/null
+++
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/TestAWSCredentials.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.camel.test.infra.aws2.common;
+
+import java.util.Objects;
+
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+
+public class TestAWSCredentials implements AwsCredentials {
+ private final String accessKey;
+ private final String secretKey;
+
+ public TestAWSCredentials(String accessKey, String secretKey) {
+ this.accessKey = Objects.requireNonNull(accessKey);
+ this.secretKey = Objects.requireNonNull(secretKey);
+ }
+
+ @Override
+ public String accessKeyId() {
+ return accessKey;
+ }
+
+ @Override
+ public String secretAccessKey() {
+ return secretKey;
+ }
+
+};
diff --git
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/TestAWSCredentialsProvider.java
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/TestAWSCredentialsProvider.java
index 6ecbca4..7f5b511 100644
---
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/TestAWSCredentialsProvider.java
+++
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/common/TestAWSCredentialsProvider.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.test.infra.aws2.common;
-import org.apache.camel.test.infra.aws.common.AWSConfigs;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
@@ -24,39 +23,8 @@ public class TestAWSCredentialsProvider implements
AwsCredentialsProvider {
public static final TestAWSCredentialsProvider
CONTAINER_LOCAL_DEFAULT_PROVIDER
= new TestAWSCredentialsProvider("accesskey", "secretkey");
- public static final TestAWSCredentialsProvider SYSTEM_PROPERTY_PROVIDER =
new TestAWSCredentialsProvider();
-
- private static class TestAWSCredentials implements AwsCredentials {
- private final String accessKey;
- private final String secretKey;
-
- public TestAWSCredentials() {
- this(System.getProperty(AWSConfigs.ACCESS_KEY),
System.getProperty(AWSConfigs.SECRET_KEY));
- }
-
- public TestAWSCredentials(String accessKey, String secretKey) {
- this.accessKey = accessKey;
- this.secretKey = secretKey;
- }
-
- @Override
- public String accessKeyId() {
- return accessKey;
- }
-
- @Override
- public String secretAccessKey() {
- return secretKey;
- }
-
- };
-
private AwsCredentials credentials;
- public TestAWSCredentialsProvider() {
- credentials = new TestAWSCredentials();
- }
-
public TestAWSCredentialsProvider(String accessKey, String secretKey) {
credentials = new TestAWSCredentials(accessKey, secretKey);
}
diff --git
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSLocalContainerService.java
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSLocalContainerService.java
index f48c9bf..ecba4fc 100644
---
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSLocalContainerService.java
+++
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSLocalContainerService.java
@@ -54,24 +54,25 @@ abstract class AWSLocalContainerService<T> implements
AWSService<T> {
AwsCredentials credentials =
container.getCredentialsProvider().resolveCredentials();
properties.put(AWSConfigs.ACCESS_KEY, credentials.accessKeyId());
-
properties.put(AWSConfigs.SECRET_KEY, credentials.secretAccessKey());
-
properties.put(AWSConfigs.REGION, Region.US_EAST_1.toString());
-
properties.put(AWSConfigs.AMAZON_AWS_HOST, container.getAmazonHost());
+ properties.put(AWSConfigs.PROTOCOL, "http");
/**
- * We need to set this one. For some sets, when they instantiate the
clients within Camel, they need to know
- * what is the Amazon host being used (ie.: when creating them using
the withEndpointConfiguration()). Because
- * this happens within Camel, there's no way to pass that information
easily. Therefore, the host is set as a
+ * We need to set these. For some sets, when they instantiate the
clients within Camel, they need to know what
+ * is the Amazon host being used (ie.: when creating them using the
withEndpointConfiguration()). Because this
+ * happens within Camel, there's no way to pass that information
easily. Therefore, the host is set as a
* property and read by whatever class/method creates the clients to
pass to Camel.
*
* Do not unset.
*/
System.setProperty(AWSConfigs.AMAZON_AWS_HOST, getAmazonHost());
-
- properties.put(AWSConfigs.PROTOCOL, "http");
+ System.setProperty(AWSConfigs.SECRET_KEY,
credentials.secretAccessKey());
+ System.setProperty(AWSConfigs.ACCESS_KEY, credentials.accessKeyId());
+ System.setProperty(AWSConfigs.AMAZON_AWS_HOST, getAmazonHost());
+ System.setProperty(AWSConfigs.REGION, Region.US_EAST_1.toString());
+ System.setProperty(AWSConfigs.PROTOCOL, "http");
return properties;
}
@@ -82,7 +83,11 @@ abstract class AWSLocalContainerService<T> implements
AWSService<T> {
@Override
public void initialize() {
+ LOG.debug("Trying to start the container");
+ container.start();
+
LOG.info("AWS service running at address {}", getServiceEndpoint());
+ getConnectionProperties();
}
@Override
diff --git
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSRemoteService.java
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSRemoteService.java
index c45c0ea..f120edf 100644
---
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSRemoteService.java
+++
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSRemoteService.java
@@ -22,13 +22,11 @@ import java.util.function.Supplier;
import org.apache.camel.test.infra.aws.common.AWSConfigs;
import org.apache.camel.test.infra.aws.common.services.AWSService;
-import org.apache.camel.test.infra.aws2.common.TestAWSCredentialsProvider;
+import
org.apache.camel.test.infra.aws2.common.SystemPropertiesAWSCredentialsProvider;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
-import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.regions.Region;
public class AWSRemoteService<T> implements AWSService<T> {
- private static final AwsCredentialsProvider CREDENTIALS_PROVIDER = new
TestAWSCredentialsProvider();
private Supplier<T> remoteClientSupplier;
public AWSRemoteService(Supplier<T> remoteClientSupplier) {
@@ -44,7 +42,7 @@ public class AWSRemoteService<T> implements AWSService<T> {
public Properties getConnectionProperties() {
Properties properties = new Properties();
- AwsCredentials credentials = CREDENTIALS_PROVIDER.resolveCredentials();
+ AwsCredentials credentials = new
SystemPropertiesAWSCredentialsProvider().resolveCredentials();
properties.put(AWSConfigs.ACCESS_KEY, credentials.accessKeyId());
properties.put(AWSConfigs.SECRET_KEY, credentials.secretAccessKey());
diff --git
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSSQSLocalContainerService.java
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSSQSLocalContainerService.java
index c6e59ab..b5e9499 100644
---
a/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSSQSLocalContainerService.java
+++
b/test-infra/camel-test-infra-aws-v2/src/test/java/org/apache/camel/test/infra/aws2/services/AWSSQSLocalContainerService.java
@@ -30,9 +30,6 @@ public class AWSSQSLocalContainerService extends
AWSLocalContainerService<SqsCli
// Current latest container - localstack/localstack:0.11.3 - is broken
for SQS
// therefore uses an older version
super("localstack/localstack:0.11.2", Service.SQS);
-
- LOG.info("Initializing the local AWS services");
- getContainer().start();
}
@Override