Match and actions (de)serialization + fix
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / GroupModInputMessageFactoryTest.java
index bc5950fda4793cb599b967ed25fc1cc05580e1df..d42d52553bf34a2cdf7e72b95e74ba0b363799d4 100644 (file)
@@ -7,8 +7,7 @@ import io.netty.buffer.UnpooledByteBufAllocator;
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
-import junit.framework.Assert;\r
-\r
+import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
@@ -17,8 +16,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.group.mod.BucketsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.group.mod.BucketsListBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsListBuilder;\r
 \r
 /**\r
  * @author timotej.kubas\r
@@ -38,7 +37,8 @@ public class GroupModInputMessageFactoryTest {
         builder.setCommand(GroupModCommand.forValue(2));\r
         builder.setType(GroupType.forValue(3));\r
         builder.setGroupId(256L);\r
-        builder.setBucketsList(createBucketsList());\r
+        List<BucketsList> exp = createBucketsList();\r
+        builder.setBucketsList(exp);\r
         GroupModInput message = builder.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
@@ -46,11 +46,12 @@ public class GroupModInputMessageFactoryTest {
         factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
         \r
         BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readByte());\r
+        Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort());\r
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte());\r
         out.skipBytes(PADDING_IN_GROUP_MOD_MESSAGE);\r
         Assert.assertEquals("Wrong groupId", message.getGroupId().intValue(), out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong bucketList", createBucketsList(), createBucketsListFromBufer(out));\r
+        List<BucketsList> rec = createBucketsListFromBufer(out);\r
+        Assert.assertArrayEquals("Wrong bucketList", exp.toArray(), rec.toArray());\r
     }\r
     \r
     private static List<BucketsList> createBucketsList(){\r
@@ -69,7 +70,8 @@ public class GroupModInputMessageFactoryTest {
         List<BucketsList> bucketsList = new ArrayList<>();\r
         BucketsListBuilder bucketsBuilder = new BucketsListBuilder();\r
         BucketsList bucket;\r
-        bucketsBuilder.setWeight((int) out.readShort());\r
+        out.skipBytes(Short.SIZE / Byte.SIZE);\r
+        bucketsBuilder.setWeight(out.readUnsignedShort());\r
         bucketsBuilder.setWatchPort(new PortNumber(out.readUnsignedInt()));\r
         bucketsBuilder.setWatchGroup(out.readUnsignedInt());\r
         out.skipBytes(4);\r