You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/03/12 03:49:08 UTC
[4/4] git commit: CAMEL-7286 Fixed the issue of amazonSNSEndpoint
option
CAMEL-7286 Fixed the issue of amazonSNSEndpoint option
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/275bcbe9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/275bcbe9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/275bcbe9
Branch: refs/heads/camel-2.11.x
Commit: 275bcbe97b1d0c01e7484a71b820bfd4e02c624d
Parents: f23e57a
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Mar 12 10:45:19 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Mar 12 10:48:13 2014 +0800
----------------------------------------------------------------------
.../org/apache/camel/component/aws/sns/SnsEndpoint.java | 8 +++++++-
.../camel/component/aws/sns/AmazonSNSClientMock.java | 12 +++++++++++-
.../aws/sns/SnsComponentConfigurationTest.java | 6 ++++--
3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/275bcbe9/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
index 2efdd2c..63c5046 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
@@ -30,6 +30,7 @@ import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,13 +81,18 @@ public class SnsEndpoint extends DefaultEndpoint {
LOG.trace("Topic created with Amazon resource name: {}", configuration.getTopicArn());
- if (configuration.getPolicy() != null) {
+ if (ObjectHelper.isNotEmpty(configuration.getPolicy())) {
LOG.trace("Updating topic [{}] with policy [{}]", configuration.getTopicArn(), configuration.getPolicy());
getSNSClient().setTopicAttributes(new SetTopicAttributesRequest(configuration.getTopicArn(), "Policy", configuration.getPolicy()));
LOG.trace("Topic policy updated");
}
+
+ if (ObjectHelper.isNotEmpty(configuration.getAmazonSNSEndpoint())) {
+ LOG.trace("Updating the SNS region with : {} " + configuration.getAmazonSNSEndpoint());
+ getSNSClient().setEndpoint(configuration.getAmazonSNSEndpoint());
+ }
}
public SnsConfiguration getConfiguration() {
http://git-wip-us.apache.org/repos/asf/camel/blob/275bcbe9/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java
index aca89e3..3096017 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java
@@ -49,11 +49,21 @@ import org.junit.Assert;
public class AmazonSNSClientMock extends AmazonSNSClient {
private static final String DEFAULT_TOPIC_ARN = "arn:aws:sns:us-east-1:541925086079:MyTopic";
+ private String endpoint;
public AmazonSNSClientMock() {
super(new BasicAWSCredentials("myAccessKey", "mySecretKey"));
}
-
+
+ @Override
+ public void setEndpoint(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
@Override
public ConfirmSubscriptionResult confirmSubscription(ConfirmSubscriptionRequest confirmSubscriptionRequest) throws AmazonServiceException, AmazonClientException {
throw new UnsupportedOperationException();
http://git-wip-us.apache.org/repos/asf/camel/blob/275bcbe9/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
index 7685ef4..8a1283b 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
@@ -45,18 +45,20 @@ public class SnsComponentConfigurationTest extends CamelTestSupport {
((JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry()).bind("amazonSNSClient", mock);
SnsComponent component = new SnsComponent(context);
- SnsEndpoint endpoint = (SnsEndpoint) component.createEndpoint("aws-sns://MyTopic?amazonSNSClient=#amazonSNSClient");
+ SnsEndpoint endpoint = (SnsEndpoint) component.createEndpoint("aws-sns://MyTopic?amazonSNSClient=#amazonSNSClient&amazonSNSEndpoint=sns.ap-southeast-2.amazonaws.com");
assertEquals("MyTopic", endpoint.getConfiguration().getTopicName());
assertNull(endpoint.getConfiguration().getAccessKey());
assertNull(endpoint.getConfiguration().getSecretKey());
assertNull(endpoint.getConfiguration().getTopicArn());
assertNull(endpoint.getConfiguration().getSubject());
- assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
+ assertNotNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
assertNull(endpoint.getConfiguration().getPolicy());
endpoint.start();
assertEquals("arn:aws:sns:us-east-1:541925086079:MyTopic", endpoint.getConfiguration().getTopicArn());
+ // check the setting of AmazonSNSEndpoint
+ assertEquals("sns.ap-southeast-2.amazonaws.com", mock.getEndpoint());
endpoint.stop();
}