ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [37/39] incubator-ignite git commit: ignite-45 - Fixed listeners test.
Date Mon, 16 Mar 2015 05:33:41 GMT
ignite-45 - Fixed listeners test.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3df716d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3df716d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3df716d9

Branch: refs/heads/ignite-45
Commit: 3df716d94e1c9f7d254e68cbbbcf7ca7cd49656d
Parents: afe27c7
Author: Alexey Goncharuk <agoncharuk@gridgain.com>
Authored: Sun Mar 15 22:20:47 2015 -0700
Committer: Alexey Goncharuk <agoncharuk@gridgain.com>
Committed: Sun Mar 15 22:20:47 2015 -0700

----------------------------------------------------------------------
 .../IgniteCacheEntryListenerAbstractTest.java   | 191 ++++++++++++-------
 1 file changed, 123 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3df716d9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
index 66892ea..b07493d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
@@ -283,11 +283,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
             return;
 
         lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
-            new Factory<CacheEntryListener<Integer, Integer>>() {
-                @Override public CacheEntryListener<Integer, Integer> create() {
-                    return new NoOpCreateUpdateListener();
-                }
-            },
+            new NoOpCreateUpdateListenerFactory(),
             null,
             true,
             true
@@ -382,34 +378,6 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
      * @throws Exception If failed.
      */
     public void testEvents() throws Exception {
-        CacheEntryCreatedListener<Integer, Integer> createLsnr = new CacheEntryCreatedListener<Integer,
Integer>() {
-            @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
-                for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
-                    onEvent(evt);
-            }
-        };
-
-        CacheEntryUpdatedListener<Integer, Integer> updateLsnr = new CacheEntryUpdatedListener<Integer,
Integer>() {
-            @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
-                for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
-                    onEvent(evt);
-            }
-        };
-
-        CacheEntryRemovedListener<Integer, Integer> rmvLsnr = new CacheEntryRemovedListener<Integer,
Integer>() {
-            @Override public void onRemoved(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
-                for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
-                    onEvent(evt);
-            }
-        };
-
-        CacheEntryExpiredListener<Integer, Integer> expireLsnr = new CacheEntryExpiredListener<Integer,
Integer>() {
-            @Override public void onExpired(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
-                for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
-                    onEvent(evt);
-            }
-        };
-
         IgniteCache<Integer, Integer> cache = jcache();
 
         Map<Integer, Integer> vals = new HashMap<>();
@@ -422,35 +390,31 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
         for (Integer key : keys()) {
             log.info("Check create event [key=" + key + ']');
 
-            checkEvents(cache, createLsnr, key, true, false, false, false);
+            checkEvents(cache, new CreateListenerFactory(), key, true, false, false, false);
 
             log.info("Check update event [key=" + key + ']');
 
-            checkEvents(cache, updateLsnr, key, false, true, false, false);
+            checkEvents(cache, new UpdateListenerFactory(), key, false, true, false, false);
 
             log.info("Check remove event [key=" + key + ']');
 
-            checkEvents(cache, rmvLsnr, key, false, false, true, false);
+            checkEvents(cache, new RemoveListenerFactory(), key, false, false, true, false);
 
             log.info("Check expire event [key=" + key + ']');
 
-            checkEvents(cache, expireLsnr, key, false, false, false, true);
+            checkEvents(cache, new ExpireListenerFactory(), key, false, false, false, true);
 
             log.info("Check create/update events [key=" + key + ']');
 
-            checkEvents(cache, new CreateUpdateListener(), key, true, true, false, false);
+            checkEvents(cache, new CreateUpdateListenerFactory(), key, true, true, false,
false);
 
             log.info("Check create/update/remove/expire events [key=" + key + ']');
 
-            checkEvents(cache, new CreateUpdateRemoveExpireListener(), key, true, true, true,
true);
+            checkEvents(cache, new CreateUpdateRemoveExpireListenerFactory(), key, true,
true, true, true);
         }
 
         CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
-            new Factory<CacheEntryListener<Integer, Integer>>() {
-                @Override public CacheEntryListener<Integer, Integer> create() {
-                    return new CreateUpdateRemoveExpireListener();
-                }
-            },
+            new CreateUpdateRemoveExpireListenerFactory(),
             new TestFilterFactory(),
             true,
             false
@@ -484,11 +448,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
     @SuppressWarnings("unchecked")
     private void checkListenerOnStart(Map<Integer, Integer> vals) throws Exception
{
         lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
-            new Factory<CacheEntryListener<Integer, Integer>>() {
-                @Override public CacheEntryListener<Integer, Integer> create() {
-                    return new CreateUpdateRemoveExpireListener();
-                }
-            },
+            new CreateUpdateRemoveExpireListenerFactory(),
             null,
             true,
             false
@@ -512,11 +472,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
         }
 
         lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
-            new Factory<CacheEntryListener<Integer, Integer>>() {
-                @Override public CacheEntryListener<Integer, Integer> create() {
-                    return new CreateUpdateRemoveExpireListener();
-                }
-            },
+            new CreateUpdateRemoveExpireListenerFactory(),
             new TestFilterFactory(),
             true,
             false
