Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Laboratory |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +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 | import org.junit.After; |
| 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | import org.onlab.packet.Ip4Address; |
| 22 | import org.onlab.packet.IpAddress; |
| 23 | import org.onosproject.ospf.controller.OspfDeviceTed; |
| 24 | |
| 25 | import java.util.List; |
| 26 | |
| 27 | import static org.hamcrest.CoreMatchers.is; |
| 28 | import static org.hamcrest.CoreMatchers.notNullValue; |
| 29 | import static org.hamcrest.MatcherAssert.assertThat; |
| 30 | |
| 31 | /** |
| 32 | * Unit test class for OspfRouterImpl. |
| 33 | */ |
| 34 | public class OspfRouterImplTest { |
| 35 | private OspfRouterImpl ospfRouter; |
| 36 | private OspfDeviceTed ospfDeviceTed; |
| 37 | private List<OspfDeviceTed> list; |
| 38 | |
| 39 | @Before |
| 40 | public void setUp() throws Exception { |
| 41 | ospfRouter = new OspfRouterImpl(); |
| 42 | } |
| 43 | |
| 44 | @After |
| 45 | public void tearDown() throws Exception { |
| 46 | ospfRouter = null; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Tests routerIp() getter method. |
| 51 | */ |
| 52 | @Test |
| 53 | public void testRouterIp() throws Exception { |
| 54 | ospfRouter.setRouterIp(Ip4Address.valueOf("1.1.1.1")); |
| 55 | assertThat(ospfRouter.routerIp(), is(IpAddress.valueOf("1.1.1.1"))); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Tests routerIp() setter method. |
| 60 | */ |
| 61 | @Test |
| 62 | public void testSetRouterIp() throws Exception { |
| 63 | ospfRouter.setRouterIp(Ip4Address.valueOf("1.1.1.1")); |
| 64 | assertThat(ospfRouter.routerIp(), is(IpAddress.valueOf("1.1.1.1"))); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Tests areaIdOfInterface() getter method. |
| 69 | */ |
| 70 | @Test |
| 71 | public void testAreaIdOfInterface() throws Exception { |
| 72 | ospfRouter.setAreaIdOfInterface(Ip4Address.valueOf("1.1.1.1")); |
| 73 | assertThat(ospfRouter.areaIdOfInterface(), is(IpAddress.valueOf("1.1.1.1"))); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Tests areaIdOfInterface() setter method. |
| 78 | */ |
| 79 | @Test |
| 80 | public void testSetAreaIdOfInterface() throws Exception { |
| 81 | ospfRouter.setAreaIdOfInterface(Ip4Address.valueOf("1.1.1.1")); |
| 82 | assertThat(ospfRouter.areaIdOfInterface(), is(IpAddress.valueOf("1.1.1.1"))); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Tests interfaceId() getter method. |
| 87 | */ |
| 88 | @Test |
| 89 | public void testInterfaceId() throws Exception { |
| 90 | ospfRouter.setInterfaceId(Ip4Address.valueOf("1.1.1.1")); |
| 91 | assertThat(ospfRouter.interfaceId(), is(IpAddress.valueOf("1.1.1.1"))); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Tests interfaceId() setter method. |
| 96 | */ |
| 97 | @Test |
| 98 | public void testSetInterfaceId() throws Exception { |
| 99 | ospfRouter.setInterfaceId(Ip4Address.valueOf("1.1.1.1")); |
| 100 | assertThat(ospfRouter.interfaceId(), is(IpAddress.valueOf("1.1.1.1"))); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Tests isDr() setter method. |
| 105 | */ |
| 106 | @Test |
| 107 | public void testSetDr() throws Exception { |
| 108 | ospfRouter.setDr(true); |
| 109 | assertThat(ospfRouter.isDr(), is(true)); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Tests isDr() getter method. |
| 114 | */ |
| 115 | @Test |
| 116 | public void testIsDr() throws Exception { |
| 117 | ospfRouter.setDr(true); |
| 118 | assertThat(ospfRouter.isDr(), is(true)); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Tests isOpaque() setter method. |
| 123 | */ |
| 124 | @Test |
| 125 | public void testSetOpaque() throws Exception { |
| 126 | ospfRouter.setOpaque(true); |
| 127 | assertThat(ospfRouter.isOpaque(), is(true)); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Tests isOpaque() getter method. |
| 132 | */ |
| 133 | @Test |
| 134 | public void testisOpaque() throws Exception { |
| 135 | ospfRouter.setOpaque(true); |
| 136 | assertThat(ospfRouter.isOpaque(), is(true)); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Tests deviceTed() getter method. |
| 141 | */ |
| 142 | @Test |
| 143 | public void testDeviceTed() throws Exception { |
| 144 | ospfRouter.setDeviceTed(new OspfDeviceTedImpl()); |
| 145 | assertThat(ospfRouter.deviceTed(), is(notNullValue())); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Tests deviceTed() Setter method. |
| 150 | */ |
| 151 | @Test |
| 152 | public void testSetDeviceTed() throws Exception { |
| 153 | ospfRouter.setDeviceTed(new OspfDeviceTedImpl()); |
| 154 | assertThat(ospfRouter.deviceTed(), is(notNullValue())); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Tests neighborRouterId() getter method. |
| 159 | */ |
| 160 | @Test |
| 161 | public void testNeighborRouterId() throws Exception { |
| 162 | ospfRouter.setNeighborRouterId(Ip4Address.valueOf("1.1.1.1")); |
| 163 | assertThat(ospfRouter.neighborRouterId(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Tests neighborRouterId() Setter method. |
| 168 | */ |
| 169 | @Test |
| 170 | public void testSetNeighborRouterId() throws Exception { |
| 171 | ospfRouter.setNeighborRouterId(Ip4Address.valueOf("1.1.1.1")); |
| 172 | assertThat(ospfRouter.neighborRouterId(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 173 | } |
| 174 | } |