You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2021/02/12 15:30:03 UTC

[camel-quarkus] branch master updated (ee2c896 -> 9bc79b9)

This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git.


    from ee2c896  AtlasMap native support #1989
     new 77072a2  Test AWS 2 DynamoDB Streams
     new 9bc79b9  Test AWS 2 Kinesis

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../aws2/ddb/it/Aws2DdbStreamResource.java         | 75 ++++++++++++++++++++++
 .../src/main/resources/application.properties      |  4 ++
 .../quarkus/component/aws2/ddb/it/Aws2DdbTest.java | 18 ++++++
 .../aws2/ddb/it/Aws2DdbTestEnvCustomizer.java      | 11 +++-
 .../{aws2-ddb => aws2-kinesis}/pom.xml             | 10 +--
 .../aws2/kinesis/it/Aws2KinesisResource.java       | 55 ++++++++++------
 .../src/main/resources/application.properties      |  4 +-
 .../component/aws2/kinesis/it/Aws2KinesisIT.java   |  4 +-
 .../component/aws2/kinesis/it/Aws2KinesisTest.java | 27 ++++----
 .../kinesis/it/Aws2KinesisTestEnvCustomizer.java   | 62 ++++++++++++++++++
 ...quarkus.test.support.aws2.Aws2TestEnvCustomizer |  1 +
 integration-tests-aws2/pom.xml                     |  1 +
 .../test/support/aws2/Aws2TestEnvContext.java      |  3 +
 .../test/support/aws2/Aws2TestResource.java        |  1 +
 integration-tests/aws2-grouped/pom.xml             | 17 +++++
 15 files changed, 248 insertions(+), 45 deletions(-)
 create mode 100644 integration-tests-aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbStreamResource.java
 copy integration-tests-aws2/{aws2-ddb => aws2-kinesis}/pom.xml (93%)
 copy integration-tests/ftp/src/main/java/org/apache/camel/quarkus/component/sftp/it/SftpResource.java => integration-tests-aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisResource.java (58%)
 copy {integration-tests/as2 => integration-tests-aws2/aws2-kinesis}/src/main/resources/application.properties (84%)
 copy integration-tests/activemq/src/test/java/org/apache/camel/quarkus/component/activemq/it/ActiveMQIT.java => integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisIT.java (89%)
 copy integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaTest.java => integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java (68%)
 create mode 100644 integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTestEnvCustomizer.java
 create mode 100644 integration-tests-aws2/aws2-kinesis/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer


[camel-quarkus] 02/02: Test AWS 2 Kinesis

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 9bc79b9d3e00103f2eb076e3ddb329bdb4f19d97
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Fri Feb 12 12:45:53 2021 +0100

    Test AWS 2 Kinesis
---
 integration-tests-aws2/aws2-kinesis/pom.xml        | 146 +++++++++++++++++++++
 .../aws2/kinesis/it/Aws2KinesisResource.java       |  82 ++++++++++++
 .../src/main/resources/application.properties      |  20 +++
 .../component/aws2/kinesis/it/Aws2KinesisIT.java   |  24 ++++
 .../component/aws2/kinesis/it/Aws2KinesisTest.java |  47 +++++++
 .../kinesis/it/Aws2KinesisTestEnvCustomizer.java   |  62 +++++++++
 ...quarkus.test.support.aws2.Aws2TestEnvCustomizer |   1 +
 integration-tests-aws2/pom.xml                     |   1 +
 .../test/support/aws2/Aws2TestResource.java        |   1 +
 integration-tests/aws2-grouped/pom.xml             |  17 +++
 10 files changed, 401 insertions(+)

