Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / sal / api / src / test / java / org / opendaylight / controller / sal / utils / EtherTypesTest.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.sal.utils;
11
12 import java.util.ArrayList;
13 import org.junit.Assert;
14 import org.junit.Test;
15
16 public class EtherTypesTest {
17
18         @Test
19         public void testEthertypesCreation() {
20
21                 EtherTypes arp = EtherTypes.ARP;
22
23                 Assert.assertTrue(arp.toString().equals("ARP"));
24                 Assert.assertTrue(arp.intValue() == 2054);
25                 Assert.assertTrue(arp.shortValue() == (short)2054);
26         }
27
28         @Test
29         public void testGetEtherTypesString() {
30
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"));
34
35                 Assert.assertFalse(EtherTypes.getEtherTypeName(0x800).equals("ARP"));
36         }
37
38         @Test
39         public void testGetEtherTypesNumber() {
40                 Assert.assertTrue(EtherTypes.getEtherTypeNumberInt("VLAN Tagged") == 33024);
41                 Assert.assertTrue(EtherTypes.getEtherTypeNumberShort("ARP") == 2054);
42
43                 Assert.assertFalse(EtherTypes.getEtherTypeNumberInt("CDP") == 1000);
44         }
45
46         @Test
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"));
63         }
64
65         @Test
66         public void testGetEtherTypesloadFromString() {
67                 Assert.assertTrue(EtherTypes.loadFromString("37376").equals(EtherTypes.CISCOQINQ));
68                 Assert.assertTrue(EtherTypes.loadFromString("100") == null);
69         }
70
71 }