Kalyankumar Asangi | 19f6449 | 2016-02-17 17:34:16 +0530 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.ospf.controller.area; |
| 17 | |
| 18 | |
Kalyankumar Asangi | 19f6449 | 2016-02-17 17:34:16 +0530 | [diff] [blame] | 19 | import org.junit.After; |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
| 22 | import org.onlab.packet.Ip4Address; |
| 23 | import org.onosproject.ospf.controller.OspfAreaAddressRange; |
| 24 | |
| 25 | import static org.hamcrest.CoreMatchers.is; |
| 26 | import static org.hamcrest.CoreMatchers.notNullValue; |
| 27 | import static org.hamcrest.MatcherAssert.assertThat; |
| 28 | |
| 29 | /** |
| 30 | * Unit test class for OspfAreaAddressRangeImpl. |
| 31 | */ |
| 32 | public class OspfAreaAddressRangeImplTest { |
| 33 | |
| 34 | private OspfAreaAddressRange ospfAreaAddressRange; |
| 35 | private int result; |
| 36 | private String result1; |
| 37 | |
| 38 | @Before |
| 39 | public void setUp() throws Exception { |
| 40 | ospfAreaAddressRange = new OspfAreaAddressRangeImpl(); |
| 41 | } |
| 42 | |
| 43 | @After |
| 44 | public void tearDown() throws Exception { |
| 45 | ospfAreaAddressRange = null; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Tests ipAddress() getter method. |
| 50 | */ |
| 51 | @Test |
| 52 | public void testGetIpAddress() throws Exception { |
| 53 | ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("1.1.1.1")); |
| 54 | assertThat(ospfAreaAddressRange.ipAddress(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Tests ipAddress() setter method. |
| 59 | */ |
| 60 | @Test |
| 61 | public void testSetIpAddress() throws Exception { |
| 62 | ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("1.1.1.1")); |
| 63 | assertThat(ospfAreaAddressRange.ipAddress(), is(Ip4Address.valueOf("1.1.1.1"))); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Tests mask() getter method. |
| 68 | */ |
| 69 | @Test |
| 70 | public void testGetMask() throws Exception { |
| 71 | ospfAreaAddressRange.setMask("1.1.1.1"); |
| 72 | assertThat(ospfAreaAddressRange.mask(), is("1.1.1.1")); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Tests mask() setter method. |
| 77 | */ |
| 78 | @Test |
| 79 | public void testSetMask() throws Exception { |
| 80 | ospfAreaAddressRange.setMask("1.1.1.1"); |
| 81 | assertThat(ospfAreaAddressRange.mask(), is("1.1.1.1")); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Tests isAdvertise() getter method. |
| 86 | */ |
| 87 | @Test |
| 88 | public void testIsAdvertise() throws Exception { |
| 89 | ospfAreaAddressRange.setAdvertise(true); |
| 90 | assertThat(ospfAreaAddressRange.isAdvertise(), is(true)); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Tests isAdvertise() setter method. |
| 95 | */ |
| 96 | @Test |
| 97 | public void testSetAdvertise() throws Exception { |
| 98 | ospfAreaAddressRange.setAdvertise(true); |
| 99 | assertThat(ospfAreaAddressRange.isAdvertise(), is(true)); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Tests equals() method. |
| 104 | */ |
| 105 | @Test |
| 106 | public void testEquals() throws Exception { |
sunish vk | aa48da8 | 2016-03-02 23:17:06 +0530 | [diff] [blame] | 107 | assertThat(ospfAreaAddressRange.equals(new OspfAreaAddressRangeImpl()), is(true)); |
Kalyankumar Asangi | 19f6449 | 2016-02-17 17:34:16 +0530 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /** |
sunish vk | aa48da8 | 2016-03-02 23:17:06 +0530 | [diff] [blame] | 111 | * Tests hashCode() method. |
Kalyankumar Asangi | 19f6449 | 2016-02-17 17:34:16 +0530 | [diff] [blame] | 112 | */ |
| 113 | @Test |
Kalyankumar Asangi | 19f6449 | 2016-02-17 17:34:16 +0530 | [diff] [blame] | 114 | public void testHashCode() throws Exception { |
| 115 | result = ospfAreaAddressRange.hashCode(); |
| 116 | assertThat(result, is(notNullValue())); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Tests to string method. |
| 121 | */ |
| 122 | @Test |
| 123 | public void testToString() throws Exception { |
| 124 | result1 = ospfAreaAddressRange.toString(); |
| 125 | assertThat(result1, is(notNullValue())); |
| 126 | } |
| 127 | } |