diff --git a/integration-tests-aws2/aws2-kinesis/pom.xml b/integration-tests-aws2/aws2-kinesis/pom.xml
new file mode 100644
index 0000000..e850bed
--- /dev/null
+++ b/integration-tests-aws2/aws2-kinesis/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.camel.quarkus</groupId>
+        <artifactId>camel-quarkus-integration-tests-aws2</artifactId>
+        <version>1.7.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>camel-quarkus-integration-test-aws2-kinesis</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: AWS 2 Kinesis</name>
+    <description>Integration tests for Camel Quarkus AWS 2 Kinesis extension</description>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.camel.quarkus</groupId>
+                <artifactId>camel-quarkus-bom-test</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-main</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-aws2-kinesis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy-jackson</artifactId>
+        </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.rest-assured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-aws2-kinesis-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-main-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <profile>
+            <id>native</id>
+            <activation>
+                <property>
+                    <name>native</name>
+                </property>
+            </activation>
+            <properties>
+                <quarkus.package.type>native</quarkus.package.type>
+            </properties>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/integration-tests-aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisResource.java b/integration-tests-aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisResource.java
new file mode 100644
index 0000000..df7c742
--- /dev/null
+++ b/integration-tests-aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisResource.java
@@ -0,0 +1,82 @@
+/*
+ * 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.quarkus.component.aws2.kinesis.it;
+
+import java.net.URI;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.aws2.kinesis.Kinesis2Constants;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import software.amazon.awssdk.services.kinesis.model.Record;
+
+@Path("/aws2-kinesis")
+@ApplicationScoped
+public class Aws2KinesisResource {
+
+    @ConfigProperty(name = "aws-kinesis.stream-name")
+    String streamName;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @Path("/send")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response send(String message) throws Exception {
+        final String response = producerTemplate.requestBodyAndHeader(
+                componentUri(),
+                message,
+                Kinesis2Constants.PARTITION_KEY,
+                "foo-partition-key",
+                String.class);
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response)
+                .build();
+    }
+
+    @Path("/receive")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public String receive() {
+        Record record = consumerTemplate.receiveBody(componentUri(), 10000, Record.class);
+        if (record == null) {
+            return null;
+        }
+        return record.data().asUtf8String();
+    }
+
+    private String componentUri() {
+        return "aws2-kinesis://" + streamName;
+    }
+
+}
diff --git a/integration-tests-aws2/aws2-kinesis/src/main/resources/application.properties b/integration-tests-aws2/aws2-kinesis/src/main/resources/application.properties
new file mode 100644
index 0000000..926eb0c
--- /dev/null
+++ b/integration-tests-aws2/aws2-kinesis/src/main/resources/application.properties
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+camel.component.aws2-kinesis.access-key=${AWS_ACCESS_KEY}
+camel.component.aws2-kinesis.secret-key=${AWS_SECRET_KEY}
+camel.component.aws2-kinesis.region=${AWS_REGION:us-east-1}
diff --git a/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisIT.java b/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisIT.java
new file mode 100644
index 0000000..c208a60
--- /dev/null
+++ b/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisIT.java
@@ -0,0 +1,24 @@
+/*
+ * 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.quarkus.component.aws2.kinesis.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class Aws2KinesisIT extends Aws2KinesisTest {
+
+}
diff --git a/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java b/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
new file mode 100644
index 0000000..7efffec
--- /dev/null
+++ b/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.quarkus.component.aws2.kinesis.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+@QuarkusTestResource(Aws2TestResource.class)
+class Aws2KinesisTest {
+
+    @Test
+    public void test() {
+        final String msg = "kinesis-" + java.util.UUID.randomUUID().toString().replace("-", "");
+        RestAssured.given() //
+                .contentType(ContentType.TEXT)
+                .body(msg)
+                .post("/aws2-kinesis/send") //
+                .then()
+                .statusCode(201);
+
+        RestAssured.get("/aws2-kinesis/receive")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is(msg));
+    }
+
+}
diff --git a/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTestEnvCustomizer.java b/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTestEnvCustomizer.java
new file mode 100644
index 0000000..189465d
--- /dev/null
+++ b/integration-tests-aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTestEnvCustomizer.java
@@ -0,0 +1,62 @@
+/*
+ * 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.quarkus.component.aws2.kinesis.it;
+
+import java.util.Locale;
+
+import org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvContext;
+import org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.testcontainers.containers.localstack.LocalStackContainer.Service;
+import software.amazon.awssdk.services.kinesis.KinesisClient;
+import software.amazon.awssdk.services.kinesis.model.CreateStreamRequest;
+import software.amazon.awssdk.services.kinesis.model.DeleteStreamRequest;
+import software.amazon.awssdk.services.kinesis.model.DescribeStreamRequest;
+import software.amazon.awssdk.services.kinesis.waiters.KinesisWaiter;
+
+public class Aws2KinesisTestEnvCustomizer implements Aws2TestEnvCustomizer {
+
+    @Override
+    public Service[] localstackServices() {
+        return new Service[] { Service.KINESIS };
+    }
+
+    @Override
+    public void customize(Aws2TestEnvContext envContext) {
+
+        final String streamName = "camel-quarkus-" + RandomStringUtils.randomAlphanumeric(16).toLowerCase(Locale.ROOT);
+        envContext.property("aws-kinesis.stream-name", streamName);
+
+        final KinesisClient client = envContext.client(Service.KINESIS, KinesisClient::builder);
+        {
+            client.createStream(
+                    CreateStreamRequest.builder()
+                            .shardCount(1)
+                            .streamName(streamName)
+                            .build());
+
+            try (KinesisWaiter waiter = client.waiter()) {
+                waiter.waitUntilStreamExists(DescribeStreamRequest.builder()
+                        .streamName(streamName)
+                        .build());
+            }
+
+            envContext.closeable(() -> client.deleteStream(DeleteStreamRequest.builder().streamName(streamName).build()));
+        }
+
+    }
+}
diff --git a/integration-tests-aws2/aws2-kinesis/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer b/integration-tests-aws2/aws2-kinesis/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer
new file mode 100644
index 0000000..d6d9b22
--- /dev/null
+++ b/integration-tests-aws2/aws2-kinesis/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer
@@ -0,0 +1 @@
+org.apache.camel.quarkus.component.aws2.kinesis.it.Aws2KinesisTestEnvCustomizer
\ No newline at end of file
diff --git a/integration-tests-aws2/pom.xml b/integration-tests-aws2/pom.xml
index c919263..cccb2da 100644
--- a/integration-tests-aws2/pom.xml
+++ b/integration-tests-aws2/pom.xml
@@ -39,6 +39,7 @@
     <modules>
         <!-- extensions a..z; do not remove this comment, it is important when sorting via  mvn process-resources -Pformat -->
         <module>aws2-ddb</module>
+        <module>aws2-kinesis</module>
         <module>aws2-s3</module>
         <module>aws2-sqs-sns</module>
     </modules>
diff --git a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
index f7ae407..4e4e48a 100644
--- a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
+++ b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
@@ -51,6 +51,7 @@ public final class Aws2TestResource implements ContainerResourceLifecycleManager
             LOG.info("Loaded Aws2TestEnvCustomizer " + customizer.getClass().getName());
             customizers.add(customizer);
         }
+        LOG.info("Loaded " + customizers.size() + " Aws2TestEnvCustomizers");
         if (usingMockBackend) {
             MockBackendUtils.logMockBackendUsed();
 
diff --git a/integration-tests/aws2-grouped/pom.xml b/integration-tests/aws2-grouped/pom.xml
index 0c96dd1..c88fe59 100644
--- a/integration-tests/aws2-grouped/pom.xml
+++ b/integration-tests/aws2-grouped/pom.xml
@@ -57,6 +57,10 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-aws2-kinesis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-aws2-s3</artifactId>
         </dependency>
         <dependency>
@@ -108,6 +112,19 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-aws2-kinesis-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-aws2-s3-deployment</artifactId>
             <version>${project.version}</version>
             <type>pom</type>


[camel-quarkus] 01/02: Test AWS 2 DynamoDB Streams

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 77072a23a8a82231095493d1995d24c39ecc17f4
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Fri Feb 12 11:30:50 2021 +0100

    Test AWS 2 DynamoDB Streams
---
 .../aws2/ddb/it/Aws2DdbStreamResource.java         | 75 ++++++++++++++++++++++
 .../src/main/resources/application.properties      |  4 ++
 .../quarkus/component/aws2/ddb/it/Aws2DdbTest.java | 18 ++++++
 .../aws2/ddb/it/Aws2DdbTestEnvCustomizer.java      | 11 +++-
 .../test/support/aws2/Aws2TestEnvContext.java      |  3 +
 5 files changed, 108 insertions(+), 3 deletions(-)

diff --git a/integration-tests-aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbStreamResource.java b/integration-tests-aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbStreamResource.java
new file mode 100644
index 0000000..654f121
--- /dev/null
+++ b/integration-tests-aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbStreamResource.java
@@ -0,0 +1,75 @@
+/*
+ * 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.quarkus.component.aws2.ddb.it;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import io.quarkus.runtime.StartupEvent;
+import org.apache.camel.ConsumerTemplate;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import software.amazon.awssdk.services.dynamodb.model.Record;
+import software.amazon.awssdk.services.dynamodb.model.StreamRecord;
+
+@Path("/aws2-ddbstream")
+@ApplicationScoped
+public class Aws2DdbStreamResource {
+
+    @ConfigProperty(name = "aws-ddb.table-name")
+    String tableName;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    void startup(@Observes StartupEvent event) {
+        /* Hit the consumer URI at application startup so that the consumer starts polling eagerly */
+        consumerTemplate.receiveBody(componentUri(), 1000);
+    }
+
+    @Path("/change")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Map<String, String> change() {
+        Map<String, String> result = new LinkedHashMap<>();
+        Record record = consumerTemplate.receiveBody(componentUri(), 10000, Record.class);
+        if (record == null) {
+            return null;
+        }
+        StreamRecord item = record.dynamodb();
+        result.put("key", item.keys().get("key").s());
+        if (item.hasOldImage()) {
+            result.put("old", item.oldImage().get("value").s());
+        }
+        if (item.hasNewImage()) {
+            result.put("new", item.newImage().get("value").s());
+        }
+        return result;
+    }
+
+    private String componentUri() {
+        return "aws2-ddbstream://" + tableName;
+    }
+
+}
diff --git a/integration-tests-aws2/aws2-ddb/src/main/resources/application.properties b/integration-tests-aws2/aws2-ddb/src/main/resources/application.properties
index 2cfb3d1..ea1c7a8 100644
--- a/integration-tests-aws2/aws2-ddb/src/main/resources/application.properties
+++ b/integration-tests-aws2/aws2-ddb/src/main/resources/application.properties
@@ -18,3 +18,7 @@
 camel.component.aws2-ddb.access-key=${AWS_ACCESS_KEY}
 camel.component.aws2-ddb.secret-key=${AWS_SECRET_KEY}
 camel.component.aws2-ddb.region=${AWS_REGION:us-east-1}
