Error code support for ErrorMessage
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / GetQueueConfigInputMessageFactoryTest.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
3
4 import io.netty.buffer.ByteBuf;
5 import io.netty.buffer.UnpooledByteBufAllocator;
6 import junit.framework.Assert;
7
8 import org.junit.Test;
9 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
10 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
11 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;
15
16 /**
17  * @author timotej.kubas
18  * @author michal.polkorab
19  */
20 public class GetQueueConfigInputMessageFactoryTest {
21     private static final byte GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE = 22;
22     private static final byte PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE = 4;
23     
24     /**
25      * Testing of {@link GetQueueConfigInputMessageFactory} for correct translation from POJO
26      * @throws Exception 
27      */
28     @Test
29     public void testGetQueueConfigInputMessage() throws Exception {
30         GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
31         BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
32         builder.setPort(new PortNumber(0x00010203L));
33         GetQueueConfigInput message = builder.build();
34         
35         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
36         GetQueueConfigInputMessageFactory factory = GetQueueConfigInputMessageFactory.getInstance();
37         factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
38         
39         BufferHelper.checkHeaderV13(out, GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE, 16);
40         Assert.assertEquals("Wrong port", 0x00010203, out.readUnsignedInt());
41         out.skipBytes(PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE);
42     }
43 }