@@ -543,7 +499,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
 
     /**
      * @param cache Cache.
-     * @param lsnr Listener.
+     * @param lsnrFactory Listener factory.
      * @param key Key.
      * @param create {@code True} if listens for create events.
      * @param update {@code True} if listens for update events.
@@ -553,18 +509,14 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
      */
     private void checkEvents(
         final IgniteCache<Integer, Integer> cache,
-        final CacheEntryListener<Integer, Integer> lsnr,
+        final Factory<CacheEntryListener<Integer, Integer>> lsnrFactory,
         Integer key,
         boolean create,
         boolean update,
         boolean rmv,
         boolean expire) throws Exception {
         CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
-            new Factory<CacheEntryListener<Integer, Integer>>() {
-                @Override public CacheEntryListener<Integer, Integer> create() {
-                    return lsnr;
-                }
-            },
+            lsnrFactory,
             null,
             true,
             false
@@ -936,7 +888,70 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
     /**
      *
      */
-    static class TestFilterFactory implements Factory<CacheEntryEventFilter<Integer,
Integer>> {
+    private static class CreateUpdateRemoveExpireListenerFactory implements Factory<CacheEntryListener<Integer,
Integer>> {
+        @Override public CacheEntryListener<Integer, Integer> create() {
+            return new CreateUpdateRemoveExpireListener();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NoOpCreateUpdateListenerFactory implements Factory<CacheEntryListener<Integer,
Integer>> {
+        @Override public CacheEntryListener<Integer, Integer> create() {
+            return new NoOpCreateUpdateListener();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CreateUpdateListenerFactory implements Factory<CacheEntryListener<Integer,
Integer>> {
+        @Override public CacheEntryListener<Integer, Integer> create() {
+            return new CreateUpdateListener();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CreateListenerFactory implements Factory<CacheEntryListener<Integer,
Integer>> {
+        @Override public CacheEntryListener<Integer, Integer> create() {
+            return new CreateListener();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveListenerFactory implements Factory<CacheEntryListener<Integer,
Integer>> {
+        @Override public CacheEntryListener<Integer, Integer> create() {
+            return new RemoveListener();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class UpdateListenerFactory implements Factory<CacheEntryListener<Integer,
Integer>> {
+        @Override public CacheEntryListener<Integer, Integer> create() {
+            return new UpdateListener();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ExpireListenerFactory implements Factory<CacheEntryListener<Integer,
Integer>> {
+        @Override public CacheEntryListener<Integer, Integer> create() {
+            return new ExpireListener();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class TestFilterFactory implements Factory<CacheEntryEventFilter<Integer,
Integer>> {
         /** {@inheritDoc} */
         @Override public CacheEntryEventFilter<Integer, Integer> create() {
             return new TestFilter();
@@ -946,7 +961,47 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
     /**
      *
      */
-    static class TestFilter implements CacheEntryEventFilter<Integer, Integer> {
+    private static class CreateListener implements CacheEntryCreatedListener<Integer,
Integer> {
+        @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
+            for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+                onEvent(evt);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class UpdateListener implements CacheEntryUpdatedListener<Integer,
Integer> {
+        @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
+            for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+                onEvent(evt);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveListener implements CacheEntryRemovedListener<Integer,
Integer> {
+        @Override public void onRemoved(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
+            for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+                onEvent(evt);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ExpireListener implements CacheEntryExpiredListener<Integer,
Integer> {
+        @Override public void onExpired(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
+            for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+                onEvent(evt);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class TestFilter implements CacheEntryEventFilter<Integer, Integer>
{
         /** {@inheritDoc} */
         @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends
Integer> evt) {
             assert evt != null;
@@ -961,7 +1016,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
     /**
      *
      */
-    static class CreateUpdateListener implements CacheEntryCreatedListener<Integer, Integer>,
+    private static class CreateUpdateListener implements CacheEntryCreatedListener<Integer,
Integer>,
         CacheEntryUpdatedListener<Integer, Integer> {
         /** {@inheritDoc} */
         @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
@@ -979,7 +1034,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
     /**
      *
      */
-    static class NoOpCreateUpdateListener implements CacheEntryCreatedListener<Integer,
Integer>,
+    private static class NoOpCreateUpdateListener implements CacheEntryCreatedListener<Integer,
Integer>,
         CacheEntryUpdatedListener<Integer, Integer> {
         /** {@inheritDoc} */
         @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
@@ -1005,7 +1060,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
     /**
      *
      */
-    static class CreateUpdateRemoveExpireListener extends CreateUpdateListener
+    private static class CreateUpdateRemoveExpireListener extends CreateUpdateListener
         implements CacheEntryRemovedListener<Integer, Integer>, CacheEntryExpiredListener<Integer,
Integer> {
         /** {@inheritDoc} */
         @Override public void onRemoved(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {
@@ -1023,7 +1078,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
     /**
      *
      */
-    static class ExceptionFilter implements CacheEntryEventFilter<Integer, Integer>
{
+    private static class ExceptionFilter implements CacheEntryEventFilter<Integer, Integer>
{
         /** {@inheritDoc} */
         @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends
Integer> evt) {
             throw new RuntimeException("Test filter error.");
@@ -1033,7 +1088,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
     /**
      *
      */
-    static class ExceptionListener extends CreateUpdateListener
+    private static class ExceptionListener extends CreateUpdateListener
         implements CacheEntryRemovedListener<Integer, Integer>, CacheEntryExpiredListener<Integer,
Integer> {
         /** {@inheritDoc} */
         @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer,
? extends Integer>> evts) {


Mime
View raw message