blob: 5ae7c27b31c7e0e409e4dba444bded657755d918 [file] [log] [blame]
Ayaka Koshibe93afebc2014-09-15 13:25:22 -07001package org.onlab.onos.net.host;
2
Ayaka Koshibe93afebc2014-09-15 13:25:22 -07003import org.junit.Test;
4import org.onlab.onos.net.DeviceId;
5import org.onlab.onos.net.HostLocation;
6import org.onlab.onos.net.PortNumber;
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -07007import org.onlab.packet.IpPrefix;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -07008import org.onlab.packet.MacAddress;
9import org.onlab.packet.VlanId;
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070010
tom093340b2014-10-10 00:15:36 -070011import static org.junit.Assert.assertEquals;
12import static org.junit.Assert.assertTrue;
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070013
14/**
15 * Test for the default host description.
16 */
17public class DefualtHostDecriptionTest {
18
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070019 private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01");
20 private static final VlanId VLAN = VlanId.vlanId((short) 10);
tom093340b2014-10-10 00:15:36 -070021 private static final IpPrefix IP = IpPrefix.valueOf("10.0.0.1");
22
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070023 private static final HostLocation LOC = new HostLocation(
tom093340b2014-10-10 00:15:36 -070024 DeviceId.deviceId("of:foo"),
25 PortNumber.portNumber(100),
26 123L
27 );
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070028
29 @Test
30 public void basics() {
31 HostDescription host =
tom093340b2014-10-10 00:15:36 -070032 new DefaultHostDescription(MAC, VLAN, LOC, IP);
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070033 assertEquals("incorrect mac", MAC, host.hwAddress());
34 assertEquals("incorrect vlan", VLAN, host.vlan());
35 assertEquals("incorrect location", LOC, host.location());
tom093340b2014-10-10 00:15:36 -070036 assertEquals("incorrect ip's", IP, host.ipAddress());
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070037 assertTrue("incorrect toString", host.toString().contains("vlan=10"));
38 }
39
40}