Kalyankumar Asangi | 19f6449 | 2016-02-17 17:34:16 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Laboratory |
Kalyankumar Asangi | 19f6449 | 2016-02-17 17:34:16 +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.util; |
| 17 | |
| 18 | import org.junit.After; |
| 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | import org.onlab.packet.Ip4Address; |
| 22 | |
| 23 | import static org.hamcrest.CoreMatchers.is; |
| 24 | import static org.hamcrest.MatcherAssert.assertThat; |
| 25 | |
| 26 | /** |
| 27 | * Unit test class for OspfEligibleRouter. |
| 28 | */ |
| 29 | public class OspfEligibleRouterTest { |
| 30 | |
| 31 | private OspfEligibleRouter ospfEligibleRouter; |
| 32 | |
| 33 | @Before |
| 34 | public void setUp() throws Exception { |
| 35 | ospfEligibleRouter = new OspfEligibleRouter(); |
| 36 | } |
| 37 | |
| 38 | @After |
| 39 | public void tearDown() throws Exception { |
| 40 | ospfEligibleRouter = null; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Tests getIpAddress() getter method. |
| 45 | */ |
| 46 | @Test |
| 47 | public void testGetIpAddress() throws Exception { |
| 48 | ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1")); |
| 49 | assertThat(ospfEligibleRouter.getIpAddress(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Tests setIpAddress() setter method. |
| 54 | */ |
| 55 | @Test |
| 56 | public void testSetIpAddress() throws Exception { |
| 57 | ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1")); |
| 58 | assertThat(ospfEligibleRouter.getIpAddress(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Tests getRouterId() getter method. |
| 63 | */ |
| 64 | @Test |
| 65 | public void testGetRouterId() throws Exception { |
| 66 | ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1")); |
| 67 | assertThat(ospfEligibleRouter.getRouterId(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Tests setRouterId() setter method. |
| 72 | */ |
| 73 | @Test |
| 74 | public void testSetRouterId() throws Exception { |
| 75 | ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1")); |
| 76 | assertThat(ospfEligibleRouter.getRouterId(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Tests getRouterPriority() getter method. |
| 81 | */ |
| 82 | @Test |
| 83 | public void testGetRouterPriority() throws Exception { |
| 84 | ospfEligibleRouter.setRouterPriority(1); |
| 85 | assertThat(ospfEligibleRouter.getRouterPriority(), is(1)); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Tests getRouterPriority() setter method. |
| 90 | */ |
| 91 | @Test |
| 92 | public void testSetRouterPriority() throws Exception { |
| 93 | ospfEligibleRouter.setRouterPriority(1); |
| 94 | assertThat(ospfEligibleRouter.getRouterPriority(), is(1)); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Tests isDr() getter method. |
| 99 | */ |
| 100 | @Test |
| 101 | public void testIsDr() throws Exception { |
| 102 | ospfEligibleRouter.setIsDr(true); |
| 103 | assertThat(ospfEligibleRouter.isDr(), is(true)); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Tests isDr() setter method. |
| 108 | */ |
| 109 | @Test |
| 110 | public void testSetIsDr() throws Exception { |
| 111 | ospfEligibleRouter.setIsDr(true); |
| 112 | assertThat(ospfEligibleRouter.isDr(), is(true)); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Tests isBdr() getter method. |
| 117 | */ |
| 118 | @Test |
| 119 | public void testIsBdr() throws Exception { |
| 120 | ospfEligibleRouter.setIsBdr(true); |
| 121 | assertThat(ospfEligibleRouter.isBdr(), is(true)); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Tests isBdr() setter method. |
| 126 | */ |
| 127 | @Test |
| 128 | public void testSetIsBdr() throws Exception { |
| 129 | ospfEligibleRouter.setIsBdr(true); |
| 130 | assertThat(ospfEligibleRouter.isBdr(), is(true)); |
| 131 | } |
| 132 | } |