blob: 947f34a63f3a8857240056b819c945eb00c174e2 [file] [log] [blame]
Mohamed Rahila3b9e992016-02-16 20:26:49 +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.protocol.lsa.subtypes;
17
18import org.junit.After;
19import org.junit.Before;
20import org.junit.Test;
21import org.onlab.packet.Ip4Address;
22
23import java.net.InetAddress;
24
25import static org.hamcrest.MatcherAssert.assertThat;
26import static org.hamcrest.Matchers.is;
27import static org.hamcrest.Matchers.notNullValue;
28
29/**
30 * Unit test class for OspfRouterId.
31 */
32public class OspfExternalDestinationTest {
33
34 private OspfExternalDestination ospfExternalDestination;
35
36 @Before
37 public void setUp() throws Exception {
38 ospfExternalDestination = new OspfExternalDestination();
39 }
40
41 @After
42 public void tearDown() throws Exception {
43 ospfExternalDestination = null;
44 }
45
46 /**
47 * Tests isType1orType2Metric() getter method.
48 */
49 @Test
50 public void testIsType1orType2Metric() throws Exception {
51 ospfExternalDestination.setType1orType2Metric(true);
52 assertThat(ospfExternalDestination.isType1orType2Metric(), is(true));
53 }
54
55 /**
56 * Tests isType1orType2Metric() setter method.
57 */
58 @Test
59 public void testSetType1orType2Metric() throws Exception {
60 ospfExternalDestination.setType1orType2Metric(true);
61 assertThat(ospfExternalDestination.isType1orType2Metric(), is(true));
62 }
63
64 /**
65 * Tests metric() getter method.
66 */
67 @Test
68 public void testGetMetric() throws Exception {
69 ospfExternalDestination.setMetric(100);
70 assertThat(ospfExternalDestination.metric(), is(100));
71 }
72
73 /**
74 * Tests metric() setter method.
75 */
76 @Test
77 public void testSetMetric() throws Exception {
78 ospfExternalDestination.setMetric(100);
79 assertThat(ospfExternalDestination.metric(), is(100));
80 }
81
82 /**
83 * Tests forwardingAddress() getter method.
84 */
85 @Test
86 public void testGetForwardingAddress() throws Exception {
87 ospfExternalDestination.setForwardingAddress(Ip4Address.valueOf(InetAddress.getLocalHost()));
88 assertThat(ospfExternalDestination.forwardingAddress(), is(Ip4Address.valueOf(InetAddress.getLocalHost())));
89
90 }
91
92 /**
93 * Tests forwardingAddress() setter method.
94 */
95 @Test
96 public void testSetForwardingAddress() throws Exception {
97 ospfExternalDestination.setForwardingAddress(Ip4Address.valueOf(InetAddress.getLocalHost()));
98 assertThat(ospfExternalDestination.forwardingAddress(), is(Ip4Address.valueOf(InetAddress.getLocalHost())));
99 }
100
101 /**
102 * Tests externalRouterTag() getter method.
103 */
104 @Test
105 public void testGetExternalRouterTag() throws Exception {
106 ospfExternalDestination.setExternalRouterTag(100);
107 assertThat(ospfExternalDestination.externalRouterTag(), is(100));
108 }
109
110 /**
111 * Tests externalRouterTag() setter method.
112 */
113 @Test
114 public void testSetExternalRouterTag() throws Exception {
115 ospfExternalDestination.setExternalRouterTag(100);
116 assertThat(ospfExternalDestination.externalRouterTag(), is(100));
117 }
118
119 /**
120 * Tests to string method.
121 */
122 @Test
123 public void testToString() throws Exception {
124 assertThat(ospfExternalDestination.toString(), is(notNullValue()));
125 }
126}