camel-commits mailing list archives

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


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

Branch: refs/heads/master
Commit: 1cb5207bdf9a138021ef0ad93d53b26383b5b159
Parents: d070697
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Fri Jul 3 21:58:47 2015 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Fri Jul 3 21:58:47 2015 +0200

----------------------------------------------------------------------
 .../processor/idempotent/KratiIdempotentRepository.java  | 10 ++++++++++
 .../idempotent/KratiIdempotentRepositoryTest.java        | 11 +++++++++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1cb5207b/components/camel-krati/src/main/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-krati/src/main/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepository.java
b/components/camel-krati/src/main/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepository.java
index eb7cf6e..7bd414d 100644
--- a/components/camel-krati/src/main/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepository.java
+++ b/components/camel-krati/src/main/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepository.java
@@ -20,6 +20,7 @@ import krati.core.segment.ChannelSegmentFactory;
 import krati.core.segment.SegmentFactory;
 import krati.io.Serializer;
 import krati.store.DataSet;
+
 import org.apache.camel.api.management.ManagedOperation;
 import org.apache.camel.component.krati.KratiHelper;
 import org.apache.camel.component.krati.serializer.KratiDefaultSerializer;
@@ -90,6 +91,15 @@ public class KratiIdempotentRepository extends ServiceSupport implements
Idempot
     public boolean confirm(String s) {
         return true;
     }
+    
+	@Override
+	public void clear() {
+		try {
+			dataSet.clear();
+		} catch (Exception e) {
+			LOG.warn("Error clear Krati idempotent repository. This exception is ignored.", e);
+		}
+	}
 
     @Override
     protected void doStart() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/1cb5207b/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
b/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
index 8eb38ab..d1ec430 100644
--- a/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
+++ b/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
@@ -85,6 +85,17 @@ public class KratiIdempotentRepositoryTest extends CamelTestSupport {
         assertFalse(repository.remove(key02));
     }
 
+    @Test
+    public void testClear() throws Exception {
+        // add keys to clear
+        assertTrue(repository.add(key01));
+        assertTrue(repository.add(key02));
+
+        repository.clear();
+        
+        assertFalse(repository.contains(key01));
+        assertFalse(repository.contains(key02));
+    }
 
     @Test
     public void testRepositoryInRoute() throws Exception {


Mime
View raw message