Extend openflow-protocol-impl serialization
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / OF10PortModInputMessageFactoryTest.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.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
25
26 /**
27  * @author giuseppex.petralia@intel.com
28  *
29  */
30 public class OF10PortModInputMessageFactoryTest {
31     private OFDeserializer<PortModInput> factory;
32
33     @Before
34     public void startUp() {
35         DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
36         desRegistry.init();
37         factory = desRegistry
38                 .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 15, PortModInput.class));
39     }
40
41     @Test
42     public void test() {
43         ByteBuf bb = BufferHelper
44                 .buildBuffer("19 e9 08 00 27 00 b0 eb " + "00 00 00 15 00 00 00 62 00 00 02 8c 00 00 00 00 ");
45         PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
46         BufferHelper.checkHeaderV10(deserializedMessage);
47         Assert.assertEquals("Wrong port", new PortNumber(6633L), deserializedMessage.getPortNo());
48         Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:B0:EB"), deserializedMessage.getHwAddress());
49         Assert.assertEquals("Wrong config", new PortConfigV10(true, false, false, true, false, false, true),
50                 deserializedMessage.getConfigV10());
51         Assert.assertEquals("Wrong mask", new PortConfigV10(false, true, true, false, false, true, false),
52                 deserializedMessage.getMaskV10());
53         Assert.assertEquals("Wrong advertise",
54                 new PortFeaturesV10(true, true, false, false, false, false, false, true, true, false, false, false),
55                 deserializedMessage.getAdvertiseV10());
56     }
57 }