Author: cmueller
Date: Sun Apr 17 19:13:51 2011
New Revision: 1094187

URL: http://svn.apache.org/viewvc?rev=1094187&view=rev
Log:
CAMEL-3874: add awsSNSEndpoint to aws-sns component\nThanks Preben Asmussen for 
the patch

Modified:
    
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
    
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
    
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
    
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
    
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java
    
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java
    
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java
    
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
    
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java

Modified: 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
 Sun Apr 17 19:13:51 2011
@@ -31,6 +31,15 @@ public class S3Configuration implements 
     private String bucketName;
     private String region;
     private boolean deleteAfterRead = true;
+    private String amazonS3Endpoint;
+    
+    public void setAmazonS3Endpoint(String amazonS3Endpoint) {
+        this.amazonS3Endpoint = amazonS3Endpoint;
+    }
+    
+    public String getAmazonS3Endpoint() {
+        return amazonS3Endpoint;
+    }
     
     public String getAccessKey() {
         return accessKey;

Modified: 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
 Sun Apr 17 19:13:51 2011
@@ -156,7 +156,11 @@ public class S3Endpoint extends Schedule
      */
     AmazonS3Client createS3Client() {
         AWSCredentials credentials = new 
BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
-        return new AmazonS3Client(credentials);
+        AmazonS3Client client = new AmazonS3Client(credentials);
+        if (configuration.getAmazonS3Endpoint() != null) {
+            client.setEndpoint(configuration.getAmazonS3Endpoint());
+        }
+        return client;
     }
     
     public int getMaxMessagesPerPoll() {

Modified: 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
 Sun Apr 17 19:13:51 2011
@@ -29,11 +29,20 @@ public class SnsConfiguration implements
     private AmazonSNSClient amazonSNSClient;
     private String accessKey;
     private String secretKey;
+    private String amazonSNSEndpoint;
 
     // Producer only properties
     private String subject;
     private String topicArn;
 
+    public void setAmazonSNSEndpoint(String awsSNSEndpoint) {
+        this.amazonSNSEndpoint = awsSNSEndpoint;
+    }
+    
+    public String getAmazonSNSEndpoint() {
+        return amazonSNSEndpoint;
+    }
+    
     public String getSubject() {
         return subject;
     }

Modified: 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
 Sun Apr 17 19:13:51 2011
@@ -101,6 +101,10 @@ public class SnsEndpoint extends Default
      */
     AmazonSNSClient createSNSClient() {
         AWSCredentials credentials = new 
BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
-        return new AmazonSNSClient(credentials);
+        AmazonSNSClient client = new AmazonSNSClient(credentials);
+        if (configuration.getAmazonSNSEndpoint() != null) {
+            client.setEndpoint(configuration.getAmazonSNSEndpoint());
+        }
+        return client;
     }
 }
\ No newline at end of file

Modified: 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java
 Sun Apr 17 19:13:51 2011
@@ -31,12 +31,21 @@ public class SqsConfiguration {
     private AmazonSQSClient amazonSQSClient;
     private String accessKey;
     private String secretKey;
+    private String amazonSQSEndpoint;
     
     // consumer properties
     private Boolean deleteAfterRead = Boolean.TRUE;
     private Integer visibilityTimeout;
     private Collection<String> attributeNames;
     private Integer defaultVisibilityTimeout;
+    
+    public void setAmazonSQSEndpoint(String amazonSQSEndpoint) {
+        this.amazonSQSEndpoint = amazonSQSEndpoint;
+    }
+    
+    public String getAmazonSQSEndpoint() {
+        return amazonSQSEndpoint;
+    }
 
     public String getQueueName() {
         return queueName;

Modified: 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java
 Sun Apr 17 19:13:51 2011
@@ -131,7 +131,11 @@ public class SqsEndpoint extends Schedul
      */
     AmazonSQSClient createClient() {
         AWSCredentials credentials = new 
BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
-        return new AmazonSQSClient(credentials);
+        AmazonSQSClient client = new AmazonSQSClient(credentials);
+        if (configuration.getAmazonSQSEndpoint() != null) {
+            client.setEndpoint(configuration.getAmazonSQSEndpoint());
+        }
+        return client;
     }
 
     protected String getQueueUrl() {

Modified: 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java
 Sun Apr 17 19:13:51 2011
@@ -35,6 +35,7 @@ public class S3ComponentConfigurationTes
         assertNull(endpoint.getConfiguration().getRegion());
         assertTrue(endpoint.getConfiguration().isDeleteAfterRead());
         assertEquals(10, endpoint.getMaxMessagesPerPoll());
+        assertNull(endpoint.getConfiguration().getAmazonS3Endpoint());
     }
     
     @Test
@@ -53,12 +54,14 @@ public class S3ComponentConfigurationTes
         assertNull(endpoint.getConfiguration().getRegion());
         assertTrue(endpoint.getConfiguration().isDeleteAfterRead());
         assertEquals(10, endpoint.getMaxMessagesPerPoll());
+        assertNull(endpoint.getConfiguration().getAmazonS3Endpoint());
     }
     
     @Test
     public void createEndpointWithMaximalConfiguration() throws Exception {
         S3Component component = new S3Component(context);
-        S3Endpoint endpoint = (S3Endpoint) 
component.createEndpoint("aws-s3://MyBucket?accessKey=xxx&secretKey=yyy&region=us-west-1&deleteAfterRead=false&maxMessagesPerPoll=1");
+        S3Endpoint endpoint = (S3Endpoint) 
component.createEndpoint("aws-s3://MyBucket?amazonS3Endpoint=sns.eu-west-1.amazonaws.com"
+                + 
"&accessKey=xxx&secretKey=yyy&region=us-west-1&deleteAfterRead=false&maxMessagesPerPoll=1");
         
         assertEquals("MyBucket", endpoint.getConfiguration().getBucketName());
         assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
@@ -67,6 +70,7 @@ public class S3ComponentConfigurationTes
         assertEquals("us-west-1", endpoint.getConfiguration().getRegion());
         assertFalse(endpoint.getConfiguration().isDeleteAfterRead());
         assertEquals(1, endpoint.getMaxMessagesPerPoll());
+        assertEquals("sns.eu-west-1.amazonaws.com", 
endpoint.getConfiguration().getAmazonS3Endpoint());
     }
     
     @Test(expected = IllegalArgumentException.class)

Modified: 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
 Sun Apr 17 19:13:51 2011
@@ -34,6 +34,7 @@ public class SnsComponentConfigurationTe
         assertNull(endpoint.getConfiguration().getAmazonSNSClient());
         assertNull(endpoint.getConfiguration().getTopicArn());
         assertNull(endpoint.getConfiguration().getSubject());
+        assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
     }
     
     @Test
@@ -50,7 +51,7 @@ public class SnsComponentConfigurationTe
         assertNull(endpoint.getConfiguration().getSecretKey());
         assertNull(endpoint.getConfiguration().getTopicArn());
         assertNull(endpoint.getConfiguration().getSubject());
-        
+        assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
         endpoint.start();
         
         assertEquals("arn:aws:sns:us-east-1:541925086079:MyTopic", 
endpoint.getConfiguration().getTopicArn());
@@ -61,9 +62,10 @@ public class SnsComponentConfigurationTe
     @Test
     public void createEndpointWithMaximalConfiguration() throws Exception {
         SnsComponent component = new SnsComponent(context);
-        SnsEndpoint endpoint = (SnsEndpoint) 
component.createEndpoint("aws-sns://MyTopic?accessKey=xxx&secretKey=yyy&subject=The+subject+message");
+        SnsEndpoint endpoint = (SnsEndpoint) 
component.createEndpoint("aws-sns://MyTopic?amazonSNSEndpoint=sns.eu-west-1.amazonaws.com&accessKey=xxx&secretKey=yyy&subject=The+subject+message");
         
         assertEquals("MyTopic", endpoint.getConfiguration().getTopicName());
+        assertEquals("sns.eu-west-1.amazonaws.com", 
endpoint.getConfiguration().getAmazonSNSEndpoint());
         assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
         assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
         assertNull(endpoint.getConfiguration().getTopicArn());

Modified: 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java?rev=1094187&r1=1094186&r2=1094187&view=diff
==============================================================================
--- 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
 (original)
+++ 
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
 Sun Apr 17 19:13:51 2011
@@ -38,6 +38,7 @@ public class SqsComponentConfigurationTe
         assertNull(endpoint.getConfiguration().getAttributeNames());
         assertNull(endpoint.getConfiguration().getDefaultVisibilityTimeout());
         assertNull(endpoint.getConfiguration().getVisibilityTimeout());
+        assertNull(endpoint.getConfiguration().getAmazonSQSEndpoint());
     }
     
     @Test
@@ -56,6 +57,7 @@ public class SqsComponentConfigurationTe
         assertNull(endpoint.getConfiguration().getAttributeNames());
         assertNull(endpoint.getConfiguration().getDefaultVisibilityTimeout());
         assertNull(endpoint.getConfiguration().getVisibilityTimeout());
+        assertNull(endpoint.getConfiguration().getAmazonSQSEndpoint());
     }
     
     @Test
