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.util.Bandwidth; |
| 23 | |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 24 | import java.util.ArrayList; |
| 25 | import java.util.List; |
| 26 | |
| 27 | import static org.hamcrest.CoreMatchers.is; |
| 28 | import static org.hamcrest.CoreMatchers.notNullValue; |
| 29 | import static org.junit.Assert.assertThat; |
| 30 | |
| 31 | /** |
| 32 | * Unit test class for OspfDeviceTedImpl. |
| 33 | */ |
| 34 | public class OspfLinkTedImplTest { |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 35 | private static final Ip4Address LOCAL_ADDRESS = Ip4Address.valueOf("127.0.0.1"); |
| 36 | |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 37 | private OspfLinkTedImpl ospfLinkTed; |
| 38 | |
| 39 | @Before |
| 40 | public void setUp() throws Exception { |
| 41 | ospfLinkTed = new OspfLinkTedImpl(); |
| 42 | } |
| 43 | |
| 44 | @After |
| 45 | public void tearDown() throws Exception { |
| 46 | ospfLinkTed = null; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Tests maximumLink() getter method. |
| 51 | */ |
| 52 | @Test |
| 53 | public void testMaximumLink() throws Exception { |
| 54 | |
| 55 | ospfLinkTed.setMaximumLink(Bandwidth.bps(1234)); |
| 56 | assertThat(ospfLinkTed.maximumLink(), is(Bandwidth.bps(1234))); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Tests maximumLink() setter method. |
| 61 | */ |
| 62 | @Test |
| 63 | public void testSetMaximumLink() throws Exception { |
| 64 | ospfLinkTed.setMaximumLink(Bandwidth.bps(1234)); |
| 65 | assertThat(ospfLinkTed.maximumLink(), is(Bandwidth.bps(1234))); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Tests ipv6RemRouterId() getter method. |
| 70 | */ |
| 71 | @Test |
| 72 | public void testIpv6RemRouterId() throws Exception { |
| 73 | List list = new ArrayList(); |
| 74 | ospfLinkTed.setIpv6RemRouterId(list); |
| 75 | assertThat(ospfLinkTed.ipv6RemRouterId().size(), is(0)); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Tests ipv6RemRouterId() setter method. |
| 80 | */ |
| 81 | @Test |
| 82 | public void testSetIpv6RemRouterId() throws Exception { |
| 83 | List list = new ArrayList(); |
| 84 | ospfLinkTed.setIpv6RemRouterId(list); |
| 85 | assertThat(ospfLinkTed.ipv6RemRouterId().size(), is(0)); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Tests ipv4RemRouterId() getter method. |
| 90 | */ |
| 91 | @Test |
| 92 | public void testIpv4RemRouterId() throws Exception { |
| 93 | List list = new ArrayList(); |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 94 | list.add(LOCAL_ADDRESS); |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 95 | ospfLinkTed.setIpv4RemRouterId(list); |
| 96 | assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1)); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Tests ipv4RemRouterId() setter method. |
| 101 | */ |
| 102 | @Test |
| 103 | public void testSetIpv4RemRouterId() throws Exception { |
| 104 | List list = new ArrayList(); |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 105 | list.add(LOCAL_ADDRESS); |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 106 | ospfLinkTed.setIpv4RemRouterId(list); |
| 107 | assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1)); |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Tests ipv6LocRouterId() getter method. |
| 112 | */ |
| 113 | @Test |
| 114 | public void testIpv6LocRouterId() throws Exception { |
| 115 | List list = new ArrayList(); |
| 116 | ospfLinkTed.setIpv4LocRouterId(list); |
| 117 | assertThat(ospfLinkTed.ipv6LocRouterId().size(), is(0)); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Tests ipv6LocRouterId() setter method. |
| 122 | */ |
| 123 | @Test |
| 124 | public void testSetIpv6LocRouterId() throws Exception { |
| 125 | List list = new ArrayList(); |
| 126 | ospfLinkTed.setIpv4LocRouterId(list); |
| 127 | assertThat(ospfLinkTed.ipv6LocRouterId().size(), is(0)); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Tests ipv4LocRouterId() getter method. |
| 132 | */ |
| 133 | @Test |
| 134 | public void testIpv4LocRouterId() throws Exception { |
| 135 | List list = new ArrayList(); |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 136 | list.add(LOCAL_ADDRESS); |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 137 | ospfLinkTed.setIpv4LocRouterId(list); |
| 138 | assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1)); |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Tests ipv4LocRouterId() setter method. |
| 143 | */ |
| 144 | @Test |
| 145 | public void testSetIpv4LocRouterId() throws Exception { |
| 146 | List list = new ArrayList(); |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 147 | list.add(LOCAL_ADDRESS); |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 148 | ospfLinkTed.setIpv4LocRouterId(list); |
| 149 | assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1)); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Tests teMetric() getter method. |
| 154 | */ |
| 155 | @Test |
| 156 | public void testTeMetric() throws Exception { |
| 157 | ospfLinkTed.setTeMetric(1234); |
| 158 | assertThat(ospfLinkTed.teMetric(), is(1234)); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Tests teMetric() setter method. |
| 163 | */ |
| 164 | @Test |
| 165 | public void testSetTeMetric() throws Exception { |
| 166 | ospfLinkTed.setTeMetric(1234); |
| 167 | assertThat(ospfLinkTed.teMetric(), is(1234)); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Tests maxReserved() getter method. |
| 172 | */ |
| 173 | @Test |
| 174 | public void testMaxReserved() throws Exception { |
| 175 | ospfLinkTed.setMaxReserved(Bandwidth.bps(1234)); |
| 176 | assertThat(ospfLinkTed.maxReserved(), is(Bandwidth.bps(1234))); |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Tests maxReserved() setter method. |
| 181 | */ |
| 182 | @Test |
| 183 | public void testSetMaxReserved() throws Exception { |
| 184 | ospfLinkTed.setMaxReserved(Bandwidth.bps(1234)); |
| 185 | assertThat(ospfLinkTed.maxReserved(), is(Bandwidth.bps(1234))); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Tests maxUnResBandwidth() getter method. |
| 190 | */ |
| 191 | @Test |
| 192 | public void testMaxUnResBandwidth() throws Exception { |
| 193 | ospfLinkTed.setMaxUnResBandwidth(Bandwidth.bps(1234)); |
| 194 | assertThat(ospfLinkTed.maxUnResBandwidth(), is(notNullValue())); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Tests maxUnResBandwidth() setter method. |
| 199 | */ |
| 200 | @Test |
| 201 | public void testSetMaxUnResBandwidth() throws Exception { |
| 202 | ospfLinkTed.setMaxUnResBandwidth(Bandwidth.bps(1234.0)); |
| 203 | assertThat(ospfLinkTed.maxUnResBandwidth(), is(notNullValue())); |
| 204 | } |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 205 | } |