samueljcc | 12d2f97 | 2015-10-28 15:58:05 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
samueljcc | 12d2f97 | 2015-10-28 15:58:05 -0700 | [diff] [blame] | 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 | */ |
| 16 | |
Ray Milkey | 6c1bac3 | 2015-11-13 14:40:40 -0800 | [diff] [blame] | 17 | package org.onosproject.vtnrsc; |
| 18 | |
| 19 | import org.junit.Test; |
| 20 | import org.onlab.packet.IpAddress; |
| 21 | import org.onlab.packet.MacAddress; |
| 22 | |
| 23 | import com.google.common.testing.EqualsTester; |
samueljcc | 12d2f97 | 2015-10-28 15:58:05 -0700 | [diff] [blame] | 24 | |
| 25 | import static org.hamcrest.MatcherAssert.assertThat; |
| 26 | import static org.hamcrest.Matchers.is; |
| 27 | import static org.hamcrest.Matchers.notNullValue; |
| 28 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 29 | |
samueljcc | 12d2f97 | 2015-10-28 15:58:05 -0700 | [diff] [blame] | 30 | /** |
| 31 | * Unit tests for AllowedAddressPair class. |
| 32 | */ |
| 33 | public class AllowedAddressPairTest { |
| 34 | |
| 35 | final IpAddress ip1 = IpAddress.valueOf("192.168.0.1"); |
| 36 | final IpAddress ip2 = IpAddress.valueOf("192.168.0.2"); |
| 37 | final MacAddress mac1 = MacAddress.valueOf("fa:16:3e:76:83:88"); |
| 38 | final MacAddress mac2 = MacAddress.valueOf("aa:16:3e:76:83:88"); |
| 39 | |
| 40 | /** |
| 41 | * Checks that the AllowedAddressPair class is immutable. |
| 42 | */ |
| 43 | @Test |
| 44 | public void testImmutability() { |
| 45 | assertThatClassIsImmutable(AllowedAddressPair.class); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Checks the operation of equals(). |
| 50 | */ |
| 51 | @Test |
| 52 | public void testEquals() { |
| 53 | AllowedAddressPair p1 = AllowedAddressPair |
| 54 | .allowedAddressPair(ip1, mac1); |
| 55 | AllowedAddressPair p2 = AllowedAddressPair |
| 56 | .allowedAddressPair(ip1, mac1); |
| 57 | AllowedAddressPair p3 = AllowedAddressPair |
| 58 | .allowedAddressPair(ip2, mac2); |
| 59 | new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3) |
| 60 | .testEquals(); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Checks the construction of a AllowedAddressPair object. |
| 65 | */ |
| 66 | @Test |
| 67 | public void testConstruction() { |
| 68 | AllowedAddressPair allowedAddressPair = AllowedAddressPair |
| 69 | .allowedAddressPair(ip1, mac1); |
| 70 | assertThat(ip1, is(notNullValue())); |
| 71 | assertThat(ip1, is(allowedAddressPair.ip())); |
| 72 | assertThat(mac1, is(notNullValue())); |
| 73 | assertThat(mac1, is(allowedAddressPair.mac())); |
| 74 | } |
| 75 | } |