ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [19/19] incubator-ignite git commit: ignite-471-2: fixed grid messaging tests
Date Wed, 20 May 2015 10:02:36 GMT
ignite-471-2: fixed grid messaging tests


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

Branch: refs/heads/ignite-471-2
Commit: 19d3aac7c878255639dbc30a163699b6883b2b00
Parents: 490a252
Author: Denis Magda <dmagda@gridgain.com>
Authored: Wed May 20 12:47:49 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Wed May 20 12:47:49 2015 +0300

----------------------------------------------------------------------
 ...GridMessagingNoPeerClassLoadingSelfTest.java | 70 ++++++++++++++------
 1 file changed, 48 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/19d3aac7/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java
index 610ce64..b6a775f 100644
--- a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java
@@ -17,8 +17,10 @@
 
 package org.apache.ignite.messaging;
 
+import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.resources.*;
 import org.apache.ignite.testframework.config.*;
 
 import java.net.*;
@@ -54,37 +56,61 @@ public class GridMessagingNoPeerClassLoadingSelfTest extends GridMessagingSelfTe
 
         Class rcCls = extLdr.loadClass(EXT_RESOURCE_CLS_NAME);
 
+        MessageListener list = new MessageListener(ignite1);
+
+        ignite2.message().remoteListen("", list);
+
+        message(ignite1.cluster().forRemotes()).send(null, Collections.singleton(rcCls.newInstance()));
+
+        /*
+            We shouldn't get a message, because remote node won't be able to
+            unmarshal it (peer class loading is disabled.)
+         */
+        assertFalse(list.rcvLatch.await(3, TimeUnit.SECONDS));
+    }
+
+    /**
+     *
+     */
+    private static class MessageListener<UUID, Object> implements P2<UUID, Object>
{
+        /** */
         final AtomicBoolean error = new AtomicBoolean(false); //to make it modifiable
 
+        /** */
         final CountDownLatch rcvLatch = new CountDownLatch(1);
 
-        ignite2.message().remoteListen("", new P2<UUID, Object>() {
-            @Override public boolean apply(UUID nodeId, Object msg) {
-                try {
-                    log.info("Received new message [msg=" + msg + ", senderNodeId=" + nodeId
+ ']');
+        /** */
+        final Ignite sender;
 
-                    if (!nodeId.equals(ignite1.cluster().localNode().id())) {
-                        log.error("Unexpected sender node: " + nodeId);
+        /** */
+        @LoggerResource
+        private transient IgniteLogger log;
 
-                        error.set(true);
+        /**
+         * @param sender
+         */
+        private MessageListener(Ignite sender) {
+            this.sender = sender;
+        }
 
-                        return false;
-                    }
+        /** {@inheritDoc} */
+        @Override public boolean apply(UUID nodeId, Object msg) {
+            try {
+                log.info("Received new message [msg=" + msg + ", senderNodeId=" + nodeId
+ ']');
 
-                    return true;
-                }
-                finally {
-                    rcvLatch.countDown();
-                }
-            }
-        });
+                if (!nodeId.equals(sender.cluster().localNode().id())) {
+                    log.error("Unexpected sender node: " + nodeId);
 
-        message(ignite1.cluster().forRemotes()).send(null, Collections.singleton(rcCls.newInstance()));
+                    error.set(true);
 
-        /*
-            We shouldn't get a message, because remote node won't be able to
-            unmarshal it (peer class loading is disabled.)
-         */
-        assertFalse(rcvLatch.await(3, TimeUnit.SECONDS));
+                    return false;
+                }
+
+                return true;
+            }
+            finally {
+                rcvLatch.countDown();
+            }
+        }
     }
 }


Mime
View raw message