Migrate openflow-protocol-impl tests to Uint types
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / BarrierInputMessageFactoryTest.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.deserialization.factories;
9
10 import io.netty.buffer.ByteBuf;
11 import java.util.ArrayList;
12 import java.util.Arrays;
13 import java.util.Collections;
14 import java.util.List;
15 import org.junit.Test;
16 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
17 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
18 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
19 import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
21
22 /**
23  * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierInputMessageFactory}.
24  * @author giuseppex.petralia@intel.com
25  */
26 public class BarrierInputMessageFactoryTest extends DefaultDeserializerFactoryTest<BarrierInput> {
27
28
29     /**
30      * Initializes deserializer registry and lookups OF13 deserializer.
31      */
32     public BarrierInputMessageFactoryTest() {
33         super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 20, BarrierInput.class));
34     }
35
36     /**
37      * Testing of {@link BarrierInputMessageFactory} for correct header version.
38      */
39     @Test
40     public void testVersions() {
41         List<Byte> versions = new ArrayList<>(Arrays.asList(
42                 EncodeConstants.OF13_VERSION_ID,
43                 EncodeConstants.OF14_VERSION_ID,
44                 EncodeConstants.OF15_VERSION_ID
45         ));
46         ByteBuf bb = BufferHelper.buildBuffer();
47         testHeaderVersions(versions, bb);
48
49         // OFP v1.0 need to be tested separately cause of different message type value
50         messageCodeKey = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 18, BarrierInput.class);
51         testHeaderVersions(Collections.singletonList(EncodeConstants.OF10_VERSION_ID), bb);
52     }
53 }