sunish vk | 1857c42 | 2016-02-17 18:05:52 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Laboratory |
sunish vk | 1857c42 | 2016-02-17 18:05:52 +0530 | [diff] [blame] | 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.ospf.controller.impl; |
| 17 | |
| 18 | |
| 19 | import org.easymock.EasyMock; |
| 20 | import org.jboss.netty.channel.Channel; |
| 21 | import org.junit.After; |
| 22 | import org.junit.Assert; |
| 23 | import org.junit.Before; |
| 24 | import org.junit.Test; |
| 25 | import org.onlab.packet.Ip4Address; |
| 26 | import org.onosproject.ospf.controller.OspfInterface; |
| 27 | import org.onosproject.ospf.controller.OspfLsa; |
| 28 | import org.onosproject.ospf.controller.OspfLsaType; |
| 29 | import org.onosproject.ospf.controller.OspfNeighborState; |
| 30 | import org.onosproject.ospf.controller.TopologyForDeviceAndLink; |
| 31 | import org.onosproject.ospf.controller.area.OspfAreaImpl; |
| 32 | import org.onosproject.ospf.controller.area.OspfInterfaceImpl; |
| 33 | import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl; |
| 34 | import org.onosproject.ospf.controller.lsdb.LsdbAgeImpl; |
| 35 | import org.onosproject.ospf.protocol.lsa.LsaHeader; |
sunish vk | 1857c42 | 2016-02-17 18:05:52 +0530 | [diff] [blame] | 36 | import org.onosproject.ospf.protocol.lsa.types.NetworkLsa; |
| 37 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; |
| 38 | import org.onosproject.ospf.protocol.ospfpacket.OspfMessage; |
| 39 | import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket; |
| 40 | import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket; |
| 41 | import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest; |
| 42 | import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; |
| 43 | import org.onosproject.ospf.protocol.util.ChecksumCalculator; |
sunish vk | 1857c42 | 2016-02-17 18:05:52 +0530 | [diff] [blame] | 44 | import org.onosproject.ospf.protocol.util.OspfUtil; |
| 45 | |
| 46 | import java.net.SocketAddress; |
| 47 | import java.util.ArrayList; |
| 48 | import java.util.List; |
| 49 | |
| 50 | import static org.hamcrest.CoreMatchers.is; |
| 51 | import static org.hamcrest.CoreMatchers.notNullValue; |
| 52 | import static org.hamcrest.MatcherAssert.assertThat; |
| 53 | |
| 54 | /** |
| 55 | * Unit test class for OspfNbrImpl. |
| 56 | */ |
| 57 | public class OspfNbrImplTest { |
| 58 | |
| 59 | private OspfNbrImpl ospfNbr; |
| 60 | private OspfInterfaceImpl ospfInterface; |
| 61 | private OspfAreaImpl ospfArea; |
| 62 | private OspfInterfaceImpl ospfInterface1; |
| 63 | private OspfInterfaceImpl ospfInterface2; |
| 64 | private List<OspfInterface> ospfInterfaces; |
| 65 | private List<OspfLsa> ospfLsaList; |
| 66 | private Channel channel; |
| 67 | private Channel channel1; |
| 68 | private Channel channel2; |
| 69 | private OspfMessage ospfMessage; |
| 70 | private TopologyForDeviceAndLink topologyForDeviceAndLink; |
| 71 | |
| 72 | @Before |
| 73 | public void setUp() throws Exception { |
| 74 | ospfInterface = new OspfInterfaceImpl(); |
| 75 | ospfInterface.setInterfaceType(2); |
| 76 | ospfInterface.setRouterDeadIntervalTime(30); |
| 77 | ospfInterface.setReTransmitInterval(30); |
| 78 | ospfInterface.setDr(Ip4Address.valueOf("1.1.1.1")); |
| 79 | ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1")); |
| 80 | ospfArea = new OspfAreaImpl(); |
| 81 | ospfInterface1 = new OspfInterfaceImpl(); |
| 82 | ospfInterface1.setInterfaceType(2); |
| 83 | ospfInterface1.setRouterDeadIntervalTime(30); |
| 84 | ospfInterface1.setReTransmitInterval(30); |
| 85 | ospfInterface1.setDr(Ip4Address.valueOf("7.7.7.7")); |
| 86 | ospfInterface1.setIpAddress(Ip4Address.valueOf("7.7.7.7")); |
| 87 | ospfInterface2 = new OspfInterfaceImpl(); |
| 88 | ospfInterface2.setInterfaceType(2); |
| 89 | ospfInterface2.setRouterDeadIntervalTime(30); |
| 90 | ospfInterface2.setReTransmitInterval(30); |
| 91 | ospfInterface2.setDr(Ip4Address.valueOf("6.6.6.6")); |
| 92 | ospfInterface2.setIpAddress(Ip4Address.valueOf("6.6.6.6")); |
| 93 | ospfInterfaces = new ArrayList(); |
| 94 | ospfInterfaces.add(ospfInterface); |
| 95 | ospfInterfaces.add(ospfInterface1); |
| 96 | ospfInterfaces.add(ospfInterface2); |
| 97 | ospfArea.setInterfacesLst(ospfInterfaces); |
| 98 | ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111")); |
| 99 | topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl(); |
| 100 | ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"), |
| 101 | Ip4Address.valueOf("2.2.2.2"), 2, |
| 102 | new OspfInterfaceChannelHandler(new Controller(), |
sunish vk | aa48da8 | 2016-03-02 23:17:06 +0530 | [diff] [blame] | 103 | ospfArea, ospfInterface), |
| 104 | topologyForDeviceAndLink); |
sunish vk | 1857c42 | 2016-02-17 18:05:52 +0530 | [diff] [blame] | 105 | |
| 106 | } |
| 107 | |
| 108 | @After |
| 109 | public void tearDown() throws Exception { |
| 110 | ospfNbr = null; |
| 111 | ospfArea = null; |
| 112 | ospfInterface = null; |
| 113 | ospfLsaList = null; |
| 114 | channel = null; |
| 115 | channel1 = null; |
| 116 | channel2 = null; |
| 117 | ospfMessage = null; |
| 118 | |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Tests neighborIpAddr() method. |
| 123 | */ |
| 124 | @Test |
| 125 | public void testNeighborIpAddr() throws Exception { |
| 126 | assertThat(ospfNbr.neighborIpAddr(), is(notNullValue())); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Tests isOpaqueCapable() getter method. |
| 131 | */ |
| 132 | @Test |
| 133 | public void testIsOpaqueCapable() throws Exception { |
| 134 | assertThat(ospfNbr.isOpaqueCapable(), is(false)); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Tests isOpaqueCapable() setter method. |
| 139 | */ |
| 140 | @Test |
| 141 | public void testSetIsOpaqueCapable() throws Exception { |
| 142 | ospfNbr.setIsOpaqueCapable(true); |
| 143 | assertThat(ospfNbr.isOpaqueCapable(), is(true)); |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Tests oneWayReceived() method. |
| 148 | */ |
| 149 | @Test |
| 150 | public void testOneWayReceived() throws Exception { |
| 151 | ospfMessage = new HelloPacket(); |
| 152 | ospfNbr.setState(OspfNeighborState.ATTEMPT); |
| 153 | channel = EasyMock.createMock(Channel.class); |
| 154 | ospfNbr.oneWayReceived(ospfMessage, channel); |
| 155 | channel1 = EasyMock.createMock(Channel.class); |
| 156 | ospfNbr.setState(OspfNeighborState.DOWN); |
| 157 | ospfNbr.oneWayReceived(ospfMessage, channel1); |
| 158 | channel2 = EasyMock.createMock(Channel.class); |
| 159 | ospfNbr.setState(OspfNeighborState.TWOWAY); |
| 160 | ospfNbr.oneWayReceived(ospfMessage, channel2); |
| 161 | assertThat(ospfNbr, is(notNullValue())); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Tests twoWayReceived() method. |
| 166 | */ |
| 167 | @Test(expected = Exception.class) |
| 168 | public void testTwoWayReceived() throws Exception { |
| 169 | ospfNbr.setNeighborDr(Ip4Address.valueOf("1.1.1.1")); |
| 170 | ospfMessage = new HelloPacket(); |
| 171 | ospfNbr.setState(OspfNeighborState.ATTEMPT); |
| 172 | ospfNbr.setNeighborDr(Ip4Address.valueOf("2.2.2.2")); |
| 173 | ospfInterface.setIpAddress(Ip4Address.valueOf("2.2.2.2")); |
| 174 | channel = EasyMock.createMock(Channel.class); |
| 175 | SocketAddress socketAddress = EasyMock.createMock(SocketAddress.class); |
| 176 | channel.bind(socketAddress); |
| 177 | ospfNbr.twoWayReceived(ospfMessage, channel); |
| 178 | ospfInterface.setIpAddress(Ip4Address.valueOf("3.3.3.3")); |
| 179 | channel1 = EasyMock.createMock(Channel.class); |
| 180 | ospfNbr.twoWayReceived(ospfMessage, channel1); |
| 181 | assertThat(ospfNbr, is(notNullValue())); |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Tests negotiationDone() method. |
| 186 | */ |
| 187 | @Test(expected = Exception.class) |
| 188 | public void testNegotiationDone() throws Exception { |
| 189 | ospfLsaList = new ArrayList(); |
| 190 | ospfLsaList.add(new RouterLsa()); |
| 191 | ospfMessage = new HelloPacket(); |
| 192 | ospfNbr.setState(OspfNeighborState.EXSTART); |
| 193 | channel = EasyMock.createMock(Channel.class); |
| 194 | ospfNbr.negotiationDone(ospfMessage, true, ospfLsaList, channel); |
| 195 | channel1 = EasyMock.createMock(Channel.class); |
| 196 | ospfNbr.negotiationDone(ospfMessage, false, ospfLsaList, channel1); |
| 197 | assertThat(ospfNbr, is(notNullValue())); |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Tests processLsas() method. |
| 202 | */ |
| 203 | @Test |
| 204 | public void testProcessLsas() throws Exception { |
| 205 | ospfLsaList = new ArrayList(); |
| 206 | RouterLsa routerLsa = new RouterLsa(); |
| 207 | routerLsa.setLsType(1); |
| 208 | ospfLsaList.add(routerLsa); |
| 209 | NetworkLsa networkLsa = new NetworkLsa(); |
| 210 | routerLsa.setLsType(2); |
| 211 | ospfLsaList.add(networkLsa); |
| 212 | routerLsa.setLsType(3); |
| 213 | ospfLsaList.add(routerLsa); |
| 214 | ospfNbr.processLsas(ospfLsaList); |
| 215 | assertThat(ospfNbr, is(notNullValue())); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Tests seqNumMismatch() method. |
| 220 | */ |
| 221 | @Test |
| 222 | public void testSeqNumMismatch() throws Exception { |
| 223 | ospfNbr.setState(OspfNeighborState.FULL); |
| 224 | assertThat(ospfNbr.seqNumMismatch("samelsa"), is(notNullValue())); |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * Tests badLSReq() method. |
| 229 | */ |
| 230 | @Test |
| 231 | public void testBadLSReq() throws Exception { |
| 232 | channel = EasyMock.createMock(Channel.class); |
| 233 | ospfNbr.setState(OspfNeighborState.FULL); |
| 234 | ospfNbr.badLSReq(channel); |
| 235 | assertThat(ospfNbr, is(notNullValue())); |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Tests processDdPacket() method. |
| 240 | */ |
| 241 | @Test |
| 242 | public void testProcessDdPacket() throws Exception { |
| 243 | ospfArea.addLsa(new RouterLsa(), false, ospfInterface); |
| 244 | ospfArea.addLsa(new RouterLsa(), ospfInterface); |
| 245 | ospfArea.addLsaToMaxAgeBin("lsa", new LsaWrapperImpl()); |
| 246 | channel = EasyMock.createMock(Channel.class); |
| 247 | DdPacket ddPacket = new DdPacket(); |
| 248 | ddPacket.addLsaHeader(new LsaHeader()); |
| 249 | ospfNbr.processDdPacket(true, ddPacket, channel); |
| 250 | channel1 = EasyMock.createMock(Channel.class); |
| 251 | ddPacket.setIsMore(1); |
| 252 | ospfNbr.processDdPacket(false, ddPacket, channel1); |
| 253 | assertThat(ospfNbr, is(notNullValue())); |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Tests exchangeDone() method. |
| 258 | */ |
| 259 | @Test |
| 260 | public void testExchangeDone() throws Exception { |
| 261 | ospfMessage = new HelloPacket(); |
| 262 | channel = EasyMock.createMock(Channel.class); |
| 263 | ospfNbr.setState(OspfNeighborState.EXCHANGE); |
| 264 | ospfNbr.exchangeDone(ospfMessage, channel); |
| 265 | assertThat(ospfNbr, is(notNullValue())); |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Tests exchangeDone() method. |
| 270 | */ |
| 271 | @Test |
| 272 | public void testExchangeDone1() throws Exception { |
| 273 | ospfMessage = new HelloPacket(); |
| 274 | channel = EasyMock.createMock(Channel.class); |
| 275 | ospfNbr.setState(OspfNeighborState.EXCHANGE); |
| 276 | ospfLsaList = new ArrayList(); |
| 277 | RouterLsa routerLsa = new RouterLsa(); |
| 278 | routerLsa.setLsType(1); |
| 279 | ospfLsaList.add(routerLsa); |
| 280 | NetworkLsa networkLsa = new NetworkLsa(); |
| 281 | routerLsa.setLsType(2); |
| 282 | ospfLsaList.add(networkLsa); |
| 283 | routerLsa.setLsType(3); |
| 284 | ospfLsaList.add(routerLsa); |
| 285 | ospfNbr.processLsas(ospfLsaList); |
| 286 | ospfNbr.setState(OspfNeighborState.EXCHANGE); |
| 287 | ospfNbr.exchangeDone(ospfMessage, channel); |
| 288 | assertThat(ospfNbr, is(notNullValue())); |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Tests adjOk() method. |
| 293 | */ |
| 294 | @Test |
| 295 | public void testAdjOk() throws Exception { |
| 296 | channel = EasyMock.createMock(Channel.class); |
| 297 | ospfInterface.setIpAddress(Ip4Address.valueOf("2.2.2.2")); |
| 298 | ospfNbr.setState(OspfNeighborState.TWOWAY); |
| 299 | ospfNbr.setNeighborDr(Ip4Address.valueOf("2.2.2.2")); |
| 300 | ospfNbr.adjOk(channel); |
| 301 | Assert.assertNotNull(ospfNbr); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Tests processLsUpdate() method. |
| 306 | */ |
| 307 | @Test |
| 308 | public void testProcessLsUpdate() throws Exception { |
| 309 | LsUpdate ospfMessage = new LsUpdate(); |
| 310 | ospfMessage.setSourceIp(Ip4Address.valueOf("10.10.10.10")); |
| 311 | ospfMessage.addLsa(new RouterLsa()); |
| 312 | ospfMessage.addLsa(new NetworkLsa()); |
| 313 | channel = EasyMock.createMock(Channel.class); |
| 314 | ospfNbr.setState(OspfNeighborState.EXCHANGE); |
| 315 | ospfNbr.processLsUpdate(ospfMessage, channel); |
| 316 | assertThat(ospfNbr, is(notNullValue())); |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Tests loadingDone() method. |
| 321 | */ |
| 322 | @Test |
| 323 | public void testLoadingDone() throws Exception { |
| 324 | ospfArea.addLsa(new RouterLsa(), false, ospfInterface); |
| 325 | ospfArea.addLsa(new RouterLsa(), ospfInterface); |
| 326 | ospfArea.addLsaToMaxAgeBin("lsa", new LsaWrapperImpl()); |
| 327 | ospfNbr.loadingDone(); |
| 328 | assertThat(ospfNbr, is(notNullValue())); |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Tests processReceivedLsa() method. |
| 333 | */ |
| 334 | @Test |
| 335 | public void testProcessReceivedLsa() throws Exception { |
| 336 | LsaWrapperImpl lsaWrapper = new LsaWrapperImpl(); |
| 337 | LsdbAgeImpl lsdbAge = new LsdbAgeImpl(new OspfAreaImpl()); |
| 338 | lsdbAge.ageLsaAndFlood(); |
| 339 | lsaWrapper.setLsdbAge(lsdbAge); |
| 340 | lsaWrapper.setLsaHeader(new NetworkLsa()); |
| 341 | RouterLsa routerlsa = new RouterLsa(); |
| 342 | routerlsa.setLsType(1); |
| 343 | routerlsa.setOptions(2); |
| 344 | routerlsa.setAdvertisingRouter(Ip4Address.valueOf("1.1.1.1")); |
| 345 | routerlsa.setAge(100); |
| 346 | routerlsa.setLinkStateId("2.2.2.2"); |
| 347 | routerlsa.setLsSequenceNo(1010101); |
| 348 | lsaWrapper.setLsaHeader(new RouterLsa()); |
| 349 | ospfArea.addLsa(routerlsa, false, ospfInterface); |
| 350 | |
| 351 | lsaWrapper.addLsa(OspfLsaType.ROUTER, routerlsa); |
| 352 | ospfArea.addLsa(routerlsa, ospfInterface); |
| 353 | ospfArea.addLsaToMaxAgeBin("lsa", new LsaWrapperImpl()); |
| 354 | byte[] res = routerlsa.asBytes(); |
| 355 | routerlsa.setLsPacketLen(res.length); |
| 356 | res = new ChecksumCalculator().calculateLsaChecksum(routerlsa.asBytes(), 16, 17); |
| 357 | routerlsa.setLsCheckSum(OspfUtil.byteToInteger(res)); |
| 358 | channel = EasyMock.createMock(Channel.class); |
| 359 | lsdbAge.ageLsaAndFlood(); |
| 360 | assertThat(ospfNbr.processReceivedLsa(lsaWrapper.lsaHeader(), true, channel, |
| 361 | Ip4Address.valueOf("10.10.10.10")), is(true)); |
| 362 | channel1 = EasyMock.createMock(Channel.class); |
| 363 | assertThat(ospfNbr.processReceivedLsa(routerlsa, true, channel1, |
| 364 | Ip4Address.valueOf("10.10.10.10")), is(true)); |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * Tests isNullorLatest() method. |
| 369 | */ |
| 370 | @Test |
| 371 | public void testIsNullorLatest() throws Exception { |
| 372 | |
| 373 | LsaWrapperImpl lsaWrapper = new LsaWrapperImpl(); |
| 374 | LsdbAgeImpl lsdbAge = new LsdbAgeImpl(new OspfAreaImpl()); |
| 375 | lsdbAge.ageLsaAndFlood(); |
| 376 | lsaWrapper.setLsdbAge(lsdbAge); |
| 377 | lsaWrapper.setLsaHeader(new LsaHeader()); |
| 378 | lsaWrapper.addLsa(OspfLsaType.ROUTER, new RouterLsa()); |
| 379 | assertThat(ospfNbr.isNullorLatest(lsaWrapper, new LsaHeader()), is(notNullValue())); |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * Tests processSelfOriginatedLsa() method. |
| 384 | */ |
| 385 | @Test |
| 386 | public void testProcessSelfOriginatedLsa() throws Exception { |
| 387 | ospfNbr.processSelfOriginatedLsa(); |
| 388 | assertThat(ospfNbr, is(notNullValue())); |
| 389 | } |
| 390 | |
| 391 | /** |
| 392 | * Tests sendLsa() method. |
| 393 | */ |
| 394 | @Test |
| 395 | public void testSendLsa() throws Exception { |
| 396 | channel = EasyMock.createMock(Channel.class); |
| 397 | ospfNbr.sendLsa(new LsaHeader(), Ip4Address.valueOf("1.1.1.1"), channel); |
| 398 | assertThat(ospfNbr, is(notNullValue())); |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Tests directAcknowledge() method. |
| 403 | */ |
| 404 | @Test |
| 405 | public void testDirectAcknowledge() throws Exception { |
| 406 | channel = EasyMock.createMock(Channel.class); |
| 407 | ospfNbr.directAcknowledge(new LsaHeader(), channel, Ip4Address.valueOf("1.1.1.1")); |
| 408 | assertThat(ospfNbr, is(notNullValue())); |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * Tests neighborDown() method. |
| 413 | */ |
| 414 | @Test(expected = Exception.class) |
| 415 | public void testNeighborDown() throws Exception { |
| 416 | ospfNbr.neighborDown(); |
| 417 | assertThat(ospfNbr, is(notNullValue())); |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Tests startFloodingTimer() method. |
| 422 | */ |
| 423 | @Test |
| 424 | public void testStartFloodingTimer() throws Exception { |
| 425 | channel = EasyMock.createMock(Channel.class); |
| 426 | ospfNbr.startFloodingTimer(channel); |
| 427 | assertThat(ospfNbr, is(notNullValue())); |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * Tests lastDdPacket() getter method. |
| 432 | */ |
| 433 | @Test |
| 434 | public void testGetLastDdPacket() throws Exception { |
| 435 | ospfNbr.setLastDdPacket(new DdPacket()); |
| 436 | assertThat(ospfNbr.lastDdPacket(), is(notNullValue())); |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * Tests lastDdPacket() setter method. |
| 441 | */ |
| 442 | @Test |
| 443 | public void testSetLastDdPacket() throws Exception { |
| 444 | ospfNbr.setLastDdPacket(new DdPacket()); |
| 445 | assertThat(ospfNbr.lastDdPacket(), is(notNullValue())); |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * Tests neighborId() getter method. |
| 450 | */ |
| 451 | @Test |
| 452 | public void testNeighborId() throws Exception { |
| 453 | ospfNbr.setNeighborId(Ip4Address.valueOf("1.1.1.1")); |
| 454 | assertThat(ospfNbr.neighborId(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * Tests neighborId() setter method. |
| 459 | */ |
| 460 | @Test |
| 461 | public void testSetNeighborId() throws Exception { |
| 462 | ospfNbr.setNeighborId(Ip4Address.valueOf("1.1.1.1")); |
| 463 | assertThat(ospfNbr.neighborId(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * Tests neighborDr() getter method. |
| 468 | */ |
| 469 | @Test |
| 470 | public void testNeighborDr() throws Exception { |
| 471 | ospfNbr.setNeighborDr(Ip4Address.valueOf("1.1.1.1")); |
| 472 | assertThat(ospfNbr.neighborDr(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 473 | } |
| 474 | |
| 475 | /** |
| 476 | * Tests neighborDr() setter method. |
| 477 | */ |
| 478 | @Test |
| 479 | public void testSetNeighborDr() throws Exception { |
| 480 | ospfNbr.setNeighborDr(Ip4Address.valueOf("1.1.1.1")); |
| 481 | assertThat(ospfNbr.neighborDr(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 482 | } |
| 483 | |
| 484 | /** |
| 485 | * Tests neighborBdr() getter method. |
| 486 | */ |
| 487 | @Test |
| 488 | public void testNeighborBdr() throws Exception { |
| 489 | ospfNbr.setNeighborBdr(Ip4Address.valueOf("1.1.1.1")); |
| 490 | assertThat(ospfNbr.neighborBdr(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * Tests neighborBdr() setter method. |
| 495 | */ |
| 496 | @Test |
| 497 | public void testSetNeighborBdr() throws Exception { |
| 498 | ospfNbr.setNeighborBdr(Ip4Address.valueOf("1.1.1.1")); |
| 499 | assertThat(ospfNbr.neighborBdr(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * Tests routerPriority() getter method. |
| 504 | */ |
| 505 | @Test |
| 506 | public void testRouterPriority() throws Exception { |
| 507 | ospfNbr.setRouterPriority(1); |
| 508 | assertThat(ospfNbr.routerPriority(), is(1)); |
| 509 | } |
| 510 | |
| 511 | /** |
| 512 | * Tests routerPriority() setter method. |
| 513 | */ |
| 514 | @Test |
| 515 | public void testSetRouterPriority() throws Exception { |
| 516 | ospfNbr.setRouterPriority(1); |
| 517 | assertThat(ospfNbr.routerPriority(), is(1)); |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Tests options() getter method. |
| 522 | */ |
| 523 | @Test |
| 524 | public void testGetOptions() throws Exception { |
| 525 | ospfNbr.setOptions(1); |
| 526 | assertThat(ospfNbr.options(), is(1)); |
| 527 | } |
| 528 | |
| 529 | /** |
| 530 | * Tests options() setter method. |
| 531 | */ |
| 532 | @Test |
| 533 | public void testSetOptions() throws Exception { |
| 534 | ospfNbr.setOptions(1); |
| 535 | assertThat(ospfNbr.options(), is(1)); |
| 536 | } |
| 537 | |
| 538 | /** |
| 539 | * Tests ddSeqNum() getter method. |
| 540 | */ |
| 541 | @Test |
| 542 | public void testGetDdSeqNum() throws Exception { |
| 543 | ospfNbr.setDdSeqNum(1); |
| 544 | assertThat(ospfNbr.ddSeqNum(), is(1L)); |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * Tests ddSeqNum() setter method. |
| 549 | */ |
| 550 | @Test |
| 551 | public void testSetDdSeqNum() throws Exception { |
| 552 | ospfNbr.setDdSeqNum(1); |
| 553 | assertThat(ospfNbr.ddSeqNum(), is(1L)); |
| 554 | } |
| 555 | |
| 556 | /** |
| 557 | * Tests isMaster() getter method. |
| 558 | */ |
| 559 | @Test |
| 560 | public void testIsMaster() throws Exception { |
| 561 | ospfNbr.setIsMaster(1); |
| 562 | assertThat(ospfNbr.isMaster(), is(1)); |
| 563 | } |
| 564 | |
| 565 | /** |
| 566 | * Tests lastDdPacket() getter method. |
| 567 | */ |
| 568 | @Test |
| 569 | public void testGetLastSentDdPacket() throws Exception { |
| 570 | ospfNbr.setLastDdPacket(new DdPacket()); |
| 571 | assertThat(ospfNbr.lastDdPacket(), is(notNullValue())); |
| 572 | } |
| 573 | |
| 574 | /** |
| 575 | * Tests lastDdPacket() setter method. |
| 576 | */ |
| 577 | @Test |
| 578 | public void testSetLastSentDdPacket() throws Exception { |
| 579 | ospfNbr.setLastDdPacket(new DdPacket()); |
| 580 | assertThat(ospfNbr.lastDdPacket(), is(notNullValue())); |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * Tests getLastSentLsrPacket() getter method. |
| 585 | */ |
| 586 | @Test |
| 587 | public void testGetLastSentLsrPacket() throws Exception { |
| 588 | ospfNbr.setLastSentLsrPacket(new LsRequest()); |
| 589 | assertThat(ospfNbr.getLastSentLsrPacket(), is(notNullValue())); |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * Tests getLastSentLsrPacket() setter method. |
| 594 | */ |
| 595 | @Test |
| 596 | public void testSetLastSentLsrPacket() throws Exception { |
| 597 | ospfNbr.setLastSentLsrPacket(new LsRequest()); |
| 598 | assertThat(ospfNbr.getLastSentLsrPacket(), is(notNullValue())); |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * Tests getState() getter method. |
| 603 | */ |
| 604 | @Test |
| 605 | public void testGetState() throws Exception { |
| 606 | ospfNbr.setState(OspfNeighborState.EXCHANGE); |
| 607 | assertThat(ospfNbr.getState(), is(OspfNeighborState.EXCHANGE)); |
| 608 | } |
| 609 | |
| 610 | /** |
| 611 | * Tests getState() setter method. |
| 612 | */ |
| 613 | @Test |
| 614 | public void testSetState() throws Exception { |
| 615 | ospfNbr.setState(OspfNeighborState.EXCHANGE); |
| 616 | assertThat(ospfNbr.getState(), is(OspfNeighborState.EXCHANGE)); |
| 617 | } |
| 618 | |
| 619 | /** |
| 620 | * Tests isMaster() setter method. |
| 621 | */ |
| 622 | @Test |
| 623 | public void testSetIsMaster() throws Exception { |
| 624 | ospfNbr.setIsMaster(1); |
| 625 | assertThat(ospfNbr.isMaster(), is(1)); |
| 626 | } |
| 627 | |
| 628 | /** |
| 629 | * Tests getLsReqList() method. |
| 630 | */ |
| 631 | @Test |
| 632 | public void testGetLsReqList() throws Exception { |
| 633 | assertThat(ospfNbr.getLsReqList(), is(notNullValue())); |
| 634 | } |
| 635 | |
| 636 | /** |
| 637 | * Tests getReTxList() method. |
| 638 | */ |
| 639 | @Test |
| 640 | public void testGetReTxList() throws Exception { |
| 641 | assertThat(ospfNbr.getReTxList(), is(notNullValue())); |
| 642 | } |
| 643 | |
| 644 | /** |
| 645 | * Tests getPendingReTxList() method. |
| 646 | */ |
| 647 | @Test |
| 648 | public void testGetPendingReTxList() throws Exception { |
| 649 | assertThat(ospfNbr.getPendingReTxList(), is(notNullValue())); |
| 650 | } |
| 651 | } |