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 2022/04/05 20:15:03 UTC

[camel-quarkus] branch main updated (02191fab78 -> c67b3165b4)

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

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


    from 02191fab78 Updated CHANGELOG.md
     new 936ed3e928 Use hasItems instead of containsInAnyOrder to verify list of blob containers
     new c67b3165b4 Test Azure Blob with autowiredEnabled=false

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:
 .../storage/blob/it/AzureStorageBlobProducers.java |  8 +++++
 .../storage/blob/it/AzureStorageBlobResource.java  | 10 +++++--
 .../storage/blob/it/AzureStorageBlobRoutes.java    | 11 ++++++-
 .../storage/blob/it/AzureStorageBlobTest.java      | 34 ++++++++++++++++++++--
 4 files changed, 57 insertions(+), 6 deletions(-)


[camel-quarkus] 02/02: Test Azure Blob with autowiredEnabled=false

Posted by ja...@apache.org.
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

commit c67b3165b440ecf1d964061f0d45a4b7281f0e6e
Author: James Netherton <ja...@gmail.com>
AuthorDate: Tue Apr 5 15:11:56 2022 +0100

    Test Azure Blob with autowiredEnabled=false
    
    Fixes #3694
---
 .../storage/blob/it/AzureStorageBlobProducers.java |  8 +++++++
 .../storage/blob/it/AzureStorageBlobResource.java  | 10 ++++++--
 .../storage/blob/it/AzureStorageBlobRoutes.java    | 11 ++++++++-
 .../storage/blob/it/AzureStorageBlobTest.java      | 28 ++++++++++++++++++++++
 4 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobProducers.java b/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobProducers.java
index dfd65bea34..f15cabf492 100644
--- a/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobProducers.java
+++ b/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobProducers.java
@@ -23,6 +23,7 @@ import com.azure.core.http.policy.HttpLogOptions;
 import com.azure.storage.blob.BlobServiceClient;
 import com.azure.storage.blob.BlobServiceClientBuilder;
 import com.azure.storage.common.StorageSharedKeyCredential;
+import org.apache.camel.component.azure.storage.blob.BlobComponent;
 import org.eclipse.microprofile.config.inject.ConfigProperty;
 
 public class AzureStorageBlobProducers {
@@ -46,4 +47,11 @@ public class AzureStorageBlobProducers {
                 .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS).setPrettyPrintBody(true))
                 .buildClient();
     }
+
+    @Named("azure-storage-blob-managed-client")
+    public BlobComponent azureBlobComponentWithManagedClient() {
+        BlobComponent component = new BlobComponent();
+        component.setAutowiredEnabled(false);
+        return component;
+    }
 }
