3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.utils;
12 import java.util.ArrayList;
13 import org.junit.Assert;
14 import org.junit.Test;
16 public class EtherTypesTest {
19 public void testEthertypesCreation() {
21 EtherTypes arp = EtherTypes.ARP;
23 Assert.assertTrue(arp.toString().equals("ARP"));
24 Assert.assertTrue(arp.intValue() == 2054);
25 Assert.assertTrue(arp.shortValue() == (short)2054);
29 public void testGetEtherTypesString() {
31 Assert.assertTrue(EtherTypes.getEtherTypeName(34984).equals("QINQ"));
32 Assert.assertTrue(EtherTypes.getEtherTypeName((short)2048).equals("IPv4"));
33 Assert.assertTrue(EtherTypes.getEtherTypeName(0x010B).equals("PVSTP"));
35 Assert.assertFalse(EtherTypes.getEtherTypeName(0x800).equals("ARP"));
39 public void testGetEtherTypesNumber() {
40 Assert.assertTrue(EtherTypes.getEtherTypeNumberInt("VLAN Tagged") == 33024);
41 Assert.assertTrue(EtherTypes.getEtherTypeNumberShort("ARP") == 2054);
43 Assert.assertFalse(EtherTypes.getEtherTypeNumberInt("CDP") == 1000);
47 public void testGetEtherTypesList() {
48 ArrayList<String> etherTypeNames = (ArrayList<String>) EtherTypes.getEtherTypesNameList();
49 Assert.assertTrue(etherTypeNames.get(0).equals("PVSTP"));
50 Assert.assertTrue(etherTypeNames.get(1).equals("CDP"));
51 Assert.assertTrue(etherTypeNames.get(2).equals("VTP"));
52 Assert.assertTrue(etherTypeNames.get(3).equals("IPv4"));
53 Assert.assertTrue(etherTypeNames.get(4).equals("ARP"));
54 Assert.assertTrue(etherTypeNames.get(5).equals("Reverse ARP"));
55 Assert.assertTrue(etherTypeNames.get(6).equals("VLAN Tagged"));
56 Assert.assertTrue(etherTypeNames.get(7).equals("IPv6"));
57 Assert.assertTrue(etherTypeNames.get(8).equals("MPLS Unicast"));
58 Assert.assertTrue(etherTypeNames.get(9).equals("MPLS Multicast"));
59 Assert.assertTrue(etherTypeNames.get(10).equals("QINQ"));
60 Assert.assertTrue(etherTypeNames.get(11).equals("LLDP"));
61 Assert.assertTrue(etherTypeNames.get(12).equals("Old QINQ"));
62 Assert.assertTrue(etherTypeNames.get(13).equals("Cisco QINQ"));
66 public void testGetEtherTypesloadFromString() {
67 Assert.assertTrue(EtherTypes.loadFromString("37376").equals(EtherTypes.CISCOQINQ));
68 Assert.assertTrue(EtherTypes.loadFromString("100") == null);