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/10/01 11:43:57 UTC
[camel-quarkus] branch main updated: Enable Aws2TestEnvContext to
handle setting up Quarkus AWS configuration properties
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton 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 cb4f00f Enable Aws2TestEnvContext to handle setting up Quarkus AWS configuration properties
cb4f00f is described below
commit cb4f00f44a7bdb613dbd174da32a5cef913a8b0e
Author: James Netherton <ja...@gmail.com>
AuthorDate: Thu Sep 30 10:07:11 2021 +0100
Enable Aws2TestEnvContext to handle setting up Quarkus AWS configuration properties
Fixes #3137
---
.../aws2/ddb/it/Aws2DdbQuarkusClientTest.java | 5 +-
.../aws2/ddb/it/Aws2DdbTestEnvCustomizer.java | 26 +---------
.../component/aws2/s3/it/Aws2S3Resource.java | 24 ++++++++++
.../src/main/resources/application.properties | 6 ---
.../aws2/s3/it/Aws2S3QuarkusClientTest.java | 5 +-
.../aws2/s3/it/Aws2S3TestEnvCustomizer.java | 24 ----------
.../src/main/resources/application.properties | 20 --------
.../src/main/resources/application.properties | 24 ----------
.../src/main/resources/application.properties | 24 ----------
.../src/main/resources/application.properties | 20 --------
.../src/main/resources/application.properties | 22 ---------
.../src/main/resources/application.properties | 22 ---------
.../src/main/resources/application.properties | 24 ----------
.../quarkus/test/support/aws2/Aws2TestConfig.java | 47 ++++++++++++++++++
.../test/support/aws2/Aws2TestEnvContext.java | 56 +++++++++++-----------
.../test/support/aws2/Aws2TestResource.java | 20 ++++++--
16 files changed, 123 insertions(+), 246 deletions(-)
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..989d0e2 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
@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.common.ResourceArg;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
@@ -40,7 +41,9 @@ import software.amazon.awssdk.services.dynamodb.model.TableStatus;
import static org.hamcrest.CoreMatchers.is;
@QuarkusTest
-@QuarkusTestResource(Aws2TestResource.class)
+@QuarkusTestResource(value = Aws2TestResource.class, initArgs = {
+ @ResourceArg(name = "awsQuarkusClientTest", value = "true")
+})
class Aws2DdbQuarkusClientTest {
private static final Logger LOG = Logger.getLogger(Aws2DdbQuarkusClientTest.class);
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/Aws2DdbTestEnvCustomizer.java
index 652ee00..034f70c 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/Aws2DdbTestEnvCustomizer.java
@@ -18,8 +18,6 @@ package org.apache.camel.quarkus.component.aws2.ddb.it;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -44,7 +42,7 @@ public class Aws2DdbTestEnvCustomizer implements Aws2TestEnvCustomizer {
@Override
public Service[] localstackServices() {
- return new Service[] { Service.DYNAMODB, Service.DYNAMODB_STREAMS };
+ return new Service[] { Service.DYNAMODB };
}
@Override
@@ -83,28 +81,6 @@ public class Aws2DdbTestEnvCustomizer implements Aws2TestEnvCustomizer {
envContext.closeable(() -> client.deleteTable(DeleteTableRequest.builder().tableName(table).build()));
}
}
-
- Map<String, String> envContextProperties = envContext.getProperies();
- String accessKey = envContextProperties.get("camel.component.aws2-ddb.access-key");
- String secretKey = envContextProperties.get("camel.component.aws2-ddb.secret-key");
- String region = envContextProperties.get("camel.component.aws2-ddb.region");
-
- envContext.property("quarkus.dynamodb.aws.credentials.static-provider.access-key-id", accessKey);
- envContext.property("quarkus.dynamodb.aws.credentials.static-provider.secret-access-key", secretKey);
- envContext.property("quarkus.dynamodb.aws.region", region);
- envContext.property("quarkus.dynamodb.aws.credentials.type", "static");
-
- // Propagate localstack environment config to Quarkus AWS if required
- Optional<String> overrideEndpoint = envContextProperties
- .keySet()
- .stream()
- .filter(key -> key.endsWith("uri-endpoint-override"))
- .findFirst();
-
- if (overrideEndpoint.isPresent()) {
- String endpoint = envContextProperties.get(overrideEndpoint.get());
- envContext.property("quarkus.dynamodb.endpoint-override", endpoint);
- }
}
private CreateTableRequest.Builder createTableRequest(String tableName, String keyColumn) {
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Resource.java b/integration-test-groups/aws2-quarkus-client/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Resource.java
index 7a831d7..8472c33 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Resource.java
+++ b/integration-test-groups/aws2-quarkus-client/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Resource.java
@@ -32,6 +32,7 @@ import java.util.stream.Collectors;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
+import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
@@ -48,13 +49,20 @@ import org.apache.camel.ConsumerTemplate;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.s3.AWS2S3Constants;
import org.apache.camel.component.aws2.s3.AWS2S3Operations;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
import org.eclipse.microprofile.config.inject.ConfigProperty;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.core.ResponseInputStream;
+import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.S3ClientBuilder;
import software.amazon.awssdk.services.s3.model.Bucket;
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
import software.amazon.awssdk.services.s3.model.S3Object;
+import software.amazon.awssdk.services.s3.presigner.S3Presigner;
@Path("/aws2")
@ApplicationScoped
@@ -72,6 +80,22 @@ public class Aws2S3Resource {
@ConfigProperty(name = "aws-s3.bucket-name")
String bucketName;
+ @javax.enterprise.inject.Produces
+ @Named
+ public S3Presigner s3Presigner(S3ClientBuilder clientBuilder) {
+ // createDownloadLink operations require the presigner
+ // This could be simplified via https://github.com/quarkusio/quarkus/issues/13611
+ Config config = ConfigProvider.getConfig();
+ String accessKey = config.getValue("quarkus.s3.aws.credentials.static-provider.access-key-id", String.class);
+ String secretKey = config.getValue("quarkus.s3.aws.credentials.static-provider.secret-access-key", String.class);
+ String region = config.getValue("quarkus.s3.aws.region", String.class);
+
+ return S3Presigner.builder().credentialsProvider(StaticCredentialsProvider.create(
+ AwsBasicCredentials.create(accessKey, secretKey)))
+ .region(Region.of(region))
+ .build();
+ }
+
@Path("s3/object/{key}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-s3/src/main/resources/application.properties b/integration-test-groups/aws2-quarkus-client/aws2-s3/src/main/resources/application.properties
index be39e69..1ab9e47 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-s3/src/main/resources/application.properties
+++ b/integration-test-groups/aws2-quarkus-client/aws2-s3/src/main/resources/application.properties
@@ -15,12 +15,6 @@
## limitations under the License.
## ---------------------------------------------------------------------------
#
-# Camel :: AWS2 options
-#
-camel.component.aws2-s3.access-key=${AWS_ACCESS_KEY}
-camel.component.aws2-s3.secret-key=${AWS_SECRET_KEY}
-camel.component.aws2-s3.region=${AWS_REGION:us-east-1}
-#
# Quarkus :: S3 Client options
#
quarkus.s3.sync-client.type=apache
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3QuarkusClientTest.java b/integration-test-groups/aws2-quarkus-client/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3QuarkusClientTest.java
index 4223c1b..6f3ede2 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3QuarkusClientTest.java
+++ b/integration-test-groups/aws2-quarkus-client/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3QuarkusClientTest.java
@@ -20,6 +20,7 @@ import java.util.UUID;
import java.util.stream.Stream;
import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.common.ResourceArg;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
@@ -32,7 +33,9 @@ import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
@QuarkusTest
-@QuarkusTestResource(Aws2TestResource.class)
+@QuarkusTestResource(value = Aws2TestResource.class, initArgs = {
+ @ResourceArg(name = "awsQuarkusClientTest", value = "true")
+})
class Aws2S3QuarkusClientTest {
@Test
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3TestEnvCustomizer.java b/integration-test-groups/aws2-quarkus-client/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3TestEnvCustomizer.java
index 81deeb5..a9dd8cf 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3TestEnvCustomizer.java
+++ b/integration-test-groups/aws2-quarkus-client/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3TestEnvCustomizer.java
@@ -17,8 +17,6 @@
package org.apache.camel.quarkus.component.aws2.s3.it;
import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvContext;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer;
@@ -43,27 +41,5 @@ public class Aws2S3TestEnvCustomizer implements Aws2TestEnvCustomizer {
s3Client.createBucket(CreateBucketRequest.builder().bucket(bucketName).build());
envContext.property("aws-s3.bucket-name", bucketName);
envContext.closeable(() -> s3Client.deleteBucket(DeleteBucketRequest.builder().bucket(bucketName).build()));
-
- Map<String, String> envContextProperties = envContext.getProperies();
- String accessKey = envContextProperties.get("camel.component.aws2-s3.access-key");
- String secretKey = envContextProperties.get("camel.component.aws2-s3.secret-key");
- String region = envContextProperties.get("camel.component.aws2-s3.region");
-
- envContext.property("quarkus.s3.aws.credentials.static-provider.access-key-id", accessKey);
- envContext.property("quarkus.s3.aws.credentials.static-provider.secret-access-key", secretKey);
- envContext.property("quarkus.s3.aws.region", region);
- envContext.property("quarkus.s3.aws.credentials.type", "static");
-
- // Propagate localstack environment config to Quarkus AWS if required
- Optional<String> overrideEndpoint = envContextProperties
- .keySet()
- .stream()
- .filter(key -> key.endsWith("uri-endpoint-override"))
- .findFirst();
-
- if (overrideEndpoint.isPresent()) {
- String endpoint = envContextProperties.get(overrideEndpoint.get());
- envContext.property("quarkus.s3.endpoint-override", endpoint);
- }
}
}
diff --git a/integration-test-groups/aws2/aws2-cw/src/main/resources/application.properties b/integration-test-groups/aws2/aws2-cw/src/main/resources/application.properties
deleted file mode 100644
index 8f24b45..0000000
--- a/integration-test-groups/aws2/aws2-cw/src/main/resources/application.properties
+++ /dev/null
@@ -1,20 +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.
-## ---------------------------------------------------------------------------
-
-camel.component.aws2-cw.access-key=${AWS_ACCESS_KEY}
-camel.component.aws2-cw.secret-key=${AWS_SECRET_KEY}
-camel.component.aws2-cw.region=${AWS_REGION:us-east-1}
diff --git a/integration-test-groups/aws2/aws2-ddb/src/main/resources/application.properties b/integration-test-groups/aws2/aws2-ddb/src/main/resources/application.properties
deleted file mode 100644
index ea1c7a8..0000000
--- a/integration-test-groups/aws2/aws2-ddb/src/main/resources/application.properties
+++ /dev/null
@@ -1,24 +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.
-## ---------------------------------------------------------------------------
-
-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-test-groups/aws2/aws2-kinesis/src/main/resources/application.properties b/integration-test-groups/aws2/aws2-kinesis/src/main/resources/application.properties
deleted file mode 100644
index e7a4c2d..0000000
--- a/integration-test-groups/aws2/aws2-kinesis/src/main/resources/application.properties
+++ /dev/null
@@ -1,24 +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.
-## ---------------------------------------------------------------------------
-
-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}
-
-camel.component.aws2-kinesis-firehose.access-key=${AWS_ACCESS_KEY}
-camel.component.aws2-kinesis-firehose.secret-key=${AWS_SECRET_KEY}
-camel.component.aws2-kinesis-firehose.region=${AWS_REGION:us-east-1}
diff --git a/integration-test-groups/aws2/aws2-lambda/src/main/resources/application.properties b/integration-test-groups/aws2/aws2-lambda/src/main/resources/application.properties
deleted file mode 100644
index f8883f8..0000000
--- a/integration-test-groups/aws2/aws2-lambda/src/main/resources/application.properties
+++ /dev/null
@@ -1,20 +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.
-## ---------------------------------------------------------------------------
-
-camel.component.aws2-lambda.access-key=${AWS_ACCESS_KEY}
-camel.component.aws2-lambda.secret-key=${AWS_SECRET_KEY}
-camel.component.aws2-lambda.region=${AWS_REGION:us-east-1}
diff --git a/integration-test-groups/aws2/aws2-s3/src/main/resources/application.properties b/integration-test-groups/aws2/aws2-s3/src/main/resources/application.properties
deleted file mode 100644
index 745bd72..0000000
--- a/integration-test-groups/aws2/aws2-s3/src/main/resources/application.properties
+++ /dev/null
@@ -1,22 +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.
-## ---------------------------------------------------------------------------
-#
-# Camel :: AWS2 options
-#
-camel.component.aws2-s3.access-key=${AWS_ACCESS_KEY}
-camel.component.aws2-s3.secret-key=${AWS_SECRET_KEY}
-camel.component.aws2-s3.region=${AWS_REGION:us-east-1}
diff --git a/integration-test-groups/aws2/aws2-ses/src/main/resources/application.properties b/integration-test-groups/aws2/aws2-ses/src/main/resources/application.properties
deleted file mode 100644
index a55a15a..0000000
--- a/integration-test-groups/aws2/aws2-ses/src/main/resources/application.properties
+++ /dev/null
@@ -1,22 +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.
-## ---------------------------------------------------------------------------
-
-camel.component.aws2-ses.access-key=${AWS_ACCESS_KEY}
-camel.component.aws2-ses.secret-key=${AWS_SECRET_KEY}
-camel.component.aws2-ses.region=${AWS_REGION:us-east-1}
-
-mailslurp.api.key=${MAILSLURP_API_KEY}
diff --git a/integration-test-groups/aws2/aws2-sqs-sns/src/main/resources/application.properties b/integration-test-groups/aws2/aws2-sqs-sns/src/main/resources/application.properties
deleted file mode 100644
index 777210a..0000000
--- a/integration-test-groups/aws2/aws2-sqs-sns/src/main/resources/application.properties
+++ /dev/null
@@ -1,24 +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.
-## ---------------------------------------------------------------------------
-
-camel.component.aws2-sns.access-key=${AWS_ACCESS_KEY}
-camel.component.aws2-sns.secret-key=${AWS_SECRET_KEY}
-camel.component.aws2-sns.region=${AWS_REGION:us-east-1}
-
-camel.component.aws2-sqs.access-key=${AWS_ACCESS_KEY}
-camel.component.aws2-sqs.secret-key=${AWS_SECRET_KEY}
-camel.component.aws2-sqs.region=${AWS_REGION:us-east-1}
diff --git a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestConfig.java b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestConfig.java
new file mode 100644
index 0000000..1a72d2b
--- /dev/null
+++ b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestConfig.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.test.support.aws2;
+
+public class Aws2TestConfig {
+ private final String accessKey;
+ private final String accessSecret;
+ private final String region;
+ private final boolean awsQuarkusClientTest;
+
+ public Aws2TestConfig(String accessKey, String accessSecret, String region, boolean awsQuarkusClientTest) {
+ this.accessKey = accessKey;
+ this.accessSecret = accessSecret;
+ this.region = region;
+ this.awsQuarkusClientTest = awsQuarkusClientTest;
+ }
+
+ public String getAccessKey() {
+ return accessKey;
+ }
+
+ public String getAccessSecret() {
+ return accessSecret;
+ }
+
+ public String getRegion() {
+ return region;
+ }
+
+ public boolean isAwsQuarkusClientTest() {
+ return awsQuarkusClientTest;
+ }
+}
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 883a2a0..3d4f18e 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
@@ -46,32 +46,36 @@ public class Aws2TestEnvContext {
private final ArrayList<AutoCloseable> closeables = new ArrayList<>();
private final Map<Service, ? extends SdkClient> clients = new EnumMap<>(Service.class);
private final Map<String, String> properties = new LinkedHashMap<>();
- private final String accessKey;
- private final String secretKey;
- private final String region;
private final Optional<LocalStackContainer> localstack;
+ private final Aws2TestConfig aws2TestConfig;
- public Aws2TestEnvContext(String accessKey, String secretKey, String region, Optional<LocalStackContainer> localstack,
+ public Aws2TestEnvContext(Aws2TestConfig aws2TestConfig, Optional<LocalStackContainer> localstack,
Service[] exportCredentialsServices) {
- this.accessKey = accessKey;
- this.secretKey = secretKey;
- this.region = region;
this.localstack = localstack;
-
- localstack.ifPresent(ls -> {
- for (Service service : exportCredentialsServices) {
- String s = camelServiceAcronym(service);
- if (s != null) {
- 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);
-
- properties.put("camel.component.aws2-" + s + ".override-endpoint", "true");
- properties.put("camel.component.aws2-" + s + ".uri-endpoint-override",
- ls.getEndpointOverride(service).toString());
- }
+ this.aws2TestConfig = aws2TestConfig;
+
+ for (Service service : exportCredentialsServices) {
+ if (aws2TestConfig.isAwsQuarkusClientTest()) {
+ String prefix = String.format("quarkus.%s", service.getName());
+ properties.put(prefix + ".aws.credentials.static-provider.access-key-id", aws2TestConfig.getAccessKey());
+ properties.put(prefix + ".aws.credentials.static-provider.secret-access-key",
+ aws2TestConfig.getAccessSecret());
+ properties.put(prefix + ".aws.region", aws2TestConfig.getRegion());
+ properties.put(prefix + ".aws.credentials.type", "static");
+ localstack.ifPresent(ls -> {
+ properties.put(prefix + ".endpoint-override", ls.getEndpointOverride(service).toString());
+ });
+ } else {
+ String prefix = String.format("camel.component.aws2-%s", camelServiceAcronym(service));
+ properties.put(prefix + ".access-key", aws2TestConfig.getAccessSecret());
+ properties.put(prefix + ".secret-key", aws2TestConfig.getAccessSecret());
+ properties.put(prefix + ".region", aws2TestConfig.getRegion());
+ properties.put(prefix + ".override-endpoint", "true");
+ localstack.ifPresent(ls -> {
+ properties.put(prefix + ".uri-endpoint-override", ls.getEndpointOverride(service).toString());
+ });
}
- });
+ }
}
/**
@@ -141,13 +145,13 @@ public class Aws2TestEnvContext {
Supplier<B> builderSupplier) {
B builder = builderSupplier.get()
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(
- accessKey, secretKey)));
- builder.region(Region.of(region));
+ aws2TestConfig.getAccessKey(), aws2TestConfig.getAccessSecret())));
+ builder.region(Region.of(aws2TestConfig.getRegion()));
if (localstack.isPresent()) {
builder
.endpointOverride(localstack.get().getEndpointOverride(service))
- .region(Region.of(region));
+ .region(Region.of(aws2TestConfig.getRegion()));
} else if (service == Service.IAM) {
/* Avoid UnknownHostException: iam.eu-central-1.amazonaws.com */
builder.endpointOverride(URI.create("https://iam.amazonaws.com"));
@@ -189,8 +193,4 @@ public class Aws2TestEnvContext {
return service.name().toLowerCase(Locale.ROOT);
}
}
-
- public String getRegion() {
- return region;
- }
}
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 9864311..e0c6260 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
@@ -38,6 +38,13 @@ public final class Aws2TestResource implements QuarkusTestResourceLifecycleManag
private static final Logger LOG = LoggerFactory.getLogger(Aws2TestResource.class);
private Aws2TestEnvContext envContext;
+ private boolean awsQuarkusClientTest;
+
+ @Override
+ public void init(Map<String, String> initArgs) {
+ String awsQuarkusClientTest = initArgs.get("awsQuarkusClientTest");
+ this.awsQuarkusClientTest = awsQuarkusClientTest != null && awsQuarkusClientTest.equals("true");
+ }
@SuppressWarnings("resource")
@Override
@@ -77,16 +84,17 @@ public final class Aws2TestResource implements QuarkusTestResourceLifecycleManag
localstack.withLogConsumer(new Slf4jLogConsumer(LOG));
localstack.start();
- envContext = new Aws2TestEnvContext(localstack.getAccessKey(), localstack.getSecretKey(), localstack.getRegion(),
- Optional.of(localstack), exportCredentialsServices);
-
+ Aws2TestConfig config = new Aws2TestConfig(localstack.getAccessKey(), localstack.getSecretKey(),
+ localstack.getRegion(), awsQuarkusClientTest);
+ envContext = new Aws2TestEnvContext(config, Optional.of(localstack), exportCredentialsServices);
} else {
if (!startMockBackend && !realCredentialsProvided) {
throw new IllegalStateException(
"Set AWS_ACCESS_KEY, AWS_SECRET_KEY and AWS_REGION env vars if you set CAMEL_QUARKUS_START_MOCK_BACKEND=false");
}
MockBackendUtils.logRealBackendUsed();
- envContext = new Aws2TestEnvContext(realKey, realSecret, realRegion, Optional.empty(), new Service[0]);
+ Aws2TestConfig config = new Aws2TestConfig(realKey, realSecret, realRegion, awsQuarkusClientTest);
+ envContext = new Aws2TestEnvContext(config, Optional.empty(), new Service[0]);
}
customizers.forEach(customizer -> customizer.customize(envContext));
@@ -96,7 +104,9 @@ public final class Aws2TestResource implements QuarkusTestResourceLifecycleManag
@Override
public void stop() {
- envContext.close();
+ if (envContext != null) {
+ envContext.close();
+ }
}
@Override