0f2a54199db5c97f1770b7a8ca834346d47925ef
[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 static org.junit.Assert.*;
5 import junit.framework.Assert;
6 import io.netty.buffer.ByteBuf;
7 import io.netty.buffer.UnpooledByteBufAllocator;
8
9 import org.junit.Test;
10 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
11 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
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
22     private static final byte GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE = 22;
23     private static final byte PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE = 4;
24     
25     @Test
26     public void testWithElements() throws Exception {
27         GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
28         BufferHelper.setupHeader(builder);
29         builder.setPort(new PortNumber(0x00010203L));
30         GetQueueConfigInput message = builder.build();
31         
32         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
33         GetQueueConfigInputMessageFactory factory = GetQueueConfigInputMessageFactory.getInstance();
34         factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
35         
36         BufferHelper.checkHeaderV13(out, GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE, 16);
37         Assert.assertEquals("Wrong port", 0x00010203, out.readUnsignedInt());
38         out.skipBytes(PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE);
39     }
40         
41 }