Committed by
Ray Milkey
[ONOS-3246] Add the junit test code of DefaultHostRoute
Change-Id: I7b08664f453e75a3a470e87ca84bcbede0e4bd73
Showing
1 changed file
with
68 additions
and
0 deletions
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
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 | + */ | ||
16 | +package org.onosproject.vtnrsc.subnet; | ||
17 | + | ||
18 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
19 | +import static org.hamcrest.Matchers.is; | ||
20 | +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; | ||
21 | + | ||
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; | ||
27 | + | ||
28 | +import com.google.common.testing.EqualsTester; | ||
29 | + | ||
30 | +/** | ||
31 | + * Unit tests for DefaultHostRoute class. | ||
32 | + */ | ||
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"); | ||
38 | + | ||
39 | + /** | ||
40 | + * Checks that the DefaultHostRoute class is immutable. | ||
41 | + */ | ||
42 | + @Test | ||
43 | + public void testImmutability() { | ||
44 | + assertThatClassIsImmutable(DefaultHostRoute.class); | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Checks the operation of equals() methods. | ||
49 | + */ | ||
50 | + @Test | ||
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(); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Checks the construction of a DefaultHostRoute object. | ||
61 | + */ | ||
62 | + @Test | ||
63 | + public void testConstruction() { | ||
64 | + final HostRoute host = new DefaultHostRoute(nexthop1, destination1); | ||
65 | + assertThat(nexthop1, is(host.nexthop())); | ||
66 | + assertThat(destination1, is(host.destination())); | ||
67 | + } | ||
68 | +} |
-
Please register or login to post a comment