chidambar babu | 344dc81 | 2016-05-02 19:13:10 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present 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.isis.controller.impl; |
| 17 | |
sunish vk | 4b5ce00 | 2016-05-09 20:18:35 +0530 | [diff] [blame] | 18 | import com.fasterxml.jackson.databind.JsonNode; |
| 19 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 20 | import org.easymock.EasyMock; |
chidambar babu | 344dc81 | 2016-05-02 19:13:10 +0530 | [diff] [blame] | 21 | import org.junit.After; |
| 22 | import org.junit.Before; |
| 23 | import org.junit.Test; |
sunish vk | 4b5ce00 | 2016-05-09 20:18:35 +0530 | [diff] [blame] | 24 | import org.onosproject.isis.controller.topology.IsisRouterListener; |
chidambar babu | 344dc81 | 2016-05-02 19:13:10 +0530 | [diff] [blame] | 25 | |
| 26 | import static org.hamcrest.CoreMatchers.is; |
| 27 | import static org.hamcrest.CoreMatchers.notNullValue; |
| 28 | import static org.junit.Assert.assertThat; |
| 29 | |
| 30 | /** |
| 31 | * Unit test case for DefaultIsisController. |
| 32 | */ |
| 33 | public class DefaultIsisControllerTest { |
sunish vk | 4b5ce00 | 2016-05-09 20:18:35 +0530 | [diff] [blame] | 34 | private ObjectMapper mapper; |
| 35 | private JsonNode jsonNode; |
chidambar babu | 344dc81 | 2016-05-02 19:13:10 +0530 | [diff] [blame] | 36 | private DefaultIsisController defaultIsisController; |
sunish vk | 4b5ce00 | 2016-05-09 20:18:35 +0530 | [diff] [blame] | 37 | private String jsonString = "{" + |
| 38 | " \"processes\": [{" + |
| 39 | " \"processId\": \"4.4.4.4\"," + |
| 40 | " \"interface\": [{" + |
| 41 | " \"interfaceIndex\": \"2\"," + |
| 42 | " \"macAddress\": \"08:00:27:b7:ab:bf\"," + |
| 43 | " \"interfaceIp\": \"192.168.56.101\"," + |
| 44 | " \"networkMask\": \"255.255.255.224\"," + |
| 45 | " \"intermediateSystemName\": \"ROUTERONE\"," + |
| 46 | " \"systemId\": \"2929.2929.2929\"," + |
| 47 | " \"lanId\": \"0000.0000.0000.00\"," + |
| 48 | " \"idLength\": \"0\"," + |
| 49 | " \"maxAreaAddresses\": \"3\"," + |
| 50 | " \"reservedPacketCircuitType\": \"1\"," + |
| 51 | " \"circuitId\": \"10\"," + |
| 52 | " \"networkType\": \"2\"," + |
| 53 | " \"areaAddress\": \"490000\"," + |
| 54 | " \"areaLength\": \"3\"," + |
| 55 | " \"lspId\": \"1313131313130000\"," + |
| 56 | " \"holdingTime\": \"50\"," + |
| 57 | " \"helloInterval\": \"10\"," + |
| 58 | " \"priority\": \"0\"" + |
| 59 | " }]" + |
| 60 | " }]" + |
| 61 | "}"; |
| 62 | |
| 63 | private IsisRouterListener isisRouterListener; |
chidambar babu | 344dc81 | 2016-05-02 19:13:10 +0530 | [diff] [blame] | 64 | |
| 65 | @Before |
| 66 | public void setUp() throws Exception { |
| 67 | defaultIsisController = new DefaultIsisController(); |
sunish vk | 4b5ce00 | 2016-05-09 20:18:35 +0530 | [diff] [blame] | 68 | mapper = new ObjectMapper(); |
| 69 | jsonNode = mapper.readTree(jsonString); |
| 70 | isisRouterListener = EasyMock.createNiceMock(IsisRouterListener.class); |
chidambar babu | 344dc81 | 2016-05-02 19:13:10 +0530 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | @After |
| 74 | public void tearDown() throws Exception { |
| 75 | defaultIsisController = null; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Tests activate() method. |
| 80 | */ |
| 81 | @Test |
| 82 | public void testActivate() throws Exception { |
| 83 | defaultIsisController.activate(); |
| 84 | assertThat(defaultIsisController, is(notNullValue())); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Tests deactivate() method. |
| 89 | */ |
| 90 | @Test(expected = Exception.class) |
| 91 | public void testDeactivate() throws Exception { |
| 92 | defaultIsisController.activate(); |
| 93 | defaultIsisController.deactivate(); |
| 94 | assertThat(defaultIsisController, is(notNullValue())); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Tests allConfiguredProcesses() method. |
| 99 | */ |
| 100 | @Test |
| 101 | public void testAllConfiguredProcesses() throws Exception { |
| 102 | defaultIsisController.allConfiguredProcesses(); |
| 103 | assertThat(defaultIsisController, is(notNullValue())); |
| 104 | } |
sunish vk | 4b5ce00 | 2016-05-09 20:18:35 +0530 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Tests updateConfig() method. |
| 108 | */ |
| 109 | @Test |
| 110 | public void testUpdateConfig() throws Exception { |
| 111 | defaultIsisController.updateConfig(jsonNode); |
| 112 | assertThat(defaultIsisController, is(notNullValue())); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Tests addRouterListener() method. |
| 117 | */ |
| 118 | @Test |
| 119 | public void testaddRouterListener() throws Exception { |
| 120 | defaultIsisController.addRouterListener(isisRouterListener); |
| 121 | assertThat(defaultIsisController, is(notNullValue())); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Tests removeRouterListener() method. |
| 126 | */ |
| 127 | @Test |
| 128 | public void testremoveRouterListener() throws Exception { |
| 129 | defaultIsisController.removeRouterListener(isisRouterListener); |
| 130 | assertThat(defaultIsisController, is(notNullValue())); |
| 131 | } |
chidambar babu | 344dc81 | 2016-05-02 19:13:10 +0530 | [diff] [blame] | 132 | } |