2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
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
10 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
12 import io.netty.buffer.ByteBuf;
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;
24 * @author timotej.kubas
25 * @author michal.polkorab
27 public class PortStatusMessageFactoryTest {
30 * Testing {@link PortStatusMessageFactory} for correct translation into POJO
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 "00 00 00 41 " + //port config
41 "00 00 00 05 " + //port state
42 "00 00 00 81 " + //current features
43 "00 00 00 81 " + //advertised features
44 "00 00 00 81 " + //supported features
45 "00 00 00 81 " + //peer features
46 "00 00 00 81 " + //curr speed
47 "00 00 00 80" //max speed
50 PortStatusMessage builtByFactory = BufferHelper.decodeV13(PortStatusMessageFactory.getInstance(), bb);
52 BufferHelper.checkHeaderV13(builtByFactory);
53 Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
54 Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue());
55 Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), builtByFactory.getHwAddr());
56 Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), builtByFactory.getConfig());
57 Assert.assertEquals("Wrong portState", new PortState(false, true, true), builtByFactory.getState());
58 Assert.assertEquals("Wrong currentFeatures", new PortFeatures(true, false, false, false,
59 false, false, false, true, false, false, false, false,
60 false, false, false, false), builtByFactory.getCurrentFeatures());
61 Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, false, false, false,
62 false, false, false, true, false, false, false, false,
63 false, false, false, false), builtByFactory.getAdvertisedFeatures());
64 Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, false, false, false,
65 false, false, false, true, false, false, false, false,
66 false, false, false, false), builtByFactory.getSupportedFeatures());
67 Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, false, false, false,
68 false, false, false, true, false, false, false, false,
69 false, false, false, false), builtByFactory.getSupportedFeatures());
70 Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue());
71 Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue());