Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / OF10BarrierInputMessageFactoryTest.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 OF10BarrierInputMessageFactoryTest {
30
31     private SerializerRegistry registry;
32     private OFSerializer<BarrierInput> barrierFactory;
33
34     /**
35      * Initializes serializer registry and stores correct factory in field
36      */
37     @Before
38     public void startUp() {
39         registry = new SerializerRegistryImpl();
40         registry.init();
41         barrierFactory = registry.getSerializer(
42                 new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class));
43     }
44
45     /**
46      * Testing of {@link OF10BarrierInputMessageFactory} for correct translation from POJO
47      * @throws Exception
48      */
49     @Test
50     public void test() throws Exception {
51         BarrierInputBuilder bib = new BarrierInputBuilder();
52         BufferHelper.setupHeader(bib, EncodeConstants.OF10_VERSION_ID);
53         BarrierInput bi = bib.build();
54
55         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
56         barrierFactory.serialize(bi, out);
57
58         BufferHelper.checkHeaderV10(out, (byte) 18, 8);
59     }
60
61 }