Copyright update
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / OF10QueueGetConfigInputMessageFactoryTest.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.util.BufferHelper;
17 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;
21
22 /**
23  * @author michal.polkorab
24  *
25  */
26 public class OF10QueueGetConfigInputMessageFactoryTest {
27
28     /**
29      * Testing of {@link OF10QueueGetConfigInputMessageFactory} for correct translation from POJO
30      * @throws Exception 
31      */
32     @Test
33     public void test() throws Exception {
34         GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
35         BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
36         builder.setPort(new PortNumber(6653L));
37         GetQueueConfigInput message = builder.build();
38         
39         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
40         OF10QueueGetConfigInputMessageFactory factory = OF10QueueGetConfigInputMessageFactory.getInstance();
41         factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
42         
43         BufferHelper.checkHeaderV10(out, (byte) 20, 12);
44         Assert.assertEquals("Wrong port", 6653L, out.readUnsignedShort());
45         out.skipBytes(2);
46     }
47
48 }