Update MRI upstreams for Phosphorus
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / PortModInputMessageFactoryTest.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.rev130715.MacAddress;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
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 import org.opendaylight.yangtools.yang.common.Uint32;
26
27 /**
28  * Unit tests for PortModInputMessageFactory.
29  *
30  * @author giuseppex.petralia@intel.com
31  */
32 public class PortModInputMessageFactoryTest {
33     private OFDeserializer<PortModInput> factory;
34
35     @Before
36     public void startUp() {
37         DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
38         desRegistry.init();
39         factory = desRegistry
40                 .getDeserializer(new MessageCodeKey(EncodeConstants.OF_VERSION_1_3, 16, PortModInput.class));
41     }
42
43     @Test
44     public void test() {
45         ByteBuf bb = BufferHelper.buildBuffer(
46                 "00 00 00 09 00 00 00 00 08 00 27 00 " + "b0 eb 00 00 00 00 00 24 00 00 00 41 00 00 01 10 00 00 00 00");
47         PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
48         BufferHelper.checkHeaderV13(deserializedMessage);
49
50         // Test Message
51         Assert.assertEquals("Wrong port", new PortNumber(Uint32.valueOf(9)), deserializedMessage.getPortNo());
52         Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:b0:eb"), deserializedMessage.getHwAddress());
53         Assert.assertEquals("Wrong config", new PortConfig(true, false, true, false), deserializedMessage.getConfig());
54         Assert.assertEquals("Wrong mask", new PortConfig(false, true, false, true), deserializedMessage.getMask());
55         Assert.assertEquals("Wrong advertise", new PortFeatures(true, false, false, false, false, false, false, true,
56                 false, false, false, false, false, false, false, false), deserializedMessage.getAdvertise());
57     }
58 }