blob: 6944a6f29707a3bc75c3c1a8d3a65e097eea69f3 [file] [log] [blame]
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07003 *
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 */
sunish vk30637eb2016-02-16 15:19:32 +053016package org.onosproject.ospf.controller;
17
18import org.junit.After;
19import org.junit.Before;
20import org.junit.Test;
21import org.onlab.packet.IpAddress;
22
23import java.net.URI;
24
25import static org.hamcrest.CoreMatchers.*;
26import static org.hamcrest.MatcherAssert.assertThat;
27
28/**
29 * Unit test class for OspfRouterId.
30 */
31public class OspfRouterIdTest {
32
33 private OspfRouterId ospfRouterId;
34
35 @Before
36 public void setUp() throws Exception {
37 ospfRouterId = new OspfRouterId(IpAddress.valueOf("2.2.2.2"));
38 }
39
40 @After
41 public void tearDown() throws Exception {
42 ospfRouterId = null;
43 }
44
45 /**
46 * Tests constructor.
47 */
48 @Test
49 public void testOspfRouterId() throws Exception {
50 assertThat(OspfRouterId.ospfRouterId(IpAddress.valueOf("2.2.2.2")), instanceOf(OspfRouterId.class));
51
52 }
53
54 /**
55 * Tests ipAddress() getter method.
56 */
57 @Test
58 public void testIpAddress() throws Exception {
59 assertThat(ospfRouterId.ipAddress(), instanceOf(IpAddress.class));
60 }
61
62 /**
63 * Tests to string method.
64 */
65 @Test
66 public void testToString() throws Exception {
67 assertThat(ospfRouterId.toString(), is(notNullValue()));
68 }
69
70 /**
71 * Tests equals() method.
72 */
73 @Test
74 public void testEquals() throws Exception {
75 assertThat(ospfRouterId.equals(new OspfRouterId(IpAddress.valueOf("3.3.3.3"))), is(false));
76 }
77
78 /**
79 * Tests hashCode() method.
80 */
81 @Test
82 public void testHashCode() throws Exception {
83 assertThat(ospfRouterId.hashCode(), is(notNullValue()));
84 }
85
86 /**
87 * Tests constructor.
88 */
89 @Test
90 public void testOspfRouterId1() throws Exception {
91 assertThat(OspfRouterId.ospfRouterId(OspfRouterId.uri(ospfRouterId)), instanceOf(OspfRouterId.class));
92 }
93
94 /**
95 * Tests uri() method.
96 */
97 @Test
98 public void testUri() throws Exception {
99 assertThat(OspfRouterId.uri(IpAddress.valueOf("2.2.2.2")), instanceOf(URI.class));
100 }
101
102 /**
103 * Tests uri() method..
104 */
105 @Test
106 public void testUri1() throws Exception {
107 assertThat(OspfRouterId.uri(ospfRouterId), instanceOf(URI.class));
108 }
109}