Fixed netty & checkstyle failures
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / HelloMessageFactoryTest.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.HelloMessage;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;
22
23 /**
24  * @author giuseppex.petralia@intel.com
25  *
26  */
27 public class HelloMessageFactoryTest {
28     private static final byte MESSAGE_TYPE = 0;
29     private OFSerializer<HelloMessage> factory;
30
31     @Before
32     public void startUp() {
33         SerializerRegistry registry = new SerializerRegistryImpl();
34         registry.init();
35         factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, HelloMessage.class));
36     }
37
38     @Test
39     public void testSerialize() throws Exception {
40         HelloMessageBuilder builder = new HelloMessageBuilder();
41         BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
42         HelloMessage message = builder.build();
43
44         ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
45         factory.serialize(message, serializedBuffer);
46         BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8);
47     }
48
49 }