+
+camel.component.aws2-ddbstream.access-key=${AWS_ACCESS_KEY}
+camel.component.aws2-ddbstream.secret-key=${AWS_SECRET_KEY}
+camel.component.aws2-ddbstream.region=${AWS_REGION:us-east-1}
diff --git a/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java b/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
index 655b249..86108a0 100644
--- a/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
+++ b/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
@@ -104,6 +104,24 @@ class Aws2DdbTest {
                 },
                 Matchers.is(204));
 
+        /* The above actions should trigger the following three change events */
+        RestAssured.get("/aws2-ddbstream/change")
+                .then()
+                .statusCode(200)
+                .body("key", Matchers.is(key))
+                .body("new", Matchers.is(msg));
+        RestAssured.get("/aws2-ddbstream/change")
+                .then()
+                .statusCode(200)
+                .body("key", Matchers.is(key))
+                .body("old", Matchers.is(msg))
+                .body("new", Matchers.is(newMsg));
+        RestAssured.get("/aws2-ddbstream/change")
+                .then()
+                .statusCode(200)
+                .body("key", Matchers.is(key))
+                .body("old", Matchers.is(newMsg));
+
     }
 
 }
diff --git a/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTestEnvCustomizer.java b/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTestEnvCustomizer.java
index 1cc52e9..a2102c1 100644
--- a/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTestEnvCustomizer.java
+++ b/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTestEnvCustomizer.java
@@ -25,20 +25,21 @@ import org.testcontainers.containers.localstack.LocalStackContainer.Service;
 import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
 import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
 import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest;
