Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.host; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | import static org.junit.Assert.assertTrue; |
| 5 | |
| 6 | import java.util.Set; |
| 7 | |
| 8 | import org.junit.Test; |
| 9 | import org.onlab.onos.net.DeviceId; |
| 10 | import org.onlab.onos.net.HostLocation; |
| 11 | import org.onlab.onos.net.PortNumber; |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame^] | 12 | import org.onlab.packet.IpPrefix; |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 13 | import org.onlab.packet.MacAddress; |
| 14 | import org.onlab.packet.VlanId; |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 15 | |
| 16 | import com.google.common.collect.Sets; |
| 17 | |
| 18 | /** |
| 19 | * Test for the default host description. |
| 20 | */ |
| 21 | public class DefualtHostDecriptionTest { |
| 22 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 23 | private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01"); |
| 24 | private static final VlanId VLAN = VlanId.vlanId((short) 10); |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 25 | private static final HostLocation LOC = new HostLocation( |
| 26 | DeviceId.deviceId("of:foo"), |
| 27 | PortNumber.portNumber(100), |
| 28 | 123L |
| 29 | ); |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame^] | 30 | private static final Set<IpPrefix> IPS = Sets.newHashSet( |
| 31 | IpPrefix.valueOf("10.0.0.1"), |
| 32 | IpPrefix.valueOf("10.0.0.2") |
Ayaka Koshibe | 93afebc | 2014-09-15 13:25:22 -0700 | [diff] [blame] | 33 | ); |
| 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 | } |