blob: d919fc0f62f5ee73bbd855c81a2c67a5288953eb [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.packet.Ip6Address;
23
24import java.net.InetAddress;
25import java.util.ArrayList;
26import java.util.List;
27
28import static org.hamcrest.CoreMatchers.is;
29import static org.junit.Assert.assertThat;
30
31/**
32 * Unit test class for OspfDeviceTedImpl.
33 */
34public class OspfDeviceTedImplTest {
35 private OspfDeviceTedImpl ospfDeviceTed;
36
37 @Before
38 public void setUp() throws Exception {
39 ospfDeviceTed = new OspfDeviceTedImpl();
40 }
41
42 @After
43 public void tearDown() throws Exception {
44 ospfDeviceTed = null;
45 }
46
47 /**
48 * Tests ipv4RouterIds() getter method.
49 */
50 @Test
51 public void testIpv4RouterIds() throws Exception {
52 List list = new ArrayList();
53 list.add(Ip4Address.valueOf("1.1.1.1"));
54 ospfDeviceTed.setIpv4RouterIds(list);
55 assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
56 }
57
58 /**
59 * Tests ipv4RouterIds() setter method.
60 */
61 @Test
62 public void testSetIpv4RouterIds() throws Exception {
63 List list = new ArrayList();
64 list.add(Ip4Address.valueOf("1.1.1.1"));
65 ospfDeviceTed.setIpv4RouterIds(list);
66 assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
67 }
68
69 /**
70 * Tests abr() getter method.
71 */
72 @Test
73 public void testAbr() throws Exception {
74 ospfDeviceTed.setAbr(true);
75 assertThat(ospfDeviceTed.abr(), is(true));
76 }
77
78 /**
79 * Tests abr() setter method.
80 */
81 @Test
82 public void testSetAbr() throws Exception {
83 ospfDeviceTed.setAbr(true);
84 assertThat(ospfDeviceTed.abr(), is(true));
85 }
86
87 /**
88 * Tests asbr() getter method.
89 */
90 @Test
91 public void testAsbr() throws Exception {
92 ospfDeviceTed.setAsbr(true);
93 assertThat(ospfDeviceTed.asbr(), is(true));
94 }
95
96 /**
97 * Tests asbr() setter method.
98 */
99 @Test
100 public void testSetAsbr() throws Exception {
101 ospfDeviceTed.setAsbr(true);
102 assertThat(ospfDeviceTed.asbr(), is(true));
103 }
104
105 /**
106 * Tests topologyIds() getter method.
107 */
108 @Test
109 public void testTopologyIds() throws Exception {
110 List list = new ArrayList();
111 list.add(Ip4Address.valueOf("1.1.1.1"));
112 ospfDeviceTed.setTopologyIds(list);
113 assertThat(ospfDeviceTed.topologyIds().size(), is(1));
114 }
115
116 /**
117 * Tests topologyIds() setter method.
118 */
119 @Test
120 public void testSetTopologyIds() throws Exception {
121 List list = new ArrayList();
122 list.add(Ip4Address.valueOf("1.1.1.1"));
123 ospfDeviceTed.setTopologyIds(list);
124 assertThat(ospfDeviceTed.topologyIds().size(), is(1));
125 }
126
127 /**
128 * Tests ipv6RouterIds() getter method.
129 */
130 @Test(expected = Exception.class)
131 public void testIpv6RouterIds() throws Exception {
132 List list = new ArrayList();
133 list.add(Ip6Address.valueOf(InetAddress.getLocalHost()));
134 ospfDeviceTed.setIpv6RouterIds(list);
135 assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
136 }
137
138 /**
139 * Tests ipv6RouterIds() setter method.
140 */
141 @Test(expected = Exception.class)
142 public void testSetIpv6RouterIds() throws Exception {
143 List list = new ArrayList();
144 list.add(Ip6Address.valueOf(InetAddress.getLocalHost()));
145 ospfDeviceTed.setIpv6RouterIds(list);
146 assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
147 }
148}