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