blob: ee07e0006af4040db9a2edd8bc8a336bd2b45811 [file] [log] [blame]
Kalyankumar Asangi19f64492016-02-17 17:34:16 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Kalyankumar Asangi19f64492016-02-17 17:34:16 +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.util;
17
18import org.junit.After;
19import org.junit.Before;
20import org.junit.Test;
21import org.onlab.packet.Ip4Address;
22
23import static org.hamcrest.CoreMatchers.is;
24import static org.hamcrest.MatcherAssert.assertThat;
25
26/**
27 * Unit test class for OspfEligibleRouter.
28 */
29public class OspfEligibleRouterTest {
30
31 private OspfEligibleRouter ospfEligibleRouter;
32
33 @Before
34 public void setUp() throws Exception {
35 ospfEligibleRouter = new OspfEligibleRouter();
36 }
37
38 @After
39 public void tearDown() throws Exception {
40 ospfEligibleRouter = null;
41 }
42
43 /**
44 * Tests getIpAddress() getter method.
45 */
46 @Test
47 public void testGetIpAddress() throws Exception {
48 ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
49 assertThat(ospfEligibleRouter.getIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
50 }
51
52 /**
53 * Tests setIpAddress() setter method.
54 */
55 @Test
56 public void testSetIpAddress() throws Exception {
57 ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
58 assertThat(ospfEligibleRouter.getIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
59 }
60
61 /**
62 * Tests getRouterId() getter method.
63 */
64 @Test
65 public void testGetRouterId() throws Exception {
66 ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
67 assertThat(ospfEligibleRouter.getRouterId(), is(Ip4Address.valueOf("1.1.1.1")));
68 }
69
70 /**
71 * Tests setRouterId() setter method.
72 */
73 @Test
74 public void testSetRouterId() throws Exception {
75 ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
76 assertThat(ospfEligibleRouter.getRouterId(), is(Ip4Address.valueOf("1.1.1.1")));
77 }
78
79 /**
80 * Tests getRouterPriority() getter method.
81 */
82 @Test
83 public void testGetRouterPriority() throws Exception {
84 ospfEligibleRouter.setRouterPriority(1);
85 assertThat(ospfEligibleRouter.getRouterPriority(), is(1));
86 }
87
88 /**
89 * Tests getRouterPriority() setter method.
90 */
91 @Test
92 public void testSetRouterPriority() throws Exception {
93 ospfEligibleRouter.setRouterPriority(1);
94 assertThat(ospfEligibleRouter.getRouterPriority(), is(1));
95 }
96
97 /**
98 * Tests isDr() getter method.
99 */
100 @Test
101 public void testIsDr() throws Exception {
102 ospfEligibleRouter.setIsDr(true);
103 assertThat(ospfEligibleRouter.isDr(), is(true));
104 }
105
106 /**
107 * Tests isDr() setter method.
108 */
109 @Test
110 public void testSetIsDr() throws Exception {
111 ospfEligibleRouter.setIsDr(true);
112 assertThat(ospfEligibleRouter.isDr(), is(true));
113 }
114
115 /**
116 * Tests isBdr() getter method.
117 */
118 @Test
119 public void testIsBdr() throws Exception {
120 ospfEligibleRouter.setIsBdr(true);
121 assertThat(ospfEligibleRouter.isBdr(), is(true));
122 }
123
124 /**
125 * Tests isBdr() setter method.
126 */
127 @Test
128 public void testSetIsBdr() throws Exception {
129 ospfEligibleRouter.setIsBdr(true);
130 assertThat(ospfEligibleRouter.isBdr(), is(true));
131 }
132}