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.
16 package org.onosproject.vtnrsc.subnet;
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is;
20 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
22 import org.junit.Test;
23 import org.onlab.packet.IpAddress;
24 import org.onosproject.vtnrsc.AllocationPool;
25 import org.onosproject.vtnrsc.DefaultAllocationPool;
27 import com.google.common.testing.EqualsTester;
30 * Unit tests for DefaultAllocationPool class.
32 public class DefaultAllocationPoolTest {
34 final IpAddress startIP1 = IpAddress.valueOf("192.168.1.1");
35 final IpAddress startIP2 = IpAddress.valueOf("192.168.1.2");
36 final IpAddress endIP1 = IpAddress.valueOf("192.168.1.1");
37 final IpAddress endIP2 = IpAddress.valueOf("192.168.1.2");
40 * Checks that the DefaultAllocationPool class is immutable.
43 public void testImmutability() {
44 assertThatClassIsImmutable(DefaultAllocationPool.class);
48 * Checks the operation of equals() methods.
51 public void testEquals() {
52 AllocationPool pool1 = new DefaultAllocationPool(startIP1, endIP1);
53 AllocationPool pool2 = new DefaultAllocationPool(startIP1, endIP1);
54 AllocationPool pool3 = new DefaultAllocationPool(startIP2, endIP2);
55 new EqualsTester().addEqualityGroup(pool1, pool2)
56 .addEqualityGroup(pool3).testEquals();
60 * Checks the construction of a DefaultAllocationPool object.
63 public void testConstruction() {
64 final AllocationPool apool = new DefaultAllocationPool(startIP1, endIP1);
65 assertThat(startIP1, is(apool.startIp()));
66 assertThat(endIP1, is(apool.endIp()));