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.onlab.packet.IpPrefix;
25 import org.onosproject.vtnrsc.DefaultHostRoute;
26 import org.onosproject.vtnrsc.HostRoute;
28 import com.google.common.testing.EqualsTester;
31 * Unit tests for DefaultHostRoute class.
33 public class DefaultHostRouteTest {
34 final IpAddress nexthop1 = IpAddress.valueOf("192.168.1.1");
35 final IpAddress nexthop2 = IpAddress.valueOf("192.168.1.2");
36 final IpPrefix destination1 = IpPrefix.valueOf("1.1.1.1/1");
37 final IpPrefix destination2 = IpPrefix.valueOf("1.1.1.1/2");
40 * Checks that the DefaultHostRoute class is immutable.
43 public void testImmutability() {
44 assertThatClassIsImmutable(DefaultHostRoute.class);
48 * Checks the operation of equals() methods.
51 public void testEquals() {
52 HostRoute route1 = new DefaultHostRoute(nexthop1, destination1);
53 HostRoute route2 = new DefaultHostRoute(nexthop1, destination1);
54 HostRoute route3 = new DefaultHostRoute(nexthop2, destination2);
55 new EqualsTester().addEqualityGroup(route1, route2)
56 .addEqualityGroup(route3).testEquals();
60 * Checks the construction of a DefaultHostRoute object.
63 public void testConstruction() {
64 final HostRoute host = new DefaultHostRoute(nexthop1, destination1);
65 assertThat(nexthop1, is(host.nexthop()));
66 assertThat(destination1, is(host.destination()));