47e92623d6f3ce3e67c5c036798945b0203f597b
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / OpenflowUtilsTest.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.impl.util;\r
10 \r
11 import org.junit.Assert;\r
12 import org.junit.Test;\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;\r
16 \r
17 /**\r
18  * @author michal.polkorab\r
19  *\r
20  */\r
21 public class OpenflowUtilsTest {\r
22 \r
23     /**\r
24      * Tests {@link OpenflowUtils#createPortState(long)}\r
25      */\r
26     @Test\r
27     public void testPortState() {\r
28         PortStateV10 state = OpenflowUtils.createPortState(512L);\r
29         Assert.assertEquals("Wrong port state",\r
30                 new PortStateV10(false, false, false, false, true, false, true, false), state);\r
31 \r
32         state = OpenflowUtils.createPortState(1793L);\r
33         Assert.assertEquals("Wrong port state",\r
34                 new PortStateV10(false, true, false, true, true, true, false, true), state);\r
35 \r
36         state = OpenflowUtils.createPortState(1L);\r
37         Assert.assertEquals("Wrong port state",\r
38                 new PortStateV10(false, true, false, false, false, false, true, false), state);\r
39     }\r
40 \r
41     /**\r
42      * Tests {@link OpenflowUtils#createPortConfig(long)}\r
43      */\r
44     @Test\r
45     public void testPortConfig() {\r
46         PortConfigV10 config = OpenflowUtils.createPortConfig(127L);\r
47         Assert.assertEquals("Wrong port config",\r
48                 new PortConfigV10(true, true, true, true, true, true, true), config);\r
49 \r
50         config = OpenflowUtils.createPortConfig(0L);\r
51         Assert.assertEquals("Wrong port config",\r
52                 new PortConfigV10(false, false, false, false, false, false, false), config);\r
53     }\r
54 \r
55     /**\r
56      * Tests {@link OpenflowUtils#createPortFeatures(long)}\r
57      */\r
58     @Test\r
59     public void testPortFeatures() {\r
60         PortFeaturesV10 features = OpenflowUtils.createPortFeatures(4095L);\r
61         Assert.assertEquals("Wrong port features", new PortFeaturesV10(true, true, true, true, true, true, true,\r
62                 true, true, true, true, true), features);\r
63 \r
64         features = OpenflowUtils.createPortFeatures(0L);\r
65         Assert.assertEquals("Wrong port features", new PortFeaturesV10(false, false, false, false, false, false,\r
66                 false, false, false, false, false, false), features);\r
67     }\r
68 }