This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 22124f14a59c88cc351dbc278d9cce177e0b41b7 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Thu Feb 11 16:28:41 2021 +0100 Test AWS 2 DynamoDB properly --- .../aws2-ddb}/pom.xml | 123 +++-------------- .../component/aws2/ddb/it/Aws2DdbResource.java | 151 +++++++++++++++++++++ .../src/main/resources/application.properties | 20 +++ .../quarkus/component/aws2/ddb/it/Aws2DdbIT.java | 26 ++++ .../quarkus/component/aws2/ddb/it/Aws2DdbTest.java | 109 +++++++++++++++ .../aws2/ddb/it/Aws2DdbTestEnvCustomizer.java | 80 +++++++++++ ...quarkus.test.support.aws2.Aws2TestEnvCustomizer | 1 + integration-tests-aws2/pom.xml | 1 + .../test/support/aws2/Aws2TestEnvContext.java | 16 ++- integration-tests/aws2-grouped/pom.xml | 17 +++ 10 files changed, 434 insertions(+), 110 deletions(-) diff --git a/integration-tests/aws2-grouped/pom.xml b/integration-tests-aws2/aws2-ddb/pom.xml similarity index 51% copy from integration-tests/aws2-grouped/pom.xml copy to integration-tests-aws2/aws2-ddb/pom.xml index 74fe8a6..f10cfb3 100644 --- a/integration-tests/aws2-grouped/pom.xml +++ b/integration-tests-aws2/aws2-ddb/pom.xml @@ -17,17 +17,20 @@ 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"> +<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</artifactId> + <artifactId>camel-quarkus-integration-tests-aws2</artifactId> <version>1.7.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-integration-test-aws2-grouped</artifactId> - <name>Camel Quarkus :: Integration Tests :: AWS2 Grouped</name> - <description>AWS 2 tests from ../integration-tests-aws2 merged together</description> + <artifactId>camel-quarkus-integration-test-aws2-ddb</artifactId> + <name>Camel Quarkus :: Integration Tests :: AWS 2 DynamoDB</name> + <description>Integration tests for Camel Quarkus AWS 2 DynamoDB extension</description> <dependencyManagement> <dependencies> @@ -41,32 +44,25 @@ </dependencies> </dependencyManagement> - <!-- Regenerate the dependencies via `mvn process-resources -Pformat -N` from the source tree root directory --> <dependencies> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jackson</artifactId> - </dependency> - <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-aws2-s3</artifactId> + <artifactId>camel-quarkus-main</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-aws2-sns</artifactId> + <artifactId>camel-quarkus-aws2-ddb</artifactId> </dependency> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-aws2-sqs</artifactId> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> </dependency> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-main</artifactId> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson</artifactId> </dependency> + + <!-- test dependencies --> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-junit5</artifactId> @@ -91,33 +87,7 @@ <!-- 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-s3-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-sns-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-sqs-deployment</artifactId> + <artifactId>camel-quarkus-aws2-ddb-deployment</artifactId> <version>${project.version}</version> <type>pom</type> <scope>test</scope> @@ -141,65 +111,8 @@ </exclusion> </exclusions> </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>add-sources</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${basedir}/target/src/main/java</source> - </sources> - </configuration> - </execution> - <execution> - <id>add-test-sources</id> - <phase>generate-sources</phase> - <goals> - <goal>add-test-source</goal> - </goals> - <configuration> - <sources> - <source>${basedir}/target/src/test/java</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.gmaven</groupId> - <artifactId>groovy-maven-plugin</artifactId> - <executions> - <execution> - <id>group-sources</id> - <goals> - <goal>execute</goal> - </goals> - <phase>generate-sources</phase> - <configuration> - <source>file:///${maven.multiModuleProjectDirectory}/tooling/scripts/group-tests.groovy</source> - <properties> - <group-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-tests-aws2</group-tests.source.dir> - <group-tests.dest.module.dir>${project.basedir}</group-tests.dest.module.dir> - <group-tests.concat.rel.paths>src/main/resources/application.properties,src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer</group-tests.concat.rel.paths> - </properties> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - <profiles> <profile> <id>native</id> diff --git a/integration-tests-aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java b/integration-tests-aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java new file mode 100644 index 0000000..f1aaddf --- /dev/null +++ b/integration-tests-aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java @@ -0,0 +1,151 @@ +/* + * 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.net.URI; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.aws2.ddb.Ddb2Constants; +import org.apache.camel.component.aws2.ddb.Ddb2Operations; +import org.eclipse.microprofile.config.inject.ConfigProperty; +import software.amazon.awssdk.services.dynamodb.model.AttributeAction; +import software.amazon.awssdk.services.dynamodb.model.AttributeValue; +import software.amazon.awssdk.services.dynamodb.model.AttributeValueUpdate; + +@Path("/aws2-ddb") +@ApplicationScoped +public class Aws2DdbResource { + + @ConfigProperty(name = "aws-ddb.table-name") + String tableName; + + @Inject + ProducerTemplate producerTemplate; + + @SuppressWarnings("serial") + @Path("/item/{key}") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public Response post(String message, @PathParam("key") String key) throws Exception { + final Map<String, AttributeValue> item = new HashMap<String, AttributeValue>() { + { + put("key", AttributeValue.builder() + .s(key).build()); + put("value", AttributeValue.builder() + .s(message).build()); + } + }; + producerTemplate.sendBodyAndHeaders(componentUri(Ddb2Operations.PutItem), + message, + new HashMap<String, Object>() { + { + put(Ddb2Constants.CONSISTENT_READ, true); + put(Ddb2Constants.ITEM, item); + } + }); + return Response.created(new URI("https://camel.apache.org/")).build(); + } + + @SuppressWarnings("unchecked") + @Path("/item/{key}") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String getItem(@PathParam("key") String key) throws Exception { + final Map<String, AttributeValue> item = (Map<String, AttributeValue>) producerTemplate + .send(componentUri(Ddb2Operations.GetItem), + e -> { + e.getMessage().setHeader(Ddb2Constants.CONSISTENT_READ, true); + e.getMessage().setHeader(Ddb2Constants.ATTRIBUTE_NAMES, + new HashSet<String>(Arrays.asList("key", "value"))); + e.getMessage().setHeader(Ddb2Constants.KEY, + Collections.<String, AttributeValue> singletonMap("key", + AttributeValue.builder().s(key).build())); + + }) + .getMessage() + .getHeader(Ddb2Constants.ATTRIBUTES, Map.class); + final AttributeValue val = item.get("value"); + return val == null ? null : val.s(); + } + + @SuppressWarnings("serial") + @Path("/item/{key}") + @PUT + @Produces(MediaType.TEXT_PLAIN) + public void updateItem(String message, @PathParam("key") String key) throws Exception { + producerTemplate.sendBodyAndHeaders( + componentUri(Ddb2Operations.UpdateItem), + null, + new HashMap<String, Object>() { + { + put( + Ddb2Constants.KEY, + Collections.singletonMap("key", AttributeValue.builder().s(key).build())); + put( + Ddb2Constants.UPDATE_VALUES, + Collections.singletonMap( + "value", + AttributeValueUpdate.builder() + .action(AttributeAction.PUT) + .value(AttributeValue.builder().s(message).build()) + .build())); + } + }); + } + + @SuppressWarnings("serial") + @Path("/item/{key}") + @DELETE + @Produces(MediaType.TEXT_PLAIN) + public void deleteItem(@PathParam("key") String key) throws Exception { + producerTemplate.sendBodyAndHeaders( + componentUri(Ddb2Operations.DeleteItem), + null, + new HashMap<String, Object>() { + { + put(Ddb2Constants.CONSISTENT_READ, true); + put(Ddb2Constants.KEY, + Collections.<String, AttributeValue> singletonMap("key", + AttributeValue.builder().s(key).build())); + } + }); + } + + private String componentUri(Ddb2Operations op) { + return "aws2-ddb://" + tableName + "?operation=" + op; + } + +} diff --git a/integration-tests-aws2/aws2-ddb/src/main/resources/application.properties b/integration-tests-aws2/aws2-ddb/src/main/resources/application.properties new file mode 100644 index 0000000..2cfb3d1 --- /dev/null +++ b/integration-tests-aws2/aws2-ddb/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-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} diff --git a/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbIT.java b/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbIT.java new file mode 100644 index 0000000..31cdf1f --- /dev/null +++ b/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbIT.java @@ -0,0 +1,26 @@ +/* + * 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 io.quarkus.test.junit.NativeImageTest; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; + +@NativeImageTest +@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+") // TODO https://github.com/apache/camel-quarkus/issues/2216 +class Aws2DdbIT extends Aws2DdbTest { + +} 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 new file mode 100644 index 0000000..655b249 --- /dev/null +++ b/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java @@ -0,0 +1,109 @@ +/* + * 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.UUID; +import java.util.concurrent.TimeUnit; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import io.restassured.response.ExtractableResponse; +import io.restassured.response.Response; +import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource; +import org.awaitility.Awaitility; +import org.hamcrest.Matchers; +import org.jboss.logging.Logger; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; + +@QuarkusTest +@QuarkusTestResource(Aws2TestResource.class) +@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+") // TODO + // https://github.com/apache/camel-quarkus/issues/2216 +class Aws2DdbTest { + + private static final Logger LOG = Logger.getLogger(Aws2DdbTest.class); + + @Test + public void crud() { + + final String key = "key" + UUID.randomUUID().toString().replace("-", ""); + final String msg = "val" + UUID.randomUUID().toString().replace("-", ""); + + /* Ensure initially empty */ + RestAssured.get("/aws2-ddb/item/" + key) + .then() + .statusCode(204); + + /* Put */ + RestAssured.given() + .contentType(ContentType.TEXT) + .body(msg) + .post("/aws2-ddb/item/" + key) + .then() + .statusCode(201); + + Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120, TimeUnit.SECONDS).until( + () -> { + ExtractableResponse<Response> result = RestAssured.get("/aws2-ddb/item/" + key) + .then() + .statusCode(Matchers.anyOf(Matchers.is(200), Matchers.is(204))) + .extract(); + LOG.info("Expecting " + msg + " got " + result.statusCode() + ": " + result.body().asString()); + return result.body().asString(); + }, + Matchers.is(msg)); + + /* Update */ + final String newMsg = "newVal" + UUID.randomUUID().toString().replace("-", ""); + RestAssured.given() + .body(newMsg) + .put("/aws2-ddb/item/" + key) + .then() + .statusCode(204); + Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120, TimeUnit.SECONDS).until( + () -> { + ExtractableResponse<Response> result = RestAssured.get("/aws2-ddb/item/" + key) + .then() + .statusCode(Matchers.anyOf(Matchers.is(200), Matchers.is(204))) + .extract(); + LOG.info("Expecting " + newMsg + " got " + result.statusCode() + ": " + result.body().asString()); + return result.body().asString(); + }, + Matchers.is(newMsg)); + + /* Delete */ + RestAssured.given() + .delete("/aws2-ddb/item/" + key) + .then() + .statusCode(204); + + Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120, TimeUnit.SECONDS).until( + () -> { + ExtractableResponse<Response> result = RestAssured.get("/aws2-ddb/item/" + key) + .then() + .extract(); + LOG.info("Expecting " + msg + " got " + result.statusCode() + ": " + result.body().asString()); + return result.statusCode(); + }, + Matchers.is(204)); + + } + +} 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 new file mode 100644 index 0000000..1cc52e9 --- /dev/null +++ b/integration-tests-aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTestEnvCustomizer.java @@ -0,0 +1,80 @@ +/* + * 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.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.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.waiters.DynamoDbWaiter; + +public class Aws2DdbTestEnvCustomizer implements Aws2TestEnvCustomizer { + + @Override + public Service[] localstackServices() { + return new Service[] { Service.DYNAMODB }; + } + + @Override + public void customize(Aws2TestEnvContext envContext) { + + final String tableName = "camel-quarkus-" + RandomStringUtils.randomAlphanumeric(16).toLowerCase(Locale.ROOT); + envContext.property("aws-ddb.table-name", tableName); + + final DynamoDbClient client = envContext.client(Service.DYNAMODB, DynamoDbClient::builder); + { + final String keyColumn = "key"; + CreateTableResponse tbl = client.createTable( + CreateTableRequest.builder() + .attributeDefinitions(AttributeDefinition.builder() + .attributeName(keyColumn) + .attributeType(ScalarAttributeType.S) + .build()) + .keySchema(KeySchemaElement.builder() + .attributeName(keyColumn) + .keyType(KeyType.HASH) + .build()) + .provisionedThroughput(ProvisionedThroughput.builder() + .readCapacityUnits(new Long(10)) + .writeCapacityUnits(new Long(10)) + .build()) + .tableName(tableName) + .build()); + + try (DynamoDbWaiter dbWaiter = client.waiter()) { + dbWaiter.waitUntilTableExists(DescribeTableRequest.builder() + .tableName(tableName) + .build()); + } + + envContext.closeable(() -> client.deleteTable(DeleteTableRequest.builder().tableName(tableName).build())); + } + + } +} diff --git a/integration-tests-aws2/aws2-ddb/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer b/integration-tests-aws2/aws2-ddb/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer new file mode 100644 index 0000000..94d2241 --- /dev/null +++ b/integration-tests-aws2/aws2-ddb/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer @@ -0,0 +1 @@ +org.apache.camel.quarkus.component.aws2.ddb.it.Aws2DdbTestEnvCustomizer \ No newline at end of file diff --git a/integration-tests-aws2/pom.xml b/integration-tests-aws2/pom.xml index 0448a1c..c919263 100644 --- a/integration-tests-aws2/pom.xml +++ b/integration-tests-aws2/pom.xml @@ -38,6 +38,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-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/Aws2TestEnvContext.java b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java index 52477c9..4f7454d 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 @@ -55,7 +55,7 @@ public class Aws2TestEnvContext { localstack.ifPresent(ls -> { for (Service service : services) { - String s = serviceKey(service); + String s = camelServiceAcronym(service); properties.put("camel.component.aws2-" + s + ".access-key", accessKey); properties.put("camel.component.aws2-" + s + ".secret-key", secretKey); properties.put("camel.component.aws2-" + s + ".region", region); @@ -63,6 +63,7 @@ public class Aws2TestEnvContext { switch (service) { case SQS: case SNS: + case DYNAMODB: // TODO https://github.com/apache/camel-quarkus/issues/2216 break; default: @@ -77,7 +78,7 @@ public class Aws2TestEnvContext { /** * Add a key-value pair to the system properties seen by AWS 2 tests - * + * * @param key * @param value * @return this {@link Aws2TestEnvContext} @@ -89,7 +90,7 @@ public class Aws2TestEnvContext { /** * Add an {@link AutoCloseable} to be closed after running AWS 2 tests - * + * * @param closeable the {@link AutoCloseable} to add * @return this {@link Aws2TestEnvContext} */ @@ -144,7 +145,12 @@ public class Aws2TestEnvContext { return client; } - private static String serviceKey(Service service) { - return service.name().toLowerCase(Locale.ROOT); + private static String camelServiceAcronym(Service service) { + switch (service) { + case DYNAMODB: + return "ddb"; + default: + return service.name().toLowerCase(Locale.ROOT); + } } } diff --git a/integration-tests/aws2-grouped/pom.xml b/integration-tests/aws2-grouped/pom.xml index 74fe8a6..0c96dd1 100644 --- a/integration-tests/aws2-grouped/pom.xml +++ b/integration-tests/aws2-grouped/pom.xml @@ -53,6 +53,10 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-aws2-ddb</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-aws2-s3</artifactId> </dependency> <dependency> @@ -91,6 +95,19 @@ <!-- 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-ddb-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>