blob: 422da004f80b8a231f666d9aa1274e1585c92e45 [file] [log] [blame]
samueljcc710b55a2015-10-28 15:55:31 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samueljcc710b55a2015-10-28 15:55:31 -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 */
Ray Milkey6c1bac32015-11-13 14:40:40 -080016package org.onosproject.vtnrsc;
17
18import org.junit.Test;
19import org.onlab.packet.IpAddress;
20
21import com.google.common.testing.EqualsTester;
samueljcc710b55a2015-10-28 15:55:31 -070022
23import static org.hamcrest.MatcherAssert.assertThat;
24import static org.hamcrest.Matchers.is;
25import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
26
samueljcc710b55a2015-10-28 15:55:31 -070027/**
28 * Unit tests for DefaultAllocationPool class.
29 */
30public class DefaultAllocationPoolTest {
31
32 final IpAddress startIP1 = IpAddress.valueOf("192.168.1.1");
33 final IpAddress startIP2 = IpAddress.valueOf("192.168.1.2");
34 final IpAddress endIP1 = IpAddress.valueOf("192.168.1.1");
35 final IpAddress endIP2 = IpAddress.valueOf("192.168.1.2");
36
37 /**
38 * Checks that the DefaultAllocationPool class is immutable.
39 */
40 @Test
41 public void testImmutability() {
42 assertThatClassIsImmutable(DefaultAllocationPool.class);
43 }
44
45 /**
46 * Checks the operation of equals() methods.
47 */
48 @Test
49 public void testEquals() {
50 AllocationPool pool1 = new DefaultAllocationPool(startIP1, endIP1);
51 AllocationPool pool2 = new DefaultAllocationPool(startIP1, endIP1);
52 AllocationPool pool3 = new DefaultAllocationPool(startIP2, endIP2);
53 new EqualsTester().addEqualityGroup(pool1, pool2)
54 .addEqualityGroup(pool3).testEquals();
55 }
56
57 /**
58 * Checks the construction of a DefaultAllocationPool object.
59 */
60 @Test
61 public void testConstruction() {
62 final AllocationPool apool = new DefaultAllocationPool(startIP1, endIP1);
63 assertThat(startIP1, is(apool.startIp()));
64 assertThat(endIP1, is(apool.endIp()));
65 }
66}