Update OF header lenght
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / PortModInputMessageFactoryTest.java
index 8b5f8bfaa0bda83a8cabcdd049d0d29f62325e95..f9319019170e0be2c76f9cb3c64e534420952324 100644 (file)
@@ -10,18 +10,17 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.UnpooledByteBufAllocator;
-import junit.framework.Assert;
-
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
@@ -54,7 +53,7 @@ public class PortModInputMessageFactoryTest {
 
     /**
      * Testing of {@link PortModInputMessageFactory} for correct translation from POJO
-     * @throws Exception 
+     * @throws Exception
      */
     @Test
     public void testPortModInput() throws Exception {
@@ -65,14 +64,25 @@ public class PortModInputMessageFactoryTest {
         builder.setConfig(new PortConfig(true, false, true, false));
         builder.setMask(new PortConfig(false, true, false, true));
         builder.setAdvertise(new PortFeatures(true, false, false, false,
-                                              false, false, false, true, 
-                                              false, false, false, false, 
+                                              false, false, false, true,
+                                              false, false, false, false,
                                               false, false, false, false));
         PortModInput message = builder.build();
-        
+
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+
+        // simulate parent message
+        out.writeInt(1);
+        out.writeZero(2);
+        out.writeShort(3);
+
         portModFactory.serialize(message, out);
-        
+
+        // read parent message
+        out.readInt();
+        out.skipBytes(2);
+        out.readShort();
+
         BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
         Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());
         out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);
@@ -94,7 +104,7 @@ public class PortModInputMessageFactoryTest {
         final Boolean _noPacketIn = ((input) & (1<<6)) > 0;
         return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
     }
-    
+
     private static PortFeatures createPortFeatures(long input){
         final Boolean _10mbHd = ((input) & (1<<0)) > 0;
         final Boolean _10mbFd = ((input) & (1<<1)) > 0;
@@ -112,8 +122,8 @@ public class PortModInputMessageFactoryTest {
         final Boolean _autoneg = ((input) & (1<<13)) > 0;
         final Boolean _pause = ((input) & (1<<14)) > 0;
         final Boolean _pauseAsym = ((input) & (1<<15)) > 0;
-        return new PortFeatures(_100gbFd, _100mbFd,  _100mbHd, _10gbFd, _10mbFd, _10mbHd, 
+        return new PortFeatures(_100gbFd, _100mbFd,  _100mbHd, _10gbFd, _10mbFd, _10mbHd,
                 _1gbFd, _1gbHd, _1tbFd, _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym);
     }
-    
+
 }