blob: 587973437eb00adc1802a601f2a2b0f31285debb [file] [log] [blame]
sunish vk30637eb2016-02-16 15:19:32 +05301package org.onosproject.ospf.controller;
2
3import org.junit.After;
4import org.junit.Before;
5import org.junit.Test;
6import org.onlab.packet.IpAddress;
7
8import java.net.URI;
9
10import static org.hamcrest.CoreMatchers.*;
11import static org.hamcrest.MatcherAssert.assertThat;
12
13/**
14 * Unit test class for OspfRouterId.
15 */
16public class OspfRouterIdTest {
17
18 private OspfRouterId ospfRouterId;
19
20 @Before
21 public void setUp() throws Exception {
22 ospfRouterId = new OspfRouterId(IpAddress.valueOf("2.2.2.2"));
23 }
24
25 @After
26 public void tearDown() throws Exception {
27 ospfRouterId = null;
28 }
29
30 /**
31 * Tests constructor.
32 */
33 @Test
34 public void testOspfRouterId() throws Exception {
35 assertThat(OspfRouterId.ospfRouterId(IpAddress.valueOf("2.2.2.2")), instanceOf(OspfRouterId.class));
36
37 }
38
39 /**
40 * Tests ipAddress() getter method.
41 */
42 @Test
43 public void testIpAddress() throws Exception {
44 assertThat(ospfRouterId.ipAddress(), instanceOf(IpAddress.class));
45 }
46
47 /**
48 * Tests to string method.
49 */
50 @Test
51 public void testToString() throws Exception {
52 assertThat(ospfRouterId.toString(), is(notNullValue()));
53 }
54
55 /**
56 * Tests equals() method.
57 */
58 @Test
59 public void testEquals() throws Exception {
60 assertThat(ospfRouterId.equals(new OspfRouterId(IpAddress.valueOf("3.3.3.3"))), is(false));
61 }
62
63 /**
64 * Tests hashCode() method.
65 */
66 @Test
67 public void testHashCode() throws Exception {
68 assertThat(ospfRouterId.hashCode(), is(notNullValue()));
69 }
70
71 /**
72 * Tests constructor.
73 */
74 @Test
75 public void testOspfRouterId1() throws Exception {
76 assertThat(OspfRouterId.ospfRouterId(OspfRouterId.uri(ospfRouterId)), instanceOf(OspfRouterId.class));
77 }
78
79 /**
80 * Tests uri() method.
81 */
82 @Test
83 public void testUri() throws Exception {
84 assertThat(OspfRouterId.uri(IpAddress.valueOf("2.2.2.2")), instanceOf(URI.class));
85 }
86
87 /**
88 * Tests uri() method..
89 */
90 @Test
91 public void testUri1() throws Exception {
92 assertThat(OspfRouterId.uri(ospfRouterId), instanceOf(URI.class));
93 }
94}