0a0eff03be404224eacc7e394f318ec5b29d2916
[hc2vpp.git] /
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
18
19 import static org.junit.Assert.assertEquals;
20
21 import org.junit.Test;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
26
27 public class InterfaceUtilsTest {
28
29     @Test
30     public void testVppPhysAddrToYang() throws Exception {
31         assertEquals("01:02:03:04:05:06", InterfaceUtils.vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5, 6}));
32         assertEquals("0a:0b:0c:0d:0e:0f", InterfaceUtils.vppPhysAddrToYang(new byte[]{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0}));
33     }
34
35     @Test(expected = NullPointerException.class)
36     public void testVppPhysAddrToYangFailNullArgument() throws Exception {
37         InterfaceUtils.vppPhysAddrToYang(null);
38     }
39
40     @Test(expected = IllegalArgumentException.class)
41     public void testVppPhysAddrToYangInvalidByteArrayLength() throws Exception {
42         InterfaceUtils.vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5});
43     }
44
45     @Test
46     public void testGetInterfaceType() {
47         assertEquals(Tap.class, InterfaceUtils.getInterfaceType("tap0"));
48         assertEquals(VxlanTunnel.class, InterfaceUtils.getInterfaceType("vxlan0"));
49         assertEquals(VhostUser.class, InterfaceUtils.getInterfaceType("VirtualEthernet0/0/0"));
50         assertEquals(EthernetCsmacd.class, InterfaceUtils.getInterfaceType("local0"));
51     }
52 }