Copyright update
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / GetFeaturesInputMessageFactoryTest.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.Test;
15 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
16 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;
19
20 /**
21  * @author michal.polkorab
22  *
23  */
24 public class GetFeaturesInputMessageFactoryTest {
25
26     private static final byte FEATURES_REQUEST_MESSAGE_CODE_TYPE = GetFeaturesInputMessageFactory.MESSAGE_TYPE;
27     
28     /**
29      * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO
30      * @throws Exception 
31      */
32     @Test
33     public void testV13() throws Exception {
34         GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
35         BufferHelper.setupHeader(gfib, EncodeConstants.OF13_VERSION_ID);
36         GetFeaturesInput gfi = gfib.build();
37         
38         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
39         GetFeaturesInputMessageFactory gfimf = GetFeaturesInputMessageFactory.getInstance();
40         gfimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, gfi);
41         
42         BufferHelper.checkHeaderV13(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);
43     }
44
45     /**
46      * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO
47      * @throws Exception 
48      */
49     @Test
50     public void testV10() throws Exception {
51         GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
52         BufferHelper.setupHeader(gfib, EncodeConstants.OF10_VERSION_ID);
53         GetFeaturesInput gfi = gfib.build();
54         
55         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
56         GetFeaturesInputMessageFactory gfimf = GetFeaturesInputMessageFactory.getInstance();
57         gfimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, gfi);
58         
59         BufferHelper.checkHeaderV10(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);
60     }
61 }