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; |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 7 | import org.onlab.packet.IpPrefix; |
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 | |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 11 | import static org.junit.Assert.assertEquals; |
| 12 | import static org.junit.Assert.assertTrue; |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 13 | |
| 14 | /** |
| 15 | * Test for the default host description. |
| 16 | */ |
| 17 | public class DefualtHostDecriptionTest { |
| 18 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 19 | private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01"); |
| 20 | private static final VlanId VLAN = VlanId.vlanId((short) 10); |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 21 | private static final IpPrefix IP = IpPrefix.valueOf("10.0.0.1"); |
| 22 | |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 23 | private static final HostLocation LOC = new HostLocation( |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 24 | DeviceId.deviceId("of:foo"), |
| 25 | PortNumber.portNumber(100), |
| 26 | 123L |
| 27 | ); |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 28 | |
| 29 | @Test |
| 30 | public void basics() { |
| 31 | HostDescription host = |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 32 | new DefaultHostDescription(MAC, VLAN, LOC, IP); |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 33 | assertEquals("incorrect mac", MAC, host.hwAddress()); |
| 34 | assertEquals("incorrect vlan", VLAN, host.vlan()); |
| 35 | assertEquals("incorrect location", LOC, host.location()); |
tom | 093340b | 2014-10-10 00:15:36 -0700 | [diff] [blame] | 36 | assertEquals("incorrect ip's", IP, host.ipAddress()); |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 37 | assertTrue("incorrect toString", host.toString().contains("vlan=10")); |
| 38 | } |
| 39 | |
| 40 | } |