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