blob: 6c79bf0240752f760484bff122e0f9543186c008 [file] [log] [blame]
TeruU5d2c9392014-06-09 20:02:02 -07001package net.onrc.onos.core.devicemanager;
2
3import static org.junit.Assert.assertTrue;
4
5import java.util.Date;
6
7import net.floodlightcontroller.util.MACAddress;
8
9import org.junit.After;
10import org.junit.Before;
11import org.junit.Test;
12
13/*
14 * This is the test for OnosDevice.class.
15 */
16public class OnosDeviceTest {
17
18 MACAddress mac1;
19 MACAddress mac2;
20 Long dpid1;
21 Long dpid2;
22 Long portNum1;
23 Long portNum2;
24 Date date1;
25 Date date2;
26
27 @Before
28 public void setUp() throws Exception {
29 mac1 = MACAddress.valueOf("00:00:00:00:00:01");
30 mac2 = MACAddress.valueOf("00:00:00:00:00:01");
31 dpid1 = 1L;
32 dpid2 = 1L;
33 portNum1 = 1L;
34 portNum2 = 1L;
35 date1 = new Date(1L);
36 date2 = new Date(2L);
37 }
38
39 @After
40 public void tearDown() throws Exception {
41 }
42
43 /*
44 * Test for making sure hashCode function works properly.
45 */
46 @Test
47 public void testHashCode() {
48 OnosDevice dev1 = new OnosDevice(mac1, null, dpid1, portNum1, date1);
49 OnosDevice dev2 = new OnosDevice(mac2, null, dpid2, portNum2, date2);
50
51 assertTrue(dev1.hashCode() == dev2.hashCode());
52 }
53
54 /*
55 * Test for making sure equals function works properly.
56 */
57 @Test
58 public void testEqualsObject() {
59 OnosDevice dev1 = new OnosDevice(mac1, null, dpid1, portNum1, date1);
60 OnosDevice dev2 = new OnosDevice(mac2, null, dpid2, portNum2, date2);
61
62 assertTrue(dev1.equals(dev2));
63 }
64
65}