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() {
29 ea1 = new EthernetAddress((byte[]) null);
31 // Exception is expected if NOT raised test will fail
32 Assert.assertTrue(false);
33 } catch (ConstructionException e) {
38 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0 });
40 // Exception is expected if NOT raised test will fail
41 Assert.assertTrue(false);
42 } catch (ConstructionException e) {
47 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
48 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
51 // Exception is expected if NOT raised test will fail
52 Assert.assertTrue(false);
53 } catch (ConstructionException e) {
58 public void testEquality() {
62 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
63 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 });
65 ea2 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
66 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 });
67 Assert.assertTrue(ea1.equals(ea2));
68 } catch (ConstructionException e) {
69 // Exception is NOT expected if raised test will fail
70 Assert.assertTrue(false);
74 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
75 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 });
78 Assert.assertTrue(ea1.equals(ea2));
79 } catch (ConstructionException e) {
80 // Exception is NOT expected if raised test will fail
81 Assert.assertTrue(false);
84 // Check for well knowns
86 ea1 = EthernetAddress.BROADCASTMAC;
87 ea2 = new EthernetAddress(new byte[] { (byte) 0xff, (byte) 0xff,
88 (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff });
89 Assert.assertTrue(ea1.equals(ea2));
90 } catch (ConstructionException e) {
91 // Exception is NOT expected if raised test will fail
92 Assert.assertTrue(false);
97 public void testUnEquality() {
101 ea1 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
102 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2 });
104 ea2 = new EthernetAddress(new byte[] { (byte) 0x0, (byte) 0x0,
105 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 });
106 Assert.assertTrue(!ea1.equals(ea2));
107 } catch (ConstructionException e) {
108 // Exception is NOT expected if raised test will fail
109 Assert.assertTrue(false);