Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net; |
Ayaka Koshibe | 50ee924 | 2014-09-12 16:37:46 -0700 | [diff] [blame] | 17 | |
| 18 | import static org.junit.Assert.assertEquals; |
| 19 | |
| 20 | import org.junit.Test; |
| 21 | |
| 22 | import com.google.common.testing.EqualsTester; |
| 23 | |
| 24 | public class DefaultHostTest extends TestDeviceParams { |
| 25 | |
| 26 | @Test |
| 27 | public void testEquality() { |
| 28 | Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1, IPSET1); |
| 29 | Host h2 = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1, IPSET1); |
| 30 | Host h3 = new DefaultHost(PID, HID2, MAC2, VLAN2, LOC2, IPSET2); |
| 31 | Host h4 = new DefaultHost(PID, HID2, MAC2, VLAN2, LOC2, IPSET2); |
| 32 | Host h5 = new DefaultHost(PID, HID2, MAC2, VLAN1, LOC2, IPSET1); |
| 33 | |
| 34 | new EqualsTester().addEqualityGroup(h1, h2) |
| 35 | .addEqualityGroup(h3, h4) |
| 36 | .addEqualityGroup(h5) |
| 37 | .testEquals(); |
| 38 | } |
| 39 | |
| 40 | @Test |
| 41 | public void basics() { |
| 42 | Host host = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1, IPSET1); |
| 43 | assertEquals("incorrect provider", PID, host.providerId()); |
| 44 | assertEquals("incorrect id", HID1, host.id()); |
| 45 | assertEquals("incorrect type", MAC1, host.mac()); |
| 46 | assertEquals("incorrect VLAN", VLAN1, host.vlan()); |
| 47 | assertEquals("incorrect location", LOC1, host.location()); |
| 48 | assertEquals("incorrect IP's", IPSET1, host.ipAddresses()); |
| 49 | } |
| 50 | |
| 51 | } |