Bump MRI upstreams
[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.List;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
16 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
17 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
18 import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
20 import org.opendaylight.yangtools.yang.common.Uint8;
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      * Initializes deserializer registry and lookups OF13 deserializer.
29      */
30     public BarrierInputMessageFactoryTest() {
31         super(new MessageCodeKey(EncodeConstants.OF_VERSION_1_3, 20, BarrierInput.class));
32     }
33
34     /**
35      * Testing of {@link BarrierInputMessageFactory} for correct header version.
36      */
37     @Test
38     public void testVersions() {
39         List<Uint8> versions = new ArrayList<>(Arrays.asList(
40                 EncodeConstants.OF_VERSION_1_3,
41                 EncodeConstants.OF_VERSION_1_4,
42                 EncodeConstants.OF_VERSION_1_5
43         ));
44         ByteBuf bb = BufferHelper.buildBuffer();
45         testHeaderVersions(versions, bb);
46
47         // OFP v1.0 need to be tested separately cause of different message type value
48         messageCodeKey = new MessageCodeKey(EncodeConstants.OF_VERSION_1_0, 18, BarrierInput.class);
49         testHeaderVersions(List.of(EncodeConstants.OF_VERSION_1_0), bb);
50     }
51 }