Renamed packages to org.opendaylight.openflowjava.protocol.impl.*
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / EchoRequestMessageFactoryTest.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.deserialization.factories.EchoRequestMessageFactory;\r
9 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
11 \r
12 /**\r
13  * @author michal.polkorab\r
14  *\r
15  */\r
16 public class EchoRequestMessageFactoryTest {\r
17 \r
18     /**\r
19      * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
20      */\r
21     @Test\r
22     public void testWithEmptyDataField() {\r
23         ByteBuf bb = BufferHelper.buildBuffer(new byte[0]);\r
24         EchoRequestMessage builtByFactory = EchoRequestMessageFactory.getInstance().bufferToMessage(bb, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
25 \r
26         Assert.assertTrue(builtByFactory.getVersion() == HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
27         Assert.assertEquals(builtByFactory.getXid().longValue(), 16909060L);\r
28     }\r
29     \r
30     /**\r
31      * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
32      */\r
33     @Test\r
34     public void testWithDataFieldSet() {\r
35         byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};\r
36         ByteBuf bb = BufferHelper.buildBuffer(data);\r
37         EchoRequestMessage builtByFactory = EchoRequestMessageFactory.getInstance().bufferToMessage(bb, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
38 \r
39         Assert.assertTrue(builtByFactory.getVersion() == HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
40         Assert.assertEquals(builtByFactory.getXid().longValue(), 16909060L);\r
41     }\r
42 \r
43 }\r