Fix checkstyle violations in openflow-protocol-impl - part 12
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / BarrierReplyMessageFactoryTest.java
1 /*
2  * Copyright (c) 2015 NetIDE Consortium 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 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
9
10 import io.netty.buffer.ByteBuf;
11 import io.netty.buffer.UnpooledByteBufAllocator;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
16 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
17 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
18 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
19 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
22
23 /**
24  * Unit tests for BarrierReplyMessageFactory.
25  *
26  * @author giuseppex.petralia@intel.com
27  */
28 public class BarrierReplyMessageFactoryTest {
29     private static final byte MESSAGE_TYPE = 21;
30     private OFSerializer<BarrierOutput> factory;
31
32     @Before
33     public void startUp() throws Exception {
34         SerializerRegistry registry = new SerializerRegistryImpl();
35         registry.init();
36         factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierOutput.class));
37
38     }
39
40     @Test
41     public void testSerialize() throws Exception {
42         BarrierOutputBuilder builder = new BarrierOutputBuilder();
43         BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
44         BarrierOutput message = builder.build();
45         ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
46         factory.serialize(message, serializedBuffer);
47         BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8);
48     }
49 }