camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [2/3] camel git commit: CAMEL-8243 Enhance Infinispan listener support
Date Sat, 20 Feb 2016 09:16:58 GMT
http://git-wip-us.apache.org/repos/asf/camel/blob/c7b1e905/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
index a800fd0..c4cd561 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTest.java
@@ -47,7 +47,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Object value = currentCache().get(KEY_ONE);
         assertEquals(VALUE_ONE, value.toString());
     }
-    
+
     @Test
     public void cacheSizeTest() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -78,7 +78,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Object value = currentCache().get(KEY_ONE);
         assertEquals(VALUE_ONE, value.toString());
     }
-    
+
     @Test
     public void publishKeyAndValueAsync() throws Exception {
         Exchange exchange = template.send("direct:putasync", new Processor() {
@@ -92,7 +92,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Thread.sleep(10000);
         NotifyingFuture resultPutAsync = exchange.getIn().getHeader(InfinispanConstants.RESULT,
NotifyingFuture.class);
         assertEquals(Boolean.TRUE, resultPutAsync.isDone());
-        
+
         Object value = currentCache().get(KEY_ONE);
         assertEquals(VALUE_ONE, value.toString());
     }
@@ -112,10 +112,10 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Thread.sleep(1000);
         NotifyingFuture resultPutAsync = exchange.getIn().getHeader(InfinispanConstants.RESULT,
NotifyingFuture.class);
         assertEquals(Boolean.TRUE, resultPutAsync.isDone());
-        
+
         Object value = currentCache().get(KEY_ONE);
-        assertEquals(value.toString(), VALUE_ONE);  
-        
+        assertEquals(value.toString(), VALUE_ONE);
+
         Thread.sleep(6000);
         exchange = template.send("direct:get", new Processor() {
             @Override
@@ -126,7 +126,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void publishKeyAndValueAsyncWithLifespanAndMaxIdle() throws Exception {
         Exchange exchange = template.send("direct:putasync", new Processor() {
@@ -144,10 +144,10 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Thread.sleep(1000);
         NotifyingFuture resultPutAsync = exchange.getIn().getHeader(InfinispanConstants.RESULT,
NotifyingFuture.class);
         assertEquals(Boolean.TRUE, resultPutAsync.isDone());
-        
+
         Object value = currentCache().get(KEY_ONE);
         assertEquals(VALUE_ONE, value.toString());
-        
+
         Thread.sleep(10000);
         exchange = template.send("direct:get", new Processor() {
             @Override
@@ -158,7 +158,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void publishMapNormal() throws Exception {
         template.send("direct:start", new Processor() {
@@ -178,7 +178,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         value = currentCache().get(KEY_TWO);
         assertEquals(VALUE_TWO, value.toString());
     }
-    
+
     @Test
     public void publishMapWithLifespan() throws Exception {
         template.send("direct:start", new Processor() {
@@ -199,9 +199,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         assertEquals(VALUE_ONE, value.toString());
         value = currentCache().get(KEY_TWO);
         assertEquals(VALUE_TWO, value.toString());
-        
+
         Thread.sleep(LIFESPAN_TIME * 1000);
-        
+
         Exchange exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -210,7 +210,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         });
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -220,7 +220,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void publishMapWithLifespanAndMaxIdleTime() throws Exception {
         template.send("direct:start", new Processor() {
@@ -239,9 +239,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         });
 
         assertEquals(2, currentCache().size());
-        
+
         Thread.sleep(10000);
-        
+
         Exchange exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -250,7 +250,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         });
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -260,7 +260,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(null);
     }
-    
+
     @Test
     public void publishMapNormalAsync() throws Exception {
         template.send("direct:putallasync", new Processor() {
@@ -272,7 +272,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
                 exchange.getIn().setHeader(InfinispanConstants.MAP, map);
             }
         });
-        
+
         Thread.sleep(100);
         assertEquals(2, currentCache().size());
         Object value = currentCache().get(KEY_ONE);
@@ -280,7 +280,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         value = currentCache().get(KEY_TWO);
         assertEquals(VALUE_TWO, value.toString());
     }
-    
+
     @Test
     public void publishMapWithLifespanAsync() throws Exception {
         template.send("direct:putallasync", new Processor() {
@@ -302,9 +302,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         assertEquals(VALUE_ONE, value.toString());
         value = currentCache().get(KEY_TWO);
         assertEquals(VALUE_TWO, value.toString());
-        
+
         Thread.sleep(LIFESPAN_TIME * 1000);
-        
+
         Exchange exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -313,7 +313,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         });
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -323,7 +323,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void publishMapWithLifespanAndMaxIdleTimeAsync() throws Exception {
         template.send("direct:putallasync", new Processor() {
@@ -340,12 +340,12 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
                 exchange.getIn().setHeader(InfinispanConstants.MAX_IDLE_TIME_UNIT, TimeUnit.SECONDS.toString());
             }
         });
-        
+
         Thread.sleep(100);
         assertEquals(2, currentCache().size());
-        
+
         Thread.sleep(10000);
-        
+
         Exchange exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -354,7 +354,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         });
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -364,11 +364,11 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void putIfAbsentAlreadyExists() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
-        
+
         template.send("direct:putifabsent", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -382,11 +382,11 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         assertEquals(VALUE_ONE, value.toString());
         assertEquals(1, currentCache().size());
     }
-    
+
     @Test
     public void putIfAbsentNotExists() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
-        
+
         template.send("direct:putifabsent", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -400,7 +400,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         assertEquals(VALUE_TWO, value.toString());
         assertEquals(2, currentCache().size());
     }
-    
+
     @Test
     public void putIfAbsentKeyAndValueAsync() throws Exception {
         Exchange exchange = template.send("direct:putifabsentasync", new Processor() {
@@ -414,7 +414,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Thread.sleep(10000);
         NotifyingFuture resultPutAsync = exchange.getIn().getHeader(InfinispanConstants.RESULT,
NotifyingFuture.class);
         assertEquals(Boolean.TRUE, resultPutAsync.isDone());
-        
+
         Object value = currentCache().get(KEY_ONE);
         assertEquals(VALUE_ONE, value.toString());
     }
@@ -434,10 +434,10 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Thread.sleep(1000);
         NotifyingFuture resultPutAsync = exchange.getIn().getHeader(InfinispanConstants.RESULT,
NotifyingFuture.class);
         assertEquals(Boolean.TRUE, resultPutAsync.isDone());
-        
+
         Object value = currentCache().get(KEY_ONE);
         assertEquals(VALUE_ONE, value.toString());
-        
+
         Thread.sleep(6000);
         exchange = template.send("direct:get", new Processor() {
             @Override
@@ -448,7 +448,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void putIfAbsentKeyAndValueAsyncWithLifespanAndMaxIdle() throws Exception {
         Exchange exchange = template.send("direct:putifabsentasync", new Processor() {
@@ -466,10 +466,10 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Thread.sleep(1000);
         NotifyingFuture resultPutAsync = exchange.getIn().getHeader(InfinispanConstants.RESULT,
NotifyingFuture.class);
         assertEquals(Boolean.TRUE, resultPutAsync.isDone());
-        
+
         Object value = currentCache().get(KEY_ONE);
         assertEquals(VALUE_ONE, value.toString());
-        
+
         Thread.sleep(10000);
         exchange = template.send("direct:get", new Processor() {
             @Override
@@ -480,11 +480,11 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void notContainsKeyTest() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
-        
+
         Exchange exchange = template.request("direct:containskey", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -496,11 +496,11 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Boolean cacheContainsKey = exchange.getIn().getHeader(InfinispanConstants.RESULT,
Boolean.class);
         assertFalse(cacheContainsKey);
     }
-    
+
     @Test
     public void containsKeyTest() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
-        
+
         Exchange exchange = template.request("direct:containskey", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -512,11 +512,11 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Boolean cacheContainsKey = exchange.getIn().getHeader(InfinispanConstants.RESULT,
Boolean.class);
         assertTrue(cacheContainsKey);
     }
-    
+
     @Test
     public void notContainsValueTest() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
-        
+
         Exchange exchange = template.request("direct:containsvalue", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -528,11 +528,11 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Boolean cacheContainsValue = exchange.getIn().getHeader(InfinispanConstants.RESULT,
Boolean.class);
         assertFalse(cacheContainsValue);
     }
-    
+
     @Test
     public void containsValueTest() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
-        
+
         Exchange exchange = template.request("direct:containsvalue", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -544,7 +544,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Boolean cacheContainsValue = exchange.getIn().getHeader(InfinispanConstants.RESULT,
Boolean.class);
         assertTrue(cacheContainsValue);
     }
-    
+
     @Test
     public void publishKeyAndValueWithLifespan() throws Exception {
         template.send("direct:start", new Processor() {
@@ -560,7 +560,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         Object value = currentCache().get(KEY_ONE);
         assertEquals(VALUE_ONE, value.toString());
-        
+
         Exchange exchange;
         exchange = template.send("direct:get", new Processor() {
             @Override
@@ -570,9 +570,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         });
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertEquals(VALUE_ONE, resultGet);
-        
+
         Thread.sleep(LIFESPAN_TIME * 1000);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -614,7 +614,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         assertEquals(VALUE_ONE, exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class));
     }
-    
+
     @Test
     public void replaceAValueByKey() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -631,7 +631,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         assertEquals(VALUE_ONE, exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
     }
-    
+
     @Test
     public void replaceAValueByKeyWithLifespan() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -649,9 +649,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         assertEquals(VALUE_ONE, exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
-        
+
         Thread.sleep(LIFESPAN_TIME * 1000);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -661,7 +661,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void replaceAValueByKeyWithLifespanAndMaxIdleTime() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -681,9 +681,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         assertEquals(VALUE_ONE, exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
-        
+
         Thread.sleep(10000);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -711,7 +711,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         assertTrue(exchange.getIn().getHeader(InfinispanConstants.RESULT, Boolean.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
     }
-    
+
     @Test
     public void replaceAValueByKeyWithLifespanWithOldValue() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -730,9 +730,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         assertTrue(exchange.getIn().getHeader(InfinispanConstants.RESULT, Boolean.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
-        
+
         Thread.sleep(LIFESPAN_TIME * 1100);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -742,7 +742,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void replaceAValueByKeyWithLifespanAndMaxIdleTimeWithOldValue() throws Exception
{
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -763,9 +763,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         assertTrue(exchange.getIn().getHeader(InfinispanConstants.RESULT, Boolean.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
-        
+
         Thread.sleep(10000);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -774,9 +774,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         });
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
-    }    
-    
-    
+    }
+
+
     @Test
     public void replaceAValueByKeyAsync() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -792,7 +792,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         assertEquals(VALUE_ONE, exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
     }
-    
+
     @Test
     public void replaceAValueByKeyWithLifespanAsync() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -807,11 +807,11 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
             }
         });
 
-        assertEquals(VALUE_ONE, exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class));
-        assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
-        
-        Thread.sleep(LIFESPAN_TIME * 1000);
-        
+        assertEquals(exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class),
VALUE_ONE);
+        assertEquals(currentCache().get(KEY_ONE), VALUE_TWO);
+
+        TimeUnit.SECONDS.sleep(LIFESPAN_TIME + 1);
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -819,9 +819,10 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
             }
         });
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
-        assertNull(null, resultGet);
+        assertEquals(null, resultGet);
     }
-    
+
+
     @Test
     public void replaceAValueByKeyWithLifespanAndMaxIdleTimeAsync() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -840,9 +841,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         assertEquals(VALUE_ONE, exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
-        
+
         Thread.sleep(10000);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -852,7 +853,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void replaceAValueByKeyAsyncWithOldValue() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -869,7 +870,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         assertTrue(exchange.getIn().getHeader(InfinispanConstants.RESULT, Boolean.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
     }
-    
+
     @Test
     public void replaceAValueByKeyWithLifespanAsyncWithOldValue() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -887,9 +888,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         assertTrue(exchange.getIn().getHeader(InfinispanConstants.RESULT, Boolean.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
-        
+
         Thread.sleep(LIFESPAN_TIME * 1100);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -899,7 +900,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         String resultGet = exchange.getIn().getHeader(InfinispanConstants.RESULT, String.class);
         assertNull(resultGet);
     }
-    
+
     @Test
     public void replaceAValueByKeyWithLifespanAndMaxIdleTimeAsyncWithOldValue() throws Exception
{
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -919,9 +920,9 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
 
         assertTrue(exchange.getIn().getHeader(InfinispanConstants.RESULT, Boolean.class));
         assertEquals(VALUE_TWO, currentCache().get(KEY_ONE));
-        
+
         Thread.sleep(10000);
-        
+
         exchange = template.send("direct:get", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -949,7 +950,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Object value = currentCache().get(KEY_ONE);
         assertNull(value);
     }
-    
+
     @Test
     public void deletesExistingValueByKeyAsync() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -969,7 +970,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Object value = currentCache().get(KEY_ONE);
         assertNull(value);
     }
-    
+
     @Test
     public void deletesExistingValueByKeyWithValue() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -988,7 +989,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         Object value = currentCache().get(KEY_ONE);
         assertNull(value);
     }
-    
+
     @Test
     public void deletesExistingValueByKeyAsyncWithValue() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);
@@ -1069,7 +1070,7 @@ public class InfinispanProducerTest extends InfinispanTestSupport {
         });
         assertTrue(currentCache().isEmpty());
     }
-    
+
     @Test
     public void clearAsyncTest() throws Exception {
         currentCache().put(KEY_ONE, VALUE_ONE);

http://git-wip-us.apache.org/repos/asf/camel/blob/c7b1e905/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanTestSupport.java
b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanTestSupport.java
index e6e2223..59af67f 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanTestSupport.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanTestSupport.java
@@ -21,6 +21,9 @@ import org.apache.camel.test.junit4.CamelTestSupport;
 import org.infinispan.commons.api.BasicCache;
 import org.infinispan.commons.api.BasicCacheContainer;
 import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.util.ControlledTimeService;
+import org.infinispan.util.TimeService;
 import org.junit.Before;
 
 public class InfinispanTestSupport extends CamelTestSupport {
@@ -30,6 +33,7 @@ public class InfinispanTestSupport extends CamelTestSupport {
     protected static final String VALUE_TWO = "valueTwo";
 
     protected BasicCacheContainer basicCacheContainer;
+    protected ControlledTimeService ts;
 
     @Override
     @Before
@@ -55,4 +59,13 @@ public class InfinispanTestSupport extends CamelTestSupport {
     protected BasicCache<Object, Object> currentCache() {
         return basicCacheContainer.getCache();
     }
+
+    protected BasicCache<Object, Object> namedCache(String name) {
+        return basicCacheContainer.getCache(name);
+    }
+
+    protected void injectTimeService() {
+        ts = new ControlledTimeService(0);
+        TestingUtil.replaceComponent((DefaultCacheManager) basicCacheContainer, TimeService.class,
ts, true);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/c7b1e905/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/MyEmbeddedCustomListener.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/MyEmbeddedCustomListener.java
b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/MyEmbeddedCustomListener.java
new file mode 100644
index 0000000..1a67bfb
--- /dev/null
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/MyEmbeddedCustomListener.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.infinispan;
+
+import org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedCustomListener;
+import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
+import org.infinispan.notifications.cachelistener.event.CacheEntryEvent;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author mgencur
+ */
+@Listener(sync = true)
+public class MyEmbeddedCustomListener extends InfinispanEmbeddedCustomListener {
+
+    private final String cacheName;
+
+    public MyEmbeddedCustomListener(String cacheName) {
+        this.cacheName = cacheName;
+    }
+
+    @CacheEntryCreated
+    public void processEvent(CacheEntryEvent<Object, Object> event) {
+        if (isAccepted(event.getType().toString())) {
+            infinispanConsumer.processEvent(event.getType().toString(), event.isPre(), event.getCache().getName(),
event.getKey());
+            assertEquals(cacheName, event.getCache().getName());
+        }
+    }
+}


Mime
View raw message