Merge "Fixed padding issue with set-field action."
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / PortStatusMessageFactoryTest.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. 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
9
10 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
11
12 import io.netty.buffer.ByteBuf;
13
14 import org.junit.Assert;
15 import org.junit.Test;
16 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
22
23 /**
24  * @author timotej.kubas
25  * @author michal.polkorab
26  */
27 public class PortStatusMessageFactoryTest {
28
29     /**
30      * Testing {@link PortStatusMessageFactory} for correct translation into POJO
31      */
32     @Test
33     public void test(){
34         ByteBuf bb = BufferHelper.buildBuffer("01 " + //reason 
35                                               "00 00 00 00 00 00 00 " + //padding
36                                               "00 01 02 03 " + //port no
37                                               "00 00 00 00 " + //padding in ofp_port1
38                                               "08 00 27 00 B0 EB " + //mac address
39                                               "00 00 " + //padding in ofp_port2
40                                               "73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port name, String "s1-eth1"
41                                               "00 00 00 41 " + //port config
42                                               "00 00 00 05 " + //port state
43                                               "00 00 00 81 " + //current features
44                                               "00 00 00 81 " + //advertised features
45                                               "00 00 00 81 " + //supported features
46                                               "00 00 00 81 " + //peer features
47                                               "00 00 00 81 " + //curr speed
48                                               "00 00 00 80" //max speed
49                                               );
50         
51         PortStatusMessage builtByFactory = BufferHelper.decodeV13(PortStatusMessageFactory.getInstance(), bb);
52         
53         BufferHelper.checkHeaderV13(builtByFactory);
54         Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
55         Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue());
56         Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), builtByFactory.getHwAddr());
57         Assert.assertEquals("Wrong name", "s1-eth1", builtByFactory.getName());
58         Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), builtByFactory.getConfig());
59         Assert.assertEquals("Wrong portState", new PortState(false, true, true), builtByFactory.getState());
60         Assert.assertEquals("Wrong currentFeatures", new PortFeatures(true, false, false, false,
61                                              false, false, false, true, false, false, false, false, 
62                                              false, false, false, false), builtByFactory.getCurrentFeatures());
63         Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, false, false, false,
64                                              false, false, false, true, false, false, false, false, 
65                                              false, false, false, false), builtByFactory.getAdvertisedFeatures());
66         Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, false, false, false,
67                                              false, false, false, true, false, false, false, false, 
68                                              false, false, false, false), builtByFactory.getSupportedFeatures());
69         Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, false, false, false,
70                                              false, false, false, true, false, false, false, false, 
71                                              false, false, false, false), builtByFactory.getSupportedFeatures());
72         Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue());
73         Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue());
74     }
75 }