You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/02/11 06:33:45 UTC

[camel] 01/02: CAMEL-16079 - aws-sns2 does not recognise FIFO queue configured though arn

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

acosentino pushed a commit to branch 16079-3.7.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ac0fdd2b5717d56cb2c005cb5383669c628bf0fc
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Feb 11 06:55:39 2021 +0100

    CAMEL-16079 - aws-sns2 does not recognise FIFO queue configured though arn
---
 .../camel/component/aws2/sns/Sns2Configuration.java |  6 ++++--
 .../aws2/sns/SnsComponentConfigurationTest.java     | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Configuration.java b/components/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Configuration.java
index ab5a42c..fb957d1 100644
--- a/components/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Configuration.java
+++ b/components/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Configuration.java
@@ -351,8 +351,10 @@ public class Sns2Configuration implements Cloneable {
     boolean isFifoTopic() {
         // AWS docs suggest this is valid derivation.
         // FIFO topic names must end with .fifo, and standard topic cannot
-        if (topicName.endsWith(".fifo")) {
-            return true;
+    	if (ObjectHelper.isNotEmpty(topicName)) {
+            if (topicName.endsWith(".fifo")) {
+                return true;
+            }
         }
         if (ObjectHelper.isNotEmpty(topicArn)) {
             return topicArn.endsWith(".fifo");
diff --git a/components/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsComponentConfigurationTest.java b/components/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsComponentConfigurationTest.java
index e2238e5..399467e 100644
--- a/components/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsComponentConfigurationTest.java
+++ b/components/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/SnsComponentConfigurationTest.java
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
 import software.amazon.awssdk.core.Protocol;
 import software.amazon.awssdk.regions.Region;
 
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -227,4 +228,24 @@ public class SnsComponentConfigurationTest extends CamelTestSupport {
         Sns2Component component = context.getComponent("aws2-sns", Sns2Component.class);
         component.createEndpoint("aws2-sns://MyTopic?amazonSNSClient=#amazonSNSClient");
     }
+    
+    @Test
+    public void createEndpointWithArnConfiguration() throws Exception {
+        AmazonSNSClientMock mock = new AmazonSNSClientMock();
+
+        context.getRegistry().bind("amazonSNSClient", mock);
+
+        Sns2Component component = context.getComponent("aws2-sns", Sns2Component.class);
+        Sns2Endpoint endpoint = (Sns2Endpoint) component
+                .createEndpoint("aws2-sns://arn:aws:sns:eu-west-1:123456789:somewhere-over-the-rainbow?amazonSNSClient=#amazonSNSClient&accessKey=xxx&secretKey=yyy");
+
+        assertEquals("arn:aws:sns:eu-west-1:123456789:somewhere-over-the-rainbow", endpoint.getConfiguration().getTopicArn());
+        assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
+        assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
+        assertNotNull(endpoint.getConfiguration().getAmazonSNSClient());
+        assertNull(endpoint.getConfiguration().getTopicName());
+        assertNull(endpoint.getConfiguration().getSubject());
+        assertNull(endpoint.getConfiguration().getPolicy());
+        assertFalse(endpoint.getConfiguration().isFifoTopic());
+    }
 }