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