blob: 1b00be7eb3b55c1264eb9e5bb4a7398f74dbbb0e [file] [log] [blame]
Ayaka Koshibe93afebc2014-09-15 13:25:22 -07001package org.onlab.onos.net.host;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertTrue;
5
6import java.util.Set;
7
8import org.junit.Test;
9import org.onlab.onos.net.DeviceId;
10import org.onlab.onos.net.HostLocation;
11import org.onlab.onos.net.PortNumber;
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -070012import org.onlab.packet.IpPrefix;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070013import org.onlab.packet.MacAddress;
14import org.onlab.packet.VlanId;
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070015
16import com.google.common.collect.Sets;
17
18/**
19 * Test for the default host description.
20 */
21public class DefualtHostDecriptionTest {
22
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070023 private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01");
24 private static final VlanId VLAN = VlanId.vlanId((short) 10);
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070025 private static final HostLocation LOC = new HostLocation(
26 DeviceId.deviceId("of:foo"),
27 PortNumber.portNumber(100),
28 123L
29 );
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -070030 private static final Set<IpPrefix> IPS = Sets.newHashSet(
31 IpPrefix.valueOf("10.0.0.1"),
32 IpPrefix.valueOf("10.0.0.2")
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070033 );
34
35 @Test
36 public void basics() {
37 HostDescription host =
38 new DefaultHostDescription(MAC, VLAN, LOC, IPS);
39 assertEquals("incorrect mac", MAC, host.hwAddress());
40 assertEquals("incorrect vlan", VLAN, host.vlan());
41 assertEquals("incorrect location", LOC, host.location());
42 assertTrue("incorrect ip's", IPS.equals(host.ipAddresses()));
43 assertTrue("incorrect toString", host.toString().contains("vlan=10"));
44 }
45
46}