blob: b9eed023119a018697fa1287ba19495daf08d239 [file] [log] [blame]
Jonathan Hart03102132014-07-01 23:22:04 -07001package net.onrc.onos.core.hostmanager;
TeruU5d2c9392014-06-09 20:02:02 -07002
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
Jonathan Hart03102132014-07-01 23:22:04 -070013/**
14 * This is the test for the Host class.
TeruU5d2c9392014-06-09 20:02:02 -070015 */
Jonathan Hart03102132014-07-01 23:22:04 -070016public class HostTest {
TeruU5d2c9392014-06-09 20:02:02 -070017
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
Jonathan Hart03102132014-07-01 23:22:04 -070043 /**
TeruU5d2c9392014-06-09 20:02:02 -070044 * Test for making sure hashCode function works properly.
45 */
46 @Test
47 public void testHashCode() {
Jonathan Hart03102132014-07-01 23:22:04 -070048 Host host1 = new Host(mac1, null, dpid1, portNum1, date1);
49 Host host2 = new Host(mac2, null, dpid2, portNum2, date2);
TeruU5d2c9392014-06-09 20:02:02 -070050
Jonathan Hart03102132014-07-01 23:22:04 -070051 assertTrue(host1.hashCode() == host2.hashCode());
TeruU5d2c9392014-06-09 20:02:02 -070052 }
53
Jonathan Hart03102132014-07-01 23:22:04 -070054 /**
TeruU5d2c9392014-06-09 20:02:02 -070055 * Test for making sure equals function works properly.
56 */
57 @Test
58 public void testEqualsObject() {
Jonathan Hart03102132014-07-01 23:22:04 -070059 Host host1 = new Host(mac1, null, dpid1, portNum1, date1);
60 Host host2 = new Host(mac2, null, dpid2, portNum2, date2);
TeruU5d2c9392014-06-09 20:02:02 -070061
Jonathan Hart03102132014-07-01 23:22:04 -070062 assertTrue(host1.equals(host2));
TeruU5d2c9392014-06-09 20:02:02 -070063 }
64
65}