Copyright update
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / GetQueueConfigInputMessageFactoryTest.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
10
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.UnpooledByteBufAllocator;
13 import junit.framework.Assert;
14
15 import org.junit.Test;
16 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
17 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
18 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;
22
23 /**
24  * @author timotej.kubas
25  * @author michal.polkorab
26  */
27 public class GetQueueConfigInputMessageFactoryTest {
28     private static final byte GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE = 22;
29     private static final byte PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE = 4;
30     
31     /**
32      * Testing of {@link GetQueueConfigInputMessageFactory} for correct translation from POJO
33      * @throws Exception 
34      */
35     @Test
36     public void testGetQueueConfigInputMessage() throws Exception {
37         GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
38         BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
39         builder.setPort(new PortNumber(0x00010203L));
40         GetQueueConfigInput message = builder.build();
41         
42         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
43         GetQueueConfigInputMessageFactory factory = GetQueueConfigInputMessageFactory.getInstance();
44         factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
45         
46         BufferHelper.checkHeaderV13(out, GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE, 16);
47         Assert.assertEquals("Wrong port", 0x00010203, out.readUnsignedInt());
48         out.skipBytes(PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE);
49     }
50 }