2 * Copyright (c) 2016 Cisco and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package io.fd.honeycomb.translate.v3po.interfacesstate;
19 import static org.junit.Assert.assertEquals;
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.rev161214.Tap;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VhostUser;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanGpeTunnel;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanTunnel;
28 public class InterfaceDataTranslatorTest implements InterfaceDataTranslator {
31 public void testVppPhysAddrToYang() throws Exception {
32 assertEquals("01:02:03:04:05:06", vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5, 6}));
33 assertEquals("0a:0b:0c:0d:0e:0f", vppPhysAddrToYang(new byte[]{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0}));
36 @Test(expected = NullPointerException.class)
37 public void testVppPhysAddrToYangFailNullArgument() throws Exception {
38 vppPhysAddrToYang(null);
41 @Test(expected = IllegalArgumentException.class)
42 public void testVppPhysAddrToYangInvalidByteArrayLength() throws Exception {
43 vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5});
47 public void testGetInterfaceType() {
48 assertEquals(Tap.class, getInterfaceType("tap0"));
49 assertEquals(VxlanTunnel.class, getInterfaceType("vxlan0"));
50 assertEquals(VxlanGpeTunnel.class, getInterfaceType("vxlan_gpe0"));
51 assertEquals(VhostUser.class, getInterfaceType("VirtualEthernet0/0/0"));
52 assertEquals(EthernetCsmacd.class, getInterfaceType("eth0.0"));
53 assertEquals(EthernetCsmacd.class, getInterfaceType("local0"));