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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f9f9fed1278ef0da6e757a9baaa03722f92f0de3
Author: Andrea Cosentino <anco...@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 c190ebf..d1c93be 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
@@ -352,8 +352,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 a94185a..865b015 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());
+    }
 }

Reply via email to