blob: 8bfde9c639157c2ce66a5fcd36ea9a6753a15fd6 [file] [log] [blame]
samueljcc9f4c9712015-10-28 15:56:36 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samueljcc9f4c9712015-10-28 15:56:36 -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;
samueljcc9f4c9712015-10-28 15:56:36 -070017
18import org.junit.Test;
19import org.onlab.packet.IpAddress;
20import org.onlab.packet.IpPrefix;
samueljcc9f4c9712015-10-28 15:56:36 -070021
22import com.google.common.testing.EqualsTester;
23
Ray Milkey6c1bac32015-11-13 14:40:40 -080024import static org.hamcrest.MatcherAssert.assertThat;
25import static org.hamcrest.Matchers.is;
26import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
27
samueljcc9f4c9712015-10-28 15:56:36 -070028/**
29 * Unit tests for DefaultHostRoute class.
30 */
31public class DefaultHostRouteTest {
32 final IpAddress nexthop1 = IpAddress.valueOf("192.168.1.1");
33 final IpAddress nexthop2 = IpAddress.valueOf("192.168.1.2");
34 final IpPrefix destination1 = IpPrefix.valueOf("1.1.1.1/1");
35 final IpPrefix destination2 = IpPrefix.valueOf("1.1.1.1/2");
36
37 /**
38 * Checks that the DefaultHostRoute class is immutable.
39 */
40 @Test
41 public void testImmutability() {
42 assertThatClassIsImmutable(DefaultHostRoute.class);
43 }
44
45 /**
46 * Checks the operation of equals() methods.
47 */
48 @Test
49 public void testEquals() {
50 HostRoute route1 = new DefaultHostRoute(nexthop1, destination1);
51 HostRoute route2 = new DefaultHostRoute(nexthop1, destination1);
52 HostRoute route3 = new DefaultHostRoute(nexthop2, destination2);
53 new EqualsTester().addEqualityGroup(route1, route2)
54 .addEqualityGroup(route3).testEquals();
55 }
56
57 /**
58 * Checks the construction of a DefaultHostRoute object.
59 */
60 @Test
61 public void testConstruction() {
62 final HostRoute host = new DefaultHostRoute(nexthop1, destination1);
63 assertThat(nexthop1, is(host.nexthop()));
64 assertThat(destination1, is(host.destination()));
65 }
66}