blob: 1fe33d4c2a3544098ef4e643a589128667cc9916 [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.packet.Ip6Address;
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.junit.Assert.assertThat;
29
30/**
31 * Unit test class for OspfDeviceTedImpl.
32 */
33public class OspfDeviceTedImplTest {
34 private OspfDeviceTedImpl ospfDeviceTed;
35
36 @Before
37 public void setUp() throws Exception {
38 ospfDeviceTed = new OspfDeviceTedImpl();
39 }
40
41 @After
42 public void tearDown() throws Exception {
43 ospfDeviceTed = null;
44 }
45
46 /**
47 * Tests ipv4RouterIds() getter method.
48 */
49 @Test
50 public void testIpv4RouterIds() throws Exception {
51 List list = new ArrayList();
52 list.add(Ip4Address.valueOf("1.1.1.1"));
53 ospfDeviceTed.setIpv4RouterIds(list);
54 assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
55 }
56
57 /**
58 * Tests ipv4RouterIds() setter method.
59 */
60 @Test
61 public void testSetIpv4RouterIds() throws Exception {
62 List list = new ArrayList();
63 list.add(Ip4Address.valueOf("1.1.1.1"));
64 ospfDeviceTed.setIpv4RouterIds(list);
65 assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
66 }
67
68 /**
69 * Tests abr() getter method.
70 */
71 @Test
72 public void testAbr() throws Exception {
73 ospfDeviceTed.setAbr(true);
74 assertThat(ospfDeviceTed.abr(), is(true));
75 }
76
77 /**
78 * Tests abr() setter method.
79 */
80 @Test
81 public void testSetAbr() throws Exception {
82 ospfDeviceTed.setAbr(true);
83 assertThat(ospfDeviceTed.abr(), is(true));
84 }
85
86 /**
87 * Tests asbr() getter method.
88 */
89 @Test
90 public void testAsbr() throws Exception {
91 ospfDeviceTed.setAsbr(true);
92 assertThat(ospfDeviceTed.asbr(), is(true));
93 }
94
95 /**
96 * Tests asbr() setter method.
97 */
98 @Test
99 public void testSetAsbr() throws Exception {
100 ospfDeviceTed.setAsbr(true);
101 assertThat(ospfDeviceTed.asbr(), is(true));
102 }
103
104 /**
105 * Tests topologyIds() getter method.
106 */
107 @Test
108 public void testTopologyIds() throws Exception {
109 List list = new ArrayList();
110 list.add(Ip4Address.valueOf("1.1.1.1"));
111 ospfDeviceTed.setTopologyIds(list);
112 assertThat(ospfDeviceTed.topologyIds().size(), is(1));
113 }
114
115 /**
116 * Tests topologyIds() setter method.
117 */
118 @Test
119 public void testSetTopologyIds() throws Exception {
120 List list = new ArrayList();
121 list.add(Ip4Address.valueOf("1.1.1.1"));
122 ospfDeviceTed.setTopologyIds(list);
123 assertThat(ospfDeviceTed.topologyIds().size(), is(1));
124 }
125
126 /**
127 * Tests ipv6RouterIds() getter method.
128 */
Jonathan Hartbb6fb5c2016-08-09 17:05:54 -0700129 @Test
Dhruv Dhodyb5850122016-02-17 17:51:19 +0530130 public void testIpv6RouterIds() throws Exception {
131 List list = new ArrayList();
Jonathan Hartbb6fb5c2016-08-09 17:05:54 -0700132 list.add(Ip6Address.valueOf(1));
Dhruv Dhodyb5850122016-02-17 17:51:19 +0530133 ospfDeviceTed.setIpv6RouterIds(list);
134 assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
135 }
136
137 /**
138 * Tests ipv6RouterIds() setter method.
139 */
Jonathan Hartbb6fb5c2016-08-09 17:05:54 -0700140 @Test
Dhruv Dhodyb5850122016-02-17 17:51:19 +0530141 public void testSetIpv6RouterIds() throws Exception {
142 List list = new ArrayList();
Jonathan Hartbb6fb5c2016-08-09 17:05:54 -0700143 list.add(Ip6Address.valueOf(1));
Dhruv Dhodyb5850122016-02-17 17:51:19 +0530144 ospfDeviceTed.setIpv6RouterIds(list);
145 assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
146 }
Jonathan Hartbb6fb5c2016-08-09 17:05:54 -0700147}