Remove trailing whitespace
[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 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 timotej.kubas
28  * @author michal.polkorab
29  */
30 public class GetQueueConfigInputMessageFactoryTest {
31     private static final byte GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE = 22;
32     private static final byte PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE = 4;
33     private SerializerRegistry registry;
34     private OFSerializer<GetQueueConfigInput> getQueueFactory;
35
36     /**
37      * Initializes serializer registry and stores correct factory in field
38      */
39     @Before
40     public void startUp() {
41         registry = new SerializerRegistryImpl();
42         registry.init();
43         getQueueFactory = registry.getSerializer(
44                 new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetQueueConfigInput.class));
45     }
46
47     /**
48      * Testing of {@link GetQueueConfigInputMessageFactory} for correct translation from POJO
49      * @throws Exception
50      */
51     @Test
52     public void testGetQueueConfigInputMessage() throws Exception {
53         GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
54         BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
55         builder.setPort(new PortNumber(0x00010203L));
56         GetQueueConfigInput message = builder.build();
57
58         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
59         getQueueFactory.serialize(message, out);
60
61         BufferHelper.checkHeaderV13(out, GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE, 16);
62         Assert.assertEquals("Wrong port", 0x00010203, out.readUnsignedInt());
63         out.skipBytes(PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE);
64     }
65 }