2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onosproject.vtnrsc.virtualport;
19 import static org.hamcrest.MatcherAssert.assertThat;
20 import static org.hamcrest.Matchers.is;
21 import static org.hamcrest.Matchers.notNullValue;
22 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
24 import org.junit.Test;
25 import org.onlab.packet.IpAddress;
26 import org.onlab.packet.MacAddress;
27 import org.onosproject.vtnrsc.AllowedAddressPair;
29 import com.google.common.testing.EqualsTester;
32 * Unit tests for AllowedAddressPair class.
34 public class AllowedAddressPairTest {
36 final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
37 final IpAddress ip2 = IpAddress.valueOf("192.168.0.2");
38 final MacAddress mac1 = MacAddress.valueOf("fa:16:3e:76:83:88");
39 final MacAddress mac2 = MacAddress.valueOf("aa:16:3e:76:83:88");
42 * Checks that the AllowedAddressPair class is immutable.
45 public void testImmutability() {
46 assertThatClassIsImmutable(AllowedAddressPair.class);
50 * Checks the operation of equals().
53 public void testEquals() {
54 AllowedAddressPair p1 = AllowedAddressPair
55 .allowedAddressPair(ip1, mac1);
56 AllowedAddressPair p2 = AllowedAddressPair
57 .allowedAddressPair(ip1, mac1);
58 AllowedAddressPair p3 = AllowedAddressPair
59 .allowedAddressPair(ip2, mac2);
60 new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
65 * Checks the construction of a AllowedAddressPair object.
68 public void testConstruction() {
69 AllowedAddressPair allowedAddressPair = AllowedAddressPair
70 .allowedAddressPair(ip1, mac1);
71 assertThat(ip1, is(notNullValue()));
72 assertThat(ip1, is(allowedAddressPair.ip()));
73 assertThat(mac1, is(notNullValue()));
74 assertThat(mac1, is(allowedAddressPair.mac()));