You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2015/06/09 17:10:50 UTC

camel git commit: CAMEL-8849 Camel-Hazelcast: Add retainAll operation to list

Repository: camel
Updated Branches:
  refs/heads/master 0d7be17a0 -> 054815fd4


CAMEL-8849 Camel-Hazelcast: Add retainAll operation to list


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

Branch: refs/heads/master
Commit: 054815fd4f6f05f5a0ef670da9659b710a015f6a
Parents: 0d7be17
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jun 9 09:08:31 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jun 9 17:07:28 2015 +0200

----------------------------------------------------------------------
 .../camel/component/hazelcast/HazelcastConstants.java   |  3 ++-
 .../component/hazelcast/list/HazelcastListProducer.java |  9 +++++++++
 .../component/hazelcast/HazelcastListProducerTest.java  | 12 ++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/054815fd/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
index 6d9218b..38a3a9d 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
@@ -64,9 +64,10 @@ public final class HazelcastConstants {
     public static final int PUT_IF_ABSENT_OPERATION = 8;
     public static final int ADD_ALL_OPERATION = 9;
     public static final int REMOVE_ALL_OPERATION = 10;
+    public static final int RETAIN_ALL_OPERATION = 11;
 
     // multimap
-    public static final int REMOVEVALUE_OPERATION = 11;
+    public static final int REMOVEVALUE_OPERATION = 12;
 
     // atomic numbers
     public static final int INCREMENT_OPERATION = 20;

http://git-wip-us.apache.org/repos/asf/camel/blob/054815fd/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/list/HazelcastListProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/list/HazelcastListProducer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/list/HazelcastListProducer.java
index b29bcc2..0292e95 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/list/HazelcastListProducer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/list/HazelcastListProducer.java
@@ -87,6 +87,10 @@ public class HazelcastListProducer extends HazelcastDefaultProducer {
             this.removeAll(exchange);
             break;
 
+        case HazelcastConstants.RETAIN_ALL_OPERATION:
+            this.retainAll(exchange);
+            break;
+            
         default:
             throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the LIST cache.", operation, HazelcastConstants.OPERATION));
         }
@@ -148,4 +152,9 @@ public class HazelcastListProducer extends HazelcastDefaultProducer {
         final Object body = exchange.getIn().getBody();
         list.removeAll((Collection<?>) body);
     }
+    
+    private void retainAll(Exchange exchange) {
+        final Object body = exchange.getIn().getBody();
+        list.retainAll((Collection<?>) body);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/054815fd/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java
index 74906da..616cd19 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastListProducerTest.java
@@ -128,6 +128,15 @@ public class HazelcastListProducerTest extends HazelcastCamelTestSupport {
         template.sendBody("direct:removeAll", t);
         verify(list).removeAll(t);
     }
+    
+    @Test
+    public void retainAll() throws InterruptedException {
+        Collection t = new ArrayList();
+        t.add("test1");
+        t.add("test2");
+        template.sendBody("direct:retainAll", t);
+        verify(list).retainAll(t);
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -155,6 +164,9 @@ public class HazelcastListProducerTest extends HazelcastCamelTestSupport {
                 from("direct:removeAll").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVE_ALL_OPERATION)).to(
                         String.format("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX));
                 
+                from("direct:retainAll").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.RETAIN_ALL_OPERATION)).to(
+                        String.format("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX));
+                
                 from("direct:addWithOperationNumber").toF("hazelcast:%sbar?operation=%s", HazelcastConstants.LIST_PREFIX, HazelcastConstants.ADD_OPERATION);
                 from("direct:addWithOperationName").toF("hazelcast:%sbar?operation=add", HazelcastConstants.LIST_PREFIX);
             }