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
11 * @file EthernetAddressTest.java
13 * @brief Unit Tests for EthernetAddress class
15 * Unit Tests for EthernetAddress class
17 package org.opendaylight.controller.sal.packet.address;
19 import org.junit.Assert;
20 import org.junit.Test;
21 import org.opendaylight.controller.sal.core.ConstructionException;
23 public class EthernetAddressTest {
25 public void testNonValidConstructor() {
26 @SuppressWarnings("unused")
30 ea1 = new EthernetAddress((byte[]) null);
32 // Exception is expected if NOT raised test will fail
33 Assert.assertTrue(false);
34 } catch (ConstructionException e) {
39 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0 });
41 // Exception is expected if NOT raised test will fail
42 Assert.assertTrue(false);
43 } catch (ConstructionException e) {
48 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
49 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
52 // Exception is expected if NOT raised test will fail
53 Assert.assertTrue(false);
54 } catch (ConstructionException e) {
59 public void testEquality() {
63 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
64 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 });
66 ea2 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
67 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 });
68 Assert.assertTrue(ea1.equals(ea2));
69 } catch (ConstructionException e) {
70 // Exception is NOT expected if raised test will fail
71 Assert.assertTrue(false);
75 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
76 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 });
79 Assert.assertTrue(ea1.equals(ea2));
80 } catch (ConstructionException e) {
81 // Exception is NOT expected if raised test will fail
82 Assert.assertTrue(false);
85 // Check for well knowns
87 ea1 = EthernetAddress.BROADCASTMAC;
88 ea2 = new EthernetAddress(new byte[] { (byte) 0xff, (byte) 0xff,
89 (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff });
90 Assert.assertTrue(ea1.equals(ea2));
91 } catch (ConstructionException e) {
92 // Exception is NOT expected if raised test will fail
93 Assert.assertTrue(false);
98 public void testUnEquality() {
102 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
103 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2 });
105 ea2 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
106 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 });
107 Assert.assertTrue(!ea1.equals(ea2));
108 } catch (ConstructionException e) {
109 // Exception is NOT expected if raised test will fail
110 Assert.assertTrue(false);