Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +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.controller.impl; |
| 17 | |
| 18 | import org.junit.After; |
| 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | import org.onlab.packet.Ip4Address; |
| 22 | import org.onlab.packet.Ip6Address; |
| 23 | |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 24 | import java.util.ArrayList; |
| 25 | import java.util.List; |
| 26 | |
| 27 | import static org.hamcrest.CoreMatchers.is; |
| 28 | import static org.junit.Assert.assertThat; |
| 29 | |
| 30 | /** |
| 31 | * Unit test class for OspfDeviceTedImpl. |
| 32 | */ |
| 33 | public class OspfDeviceTedImplTest { |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 34 | private static final Ip6Address LOCAL_ADDRESS = Ip6Address.valueOf("::1"); |
| 35 | |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 36 | private OspfDeviceTedImpl ospfDeviceTed; |
| 37 | |
| 38 | @Before |
| 39 | public void setUp() throws Exception { |
| 40 | ospfDeviceTed = new OspfDeviceTedImpl(); |
| 41 | } |
| 42 | |
| 43 | @After |
| 44 | public void tearDown() throws Exception { |
| 45 | ospfDeviceTed = null; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Tests ipv4RouterIds() getter method. |
| 50 | */ |
| 51 | @Test |
| 52 | public void testIpv4RouterIds() throws Exception { |
| 53 | List list = new ArrayList(); |
| 54 | list.add(Ip4Address.valueOf("1.1.1.1")); |
| 55 | ospfDeviceTed.setIpv4RouterIds(list); |
| 56 | assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1)); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Tests ipv4RouterIds() setter method. |
| 61 | */ |
| 62 | @Test |
| 63 | public void testSetIpv4RouterIds() throws Exception { |
| 64 | List list = new ArrayList(); |
| 65 | list.add(Ip4Address.valueOf("1.1.1.1")); |
| 66 | ospfDeviceTed.setIpv4RouterIds(list); |
| 67 | assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1)); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Tests abr() getter method. |
| 72 | */ |
| 73 | @Test |
| 74 | public void testAbr() throws Exception { |
| 75 | ospfDeviceTed.setAbr(true); |
| 76 | assertThat(ospfDeviceTed.abr(), is(true)); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Tests abr() setter method. |
| 81 | */ |
| 82 | @Test |
| 83 | public void testSetAbr() throws Exception { |
| 84 | ospfDeviceTed.setAbr(true); |
| 85 | assertThat(ospfDeviceTed.abr(), is(true)); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Tests asbr() getter method. |
| 90 | */ |
| 91 | @Test |
| 92 | public void testAsbr() throws Exception { |
| 93 | ospfDeviceTed.setAsbr(true); |
| 94 | assertThat(ospfDeviceTed.asbr(), is(true)); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Tests asbr() setter method. |
| 99 | */ |
| 100 | @Test |
| 101 | public void testSetAsbr() throws Exception { |
| 102 | ospfDeviceTed.setAsbr(true); |
| 103 | assertThat(ospfDeviceTed.asbr(), is(true)); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Tests topologyIds() getter method. |
| 108 | */ |
| 109 | @Test |
| 110 | public void testTopologyIds() throws Exception { |
| 111 | List list = new ArrayList(); |
| 112 | list.add(Ip4Address.valueOf("1.1.1.1")); |
| 113 | ospfDeviceTed.setTopologyIds(list); |
| 114 | assertThat(ospfDeviceTed.topologyIds().size(), is(1)); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Tests topologyIds() setter method. |
| 119 | */ |
| 120 | @Test |
| 121 | public void testSetTopologyIds() throws Exception { |
| 122 | List list = new ArrayList(); |
| 123 | list.add(Ip4Address.valueOf("1.1.1.1")); |
| 124 | ospfDeviceTed.setTopologyIds(list); |
| 125 | assertThat(ospfDeviceTed.topologyIds().size(), is(1)); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Tests ipv6RouterIds() getter method. |
| 130 | */ |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 131 | @Test |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 132 | public void testIpv6RouterIds() throws Exception { |
| 133 | List list = new ArrayList(); |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 134 | list.add(LOCAL_ADDRESS); |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 135 | ospfDeviceTed.setIpv6RouterIds(list); |
| 136 | assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1)); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Tests ipv6RouterIds() setter method. |
| 141 | */ |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 142 | @Test |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 143 | public void testSetIpv6RouterIds() throws Exception { |
| 144 | List list = new ArrayList(); |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 145 | list.add(LOCAL_ADDRESS); |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 146 | ospfDeviceTed.setIpv6RouterIds(list); |
| 147 | assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1)); |
| 148 | } |
Jonathan Hart | 953bd00 | 2016-03-30 13:31:00 -0700 | [diff] [blame] | 149 | } |