camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [8/9] camel git commit: CAMEL-8920 Camel-JClouds: Add new operations to Blobstore component, add removeBlobs tests
Date Tue, 30 Jun 2015 15:29:10 GMT
CAMEL-8920 Camel-JClouds: Add new operations to Blobstore component, add removeBlobs tests


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/97236b5a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/97236b5a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/97236b5a

Branch: refs/heads/master
Commit: 97236b5a75c747e73abff0f17a1fbec328744065
Parents: ccb77a4
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Tue Jun 30 17:27:42 2015 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Tue Jun 30 17:27:43 2015 +0200

----------------------------------------------------------------------
 .../jclouds/JcloudsBlobStoreProducerTest.java   | 21 ++++++++++++++++++++
 .../jclouds/JcloudsSpringBlobstoreTest.java     | 18 +++++++++++++++++
 .../src/test/resources/blobstore-test.xml       | 10 ++++++++++
 3 files changed, 49 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/97236b5a/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
b/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
index 3aacf79..0590d9d 100644
--- a/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
+++ b/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
@@ -17,7 +17,9 @@
 package org.apache.camel.component.jclouds;
 
 import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.transform.TransformerException;
@@ -121,6 +123,22 @@ public class JcloudsBlobStoreProducerTest extends CamelTestSupport {
         result = template.requestBodyAndHeaders("direct:container-exists", null, headers,
Boolean.class);
         assertEquals(false, result);
     }
+    
+    @Test
+    public void testRemoveBlobs() throws InterruptedException {
+        template.sendBody("direct:put", "test message");
+        Object result = template.requestBodyAndHeader("direct:put-and-count", null, JcloudsConstants.OPERATION,
JcloudsConstants.COUNT_BLOBS, Long.class);
+        assertEquals(new Long(1), result);
+        List blobsToRemove = new ArrayList<>();
+        blobsToRemove.add(TEST_BLOB_IN_DIR);
+        Map<String,Object> headers = new HashMap<String,Object>();
+        headers.put(JcloudsConstants.OPERATION, JcloudsConstants.REMOVE_BLOBS);
+        headers.put(JcloudsConstants.CONTAINER_NAME, TEST_CONTAINER);
+        headers.put(JcloudsConstants.BLOB_NAME_LIST, blobsToRemove);
+        template.sendBodyAndHeaders("direct:remove-blobs", null, headers);
+        result = template.requestBodyAndHeader("direct:put-and-count", null, JcloudsConstants.OPERATION,
JcloudsConstants.COUNT_BLOBS, Long.class);
+        assertEquals(new Long(0), result);
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -161,6 +179,9 @@ public class JcloudsBlobStoreProducerTest extends CamelTestSupport {
                 
                 from("direct:container-exists")
                         .to("jclouds:blobstore:transient");
+                
+                from("direct:remove-blobs")
+                        .to("jclouds:blobstore:transient");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/97236b5a/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
b/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
index a250af3..12a5b76 100644
--- a/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
+++ b/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
@@ -16,7 +16,10 @@
  */
 package org.apache.camel.component.jclouds;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.camel.EndpointInject;
@@ -102,4 +105,19 @@ public class JcloudsSpringBlobstoreTest extends CamelSpringTestSupport
{
         Boolean result = template.requestBody("direct:exists", "Some message", Boolean.class);
         assertEquals(true, result);
     }
+    
+    @Test
+    public void testBlobStoreRemoveBlobs() throws InterruptedException {
+        Boolean result = template.requestBody("direct:exists", "Some message", Boolean.class);
+        assertEquals(true, result);
+        List blobsToRemove = new ArrayList<>();
+        blobsToRemove.add("testName");
+        Map<String,Object> headers = new HashMap<String,Object>();
+        headers.put(JcloudsConstants.OPERATION, JcloudsConstants.REMOVE_BLOBS);
+        headers.put(JcloudsConstants.CONTAINER_NAME, "foo");
+        headers.put(JcloudsConstants.BLOB_NAME_LIST, blobsToRemove);
+        template.sendBodyAndHeaders("direct:remove-blobs", null, headers);
+        Long count = template.requestBody("direct:count-after-remove-blobs", null, Long.class);
+        assertEquals(new Long(0), count);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/97236b5a/components/camel-jclouds/src/test/resources/blobstore-test.xml
----------------------------------------------------------------------
diff --git a/components/camel-jclouds/src/test/resources/blobstore-test.xml b/components/camel-jclouds/src/test/resources/blobstore-test.xml
index f7ab0be..ffb4530 100644
--- a/components/camel-jclouds/src/test/resources/blobstore-test.xml
+++ b/components/camel-jclouds/src/test/resources/blobstore-test.xml
@@ -81,6 +81,16 @@
             <to uri="jclouds:blobstore:transient?container=foo&amp;blobName=testName"/>
             <to uri="jclouds:blobstore:transient?container=foo&amp;blobName=testName&amp;operation=CamelJcloudsExistsContainer"/>
         </route>
+        
+        <route>
+            <from uri="direct:remove-blobs"/>
+            <to uri="jclouds:blobstore:transient?container=foo&amp;blobName=testName&amp;operation=CamelJcloudsExistsContainer"/>
+        </route>
+        
+        <route>
+            <from uri="direct:count-after-remove-blobs"/>
+            <to uri="jclouds:blobstore:transient?container=foo&amp;blobName=testName&amp;operation=CamelJcloudsCountBlobs"/>
+        </route>
 
     </camelContext>
 


Mime
View raw message