Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / BarrierInputMessageFactoryTest.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
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.protocol.rev130731.BarrierInput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
24
25 /**
26  * @author michal.polkorab
27  *
28  */
29 public class BarrierInputMessageFactoryTest {
30
31     private static final byte BARRIER_REQUEST_MESSAGE_CODE_TYPE = 20;
32     private SerializerRegistry registry;
33     private OFSerializer<BarrierInput> barrierFactory;
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         barrierFactory = registry.getSerializer(
43                 new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierInput.class));
44     }
45
46     /**
47      * Testing of {@link BarrierInputMessageFactory} for correct translation from POJO
48      * @throws Exception
49      */
50     @Test
51     public void test() throws Exception {
52         BarrierInputBuilder bib = new BarrierInputBuilder();
53         BufferHelper.setupHeader(bib, EncodeConstants.OF13_VERSION_ID);
54         BarrierInput bi = bib.build();
55
56         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
57         barrierFactory.serialize(bi, out);
58
59         BufferHelper.checkHeaderV13(out, BARRIER_REQUEST_MESSAGE_CODE_TYPE, 8);
60     }
61
62 }