Extend openflow-protocol-impl serialization
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / OF10SetConfigMessageFactoryTest.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 org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
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.deserialization.DeserializerRegistryImpl;
19 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
21
22 /**
23  * @author giuseppex.petralia@intel.com
24  *
25  */
26 public class OF10SetConfigMessageFactoryTest {
27     private OFDeserializer<SetConfigInput> factory;
28
29     @Before
30     public void startUp() {
31         DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
32         desRegistry.init();
33         factory = desRegistry
34                 .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 9, SetConfigInput.class));
35     }
36
37     @Test
38     public void test() {
39         ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03");
40         SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
41         BufferHelper.checkHeaderV10(deserializedMessage);
42         Assert.assertEquals("Wrong switchConfigFlag", 0x01, deserializedMessage.getFlags().getIntValue());
43         Assert.assertEquals("Wrong missSendLen", 0x03, deserializedMessage.getMissSendLen().intValue());
44     }
45 }