This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new ca8ad1c Refactor aws2-quarkus-client-ddb(s3) by copying files (not
duplicating) #3236
ca8ad1c is described below
commit ca8ad1c1b41a70b77abd1a0451dd6b30c56253bf
Author: JiriOndrusek <[email protected]>
AuthorDate: Mon Jan 17 12:59:32 2022 +0100
Refactor aws2-quarkus-client-ddb(s3) by copying files (not duplicating)
#3236
---
.../aws2-quarkus-client/aws2-ddb/pom.xml | 56 ++++
.../aws2/ddb/it/Aws2DdbQuarkusClientResource.java | 61 ++++
.../component/aws2/ddb/it/Aws2DdbResource.java | 321 ---------------------
.../aws2/ddb/it/Aws2DdbQuarkusClientTest.java | 266 +----------------
... => Aws2DdbQuarkusClientTestEnvCustomizer.java} | 2 +-
...quarkus.test.support.aws2.Aws2TestEnvCustomizer | 2 +-
.../aws2-quarkus-client-grouped/pom.xml | 15 +
7 files changed, 135 insertions(+), 588 deletions(-)
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
index a301bc2..78e5846 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
@@ -71,6 +71,62 @@
</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/copy-tests.groovy</source>
+ <properties>
+
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-ddb</copy-tests.source.dir>
+
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
+
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties,
**/*Stream*</copy-tests.excludes>
+ </properties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
<profiles>
<profile>
<id>native</id>
diff --git
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientResource.java
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientResource.java
new file mode 100644
index 0000000..43ca5aa
--- /dev/null
+++
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientResource.java
@@ -0,0 +1,61 @@
+/*
+ * 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 javax.enterprise.context.ApplicationScoped;
+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 org.apache.camel.CamelContext;
+import org.apache.camel.component.aws2.ddb.Ddb2Endpoint;
+import org.apache.camel.component.aws2.ddb.Ddb2Operations;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
+
+@Path("/aws2-ddb-quarkus-client")
+@ApplicationScoped
+public class Aws2DdbQuarkusClientResource {
+
+ @Inject
+ CamelContext context;
+
+ @Inject
+ DynamoDbClient dynamoDB;
+
+ @ConfigProperty(name = "aws-ddb.table-name")
+ String tableName;
+
+ @Path("/verify/client")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public boolean quarkusManagesDynamoDbClient() {
+ Ddb2Endpoint endpoint =
context.getEndpoint(componentUri(Ddb2Operations.GetItem), Ddb2Endpoint.class);
+ DynamoDbClient camelDynamoDbClient =
endpoint.getConfiguration().getAmazonDDBClient();
+ return camelDynamoDbClient != null &&
camelDynamoDbClient.equals(dynamoDB);
+ }
+
+ private String componentUri(Ddb2Operations op) {
+ return componentUri(Aws2DdbResource.Table.basic, op);
+ }
+
+ private String componentUri(Aws2DdbResource.Table table, Ddb2Operations
op) {
+ return "aws2-ddb://" + this.tableName + "?operation=" + op;
+ }
+}
diff --git
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java
deleted file mode 100644
index 58d1d0c..0000000
---
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * 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.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-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.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Message;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.aws2.ddb.Ddb2Constants;
-import org.apache.camel.component.aws2.ddb.Ddb2Endpoint;
-import org.apache.camel.component.aws2.ddb.Ddb2Operations;
-import org.apache.camel.util.CollectionHelper;
-import org.eclipse.microprofile.config.inject.ConfigProperty;
-import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
-import software.amazon.awssdk.services.dynamodb.model.AttributeAction;
-import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
-import software.amazon.awssdk.services.dynamodb.model.AttributeValueUpdate;
-import software.amazon.awssdk.services.dynamodb.model.ComparisonOperator;
-import software.amazon.awssdk.services.dynamodb.model.Condition;
-import software.amazon.awssdk.services.dynamodb.model.KeysAndAttributes;
-import
software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughputDescription;
-
-@Path("/aws2-ddb")
-@ApplicationScoped
-public class Aws2DdbResource {
-
- public enum Table {
- basic, operations, stream
- }
-
- @ConfigProperty(name = "aws-ddb.table-name")
- String tableName;
-
- @ConfigProperty(name = "aws-ddb.operations-table-name")
- String operationsTableName;
-
- @ConfigProperty(name = "aws-ddb.stream-table-name")
- String streamTableName;
-
- @Inject
- ProducerTemplate producerTemplate;
-
- @Inject
- CamelContext context;
-
- @Inject
- DynamoDbClient dynamoDB;
-
- @SuppressWarnings("serial")
- @Path("/item/{key}")
- @POST
- @Consumes(MediaType.TEXT_PLAIN)
- @Produces(MediaType.TEXT_PLAIN)
- public Response post(String message,
- @PathParam("key") String key,
- @QueryParam("table") String table) throws Exception {
- final Map<String, AttributeValue> item = new HashMap<>() {
- {
- put("key", AttributeValue.builder()
- .s(key).build());
- put("value", AttributeValue.builder()
- .s(message).build());
- }
- };
- producerTemplate.sendBodyAndHeaders(
- componentUri(Table.valueOf(table), Ddb2Operations.PutItem),
- message,
- new HashMap<>() {
- {
- 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) {
- 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<>(Arrays.asList("key",
"value")));
- e.getMessage().setHeader(Ddb2Constants.KEY,
- Collections.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();
- }
-
- @Path("/item/{key}")
- @PUT
- @Produces(MediaType.TEXT_PLAIN)
- public void updateItem(String message, @PathParam("key") String key,
@QueryParam("table") String table) {
- producerTemplate.sendBodyAndHeaders(
- componentUri(Table.valueOf(table), Ddb2Operations.UpdateItem),
- null,
- new HashMap<>() {
- {
- 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()));
- }
- });
- }
-
- @Path("/item/{key}")
- @DELETE
- @Produces(MediaType.TEXT_PLAIN)
- public void deleteItem(@PathParam("key") String key, @QueryParam("table")
String table) {
- producerTemplate.sendBodyAndHeaders(
- componentUri(Table.valueOf(table), Ddb2Operations.DeleteItem),
- null,
- new HashMap<>() {
- {
- put(Ddb2Constants.CONSISTENT_READ, true);
- put(Ddb2Constants.KEY,
- Collections.singletonMap("key",
-
AttributeValue.builder().s(key).build()));
- }
- });
- }
-
- @SuppressWarnings("unchecked")
- @Path("/batchItems")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Map<String, String> batchItems(List<String> keyValues) {
- Map<String, AttributeValue>[] keyAttrs = keyValues.stream()
- .map(v -> Collections.singletonMap("key",
AttributeValue.builder().s(v).build())).toArray(Map[]::new);
- Map<String, KeysAndAttributes> keysAttrs =
Collections.singletonMap(operationsTableName,
- KeysAndAttributes.builder().keys(keyAttrs).build());
-
- Map<String, List<Map<AttributeValue, AttributeValue>>> result =
(Map<String, List<Map<AttributeValue, AttributeValue>>>) producerTemplate
- .send(componentUri(Table.operations,
Ddb2Operations.BatchGetItems),
- e -> e.getIn().setHeader(Ddb2Constants.BATCH_ITEMS,
keysAttrs))
- .getMessage().getHeader(Ddb2Constants.BATCH_RESPONSE);
-
- Map<String, String> collected = new HashMap<>();
- for (Map<AttributeValue, AttributeValue> m :
result.get(operationsTableName)) {
- collected.put(m.get("key").s(), m.get("value").s());
- }
- return collected;
- }
-
- @SuppressWarnings("unchecked")
- @Path("/query")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Map<String, String> query(String keyEq) {
- Map<String, Condition> keyConditions = new HashMap<>();
- Condition.Builder condition =
Condition.builder().comparisonOperator(ComparisonOperator.EQ.toString())
- .attributeValueList(AttributeValue.builder().s(keyEq).build());
-
- keyConditions.put("key", condition.build());
-
- List<Map<AttributeValue, AttributeValue>> result =
(List<Map<AttributeValue, AttributeValue>>) producerTemplate
- .send(componentUri(Table.operations, Ddb2Operations.Query),
- e -> {
- e.getIn().setHeader(Ddb2Constants.ATTRIBUTE_NAMES,
- Stream.of("key",
"value").collect(Collectors.toList()));
- e.getIn().setHeader(Ddb2Constants.CONSISTENT_READ,
true);
- e.getIn().setHeader(Ddb2Constants.LIMIT, 10);
-
e.getIn().setHeader(Ddb2Constants.SCAN_INDEX_FORWARD, true);
- e.getIn().setHeader(Ddb2Constants.KEY_CONDITIONS,
keyConditions);
- })
- .getMessage().getHeader(Ddb2Constants.ITEMS);
-
- Map<String, String> collected = new HashMap<>();
- for (Map<AttributeValue, AttributeValue> m : result) {
- collected.put(m.get("key").s(), m.get("value").s());
- }
- return collected;
- }
-
- @SuppressWarnings("unchecked")
- @Path("/scan")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Map<String, String> scan() {
-
- List<Map<AttributeValue, AttributeValue>> result =
(List<Map<AttributeValue, AttributeValue>>) producerTemplate
- .send(componentUri(Table.operations, Ddb2Operations.Scan),
- e -> {
- e.getIn().setHeader(Ddb2Constants.ATTRIBUTE_NAMES,
- Stream.of("key",
"value").collect(Collectors.toList()));
- e.getIn().setHeader(Ddb2Constants.CONSISTENT_READ,
true);
- })
- .getMessage().getHeader(Ddb2Constants.ITEMS);
-
- Map<String, String> collected = new HashMap<>();
- for (Map<AttributeValue, AttributeValue> m : result) {
- collected.put(m.get("key").s(), m.get("value").s());
- }
- return collected;
- }
-
- @Path("/updateTable")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateTable(int capacity) throws Exception {
- producerTemplate
- .send(componentUri(Table.operations,
Ddb2Operations.UpdateTable),
- e -> {
- e.getIn().setHeader(Ddb2Constants.READ_CAPACITY,
capacity);
- e.getIn().setHeader(Ddb2Constants.WRITE_CAPACITY,
capacity);
- });
- return Response.created(new URI("https://camel.apache.org/")).build();
- }
-
- @Path("/operation")
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- public Map<String, Object> operation(String operation) {
- final Message message = producerTemplate
- .send(componentUri(Table.operations,
Ddb2Operations.valueOf(operation)), e -> {
- })
- .getMessage();
- return
message.getHeaders().entrySet().stream().collect(Collectors.toMap(
- Map.Entry::getKey,
- e -> {
- if (e.getValue() instanceof List) {
- return ((List) e.getValue()).size();
- }
- if (e.getValue() instanceof
ProvisionedThroughputDescription) {
- ProvisionedThroughputDescription ptd =
(ProvisionedThroughputDescription) e.getValue();
- return
CollectionHelper.mapOf(Ddb2Constants.READ_CAPACITY, ptd.readCapacityUnits(),
- Ddb2Constants.WRITE_CAPACITY,
ptd.writeCapacityUnits());
- }
- if (Ddb2Constants.TABLE_NAME.equals(e.getKey()) &&
operationsTableName.equals(e.getValue())) {
- return Table.operations.toString();
- }
- return e.getValue() == null ? "" : e.getValue().toString();
- }));
- }
-
- @Path("/verify/client")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public boolean quarkusManagesDynamoDbClient() {
- Ddb2Endpoint endpoint =
context.getEndpoint(componentUri(Ddb2Operations.GetItem), Ddb2Endpoint.class);
- DynamoDbClient camelDynamoDbClient =
endpoint.getConfiguration().getAmazonDDBClient();
- return camelDynamoDbClient != null &&
camelDynamoDbClient.equals(dynamoDB);
- }
-
- private String componentUri(Ddb2Operations op) {
- return componentUri(Table.basic, op);
- }
-
- private String componentUri(Table table, Ddb2Operations op) {
- String tableName;
-
- switch (table) {
- case operations:
- tableName = this.operationsTableName;
- break;
- case stream:
- tableName = this.streamTableName;
- break;
- default:
- tableName = this.tableName;
- }
- return "aws2-ddb://" + tableName + "?operation=" + op;
- }
-}
diff --git
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientTest.java
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientTest.java
index a4cfee5..4f15d50 100644
---
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientTest.java
+++
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientTest.java
@@ -16,26 +16,11 @@
*/
package org.apache.camel.quarkus.component.aws2.ddb.it;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
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.component.aws2.ddb.Ddb2Constants;
-import org.apache.camel.component.aws2.ddb.Ddb2Operations;
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 software.amazon.awssdk.services.dynamodb.model.TableStatus;
import static org.hamcrest.CoreMatchers.is;
@@ -43,258 +28,9 @@ import static org.hamcrest.CoreMatchers.is;
@QuarkusTestResource(Aws2TestResource.class)
class Aws2DdbQuarkusClientTest {
- private static final Logger LOG =
Logger.getLogger(Aws2DdbQuarkusClientTest.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)
- .queryParam("table", Aws2DdbResource.Table.basic)
- .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()
- .queryParam("table", Aws2DdbResource.Table.basic)
- .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()
- .queryParam("table", Aws2DdbResource.Table.basic)
- .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));
-
- }
-
- @Test
- public void operations() {
-
- final String key1 = "key-1-" +
UUID.randomUUID().toString().replace("-", "");
- final String msg1 = "val-1-" +
UUID.randomUUID().toString().replace("-", "");
- final String key2 = "key-2-" +
UUID.randomUUID().toString().replace("-", "");
- final String msg2 = "val-2-" +
UUID.randomUUID().toString().replace("-", "");
- final String key3 = "key-3-" +
UUID.randomUUID().toString().replace("-", "");
- final String msg3 = "val-3-" +
UUID.randomUUID().toString().replace("-", "");
-
- RestAssured.given()
- .contentType(ContentType.TEXT)
- .queryParam("table", Aws2DdbResource.Table.operations)
- .body(msg1)
- .post("/aws2-ddb/item/" + key1)
- .then()
- .statusCode(201);
-
- RestAssured.given()
- .contentType(ContentType.TEXT)
- .body(msg2)
- .queryParam("table", Aws2DdbResource.Table.operations)
- .post("/aws2-ddb/item/" + key2)
- .then()
- .statusCode(201);
-
- RestAssured.given()
- .contentType(ContentType.TEXT)
- .body(msg3)
- .queryParam("table", Aws2DdbResource.Table.operations)
- .post("/aws2-ddb/item/" + key3)
- .then()
- .statusCode(201);
-
- /* Batch items */
- Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120,
TimeUnit.SECONDS).until(
- () -> {
-
- ExtractableResponse<Response> result = RestAssured.given()
- .contentType(ContentType.JSON)
- .body(Stream.of(key1,
key2).collect(Collectors.toList()))
- .post("/aws2-ddb/batchItems")
- .then()
- .statusCode(200)
- .extract();
-
- LOG.info("Expecting 2 items, got " + result.statusCode() +
": " + result.body().asString());
-
- return result.jsonPath().getMap("$");
- },
- /* Both inserted pairs have to be returned */
- map -> map.size() == 2
- && msg1.equals(map.get(key1))
- && msg2.equals(map.get(key2)));
-
- /* Query */
- Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120,
TimeUnit.SECONDS).until(
- () -> {
- ExtractableResponse<Response> result = RestAssured.given()
- .contentType(ContentType.JSON)
- .body(key3)
- .post("/aws2-ddb/query")
- .then()
- .statusCode(200)
- .extract();
-
- LOG.info("Expecting 1 item, got " + result.statusCode() +
": " + result.body().asString());
-
- return result.jsonPath().getMap("$");
- },
- map -> map.size() == 1
- && msg3.equals(map.get(key3)));
-
- /* Scan */
- Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120,
TimeUnit.SECONDS).until(
- () -> {
- ExtractableResponse<Response> result =
RestAssured.get("/aws2-ddb/scan")
- .then()
- .statusCode(200)
- .extract();
-
- LOG.info("Expecting 3 items, got " + result.statusCode() +
": " + result.body().asString());
-
- return result.jsonPath().getMap("$");
- },
- map -> map.size() == 3
- && msg1.equals(map.get(key1))
- && msg2.equals(map.get(key2))
- && msg3.equals(map.get(key3)));
-
- /* Describe table */
- Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120,
TimeUnit.SECONDS).until(
- () -> {
- ExtractableResponse<Response> result = RestAssured.given()
- .contentType(ContentType.JSON)
- .body(Ddb2Operations.DescribeTable)
- .post("/aws2-ddb/operation")
- .then()
- .statusCode(200)
- .extract();
-
- LOG.info("Expecting table description, got " +
result.statusCode() + ": " + result.body().asString());
-
- return result.jsonPath().getMap("$");
- },
- map -> map.size() == 8
- && map.containsKey(Ddb2Constants.CREATION_DATE)
- && map.containsKey(Ddb2Constants.READ_CAPACITY)
- &&
TableStatus.ACTIVE.name().equals(map.get(Ddb2Constants.TABLE_STATUS))
- && map.containsKey(Ddb2Constants.WRITE_CAPACITY)
- && map.containsKey(Ddb2Constants.TABLE_SIZE)
- && map.containsKey(Ddb2Constants.KEY_SCHEMA)
- && map.containsKey(Ddb2Constants.ITEM_COUNT)
- && Aws2DdbResource.Table.operations ==
Aws2DdbResource.Table
- .valueOf((String)
map.get(Ddb2Constants.TABLE_NAME)));
-
- /* Update table */
- Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120,
TimeUnit.SECONDS).until(
- () -> {
- ExtractableResponse<Response> result = RestAssured.given()
- .contentType(ContentType.JSON)
- .body(5)
- .post("/aws2-ddb/updateTable")
- .then()
- .extract();
-
- LOG.info("Expecting table update, got " +
result.statusCode() + ": " + result.body().asString());
-
- return result.statusCode();
- },
- Matchers.is(201));
-
- /* Delete table (also verify that update from previous step took
effect) */
- Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120,
TimeUnit.SECONDS).until(
- () -> {
- ExtractableResponse<Response> result = RestAssured.given()
- .contentType(ContentType.JSON)
- .body(Ddb2Operations.DeleteTable)
- .post("/aws2-ddb/operation")
- .then()
- .statusCode(200)
- .extract();
-
- LOG.info("Expecting table deletion, got " +
result.statusCode() + ": " + result.body().asString());
-
- return result.jsonPath().getMap("$");
- },
- map -> map.size() == 7
- && map.containsKey(Ddb2Constants.CREATION_DATE)
- && map.containsKey(Ddb2Constants.TABLE_STATUS)
- && map.containsKey(Ddb2Constants.TABLE_SIZE)
- && map.containsKey(Ddb2Constants.KEY_SCHEMA)
- && map.containsKey(Ddb2Constants.ITEM_COUNT)
- && Aws2DdbResource.Table.operations ==
Aws2DdbResource.Table
- .valueOf((String)
map.get(Ddb2Constants.TABLE_NAME))
- //previous update changed throughput capacity from 10
to 5
- && ((Map)
map.get(Ddb2Constants.PROVISIONED_THROUGHPUT)).size() == 2
- && ((Map)
map.get(Ddb2Constants.PROVISIONED_THROUGHPUT)).get(Ddb2Constants.READ_CAPACITY).equals(5)
- && ((Map)
map.get(Ddb2Constants.PROVISIONED_THROUGHPUT)).get(Ddb2Constants.WRITE_CAPACITY).equals(5));
-
- /* Verify delete with describe table */
- Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120,
TimeUnit.SECONDS).until(
- () -> {
- ExtractableResponse<Response> result = RestAssured.given()
- .contentType(ContentType.JSON)
- .body(Ddb2Operations.DescribeTable)
- .post("/aws2-ddb/operation")
- .then()
- .statusCode(200)
- .extract();
-
- LOG.info("Expecting table description of non-existing
table, got " + result.statusCode() + ": "
- + result.body().asString());
-
- return result.jsonPath().getMap("$");
- },
- map -> map.isEmpty());
- }
-
@Test
public void quarkusManagesDynamoDbClient() {
- RestAssured.get("/aws2-ddb/verify/client")
+ RestAssured.get("/aws2-ddb-quarkus-client/verify/client")
.then()
.statusCode(200)
.body(is("true"));
diff --git
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTestEnvCustomizer.java
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientTestEnvCustomizer.java
similarity index 98%
rename from
integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTestEnvCustomizer.java
rename to
integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientTestEnvCustomizer.java
index e7a4780..775b3d8 100644
---
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTestEnvCustomizer.java
+++
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbQuarkusClientTestEnvCustomizer.java
@@ -40,7 +40,7 @@ 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 {
+public class Aws2DdbQuarkusClientTestEnvCustomizer implements
Aws2TestEnvCustomizer {
@Override
public Service[] localstackServices() {
diff --git
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer
index 94d2241..9c0371d 100644
---
a/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer
+++
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer
@@ -1 +1 @@
-org.apache.camel.quarkus.component.aws2.ddb.it.Aws2DdbTestEnvCustomizer
\ No newline at end of file
+org.apache.camel.quarkus.component.aws2.ddb.it.Aws2DdbQuarkusClientTestEnvCustomizer
\ No newline at end of file
diff --git a/integration-tests/aws2-quarkus-client-grouped/pom.xml
b/integration-tests/aws2-quarkus-client-grouped/pom.xml
index 9e79919..e9931c2 100644
--- a/integration-tests/aws2-quarkus-client-grouped/pom.xml
+++ b/integration-tests/aws2-quarkus-client-grouped/pom.xml
@@ -178,6 +178,21 @@
</configuration>
</execution>
<execution>
+ <id>copy-client-test-sources-ddb</id>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+
<source>file:///${maven.multiModuleProjectDirectory}/tooling/scripts/copy-tests.groovy</source>
+ <properties>
+
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-ddb</copy-tests.source.dir>
+
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
+
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties,**/*Stream*</copy-tests.excludes>
+ </properties>
+ </configuration>
+ </execution>
+ <execution>
<id>copy-client-test-sources-s3</id>
<goals>
<goal>execute</goal>