Mohamed Rahil | a3b9e99 | 2016-02-16 20:26:49 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Mohamed Rahil | a3b9e99 | 2016-02-16 20:26:49 +0530 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.ospf.protocol.lsa.subtypes; |
| 17 | |
| 18 | import org.junit.After; |
| 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | import org.onlab.packet.Ip4Address; |
| 22 | |
Mohamed Rahil | a3b9e99 | 2016-02-16 20:26:49 +0530 | [diff] [blame] | 23 | import static org.hamcrest.MatcherAssert.assertThat; |
| 24 | import static org.hamcrest.Matchers.is; |
| 25 | import static org.hamcrest.Matchers.notNullValue; |
| 26 | |
| 27 | /** |
| 28 | * Unit test class for OspfRouterId. |
| 29 | */ |
| 30 | public class OspfExternalDestinationTest { |
| 31 | |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 32 | private static final Ip4Address LOCAL_ADDRESS = Ip4Address.valueOf("127.0.0.1"); |
| 33 | |
Mohamed Rahil | a3b9e99 | 2016-02-16 20:26:49 +0530 | [diff] [blame] | 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 { |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 87 | ospfExternalDestination.setForwardingAddress(LOCAL_ADDRESS); |
| 88 | assertThat(ospfExternalDestination.forwardingAddress(), is(LOCAL_ADDRESS)); |
Mohamed Rahil | a3b9e99 | 2016-02-16 20:26:49 +0530 | [diff] [blame] | 89 | |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Tests forwardingAddress() setter method. |
| 94 | */ |
| 95 | @Test |
| 96 | public void testSetForwardingAddress() throws Exception { |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 97 | ospfExternalDestination.setForwardingAddress(LOCAL_ADDRESS); |
| 98 | assertThat(ospfExternalDestination.forwardingAddress(), is(LOCAL_ADDRESS)); |
Mohamed Rahil | a3b9e99 | 2016-02-16 20:26:49 +0530 | [diff] [blame] | 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 | } |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 126 | } |