blob: 3d57d22feb28a15a18d2d3bb3ef32f41bd59c39a [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070016package org.onlab.onos.net.host;
17
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070018import org.junit.Test;
19import org.onlab.onos.net.DeviceId;
20import org.onlab.onos.net.HostLocation;
21import org.onlab.onos.net.PortNumber;
Pavlin Radoslavov33f228a2014-10-27 19:33:16 -070022import org.onlab.packet.IpAddress;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070023import org.onlab.packet.MacAddress;
24import org.onlab.packet.VlanId;
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070025
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070026import com.google.common.collect.ImmutableSet;
27
tom093340b2014-10-10 00:15:36 -070028import static org.junit.Assert.assertEquals;
29import static org.junit.Assert.assertTrue;
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070030
31/**
32 * Test for the default host description.
33 */
Pavlin Radoslavov3a7c1f82014-10-24 13:42:38 -070034public class DefaultHostDecriptionTest {
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070035
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070036 private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01");
37 private static final VlanId VLAN = VlanId.vlanId((short) 10);
Pavlin Radoslavov33f228a2014-10-27 19:33:16 -070038 private static final IpAddress IP = IpAddress.valueOf("10.0.0.1");
tom093340b2014-10-10 00:15:36 -070039
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070040 private static final HostLocation LOC = new HostLocation(
tom093340b2014-10-10 00:15:36 -070041 DeviceId.deviceId("of:foo"),
42 PortNumber.portNumber(100),
43 123L
44 );
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070045
46 @Test
47 public void basics() {
48 HostDescription host =
tom093340b2014-10-10 00:15:36 -070049 new DefaultHostDescription(MAC, VLAN, LOC, IP);
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070050 assertEquals("incorrect mac", MAC, host.hwAddress());
51 assertEquals("incorrect vlan", VLAN, host.vlan());
52 assertEquals("incorrect location", LOC, host.location());
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070053 assertEquals("incorrect ip's", ImmutableSet.of(IP), host.ipAddress());
Ayaka Koshibe93afebc2014-09-15 13:25:22 -070054 assertTrue("incorrect toString", host.toString().contains("vlan=10"));
55 }
56
57}