diff --git a/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobResource.java b/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobResource.java
index 5bd0f54f2b..bea14e5c8b 100644
--- a/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobResource.java
+++ b/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobResource.java
@@ -113,15 +113,21 @@ public class AzureStorageBlobResource {
     @Path("/blob/read")
     @GET
     @Produces(MediaType.TEXT_PLAIN)
-    public String readBlob(@QueryParam("containerName") String containerName) {
+    public String readBlob(
+            @QueryParam("containerName") String containerName,
+            @QueryParam("uri") String uri) {
         if (containerName == null) {
             containerName = azureBlobContainerName;
         }
 
+        if (uri == null) {
+            uri = "direct:read";
+        }
+
         Map<String, Object> headers = new HashMap<>();
         headers.put(Exchange.CHARSET_NAME, StandardCharsets.UTF_8.name());
         headers.put(BlobConstants.BLOB_CONTAINER_NAME, containerName);
-        return producerTemplate.requestBodyAndHeaders("direct:read", null, headers, String.class);
+        return producerTemplate.requestBodyAndHeaders(uri, null, headers, String.class);
     }
 
     @Path("/blob/read/bytes")
diff --git a/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobRoutes.java b/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobRoutes.java
index a1de8d5903..954f55d980 100644
--- a/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobRoutes.java
+++ b/integration-test-groups/azure/azure-storage-blob/src/main/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobRoutes.java
@@ -50,6 +50,10 @@ public class AzureStorageBlobRoutes extends RouteBuilder {
         from("direct:read")
                 .to(componentUri(BlobOperationsDefinition.getBlob));
 
+        from("direct:readWithManagedClient")
+                .to(componentUri("azure-storage-blob-managed-client", BlobOperationsDefinition.getBlob)
+                        + "&autowiredEnabled=false&accessKey=RAW(" + azureStorageAccountKey + ")");
+
         from("direct:update")
                 .to(componentUri(BlobOperationsDefinition.uploadBlockBlob));
 
@@ -117,7 +121,12 @@ public class AzureStorageBlobRoutes extends RouteBuilder {
     }
 
     private String componentUri(final BlobOperationsDefinition operation) {
-        return String.format("azure-storage-blob://%s/%s?operation=%s&blobName=%s",
+        return componentUri("azure-storage-blob", operation);
+    }
+
+    private String componentUri(final String componentName, final BlobOperationsDefinition operation) {
+        return String.format("%s://%s/%s?operation=%s&blobName=%s",
+                componentName,
                 azureStorageAccountName,
                 azureBlobContainerName,
                 operation.name(), BLOB_NAME);
diff --git a/integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java b/integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java
index d7a5cd1192..de772d5902 100644
--- a/integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java
+++ b/integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java
@@ -516,4 +516,32 @@ class AzureStorageBlobTest {
                     .statusCode(anyOf(is(204), is(404)));
         }
     }
+
+    // Can only use the Camel component managed blob client with the real Azure service
+    @EnabledIf({ MockBackendDisabled.class })
+    @Test
+    public void readWithManagedClient() {
+        try {
+            // Create
+            RestAssured.given()
+                    .contentType(ContentType.TEXT)
+                    .body(BLOB_CONTENT)
+                    .post("/azure-storage-blob/blob/create")
+                    .then()
+                    .statusCode(201);
+
+            // Read
+            RestAssured.given()
+                    .queryParam("uri", "direct:readWithManagedClient")
+                    .get("/azure-storage-blob/blob/read")
+                    .then()
+                    .statusCode(200)
+                    .body(is(BLOB_CONTENT));
+        } finally {
+            // Delete
+            RestAssured.delete("/azure-storage-blob/blob/delete")
+                    .then()
+                    .statusCode(anyOf(is(204), is(404)));
+        }
+    }
 }


[camel-quarkus] 01/02: Use hasItems instead of containsInAnyOrder to verify list of blob containers

Posted by ja...@apache.org.
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

commit 936ed3e9286785b4c1d63f3ab42c09dd2fbbc39a
Author: James Netherton <ja...@gmail.com>
AuthorDate: Tue Apr 5 07:45:20 2022 +0100

    Use hasItems instead of containsInAnyOrder to verify list of blob containers
---
 .../component/azure/storage/blob/it/AzureStorageBlobTest.java       | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java b/integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java
index 1eb12e809e..d7a5cd1192 100644
--- a/integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java
+++ b/integration-test-groups/azure/azure-storage-blob/src/test/java/org/apache/camel/quarkus/component/azure/storage/blob/it/AzureStorageBlobTest.java
@@ -44,7 +44,7 @@ import org.junit.jupiter.api.Test;
 import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 import static org.hamcrest.Matchers.anyOf;
-import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.StringEndsWith.endsWith;
 import static org.hamcrest.text.MatchesPattern.matchesPattern;
@@ -375,7 +375,7 @@ class AzureStorageBlobTest {
                     .then()
                     .statusCode(200)
                     .body("containers.name",
-                            containsInAnyOrder(containerName, alternativeContainerName));
+                            hasItems(containerName, alternativeContainerName));
         } finally {
             // Delete
             RestAssured.given()
@@ -404,7 +404,7 @@ class AzureStorageBlobTest {
                     .then()
                     .statusCode(200)
                     .body("containers.name",
-                            containsInAnyOrder(containerName, alternativeContainerName));
+                            hasItems(containerName, alternativeContainerName));
 
             // Create blob in first container
             RestAssured.given()