Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions components/camel-aws-sqs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# AWS SQS component for SDK v1

# 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. If set, 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 `aws-tests-docker-env` profile:


```
mvn -Paws-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 -Paws-tests-docker-env -Daws-service.instance.type=remote -Daws.access.key=you-access-key -Daws.secret.key=you-secret-key clean test verify
```
63 changes: 63 additions & 0 deletions components/camel-aws-sqs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@
<version>${aws-java-sdk-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-v1</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<!-- for testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -73,4 +98,42 @@
<scope>test</scope>
</dependency>
</dependencies>

<!-- activate test if the DOCKER_HOST env var is set -->
<profiles>
<profile>
<id>aws-tests-docker-env</id>
<activation>
<property>
<name>env.DOCKER_HOST</name>
</property>
</activation>
<build>
<plugins>
<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>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.camel.component.aws.sqs.integration;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.services.sqs.AmazonSQS;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
Expand All @@ -24,18 +26,27 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.aws.sqs.SqsConstants;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.infra.aws.common.SystemPropertiesAWSCredentialsProvider;
import org.apache.camel.test.infra.aws.common.TestAWSCredentialsProvider;
import org.apache.camel.test.infra.aws.common.services.AWSService;
import org.apache.camel.test.infra.aws.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 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";
@SuppressWarnings("unused")
@RegisterExtension
public static AWSService<AmazonSQS> service = AWSServiceFactory.createSQSService();

@RegisterExtension
public static SharedNameGenerator sharedNameGenerator = new TestEntityNameGenerator();

@EndpointInject("direct:start")
private ProducerTemplate template;
Expand Down Expand Up @@ -93,13 +104,19 @@ public void process(Exchange exchange) throws Exception {

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
TestAWSCredentialsProvider awsCredentialsProvider = new SystemPropertiesAWSCredentialsProvider();
AWSCredentials awsCredentials = awsCredentialsProvider.getCredentials();

final String sqsEndpointUri = String
.format("aws-sqs://MyNewCamelQueue?accessKey=%s&secretKey=%s&messageRetentionPeriod=%s&maximumMessageSize=%s&visibilityTimeout=%s&policy=%s",
accessKey, secretKey,
.format("aws-sqs://%s?accessKey=%s&secretKey=%s&messageRetentionPeriod=%s&maximumMessageSize=%s&visibilityTimeout=%s&policy=%s&region=US_EAST_1&configuration=%s",
sharedNameGenerator.getName(),
awsCredentials.getAWSAccessKeyId(),
awsCredentials.getAWSSecretKey(),
"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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,33 @@
*/
package org.apache.camel.component.aws.sqs.integration;

import com.amazonaws.services.sqs.AmazonSQS;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
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.SystemPropertiesAWSCredentialsProvider;
import org.apache.camel.test.infra.aws.common.TestAWSCredentialsProvider;
import org.apache.camel.test.infra.aws.common.services.AWSService;
import org.apache.camel.test.infra.aws.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;

@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class SqsConsumerMessageIntegrationTest extends CamelTestSupport {

@SuppressWarnings("unused")
@RegisterExtension
public static AWSService<AmazonSQS> service = AWSServiceFactory.createSQSService();

@RegisterExtension
public static SharedNameGenerator sharedNameGenerator = new TestEntityNameGenerator();

@EndpointInject("direct:start")
private ProducerTemplate template;

Expand Down Expand Up @@ -57,18 +70,28 @@ public void process(Exchange exchange) throws Exception {

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
TestAWSCredentialsProvider awsCredentialsProvider = new SystemPropertiesAWSCredentialsProvider();

final String sqsEndpointUri
= String.format("aws-sqs://camel-1?accessKey=RAW(xxxx)&secretKey=RAW(xxxx)&region=EU_WEST_1");
= String.format("aws-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)&region=EU_WEST_1&configuration=#class:%s",
sharedNameGenerator.getName(),
awsCredentialsProvider.getCredentials().getAWSAccessKeyId(),
awsCredentialsProvider.getCredentials().getAWSSecretKey(),
TestSqsConfiguration.class.getName());

return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").startupOrder(2).to(sqsEndpointUri);

from("aws-sqs://camel-1?accessKey=RAW(xxxx)&secretKey=RAW(xxxx)&region=EU_WEST_1&deleteAfterRead=false&deleteIfFiltered=true")
.startupOrder(1)
.filter(simple("${body} != 'ignore'")).log("${body}").log("${header.CamelAwsSqsReceiptHandle}")
.to("mock:result");
fromF("aws-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)&region=EU_WEST_1&deleteAfterRead=false&deleteIfFiltered=true&configuration=#class:%s",
sharedNameGenerator.getName(),
awsCredentialsProvider.getCredentials().getAWSAccessKeyId(),
awsCredentialsProvider.getCredentials().getAWSSecretKey(),
TestSqsConfiguration.class.getName())
.startupOrder(1)
.filter(simple("${body} != 'ignore'")).log("${body}").log("${header.CamelAwsSqsReceiptHandle}")
.to("mock:result");
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.Collection;

import com.amazonaws.services.sqs.AmazonSQS;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
Expand All @@ -27,13 +28,25 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.aws.sqs.SqsConstants;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.infra.aws.common.SystemPropertiesAWSCredentialsProvider;
import org.apache.camel.test.infra.aws.common.TestAWSCredentialsProvider;
import org.apache.camel.test.infra.aws.common.services.AWSService;
import org.apache.camel.test.infra.aws.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;

@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class SqsProducerBatchSendFifoIntegrationTest extends CamelTestSupport {

@SuppressWarnings("unused")
@RegisterExtension
public static AWSService<AmazonSQS> service = AWSServiceFactory.createSQSService();

@RegisterExtension
public static SharedNameGenerator sharedNameGenerator = new TestEntityNameGenerator();

@EndpointInject("direct:start")
private ProducerTemplate template;

Expand Down Expand Up @@ -61,18 +74,28 @@ public void process(Exchange exchange) throws Exception {

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
TestAWSCredentialsProvider awsCredentialsProvider = new SystemPropertiesAWSCredentialsProvider();

final String sqsEndpointUri = String.format(
"aws-sqs://camel-1.fifo?accessKey=RAW(xxx)&secretKey=RAW(xxx)&region=EU_WEST_1&messageGroupIdStrategy=useExchangeId"
+ "&messageDeduplicationIdStrategy=useContentBasedDeduplication");
"aws-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)&region=EU_WEST_1&messageGroupIdStrategy=useExchangeId"
+ "&messageDeduplicationIdStrategy=useContentBasedDeduplication&configuration=#class:%s",
sharedNameGenerator.getName(),
awsCredentialsProvider.getCredentials().getAWSAccessKeyId(),
awsCredentialsProvider.getCredentials().getAWSSecretKey(),
TestSqsConfiguration.class.getName());

return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").startupOrder(2).setHeader(SqsConstants.SQS_OPERATION, constant("sendBatchMessage"))
.to(sqsEndpointUri);

from("aws-sqs://camel-1.fifo?accessKey=RAW(xxx)&secretKey=RAW(xxxx)&region=EU_WEST_1&deleteAfterRead=false")
.startupOrder(1).log("${body}").to("mock:result");
fromF("aws-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)&region=EU_WEST_1&deleteAfterRead=false&configuration=#class:%s",
sharedNameGenerator.getName(),
awsCredentialsProvider.getCredentials().getAWSAccessKeyId(),
awsCredentialsProvider.getCredentials().getAWSSecretKey(),
TestSqsConfiguration.class.getName())
.startupOrder(1).log("${body}").to("mock:result");
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.Collection;

import com.amazonaws.services.sqs.AmazonSQS;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
Expand All @@ -27,13 +28,25 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.aws.sqs.SqsConstants;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.infra.aws.common.SystemPropertiesAWSCredentialsProvider;
import org.apache.camel.test.infra.aws.common.TestAWSCredentialsProvider;
import org.apache.camel.test.infra.aws.common.services.AWSService;
import org.apache.camel.test.infra.aws.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;

@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class SqsProducerBatchSendIntegrationTest extends CamelTestSupport {

@SuppressWarnings("unused")
@RegisterExtension
public static AWSService<AmazonSQS> service = AWSServiceFactory.createSQSService();

@RegisterExtension
public static SharedNameGenerator sharedNameGenerator = new TestEntityNameGenerator();

@EndpointInject("direct:start")
private ProducerTemplate template;

Expand Down Expand Up @@ -61,16 +74,27 @@ public void process(Exchange exchange) throws Exception {

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
final String sqsEndpointUri = String.format("aws-sqs://camel-1?accessKey=RAW(xxx)&secretKey=RAW(xxx)&region=EU_WEST_1");
TestAWSCredentialsProvider awsCredentialsProvider = new SystemPropertiesAWSCredentialsProvider();

final String sqsEndpointUri
= String.format("aws-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)&region=EU_WEST_1&configuration=#class:%s",
sharedNameGenerator.getName(),
awsCredentialsProvider.getCredentials().getAWSAccessKeyId(),
awsCredentialsProvider.getCredentials().getAWSSecretKey(),
TestSqsConfiguration.class.getName());

return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").startupOrder(2).setHeader(SqsConstants.SQS_OPERATION, constant("sendBatchMessage"))
.to(sqsEndpointUri);

from("aws-sqs://camel-1?accessKey=RAW(xxx)&secretKey=RAW(xxx)&region=EU_WEST_1&deleteAfterRead=true")
.startupOrder(1).log("${body}").to("mock:result");
fromF("aws-sqs://%s?accessKey=RAW(%s)&secretKey=RAW(%s)&region=EU_WEST_1&deleteAfterRead=true&configuration=#class:%s",
sharedNameGenerator.getName(),
awsCredentialsProvider.getCredentials().getAWSAccessKeyId(),
awsCredentialsProvider.getCredentials().getAWSSecretKey(),
TestSqsConfiguration.class.getName())
.startupOrder(1).log("${body}").to("mock:result");
}
};
}
Expand Down
Loading