You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/02/14 13:11:36 UTC
[17/34] ignite git commit: IGNITE-3727 update test, added 2 new cases
IGNITE-3727 update test, added 2 new cases
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/190a5c99
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/190a5c99
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/190a5c99
Branch: refs/heads/ignite-3727-2
Commit: 190a5c99fae2fe16afea5a59ba5fd6ca6aef900c
Parents: 8b416e8
Author: DmitriyGovorukhin <dg...@gridgain.com>
Authored: Fri Sep 9 12:26:24 2016 +0300
Committer: DmitriyGovorukhin <dg...@gridgain.com>
Committed: Fri Sep 9 12:26:24 2016 +0300
----------------------------------------------------------------------
.../messaging/IgniteMessagingSendAsyncTest.java | 83 ++++++++++++++++++--
1 file changed, 75 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/190a5c99/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java
index 6f1188e..91ac6e2 100644
--- a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java
@@ -33,7 +33,9 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest {
/**
* Ignite instance for test.
*/
- private Ignite ignite;
+ private Ignite ignite1;
+
+ private Ignite ignite2;
/**
* Topic name.
@@ -47,7 +49,8 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest {
protected void beforeTest() throws Exception {
super.beforeTest();
- ignite = startGrid(0);
+ ignite1 = startGrid(1);
+ ignite2 = startGrid(2);
}
/**
@@ -57,17 +60,19 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest {
protected void afterTest() throws Exception {
super.afterTest();
- stopGrid(0);
+ stopAllGrids();
}
/**
* Test for check, that if use default mode, local listeners execute
- * in the same thread.
+ * in the same thread. 1 node in topology.
*/
public void testSendDefaultMode() throws InterruptedException {
+ stopGrid(2);
+
final String msgStr = "message";
- send(ignite.message(), msgStr, new ProcedureApply() {
+ send(ignite1.message(), msgStr, new ProcedureApply() {
@Override
public void apply(String msg, Thread thread) {
Assert.assertEquals(Thread.currentThread(), thread);
@@ -79,12 +84,46 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest {
/**
* Test for check, that if use async mode, local listeners execute
- * in another thread(through pool).
+ * in another thread(through pool). 1 node in topology.
*/
public void testSendAsyncMode() throws InterruptedException {
+ stopGrid(2);
+
+ final String msgStr = "message";
+
+ send(ignite1.message().withAsync(), msgStr, new ProcedureApply() {
+ @Override
+ public void apply(String msg, Thread thread) {
+ Assert.assertTrue(!Thread.currentThread().equals(thread));
+ Assert.assertEquals(msgStr, msg);
+ }
+ });
+ }
+
+ /**
+ * Test for check, that if use default mode, local listeners execute
+ * in the same thread. 2 node in topology.
+ */
+ public void testSendDefaultMode2Node() throws Exception {
+ final String msgStr = "message";
+
+ sendWith2Node(ignite1.message(), msgStr, new ProcedureApply() {
+ @Override
+ public void apply(String msg, Thread thread) {
+ Assert.assertEquals(Thread.currentThread(), thread);
+ Assert.assertEquals(msgStr, msg);
+ }
+ });
+ }
+
+ /**
+ * Test for check, that if use async mode, local listeners execute
+ * in another thread(through pool). 2 node in topology.
+ */
+ public void testSendAsyncMode2Node() throws Exception {
final String msgStr = "message";
- send(ignite.message().withAsync(), msgStr, new ProcedureApply() {
+ sendWith2Node(ignite1.message().withAsync(), msgStr, new ProcedureApply() {
@Override
public void apply(String msg, Thread thread) {
Assert.assertTrue(!Thread.currentThread().equals(thread));
@@ -96,7 +135,35 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest {
/**
* @param igniteMsg Ignite message.
* @param msgStr Message string.
- * @param cls callback for compare result.
+ * @param cls Callback for compare result.
+ */
+ public void sendWith2Node(
+ final IgniteMessaging igniteMsg,
+ final String msgStr,
+ final ProcedureApply cls
+ ) throws Exception {
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ ignite2.message().localListen(TOPIC, new IgniteBiPredicate<UUID, String>() {
+ @Override
+ public boolean apply(UUID uuid, String msg) {
+ Assert.assertEquals(msgStr, msg);
+ latch.countDown();
+ return false;
+ }
+ });
+
+ send(igniteMsg, msgStr, cls);
+
+ latch.await();
+ }
+
+
+ /**
+ * @param igniteMsg Ignite message.
+ * @param msgStr Message string.
+ * @param cls Callback for compare result.
*/
private void send(
IgniteMessaging igniteMsg,