-import software.amazon.awssdk.services.dynamodb.model.CreateTableResponse;
 import software.amazon.awssdk.services.dynamodb.model.DeleteTableRequest;
 import software.amazon.awssdk.services.dynamodb.model.DescribeTableRequest;
 import software.amazon.awssdk.services.dynamodb.model.KeySchemaElement;
 import software.amazon.awssdk.services.dynamodb.model.KeyType;
 import software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput;
 import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType;
+import software.amazon.awssdk.services.dynamodb.model.StreamSpecification;
+import software.amazon.awssdk.services.dynamodb.model.StreamViewType;
 import software.amazon.awssdk.services.dynamodb.waiters.DynamoDbWaiter;
 
 public class Aws2DdbTestEnvCustomizer implements Aws2TestEnvCustomizer {
 
     @Override
     public Service[] localstackServices() {
-        return new Service[] { Service.DYNAMODB };
+        return new Service[] { Service.DYNAMODB, Service.DYNAMODB_STREAMS };
     }
 
     @Override
@@ -50,7 +51,7 @@ public class Aws2DdbTestEnvCustomizer implements Aws2TestEnvCustomizer {
         final DynamoDbClient client = envContext.client(Service.DYNAMODB, DynamoDbClient::builder);
         {
             final String keyColumn = "key";
-            CreateTableResponse tbl = client.createTable(
+            client.createTable(
                     CreateTableRequest.builder()
                             .attributeDefinitions(AttributeDefinition.builder()
                                     .attributeName(keyColumn)
@@ -64,6 +65,10 @@ public class Aws2DdbTestEnvCustomizer implements Aws2TestEnvCustomizer {
                                     .readCapacityUnits(new Long(10))
                                     .writeCapacityUnits(new Long(10))
                                     .build())
+                            .streamSpecification(StreamSpecification.builder()
+                                    .streamEnabled(true)
+                                    .streamViewType(StreamViewType.NEW_AND_OLD_IMAGES)
+                                    .build())
                             .tableName(tableName)
                             .build());
 
diff --git a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java
index 4f7454d..7246bbb 100644
--- a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java
+++ b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java
@@ -64,6 +64,7 @@ public class Aws2TestEnvContext {
                 case SQS:
                 case SNS:
                 case DYNAMODB:
+                case DYNAMODB_STREAMS:
                     // TODO https://github.com/apache/camel-quarkus/issues/2216
                     break;
                 default:
@@ -149,6 +150,8 @@ public class Aws2TestEnvContext {
         switch (service) {
         case DYNAMODB:
             return "ddb";
+        case DYNAMODB_STREAMS:
+            return "ddbstream";
         default:
             return service.name().toLowerCase(Locale.ROOT);
         }