camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1204161 - in /camel/branches/camel-2.8.x/components/camel-aws/src: main/java/org/apache/camel/component/aws/s3/ main/java/org/apache/camel/component/aws/sns/ test/java/org/apache/camel/component/aws/s3/ test/java/org/apache/camel/component...
Date Sun, 20 Nov 2011 13:24:30 GMT
Author: cmueller
Date: Sun Nov 20 13:24:30 2011
New Revision: 1204161

URL: http://svn.apache.org/viewvc?rev=1204161&view=rev
Log:
CAMEL-4435: Allow specifiying ACL on S3 producer

Added:
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java
      - copied, changed from r1203982, camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentNonExistingBucketTest.java
      - copied, changed from r1203982, camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java
Removed:
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java
Modified:
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
    camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/AmazonS3ClientMock.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/integration/S3ComponentIntegrationTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/integration/SnsComponentIntegrationTest.java
    camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/integration/SqsComponentIntegrationTest.java

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Configuration.java
Sun Nov 20 13:24:30 2011
@@ -32,6 +32,7 @@ public class S3Configuration implements 
     private String region;
     private boolean deleteAfterRead = true;
     private String amazonS3Endpoint;
+    private String policy;
     
     public void setAmazonS3Endpoint(String amazonS3Endpoint) {
         this.amazonS3Endpoint = amazonS3Endpoint;
@@ -88,4 +89,12 @@ public class S3Configuration implements 
     public void setDeleteAfterRead(boolean deleteAfterRead) {
         this.deleteAfterRead = deleteAfterRead;
     }
+    
+    public String getPolicy() {
+        return policy;
+    }
+
+    public void setPolicy(String policy) {
+        this.policy = policy;
+    }
 }
\ No newline at end of file

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Endpoint.java
Sun Nov 20 13:24:30 2011
@@ -99,6 +99,14 @@ public class S3Endpoint extends Schedule
         getS3Client().createBucket(createBucketRequest);
         
         LOG.trace("Bucket created");
+        
+        if (configuration.getPolicy() != null) {
+            LOG.trace("Updating bucket [{}] with policy [{}]", bucketName, configuration.getPolicy());
+            
+            getS3Client().setBucketPolicy(bucketName, configuration.getPolicy());
+            
+            LOG.trace("Bucket policy updated");
+        }
     }
 
     public Exchange createExchange(S3Object s3Object) {

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
Sun Nov 20 13:24:30 2011
@@ -34,6 +34,7 @@ public class SnsConfiguration implements
     // Producer only properties
     private String subject;
     private String topicArn;
+    private String policy;
 
     public void setAmazonSNSEndpoint(String awsSNSEndpoint) {
         this.amazonSNSEndpoint = awsSNSEndpoint;
@@ -91,6 +92,14 @@ public class SnsConfiguration implements
         this.topicName = topicName;
     }
     
+    public String getPolicy() {
+        return policy;
+    }
+
+    public void setPolicy(String policy) {
+        this.policy = policy;
+    }
+    
     @Override
     public String toString() {
         return "SnsConfiguration[topicName=" + topicName
@@ -99,6 +108,7 @@ public class SnsConfiguration implements
             + ", secretKey=xxxxxxxxxxxxxxx" 
             + ", subject=" + subject
             + ", topicArn=" + topicArn
+            + ", policy=" + policy
             + "]";
     }
 }
\ No newline at end of file

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsEndpoint.java
Sun Nov 20 13:24:30 2011
@@ -21,6 +21,7 @@ import com.amazonaws.auth.BasicAWSCreden
 import com.amazonaws.services.sns.AmazonSNSClient;
 import com.amazonaws.services.sns.model.CreateTopicRequest;
 import com.amazonaws.services.sns.model.CreateTopicResult;
+import com.amazonaws.services.sns.model.SetTopicAttributesRequest;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
@@ -71,6 +72,14 @@ public class SnsEndpoint extends Default
         configuration.setTopicArn(result.getTopicArn());
         
         LOG.trace("Topic created with Amazon resource name: {}", configuration.getTopicArn());
