Mani | cdb2641 | 2016-02-16 19:44:34 +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.protocol.ospfpacket.subtype; |
| 17 | |
| 18 | import org.junit.After; |
| 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | |
| 22 | import static org.hamcrest.CoreMatchers.is; |
| 23 | import static org.hamcrest.CoreMatchers.notNullValue; |
| 24 | import static org.hamcrest.MatcherAssert.assertThat; |
| 25 | |
| 26 | /** |
| 27 | * Unit test class for LsRequestPacket. |
| 28 | */ |
| 29 | public class LsRequestPacketTest { |
| 30 | |
| 31 | private LsRequestPacket lsrPacket; |
| 32 | private int result; |
| 33 | |
| 34 | @Before |
| 35 | public void setUp() throws Exception { |
| 36 | lsrPacket = new LsRequestPacket(); |
| 37 | } |
| 38 | |
| 39 | @After |
| 40 | public void tearDown() throws Exception { |
| 41 | lsrPacket = null; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Tests lsType() getter method. |
| 46 | */ |
| 47 | @Test |
| 48 | public void testGetLsType() throws Exception { |
| 49 | lsrPacket.setLsType(1); |
| 50 | assertThat(lsrPacket.lsType(), is(1)); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Tests lsType() setter method. |
| 55 | */ |
| 56 | @Test |
| 57 | public void testSetLsType() throws Exception { |
| 58 | lsrPacket.setLsType(1); |
| 59 | assertThat(lsrPacket.lsType(), is(1)); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Tests linkStateId() getter method. |
| 64 | */ |
| 65 | @Test |
| 66 | public void testGetLinkStateId() throws Exception { |
| 67 | lsrPacket.setLinkStateId("1.1.1.1"); |
| 68 | assertThat(lsrPacket.linkStateId(), is("1.1.1.1")); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Tests linkStateId() setter method. |
| 73 | */ |
| 74 | @Test |
| 75 | public void testSetLinkStateId() throws Exception { |
| 76 | lsrPacket.setLinkStateId("1.1.1.1"); |
| 77 | assertThat(lsrPacket.linkStateId(), is("1.1.1.1")); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Tests ownRouterId() getter method. |
| 82 | */ |
| 83 | @Test |
| 84 | public void testGetOwnRouterId() throws Exception { |
| 85 | lsrPacket.setOwnRouterId("1.1.1.1"); |
| 86 | assertThat(lsrPacket.ownRouterId(), is("1.1.1.1")); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Tests ownRouterId() setter method. |
| 91 | */ |
| 92 | @Test |
| 93 | public void testSetOwnRouterId() throws Exception { |
| 94 | lsrPacket.setOwnRouterId("1.1.1.1"); |
| 95 | assertThat(lsrPacket.ownRouterId(), is("1.1.1.1")); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Tests to string method. |
| 100 | */ |
| 101 | @Test |
| 102 | public void testToString() throws Exception { |
| 103 | assertThat(lsrPacket.toString(), is(notNullValue())); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Tests equals() method. |
| 108 | */ |
| 109 | @Test |
| 110 | public void testEquals() throws Exception { |
| 111 | assertThat(lsrPacket.equals(new LsRequestPacket()), is(false)); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Tests hashCode() method. |
| 116 | */ |
| 117 | @Test |
| 118 | public void testHashCode() throws Exception { |
| 119 | result = lsrPacket.hashCode(); |
| 120 | assertThat(result, is(notNullValue())); |
| 121 | } |
| 122 | } |