Remove trailing whitespace
[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 org.junit.Assert;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
17 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
18 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
19 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
20 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
21 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;
25
26 /**
27  * @author michal.polkorab
28  *
29  */
30 public class OF10QueueGetConfigInputMessageFactoryTest {
31
32     private SerializerRegistry registry;
33     private OFSerializer<GetQueueConfigInput> queueFactory;
34
35     /**
36      * Initializes serializer registry and stores correct factory in field
37      */
38     @Before
39     public void startUp() {
40         registry = new SerializerRegistryImpl();
41         registry.init();
42         queueFactory = registry.getSerializer(
43                 new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, GetQueueConfigInput.class));
44     }
45
46     /**
47      * Testing of {@link OF10QueueGetConfigInputMessageFactory} for correct translation from POJO
48      * @throws Exception
49      */
50     @Test
51     public void test() throws Exception {
52         GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
53         BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
54         builder.setPort(new PortNumber(6653L));
55         GetQueueConfigInput message = builder.build();
56
57         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
58         queueFactory.serialize(message, out);
59
60         BufferHelper.checkHeaderV10(out, (byte) 20, 12);
61         Assert.assertEquals("Wrong port", 6653L, out.readUnsignedShort());
62         out.skipBytes(2);
63     }
64
65 }