blob: e65ca9d6e77701d8d2c1e6a00687c293002f5927 [file] [log] [blame]
Dhruv Dhodyb5850122016-02-17 17:51:19 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
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 {
Jonathan Hart953bd002016-03-30 13:31:00 -070034 private static final Ip6Address LOCAL_ADDRESS = Ip6Address.valueOf("::1");
35
Dhruv Dhodyb5850122016-02-17 17:51:19 +053036 private OspfDeviceTedImpl ospfDeviceTed;
37
38 @Before
39 public void setUp() throws Exception {
40 ospfDeviceTed = new OspfDeviceTedImpl();
41 }
42
43 @After
44 public void tearDown() throws Exception {
45 ospfDeviceTed = null;
46 }
47
48 /**
49 * Tests ipv4RouterIds() getter method.
50 */
51 @Test
52 public void testIpv4RouterIds() throws Exception {
53 List list = new ArrayList();
54 list.add(Ip4Address.valueOf("1.1.1.1"));
55 ospfDeviceTed.setIpv4RouterIds(list);
56 assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
57 }
58
59 /**
60 * Tests ipv4RouterIds() setter method.
61 */
62 @Test
63 public void testSetIpv4RouterIds() throws Exception {
64 List list = new ArrayList();
65 list.add(Ip4Address.valueOf("1.1.1.1"));
66 ospfDeviceTed.setIpv4RouterIds(list);
67 assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
68 }
69
70 /**
71 * Tests abr() getter method.
72 */
73 @Test
74 public void testAbr() throws Exception {
75 ospfDeviceTed.setAbr(true);
76 assertThat(ospfDeviceTed.abr(), is(true));
77 }
78
79 /**
80 * Tests abr() setter method.
81 */
82 @Test
83 public void testSetAbr() throws Exception {
84 ospfDeviceTed.setAbr(true);
85 assertThat(ospfDeviceTed.abr(), is(true));
86 }
87
88 /**
89 * Tests asbr() getter method.
90 */
91 @Test
92 public void testAsbr() throws Exception {
93 ospfDeviceTed.setAsbr(true);
94 assertThat(ospfDeviceTed.asbr(), is(true));
95 }
96
97 /**
98 * Tests asbr() setter method.
99 */
100 @Test
101 public void testSetAsbr() throws Exception {
102 ospfDeviceTed.setAsbr(true);
103 assertThat(ospfDeviceTed.asbr(), is(true));
104 }
105
106 /**
107 * Tests topologyIds() getter method.
108 */
109 @Test
110 public void testTopologyIds() throws Exception {
111 List list = new ArrayList();
112 list.add(Ip4Address.valueOf("1.1.1.1"));
113 ospfDeviceTed.setTopologyIds(list);
114 assertThat(ospfDeviceTed.topologyIds().size(), is(1));
115 }
116
117 /**
118 * Tests topologyIds() setter method.
119 */
120 @Test
121 public void testSetTopologyIds() throws Exception {
122 List list = new ArrayList();
123 list.add(Ip4Address.valueOf("1.1.1.1"));
124 ospfDeviceTed.setTopologyIds(list);
125 assertThat(ospfDeviceTed.topologyIds().size(), is(1));
126 }
127
128 /**
129 * Tests ipv6RouterIds() getter method.
130 */
Jonathan Hart953bd002016-03-30 13:31:00 -0700131 @Test
Dhruv Dhodyb5850122016-02-17 17:51:19 +0530132 public void testIpv6RouterIds() throws Exception {
133 List list = new ArrayList();
Jonathan Hart953bd002016-03-30 13:31:00 -0700134 list.add(LOCAL_ADDRESS);
Dhruv Dhodyb5850122016-02-17 17:51:19 +0530135 ospfDeviceTed.setIpv6RouterIds(list);
136 assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
137 }
138
139 /**
140 * Tests ipv6RouterIds() setter method.
141 */
Jonathan Hart953bd002016-03-30 13:31:00 -0700142 @Test
Dhruv Dhodyb5850122016-02-17 17:51:19 +0530143 public void testSetIpv6RouterIds() throws Exception {
144 List list = new ArrayList();
Jonathan Hart953bd002016-03-30 13:31:00 -0700145 list.add(LOCAL_ADDRESS);
Dhruv Dhodyb5850122016-02-17 17:51:19 +0530146 ospfDeviceTed.setIpv6RouterIds(list);
147 assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
148 }
Jonathan Hart953bd002016-03-30 13:31:00 -0700149}