Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.host; |
| 2 | |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 3 | import org.junit.Test; |
| 4 | import org.onlab.onos.net.DeviceId; |
| 5 | import org.onlab.onos.net.HostLocation; |
| 6 | import org.onlab.onos.net.PortNumber; |
Pavlin Radoslavov | 33f228a | 2014-10-27 19:33:16 -0700 | [diff] [blame^] | 7 | import org.onlab.packet.IpAddress; |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 8 | import org.onlab.packet.MacAddress; |
| 9 | import org.onlab.packet.VlanId; |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 10 | |
Yuta HIGUCHI | 5fa3dc0 | 2014-10-15 17:08:13 -0700 | [diff] [blame] | 11 | import com.google.common.collect.ImmutableSet; |
| 12 | |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 13 | import static org.junit.Assert.assertEquals; |
| 14 | import static org.junit.Assert.assertTrue; |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 15 | |
| 16 | /** |
| 17 | * Test for the default host description. |
| 18 | */ |
Pavlin Radoslavov | 3a7c1f8 | 2014-10-24 13:42:38 -0700 | [diff] [blame] | 19 | public class DefaultHostDecriptionTest { |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 20 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 21 | private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01"); |
| 22 | private static final VlanId VLAN = VlanId.vlanId((short) 10); |
Pavlin Radoslavov | 33f228a | 2014-10-27 19:33:16 -0700 | [diff] [blame^] | 23 | private static final IpAddress IP = IpAddress.valueOf("10.0.0.1"); |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 24 | |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 25 | private static final HostLocation LOC = new HostLocation( |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 26 | DeviceId.deviceId("of:foo"), |
| 27 | PortNumber.portNumber(100), |
| 28 | 123L |
| 29 | ); |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 30 | |
| 31 | @Test |
| 32 | public void basics() { |
| 33 | HostDescription host = |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 34 | new DefaultHostDescription(MAC, VLAN, LOC, IP); |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 35 | assertEquals("incorrect mac", MAC, host.hwAddress()); |
| 36 | assertEquals("incorrect vlan", VLAN, host.vlan()); |
| 37 | assertEquals("incorrect location", LOC, host.location()); |
Yuta HIGUCHI | 5fa3dc0 | 2014-10-15 17:08:13 -0700 | [diff] [blame] | 38 | assertEquals("incorrect ip's", ImmutableSet.of(IP), host.ipAddress()); |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 39 | assertTrue("incorrect toString", host.toString().contains("vlan=10")); |
| 40 | } |
| 41 | |
| 42 | } |