Change GetConfigReq/Res and SetConfig factories to version assignable
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / SetConfigInputMessageFactoryTest.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.Assert;
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.common.types.rev130731.SwitchConfigFlag;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
22
23 /**
24  * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.SetConfigInputMessageFactory}.
25  * @author giuseppex.petralia@intel.com
26  */
27 public class SetConfigInputMessageFactoryTest extends DefaultDeserializerFactoryTest<SetConfigInput> {
28
29     /**
30      * Initializes deserializer registry and lookups OF13 deserializer.
31      */
32     public SetConfigInputMessageFactoryTest() {
33         super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 9, SetConfigInput.class));
34     }
35
36     /**
37      * Testing {@link SetConfigInputMessageFactory} for correct header version.
38      */
39     @Test
40     public void testVersions() {
41         List<Byte> versions = new ArrayList<>(Arrays.asList(
42                 EncodeConstants.OF10_VERSION_ID,
43                 EncodeConstants.OF13_VERSION_ID,
44                 EncodeConstants.OF14_VERSION_ID,
45                 EncodeConstants.OF15_VERSION_ID
46         ));
47         ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0a");
48         testHeaderVersions(versions, bb);
49     }
50
51     @Test
52     public void test() {
53         ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0a");
54         SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
55
56         // Test Message
57         Assert.assertEquals("Wrong flags ", SwitchConfigFlag.forValue(2), deserializedMessage.getFlags());
58         Assert.assertEquals("Wrong Miss Send len ", 10, deserializedMessage.getMissSendLen().intValue());
59     }
60
61 }