new serialization factories and tests
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / FlowRemovedMessageFactoryTest.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
2 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
3 \r
4 import io.netty.buffer.ByteBuf;\r
5 \r
6 import org.junit.Assert;\r
7 import org.junit.Test;\r
8 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;\r
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;\r
11 \r
12 /**\r
13  * @author timotej.kubas\r
14  * @author michal.polkorab\r
15  */\r
16 public class FlowRemovedMessageFactoryTest {\r
17 \r
18     /**\r
19      * Testing {@link FlowRemovedMessageFactory} for correct translation into POJO\r
20      */\r
21     @Test\r
22     public void test(){\r
23         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 03 02 04 00 00 00 02"\r
24                 + " 00 00 00 05 00 01 00 03 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07");\r
25         FlowRemovedMessage builtByFactory = BufferHelper.decodeV13(FlowRemovedMessageFactory.getInstance(), bb);\r
26 \r
27         BufferHelper.checkHeaderV13(builtByFactory);\r
28         \r
29         Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L);\r
30         Assert.assertTrue(builtByFactory.getPriority() == 0x03);\r
31         Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue());\r
32         Assert.assertEquals("Wrong tableId", new TableId(4L), builtByFactory.getTableId());\r
33         Assert.assertEquals("Wrong durationSec", 0x02L, builtByFactory.getDurationSec().longValue());\r
34         Assert.assertEquals("Wrong durationNsec", 0x05L, builtByFactory.getDurationNsec().longValue());\r
35         Assert.assertEquals("Wrong idleTimeout", 0x01, builtByFactory.getIdleTimeout().intValue());\r
36         Assert.assertEquals("Wrong hardTimeout", 0x03, builtByFactory.getHardTimeout().intValue());\r
37         Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue());\r
38         Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue());\r
39     }\r
40     \r
41 }\r