blob: a69240817d771ace3a4f02e83855c71e220d4bb6 [file] [log] [blame]
Kalyankumar Asangi19f64492016-02-17 17:34:16 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Kalyankumar Asangi19f64492016-02-17 17:34:16 +05303 *
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 */
16package org.onosproject.ospf.controller.area;
17
18
Kalyankumar Asangi19f64492016-02-17 17:34:16 +053019import org.junit.After;
20import org.junit.Before;
21import org.junit.Test;
22import org.onlab.packet.Ip4Address;
23import org.onosproject.ospf.controller.OspfAreaAddressRange;
24
25import static org.hamcrest.CoreMatchers.is;
26import static org.hamcrest.CoreMatchers.notNullValue;
27import static org.hamcrest.MatcherAssert.assertThat;
28
29/**
30 * Unit test class for OspfAreaAddressRangeImpl.
31 */
32public class OspfAreaAddressRangeImplTest {
33
34 private OspfAreaAddressRange ospfAreaAddressRange;
35 private int result;
36 private String result1;
37
38 @Before
39 public void setUp() throws Exception {
40 ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
41 }
42
43 @After
44 public void tearDown() throws Exception {
45 ospfAreaAddressRange = null;
46 }
47
48 /**
49 * Tests ipAddress() getter method.
50 */
51 @Test
52 public void testGetIpAddress() throws Exception {
53 ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
54 assertThat(ospfAreaAddressRange.ipAddress(), is(Ip4Address.valueOf("1.1.1.1")));
55 }
56
57 /**
58 * Tests ipAddress() setter method.
59 */
60 @Test
61 public void testSetIpAddress() throws Exception {
62 ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
63 assertThat(ospfAreaAddressRange.ipAddress(), is(Ip4Address.valueOf("1.1.1.1")));
64 }
65
66 /**
67 * Tests mask() getter method.
68 */
69 @Test
70 public void testGetMask() throws Exception {
71 ospfAreaAddressRange.setMask("1.1.1.1");
72 assertThat(ospfAreaAddressRange.mask(), is("1.1.1.1"));
73 }
74
75 /**
76 * Tests mask() setter method.
77 */
78 @Test
79 public void testSetMask() throws Exception {
80 ospfAreaAddressRange.setMask("1.1.1.1");
81 assertThat(ospfAreaAddressRange.mask(), is("1.1.1.1"));
82 }
83
84 /**
85 * Tests isAdvertise() getter method.
86 */
87 @Test
88 public void testIsAdvertise() throws Exception {
89 ospfAreaAddressRange.setAdvertise(true);
90 assertThat(ospfAreaAddressRange.isAdvertise(), is(true));
91 }
92
93 /**
94 * Tests isAdvertise() setter method.
95 */
96 @Test
97 public void testSetAdvertise() throws Exception {
98 ospfAreaAddressRange.setAdvertise(true);
99 assertThat(ospfAreaAddressRange.isAdvertise(), is(true));
100 }
101
102 /**
103 * Tests equals() method.
104 */
105 @Test
106 public void testEquals() throws Exception {
sunish vkaa48da82016-03-02 23:17:06 +0530107 assertThat(ospfAreaAddressRange.equals(new OspfAreaAddressRangeImpl()), is(true));
Kalyankumar Asangi19f64492016-02-17 17:34:16 +0530108 }
109
110 /**
sunish vkaa48da82016-03-02 23:17:06 +0530111 * Tests hashCode() method.
Kalyankumar Asangi19f64492016-02-17 17:34:16 +0530112 */
113 @Test
Kalyankumar Asangi19f64492016-02-17 17:34:16 +0530114 public void testHashCode() throws Exception {
115 result = ospfAreaAddressRange.hashCode();
116 assertThat(result, is(notNullValue()));
117 }
118
119 /**
120 * Tests to string method.
121 */
122 @Test
123 public void testToString() throws Exception {
124 result1 = ospfAreaAddressRange.toString();
125 assertThat(result1, is(notNullValue()));
126 }
127}