ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] incubator-ignite git commit: #ignite-51: Change test for messaging.
Date Mon, 02 Mar 2015 13:55:30 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-51 f1188e032 -> c48ef793a


#ignite-51: Change test for messaging.


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

Branch: refs/heads/ignite-51
Commit: 5708509c42689103534f85e9f2c04592f15a1915
Parents: 2f43d32
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Mon Mar 2 16:53:00 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Mon Mar 2 16:53:00 2015 +0300

----------------------------------------------------------------------
 .../communication/GridCacheMessageSelfTest.java | 59 +++++++++++++-------
 1 file changed, 39 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5708509c/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
index c011bbc..9643572 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
@@ -23,14 +23,8 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest {
     /** Sample count. */
     private static final int SAMPLE_CNT = 3;
 
-    /** */
-    private static final byte DIRECT_TYPE = (byte)202;
-
-    /** */
-    private static final byte DIRECT_TYPE1 = (byte)203;
-
     static {
-        GridIoMessageFactory.registerCustom(DIRECT_TYPE, new CO<Message>() {
+        GridIoMessageFactory.registerCustom(TestMessage.DIRECT_TYPE, new CO<Message>()
{
             @Override public Message apply() {
                 return new TestMessage();
             }
@@ -42,7 +36,7 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest {
             }
         });
 
-        GridIoMessageFactory.registerCustom(DIRECT_TYPE1, new CO<Message>() {
+        GridIoMessageFactory.registerCustom(TestMessage1.DIRECT_TYPE, new CO<Message>()
{
             @Override public Message apply() {
                 return new TestMessage1();
             }
@@ -119,6 +113,9 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest {
     /** */
     private static class TestMessage extends GridCacheMessage {
         /** */
+        public static final byte DIRECT_TYPE = (byte)202;
+
+        /** */
         @GridDirectCollection(TestMessage1.class)
         private Collection<TestMessage1> entries = new ArrayList<>();
 
@@ -134,13 +131,16 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest
{
         }
 
         @Override public byte fieldsCount() {
-            return 1;
+            return 4;
         }
 
         /** {@inheritDoc} */
         @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
             writer.setBuffer(buf);
 
+            if (!super.writeTo(buf, writer))
+                return false;
+
             if (!writer.isHeaderWritten()) {
                 if (!writer.writeHeader(directType(), fieldsCount()))
                     return false;
@@ -149,11 +149,12 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest
{
             }
 
             switch (writer.state()) {
-                case 0:
+                case 3:
                     if (!writer.writeCollection("entries", entries, MessageCollectionItemType.MSG))
                         return false;
 
                     writer.incrementState();
+
             }
 
             return true;
@@ -166,41 +167,54 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest
{
             if (!reader.beforeMessageRead())
                 return false;
 
+            if (!super.readFrom(buf, reader))
+                return false;
+
             switch (reader.state()) {
-                case 0:
+                case 3:
                     entries = reader.readCollection("entries", MessageCollectionItemType.MSG);
 
                     if (!reader.isLastRead())
                         return false;
 
                     reader.incrementState();
+
             }
 
             return true;
         }
     }
 
-    private static class TestMessage1 extends GridCacheMessage {
-        GridTestMessage mes;
+    /**
+    * Test message class.
+    */
+    static class TestMessage1 extends GridCacheMessage {
+        /** */
+        public static final byte DIRECT_TYPE = (byte)203;
+        /** */
+        private Message mes;
 
-        public void init(GridTestMessage mes) {
+        public void init(Message mes) {
             this.mes = mes;
         }
 
         /** {@inheritDoc} */
         @Override public byte directType() {
-            return 0;
+            return DIRECT_TYPE;
         }
 
         /** {@inheritDoc} */
         @Override public byte fieldsCount() {
-            return 1;
+            return 4;
         }
 
         /** {@inheritDoc} */
         @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
             writer.setBuffer(buf);
 
+            if (!super.writeTo(buf, writer))
+                return false;
+
             if (!writer.isHeaderWritten()) {
                 if (!writer.writeHeader(directType(), fieldsCount()))
                     return false;
@@ -209,11 +223,12 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest
{
             }
 
             switch (writer.state()) {
-                case 0:
-                    if (!mes.writeTo(buf, writer))
+                case 3:
+                    if (!writer.writeMessage("mes", mes))
                         return false;
 
                     writer.incrementState();
+
             }
 
             return true;
@@ -226,14 +241,18 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest
{
             if (!reader.beforeMessageRead())
                 return false;
 
+            if (!super.readFrom(buf, reader))
+                return false;
+
             switch (reader.state()) {
-                case 0:
-                    mes.readFrom(buf, reader);
+                case 3:
+                    mes = reader.readMessage("mes");
 
                     if (!reader.isLastRead())
                         return false;
 
                     reader.incrementState();
+
             }
 
             return true;


Mime
View raw message