blob: 19e9a627f6f04765ff7be65b8451325a3b5708c8 [file] [log] [blame]
samueljcc12d2f972015-10-28 15:58:05 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samueljcc12d2f972015-10-28 15:58:05 -07003 *
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 Milkey6c1bac32015-11-13 14:40:40 -080017package org.onosproject.vtnrsc;
18
19import org.junit.Test;
20import org.onlab.packet.IpAddress;
21import org.onlab.packet.MacAddress;
22
23import com.google.common.testing.EqualsTester;
samueljcc12d2f972015-10-28 15:58:05 -070024
25import static org.hamcrest.MatcherAssert.assertThat;
26import static org.hamcrest.Matchers.is;
27import static org.hamcrest.Matchers.notNullValue;
28import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
29
samueljcc12d2f972015-10-28 15:58:05 -070030/**
31 * Unit tests for AllowedAddressPair class.
32 */
33public 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}