d4fa28bf711f89fa9155dce96babbd6fddaa0b0c
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / OF10PortStatusMessageFactoryTest.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 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
10
11 import io.netty.buffer.ByteBuf;
12
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
22
23 /**
24  * @author michal.polkorab
25  *
26  */
27 public class OF10PortStatusMessageFactoryTest {
28
29     /**
30      * Testing {@link OF10PortStatusMessageFactory} for correct translation into POJO
31      */
32     @Test
33     public void test(){
34         ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00 00 00 00 00 "
35                 + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 "
36                 + "00 00 00 00 15 00 00 01 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
37         PortStatusMessage builtByFactory = BufferHelper.decodeV10(OF10PortStatusMessageFactory.getInstance(), bb);
38         
39         BufferHelper.checkHeaderV10(builtByFactory);
40         Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason());
41         Assert.assertEquals("Wrong port - port-no", 16, builtByFactory.getPortNo().intValue());
42         Assert.assertEquals("Wrong builtByFactory - hw-addr", new MacAddress("01:01:05:01:04:02"), builtByFactory.getHwAddr());
43         Assert.assertEquals("Wrong builtByFactory - name", new String("ALOHA"), builtByFactory.getName());
44         Assert.assertEquals("Wrong builtByFactory - config", new PortConfigV10(true, false, false, true, false, false, true),
45                 builtByFactory.getConfigV10());
46         Assert.assertEquals("Wrong builtByFactory - state", new PortStateV10(false, true, false, false, false, true, false, false),
47                 builtByFactory.getStateV10());
48         Assert.assertEquals("Wrong builtByFactory - curr", new PortFeaturesV10(false, false, false, false, true, true, true,
49                 false, false, false, false, false), builtByFactory.getCurrentFeaturesV10());
50         Assert.assertEquals("Wrong builtByFactory - advertised", new PortFeaturesV10(false, false, true, true, false, false,
51                 false, false, false, false, true, false), builtByFactory.getAdvertisedFeaturesV10());
52         Assert.assertEquals("Wrong builtByFactory - supbuiltByFactoryed", new PortFeaturesV10(true, true, false, false, false, false,
53                 false, true, false, true, false, false), builtByFactory.getSupportedFeaturesV10());
54         Assert.assertEquals("Wrong builtByFactory - peer", new PortFeaturesV10(true, false, false, false, false, false, false,
55                 false, true, false, false, true), builtByFactory.getPeerFeaturesV10());
56     }
57
58 }