blob: 9f081431ceb2954a66d53f309db84255b9f47c15 [file] [log] [blame]
samueljccfd3b9902015-10-28 15:59:22 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
samueljccfd3b9902015-10-28 15:59:22 -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;
21
22import com.google.common.testing.EqualsTester;
samueljccfd3b9902015-10-28 15:59:22 -070023
24import static org.hamcrest.MatcherAssert.assertThat;
25import static org.hamcrest.Matchers.is;
26import static org.hamcrest.Matchers.notNullValue;
27import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
28
samueljccfd3b9902015-10-28 15:59:22 -070029/**
30 * Unit tests for FixedIp class.
31 */
32public class FixedIpTest {
33
34 final SubnetId subnetId1 = SubnetId.subnetId("lef11-95w-4er-9c9c");
35 final SubnetId subnetId2 = SubnetId.subnetId("lefaa-95w-4er-9c9c");
36 final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
37 final IpAddress ip2 = IpAddress.valueOf("192.168.1.1");
38
39 /**
40 * Checks that the FixedIp class is immutable.
41 */
42 @Test
43 public void testImmutability() {
44 assertThatClassIsImmutable(FixedIp.class);
45 }
46
47 /**
48 * Checks the operation of equals().
49 */
50 @Test
51 public void testEquals() {
52 FixedIp fixedIp1 = FixedIp.fixedIp(subnetId1, ip1);
53 FixedIp fixedIp2 = FixedIp.fixedIp(subnetId1, ip1);
54 FixedIp fixedIp3 = FixedIp.fixedIp(subnetId2, ip2);
55 new EqualsTester().addEqualityGroup(fixedIp1, fixedIp2)
56 .addEqualityGroup(fixedIp3).testEquals();
57 }
58
59 /**
60 * Checks the construction of a FixedIp object.
61 */
62 @Test
63 public void testConstruction() {
64 FixedIp fixedIp = FixedIp.fixedIp(subnetId1, ip1);
65 assertThat(ip1, is(notNullValue()));
66 assertThat(ip1, is(fixedIp.ip()));
67 assertThat(subnetId1, is(notNullValue()));
68 assertThat(subnetId1, is(fixedIp.subnetId()));
69 }
70}