camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [07/13] camel git commit: CAMEL-8478: IdempotentRepository - Add clear operation, align InfinispanIdempotentRepository
Date Fri, 03 Jul 2015 20:23:51 GMT
CAMEL-8478: IdempotentRepository - Add clear operation, align InfinispanIdempotentRepository


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

Branch: refs/heads/master
Commit: c4261d65e6d121420a318abec4b30e340666524a
Parents: c93ef1d
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Fri Jul 3 17:08:04 2015 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Fri Jul 3 17:08:04 2015 +0200

----------------------------------------------------------------------
 .../idempotent/InfinispanIdempotentRepository.java |  6 ++++++
 .../InfinispanDefaultIdempotentRepositoryTest.java | 17 +++++++++++++++++
 .../InfinispanIdempotentRepositoryTest.java        | 14 ++++++++++++++
 3 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c4261d65/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
index 8960628..e7838b3 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
@@ -77,6 +77,12 @@ public class InfinispanIdempotentRepository extends ServiceSupport implements
Id
     public boolean remove(Object key) {
         return getCache().remove(key) != null;
     }
+    
+    @Override
+    @ManagedOperation(description = "Clear the store")
+    public void clear() {
+        getCache().clear();      
+    }
 
     @ManagedAttribute(description = "The processor name")
     public String getCacheName() {

http://git-wip-us.apache.org/repos/asf/camel/blob/c4261d65/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanDefaultIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanDefaultIdempotentRepositoryTest.java
b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanDefaultIdempotentRepositoryTest.java
index a349bc2..c4877e4 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanDefaultIdempotentRepositoryTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanDefaultIdempotentRepositoryTest.java
@@ -37,5 +37,22 @@ public class InfinispanDefaultIdempotentRepositoryTest {
 
         assertFalse(repository.contains("One"));
         assertFalse(repository.remove("One"));
+        
+        assertTrue(repository.add("One"));
+        assertTrue(repository.add("Two"));
+        assertTrue(repository.add("Three"));
+        assertTrue(repository.add("Four"));
+        
+        assertTrue(repository.contains("One"));
+        assertTrue(repository.contains("Two"));
+        assertTrue(repository.contains("Three"));
+        assertTrue(repository.contains("Four"));
+        
+        repository.clear();
+        
+        assertFalse(repository.contains("One"));
+        assertFalse(repository.contains("Two"));
+        assertFalse(repository.contains("Three"));
+        assertFalse(repository.contains("Four"));        
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/c4261d65/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepositoryTest.java
b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepositoryTest.java
index b0015e7..36c6196 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepositoryTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepositoryTest.java
@@ -85,6 +85,20 @@ public class InfinispanIdempotentRepositoryTest {
     public void doesntRemoveMissingKey() throws Exception {
         assertFalse(idempotentRepository.remove("One"));
     }
+    
+    @Test
+    public void clearCache() throws Exception {
+        assertTrue(idempotentRepository.add("One"));
+        assertTrue(idempotentRepository.add("Two"));
+
+        assertTrue(getCache().containsKey("One"));
+        assertTrue(getCache().containsKey("Two"));
+        
+        idempotentRepository.clear();
+        
+        assertFalse(getCache().containsKey("One"));
+        assertFalse(getCache().containsKey("Two"));
+    }
 
     private BasicCache<Object, Object> getCache() {
         return basicCacheContainer.getCache(cacheName);


Mime
View raw message