X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fserialization%2Ffactories%2FPacketOutInputMessageFactoryTest.java;h=5da3a53d8ed62f84ff5be28b911851cbe27462d2;hb=07de1ed897da9d7dc70c6d550f38c59339ed751e;hp=394e70c2a41de97c66c15845c7fc89e960abc96e;hpb=37cf2e565f6ec0f86f65b35898091fcf279753a5;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index 394e70c2..5da3a53d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -59,7 +59,7 @@ public class PacketOutInputMessageFactoryTest { /** * Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testPacketOutInputMessage() throws Exception { @@ -80,10 +80,10 @@ public class PacketOutInputMessageFactoryTest { 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.checkHeaderV13(out, MESSAGE_TYPE, 56); Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), out.readUnsignedInt()); Assert.assertEquals("Wrong PortNumber", message.getInPort().getValue().longValue(), out.readUnsignedInt()); @@ -98,4 +98,27 @@ public class PacketOutInputMessageFactoryTest { out.skipBytes(PADDING_IN_ACTION_HEADER); Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array()); } -} + + /** + * Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO + * @throws Exception + */ + @Test + public void testPacketOutInputWithNoData() throws Exception { + PacketOutInputBuilder builder = new PacketOutInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setBufferId(256L); + builder.setInPort(new PortNumber(256L)); + List actions = new ArrayList<>(); + builder.setAction(actions); + builder.setData(null); + PacketOutInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + packetOutFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 24); + out.skipBytes(16); // skip packet out message to data index + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file