a7de110d04318a7f5becd0f65015be46b14f35de
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / ExperimenterInputMessageFactoryTest.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
3 \r
4 import io.netty.buffer.ByteBuf;\r
5 import io.netty.buffer.UnpooledByteBufAllocator;\r
6 \r
7 import org.junit.Assert;\r
8 import org.junit.Test;\r
9 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
10 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;\r
13 \r
14 /**\r
15  * @author michal.polkorab\r
16  *\r
17  */\r
18 public class ExperimenterInputMessageFactoryTest {\r
19 \r
20     private static final byte EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE = ExperimenterInputMessageFactory.MESSAGE_TYPE;\r
21     \r
22     /**\r
23      * Testing of {@link ExperimenterInputMessageFactory} for correct translation from POJO\r
24      * @throws Exception \r
25      */\r
26     @Test\r
27     public void test() throws Exception {\r
28         ExperimenterInputBuilder eib = new ExperimenterInputBuilder();\r
29         BufferHelper.setupHeader(eib);\r
30         eib.setExperimenter(0x0001020304L);\r
31         eib.setExpType(0x0001020304L);\r
32         ExperimenterInput ei = eib.build();\r
33         \r
34         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
35         ExperimenterInputMessageFactory eimf = ExperimenterInputMessageFactory.getInstance();\r
36         eimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, ei);\r
37         \r
38         BufferHelper.checkHeaderV13(out, EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE, 16);\r
39         Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());\r
40         Assert.assertEquals("Wrong expType", 0x0001020304L, out.readUnsignedInt());\r
41     }\r
42 \r
43 \r
44 }\r