Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / OF10PacketOutInputMessageFactoryTest.java
index 7af7384daab5f4d4a4178e596d422ebbc86cef18..791d5681c1d2b3fd89d4139fd0adee2e81bb4a33 100644 (file)
@@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
@@ -58,7 +58,7 @@ public class OF10PacketOutInputMessageFactoryTest {
 
     /**
      * Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO
-     * @throws Exception 
+     * @throws Exception
      */
     @Test
     public void testPacketOutInputMessage() throws Exception {
@@ -83,10 +83,10 @@ public class OF10PacketOutInputMessageFactoryTest {
         builder.setAction(actions);
         builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));
         PacketOutInput message = builder.build();
-        
+
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         packetOutFactory.serialize(message, out);
-        
+
         BufferHelper.checkHeaderV10(out, (byte) 13, 48);
         Assert.assertEquals("Wrong BufferId", 256, out.readUnsignedInt());
         Assert.assertEquals("Wrong PortNumber", 257, out.readUnsignedShort());
@@ -102,4 +102,26 @@ public class OF10PacketOutInputMessageFactoryTest {
         Assert.assertTrue("Unread data", out.readableBytes() == 0);
     }
 
-}
+    /**
+     * Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO
+     * @throws Exception
+     */
+    @Test
+    public void testPacketOutInputWithNoData() throws Exception {
+        PacketOutInputBuilder builder = new PacketOutInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setBufferId(256L);
+        builder.setInPort(new PortNumber(257L));
+        List<Action> actions = new ArrayList<>();
+        builder.setAction(actions);
+        builder.setData(null);
+        PacketOutInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        packetOutFactory.serialize(message, out);
+
+        BufferHelper.checkHeaderV10(out, (byte) 13, 16);
+        out.skipBytes(8); // skip packet out message to data index
+        Assert.assertTrue("Unread data", out.readableBytes() == 0);
+    }
+}
\ No newline at end of file