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.onosproject.vtnrsc.FixedIp;
27 import org.onosproject.vtnrsc.SubnetId;
29 import com.google.common.testing.EqualsTester;
32 * Unit tests for FixedIp class.
34 public class FixedIpTest {
36 final SubnetId subnetId1 = SubnetId.subnetId("lef11-95w-4er-9c9c");
37 final SubnetId subnetId2 = SubnetId.subnetId("lefaa-95w-4er-9c9c");
38 final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
39 final IpAddress ip2 = IpAddress.valueOf("192.168.1.1");
42 * Checks that the FixedIp class is immutable.
45 public void testImmutability() {
46 assertThatClassIsImmutable(FixedIp.class);
50 * Checks the operation of equals().
53 public void testEquals() {
54 FixedIp fixedIp1 = FixedIp.fixedIp(subnetId1, ip1);
55 FixedIp fixedIp2 = FixedIp.fixedIp(subnetId1, ip1);
56 FixedIp fixedIp3 = FixedIp.fixedIp(subnetId2, ip2);
57 new EqualsTester().addEqualityGroup(fixedIp1, fixedIp2)
58 .addEqualityGroup(fixedIp3).testEquals();
62 * Checks the construction of a FixedIp object.
65 public void testConstruction() {
66 FixedIp fixedIp = FixedIp.fixedIp(subnetId1, ip1);
67 assertThat(ip1, is(notNullValue()));
68 assertThat(ip1, is(fixedIp.ip()));
69 assertThat(subnetId1, is(notNullValue()));
70 assertThat(subnetId1, is(fixedIp.subnetId()));