OF1.0 fixes
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / OF10PacketInMessageFactoryTest.java
1 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
2 \r
3 import io.netty.buffer.ByteBuf;\r
4 \r
5 import org.junit.Assert;\r
6 import org.junit.Test;\r
7 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
8 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\r
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;\r
11 \r
12 public class OF10PacketInMessageFactoryTest {\r
13 \r
14         /**\r
15      * Testing {@link OF10PacketInMessageFactory} for correct translation into POJO\r
16      */\r
17     @Test\r
18     public void test(){\r
19         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00 01 02 03 04");\r
20         PacketInMessage builtByFactory = BufferHelper.decodeV10(OF10PacketInMessageFactory.getInstance(), bb); \r
21         \r
22         BufferHelper.checkHeaderV10(builtByFactory);\r
23         Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());\r
24         Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());\r
25         Assert.assertEquals("Wrong inPort", 0x0102, builtByFactory.getInPort().intValue());\r
26         Assert.assertEquals("Wrong reason", PacketInReason.OFPRNOMATCH, builtByFactory.getReason());\r
27         Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());\r
28     }\r
29 \r
30 }\r