Repository: camel Updated Branches: refs/heads/master 11ccb8231 -> 0c7d9a839
CAMEL-8839 Camel-Hazelcast: Add clear 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/0c7d9a83 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0c7d9a83 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0c7d9a83 Branch: refs/heads/master Commit: 0c7d9a839809c68510aef2f81f75e67dabd277e1 Parents: 11ccb82 Author: Andrea Cosentino <anco...@gmail.com> Authored: Sun Jun 7 11:05:43 2015 +0200 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Sun Jun 7 11:05:43 2015 +0200 ---------------------------------------------------------------------- .../component/hazelcast/list/HazelcastListProducer.java | 8 ++++++++ .../camel/component/hazelcast/HazelcastListProducerTest.java | 8 ++++++++ 2 files changed, 16 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/0c7d9a83/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 88b7e6f..fa26556 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 @@ -73,6 +73,10 @@ public class HazelcastListProducer extends HazelcastDefaultProducer { case HazelcastConstants.REMOVEVALUE_OPERATION: this.remove(pos, exchange); break; + + case HazelcastConstants.CLEAR_OPERATION: + this.clear(); + break; default: throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the LIST cache.", operation, HazelcastConstants.OPERATION)); @@ -120,4 +124,8 @@ public class HazelcastListProducer extends HazelcastDefaultProducer { list.remove(position); } } + + private void clear() { + list.clear(); + } } http://git-wip-us.apache.org/repos/asf/camel/blob/0c7d9a83/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 caa26ff..2b5c5a7 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 @@ -102,6 +102,12 @@ public class HazelcastListProducerTest extends HazelcastCamelTestSupport { template.sendBody("direct:removevalue", "foo1"); verify(list).remove("foo1"); } + + @Test + public void clearList() { + template.sendBody("direct:clear", ""); + verify(list).clear(); + } @Override protected RouteBuilder createRouteBuilder() throws Exception { @@ -120,6 +126,8 @@ public class HazelcastListProducerTest extends HazelcastCamelTestSupport { from("direct:removevalue").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUE_OPERATION)).to( String.format("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX)); + + from("direct:clear").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.CLEAR_OPERATION)).toF("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);