@@ -67,7 +69,7 @@ public class SqsComponentConfigurationTe
         ((JndiRegistry) ((PropertyPlaceholderDelegateRegistry) 
context.getRegistry()).getRegistry()).bind("attributeNames", attributeNames);
         
         SqsComponent component = new SqsComponent(context);
-        SqsEndpoint endpoint = (SqsEndpoint) 
component.createEndpoint("aws-sqs://MyQueue?accessKey=xxx&secretKey=yyy&attributeNames=#attributeNames"
+        SqsEndpoint endpoint = (SqsEndpoint) 
component.createEndpoint("aws-sqs://MyQueue?amazonSQSEndpoint=sns.eu-west-1.amazonaws.com&accessKey=xxx&secretKey=yyy&attributeNames=#attributeNames"
                 + "&DefaultVisibilityTimeout=1000&visibilityTimeout=2000");
         
         assertEquals("MyQueue", endpoint.getConfiguration().getQueueName());
@@ -77,6 +79,7 @@ public class SqsComponentConfigurationTe
         assertSame(attributeNames, 
endpoint.getConfiguration().getAttributeNames());
         assertEquals(new Integer(1000), 
endpoint.getConfiguration().getDefaultVisibilityTimeout());
         assertEquals(new Integer(2000), 
endpoint.getConfiguration().getVisibilityTimeout());
+        assertEquals("sns.eu-west-1.amazonaws.com", 
endpoint.getConfiguration().getAmazonSQSEndpoint());
     }
     
     @Test


Reply via email to