+        
+        if (configuration.getPolicy() != null) {
+            LOG.trace("Updating topic [{}] with policy [{}]", configuration.getTopicArn(),
configuration.getPolicy());
+            
+            getSNSClient().setTopicAttributes(new SetTopicAttributesRequest(configuration.getTopicArn(),
"Policy", configuration.getPolicy()));
+            
+            LOG.trace("Topic policy updated");
+        }
     }
 
     public SnsConfiguration getConfiguration() {

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/AmazonS3ClientMock.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/AmazonS3ClientMock.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/AmazonS3ClientMock.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/AmazonS3ClientMock.java
Sun Nov 20 13:24:30 2011
@@ -23,6 +23,8 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import junit.framework.Assert;
+
 import com.amazonaws.AmazonClientException;
 import com.amazonaws.AmazonServiceException;
 import com.amazonaws.AmazonWebServiceRequest;
@@ -76,7 +78,9 @@ import com.amazonaws.services.s3.model.V
 
 public class AmazonS3ClientMock extends AmazonS3Client {
     
-    List<S3Object> objects = new ArrayList<S3Object>();    
+    List<S3Object> objects = new ArrayList<S3Object>();
+    
+    private boolean nonExistingBucketCreated;
     
     public AmazonS3ClientMock() {
         super(null);
@@ -115,6 +119,12 @@ public class AmazonS3ClientMock extends 
 
     @Override
     public ObjectListing listObjects(ListObjectsRequest listObjectsRequest) throws AmazonClientException,
AmazonServiceException {
+        if ("nonExistingBucket".equals(listObjectsRequest.getBucketName()) && !nonExistingBucketCreated)
{
+            AmazonServiceException ex = new AmazonServiceException("Unknow bucket");
+            ex.setStatusCode(404);
+            throw ex; 
+        }
+        
         ObjectListing objectListing = new ObjectListing();
         int capacity = listObjectsRequest.getMaxKeys();
         
@@ -171,6 +181,10 @@ public class AmazonS3ClientMock extends 
 
     @Override
     public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException,
AmazonServiceException {
+        if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
+            nonExistingBucketCreated = true; 
+        }
+        
         Bucket bucket = new Bucket();
         bucket.setName(createBucketRequest.getBucketName());
         bucket.setCreationDate(new Date());
@@ -364,7 +378,8 @@ public class AmazonS3ClientMock extends 
 
     @Override
     public void setBucketPolicy(String bucketName, String policyText) throws AmazonClientException,
AmazonServiceException {
-        throw new UnsupportedOperationException();
+        Assert.assertEquals("nonExistingBucket", bucketName);
+        Assert.assertEquals("xxx", policyText);
     }
 
     @Override

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java
Sun Nov 20 13:24:30 2011
@@ -36,6 +36,7 @@ public class S3ComponentConfigurationTes
         assertTrue(endpoint.getConfiguration().isDeleteAfterRead());
         assertEquals(10, endpoint.getMaxMessagesPerPoll());
         assertNull(endpoint.getConfiguration().getAmazonS3Endpoint());
+        assertNull(endpoint.getConfiguration().getPolicy());
     }
     
     @Test
@@ -55,13 +56,16 @@ public class S3ComponentConfigurationTes
         assertTrue(endpoint.getConfiguration().isDeleteAfterRead());
         assertEquals(10, endpoint.getMaxMessagesPerPoll());
         assertNull(endpoint.getConfiguration().getAmazonS3Endpoint());
+        assertNull(endpoint.getConfiguration().getPolicy());
     }
     
     @Test
     public void createEndpointWithMaximalConfiguration() throws Exception {
         S3Component component = new S3Component(context);
         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");
+                + "&accessKey=xxx&secretKey=yyy&region=us-west-1&deleteAfterRead=false&maxMessagesPerPoll=1&policy=%7B%22Version%22%3A%222008-10-17%22,%22Id%22%3A%22Policy4324355464%22,"
+                + "%22Statement%22%3A%5B%7B%22Sid%22%3A%22Stmt456464646477%22,%22Action%22%3A%5B%22s3%3AGetObject%22%5D,%22Effect%22%3A%22Allow%22,"
+                + "%22Resource%22%3A%5B%22arn%3Aaws%3As3%3A%3A%3Amybucket/some/path/*%22%5D,%22Principal%22%3A%7B%22AWS%22%3A%5B%22*%22%5D%7D%7D%5D%7D");
         
         assertEquals("MyBucket", endpoint.getConfiguration().getBucketName());
         assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
@@ -71,6 +75,8 @@ public class S3ComponentConfigurationTes
         assertFalse(endpoint.getConfiguration().isDeleteAfterRead());
         assertEquals(1, endpoint.getMaxMessagesPerPoll());
         assertEquals("sns.eu-west-1.amazonaws.com", endpoint.getConfiguration().getAmazonS3Endpoint());
+        assertEquals("{\"Version\":\"2008-10-17\",\"Id\":\"Policy4324355464\",\"Statement\":[{\"Sid\":\"Stmt456464646477\",\"Action\":[\"s3:GetObject\"],\"Effect\":\"Allow\",\"Resource\":"
+                + "[\"arn:aws:s3:::mybucket/some/path/*\"],\"Principal\":{\"AWS\":[\"*\"]}}]}",
endpoint.getConfiguration().getPolicy());
     }
     
     @Test(expected = IllegalArgumentException.class)

Copied: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java
(from r1203982, camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java?p2=camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java&p1=camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java&r1=1203982&r2=1204161&rev=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java
Sun Nov 20 13:24:30 2011
@@ -30,7 +30,7 @@ import org.apache.camel.impl.JndiRegistr
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class S3ComponentTest extends CamelTestSupport {
+public class S3ComponentExistingBucketTest extends CamelTestSupport {
     
     @EndpointInject(uri = "direct:start")
     private ProducerTemplate template;
@@ -39,7 +39,7 @@ public class S3ComponentTest extends Cam
     private MockEndpoint result;
     
     @Test
-    public void sendInOnly() throws Exception {
+    public void sendIn() throws Exception {
         result.expectedMessageCount(1);
         
         Exchange exchange = template.send("direct:start", ExchangePattern.InOnly, new Processor()
{
@@ -108,10 +108,12 @@ public class S3ComponentTest extends Cam
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                String awsEndpoint = "aws-s3://mycamelbucket?amazonS3Client=#amazonS3Client&region=us-west-1";
+                
                 from("direct:start")
-                    .to("aws-s3://mycamelbucket?amazonS3Client=#amazonS3Client&region=us-west-1");
+                    .to(awsEndpoint);
                 
-                from("aws-s3://mycamelbucket?amazonS3Client=#amazonS3Client&region=us-west-1&maxMessagesPerPoll=5")
+                from(awsEndpoint + "&maxMessagesPerPoll=5")
                     .to("mock:result");
             }
         };

Copied: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentNonExistingBucketTest.java
(from r1203982, camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentNonExistingBucketTest.java?p2=camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentNonExistingBucketTest.java&p1=camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java&r1=1203982&r2=1204161&rev=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentNonExistingBucketTest.java
Sun Nov 20 13:24:30 2011
@@ -30,7 +30,7 @@ import org.apache.camel.impl.JndiRegistr
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class S3ComponentTest extends CamelTestSupport {
+public class S3ComponentNonExistingBucketTest extends CamelTestSupport {
     
     @EndpointInject(uri = "direct:start")
     private ProducerTemplate template;
@@ -77,7 +77,7 @@ public class S3ComponentTest extends Cam
     private void assertResultExchange(Exchange resultExchange) {
         assertIsInstanceOf(InputStream.class, resultExchange.getIn().getBody());
         assertEquals("This is my bucket content.", resultExchange.getIn().getBody(String.class));
-        assertEquals("mycamelbucket", resultExchange.getIn().getHeader(S3Constants.BUCKET_NAME));
+        assertEquals("nonExistingBucket", resultExchange.getIn().getHeader(S3Constants.BUCKET_NAME));
         assertEquals("CamelUnitTest", resultExchange.getIn().getHeader(S3Constants.KEY));
         assertNull(resultExchange.getIn().getHeader(S3Constants.VERSION_ID)); // not enabled
on this bucket
         assertNull(resultExchange.getIn().getHeader(S3Constants.LAST_MODIFIED));
@@ -108,10 +108,12 @@ public class S3ComponentTest extends Cam
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                String awsEndpoint = "aws-s3://nonExistingBucket?amazonS3Client=#amazonS3Client&region=us-west-1&policy=xxx";
+                
                 from("direct:start")
-                    .to("aws-s3://mycamelbucket?amazonS3Client=#amazonS3Client&region=us-west-1");
+                    .to(awsEndpoint);
                 
-                from("aws-s3://mycamelbucket?amazonS3Client=#amazonS3Client&region=us-west-1&maxMessagesPerPoll=5")
+                from(awsEndpoint + "&maxMessagesPerPoll=5")
                     .to("mock:result");
             }
         };

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/integration/S3ComponentIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/integration/S3ComponentIntegrationTest.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/integration/S3ComponentIntegrationTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/integration/S3ComponentIntegrationTest.java
Sun Nov 20 13:24:30 2011
@@ -79,7 +79,7 @@ public class S3ComponentIntegrationTest 
     private void assertResultExchange(Exchange resultExchange) {
         assertIsInstanceOf(InputStream.class, resultExchange.getIn().getBody());
         assertEquals("This is my bucket content.", resultExchange.getIn().getBody(String.class));
-        assertEquals("mycamelbucket", resultExchange.getIn().getHeader(S3Constants.BUCKET_NAME));
+        assertEquals("mynewcamelbucket", resultExchange.getIn().getHeader(S3Constants.BUCKET_NAME));
         assertEquals("CamelUnitTest", resultExchange.getIn().getHeader(S3Constants.KEY));
         assertNull(resultExchange.getIn().getHeader(S3Constants.VERSION_ID)); // not enabled
on this bucket
         assertNotNull(resultExchange.getIn().getHeader(S3Constants.LAST_MODIFIED));
@@ -101,10 +101,14 @@ public class S3ComponentIntegrationTest 
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                String s3EndpointUri = "aws-s3://mynewcamelbucket?accessKey=xxx&secretKey=yyy&region=us-west-1&policy=%7B%22Version%22%3A%222008-10-17%22,%22Id%22%3A%22Policy4324355464%22,"
+                    + "%22Statement%22%3A%5B%7B%22Sid%22%3A%22Stmt456464646477%22,%22Action%22%3A%5B%22s3%3AGetObject%22%5D,%22Effect%22%3A%22Allow%22,%22Resource%22%3A%5B%22arn%3A"
+                    + "aws%3As3%3A%3A%3Amynewcamelbucket/*%22%5D,%22Principal%22%3A%7B%22AWS%22%3A%5B%22*%22%5D%7D%7D%5D%7D";
+                
                 from("direct:start")
-                    .to("aws-s3://mycamelbucket?accessKey=xxx&secretKey=yyy&region=us-west-1");
+                    .to(s3EndpointUri);
                 
-                from("aws-s3://mycamelbucket?accessKey=xxx&secretKey=yyy&region=us-west-1")
+                from(s3EndpointUri)
                     .to("mock:result");
             }
         };

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/AmazonSNSClientMock.java
Sun Nov 20 13:24:30 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.aws.sns;
 
+import junit.framework.Assert;
+
 import com.amazonaws.AmazonClientException;
 import com.amazonaws.AmazonServiceException;
 import com.amazonaws.AmazonWebServiceRequest;
@@ -45,6 +47,8 @@ import com.amazonaws.services.sns.model.
 
 public class AmazonSNSClientMock extends AmazonSNSClient {
     
+    private static final String DEFAULT_TOPIC_ARN = "arn:aws:sns:us-east-1:541925086079:MyTopic";
+    
     public AmazonSNSClientMock() {
         super(null);
     }
@@ -66,7 +70,9 @@ public class AmazonSNSClientMock extends
 
     @Override
     public void setTopicAttributes(SetTopicAttributesRequest setTopicAttributesRequest) throws
AmazonServiceException, AmazonClientException {
-        throw new UnsupportedOperationException();
+        Assert.assertEquals(DEFAULT_TOPIC_ARN, setTopicAttributesRequest.getTopicArn());
+        Assert.assertEquals("Policy", setTopicAttributesRequest.getAttributeName());
+        Assert.assertEquals("XXX", setTopicAttributesRequest.getAttributeValue());
     }
 
     @Override
@@ -92,7 +98,7 @@ public class AmazonSNSClientMock extends
     @Override
     public CreateTopicResult createTopic(CreateTopicRequest createTopicRequest) throws AmazonServiceException,
AmazonClientException {
         CreateTopicResult createTopicResult = new CreateTopicResult();
-        createTopicResult.setTopicArn("arn:aws:sns:us-east-1:541925086079:MyTopic");
+        createTopicResult.setTopicArn(DEFAULT_TOPIC_ARN);
         return createTopicResult;
     }
 

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
Sun Nov 20 13:24:30 2011
@@ -35,6 +35,7 @@ public class SnsComponentConfigurationTe
         assertNull(endpoint.getConfiguration().getTopicArn());
         assertNull(endpoint.getConfiguration().getSubject());
         assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
+        assertNull(endpoint.getConfiguration().getPolicy());
     }
     
     @Test
@@ -52,6 +53,7 @@ public class SnsComponentConfigurationTe
         assertNull(endpoint.getConfiguration().getTopicArn());
         assertNull(endpoint.getConfiguration().getSubject());
         assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint());
+        assertNull(endpoint.getConfiguration().getPolicy());
         endpoint.start();
         
         assertEquals("arn:aws:sns:us-east-1:541925086079:MyTopic", endpoint.getConfiguration().getTopicArn());
@@ -62,7 +64,9 @@ public class SnsComponentConfigurationTe
     @Test
     public void createEndpointWithMaximalConfiguration() throws Exception {
         SnsComponent component = new SnsComponent(context);
-        SnsEndpoint endpoint = (SnsEndpoint) component.createEndpoint("aws-sns://MyTopic?amazonSNSEndpoint=sns.eu-west-1.amazonaws.com&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"
+                + "&policy=%7B%22Version%22%3A%222008-10-17%22,%22Statement%22%3A%5B%7B%22Sid%22%3A%221%22,%22Effect%22%3A%22Allow%22,%22Principal%22%3A%7B%22AWS%22%3A%5B%22*%22%5D%7D,"
+                + "%22Action%22%3A%5B%22sns%3ASubscribe%22%5D%7D%5D%7D&subject=The+subject+message");
         
         assertEquals("MyTopic", endpoint.getConfiguration().getTopicName());
         assertEquals("sns.eu-west-1.amazonaws.com", endpoint.getConfiguration().getAmazonSNSEndpoint());
@@ -71,6 +75,9 @@ public class SnsComponentConfigurationTe
         assertNull(endpoint.getConfiguration().getTopicArn());
         assertNull(endpoint.getConfiguration().getAmazonSNSClient());
         assertEquals("The subject message", endpoint.getConfiguration().getSubject());
+        assertEquals(
+                "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"1\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"sns:Subscribe\"]}]}",
+                endpoint.getConfiguration().getPolicy());
     }
     
     @Test(expected = IllegalArgumentException.class)

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentTest.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentTest.java
Sun Nov 20 13:24:30 2011
@@ -64,7 +64,7 @@ public class SnsComponentTest extends Ca
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("aws-sns://MyTopic?amazonSNSClient=#amazonSNSClient");
+                    .to("aws-sns://MyTopic?amazonSNSClient=#amazonSNSClient&policy=XXX");
             }
         };
     }

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/integration/SnsComponentIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/integration/SnsComponentIntegrationTest.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/integration/SnsComponentIntegrationTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/integration/SnsComponentIntegrationTest.java
Sun Nov 20 13:24:30 2011
@@ -25,10 +25,10 @@ import org.apache.camel.test.junit4.Came
 import org.junit.Ignore;
 import org.junit.Test;
 
+@Ignore("Must be manually tested. Provide your own accessKey and secretKey!")
 public class SnsComponentIntegrationTest extends CamelTestSupport {
     
     @Test
-    @Ignore("Must be manually tested. Provide your own accessKey and secretKey!")
     public void sendInOnly() throws Exception {
         Exchange exchange = template.send("direct:start", ExchangePattern.InOnly, new Processor()
{
             public void process(Exchange exchange) throws Exception {
@@ -41,7 +41,6 @@ public class SnsComponentIntegrationTest
     }
     
     @Test
-    @Ignore("Must be manually tested. Provide your own accessKey and secretKey!")
     public void sendInOut() throws Exception {
         Exchange exchange = template.send("direct:start", ExchangePattern.InOut, new Processor()
{
             public void process(Exchange exchange) throws Exception {
@@ -58,7 +57,8 @@ public class SnsComponentIntegrationTest
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("aws-sns://MyTopic?accessKey=xxx&secretKey=yyy");
+                    .to("aws-sns://MyNewTopic?accessKey=xxx&secretKey=yyy&policy=%7B%22Version%22%3A%222008-10-17%22,%22Statement%22%3A%5B%7B%22Sid%22%3A%221%22,%22Effect%22%3A%22Allow%22,"
+                            + "%22Principal%22%3A%7B%22AWS%22%3A%5B%22*%22%5D%7D,%22Action%22%3A%5B%22sns%3ASubscribe%22%5D%7D%5D%7D&subject=The+subject+message");
             }
         };
     }

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/integration/SqsComponentIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/integration/SqsComponentIntegrationTest.java?rev=1204161&r1=1204160&r2=1204161&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/integration/SqsComponentIntegrationTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/integration/SqsComponentIntegrationTest.java
Sun Nov 20 13:24:30 2011
@@ -87,15 +87,18 @@ public class SqsComponentIntegrationTest
     }
     
     protected RouteBuilder createRouteBuilder() throws Exception {
-        final String sqsURI = String.format("aws-sqs://MyQueue?accessKey=%s&secretKey=%s&messageRetentionPeriod=%s&maximumMessageSize=%s&policy=%s",
-                accessKey, secretKey, "1209600", "65536", "");
+        final String sqsEndpointUri = String.format("aws-sqs://MyNewCamelQueue?accessKey=%s&secretKey=%s&messageRetentionPeriod=%s&maximumMessageSize=%s&policy=%s",
+                accessKey, secretKey, "1209600", "65536", "%7B%22Version%22%3A%222008-10-17%22%2C%22Id%22%3A%22%2F195004372649%2FMyNewCamelQueue%2FSQSDefaultPolicy%22%2C%22"
+                        + "Statement%22%3A%5B%7B%22Sid%22%3A%22Queue1ReceiveMessage%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22AWS%22%3A%22*%22%7D%2C%22"
+                        + "Action%22%3A%22SQS%3AReceiveMessage%22%2C%22Resource%22%3A%22%2F195004372649%2FMyNewCamelQueue%22%7D%5D%7D");
+        
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to(sqsURI);
+                    .to(sqsEndpointUri);
                 
-                from(sqsURI)
+                from(sqsEndpointUri)
                     .to("mock:result");
             }
         };



Mime
View raw message