blob: 1ae1e58f6e922dcaf746b2952d6733dd32ae660e [file] [log] [blame]
chidambar babu344dc812016-05-02 19:13:10 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
chidambar babu344dc812016-05-02 19:13:10 +05303 *
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 */
16package org.onosproject.isis.controller.impl;
17
sunish vk4b5ce002016-05-09 20:18:35 +053018import com.fasterxml.jackson.databind.JsonNode;
19import com.fasterxml.jackson.databind.ObjectMapper;
20import org.easymock.EasyMock;
chidambar babu344dc812016-05-02 19:13:10 +053021import org.junit.After;
22import org.junit.Before;
23import org.junit.Test;
sunish vk4b5ce002016-05-09 20:18:35 +053024import org.onosproject.isis.controller.topology.IsisRouterListener;
chidambar babu344dc812016-05-02 19:13:10 +053025
26import static org.hamcrest.CoreMatchers.is;
27import static org.hamcrest.CoreMatchers.notNullValue;
28import static org.junit.Assert.assertThat;
29
30/**
31 * Unit test case for DefaultIsisController.
32 */
33public class DefaultIsisControllerTest {
sunish vk4b5ce002016-05-09 20:18:35 +053034 private ObjectMapper mapper;
35 private JsonNode jsonNode;
chidambar babu344dc812016-05-02 19:13:10 +053036 private DefaultIsisController defaultIsisController;
sunish vk4b5ce002016-05-09 20:18:35 +053037 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 babu344dc812016-05-02 19:13:10 +053064
65 @Before
66 public void setUp() throws Exception {
67 defaultIsisController = new DefaultIsisController();
sunish vk4b5ce002016-05-09 20:18:35 +053068 mapper = new ObjectMapper();
69 jsonNode = mapper.readTree(jsonString);
70 isisRouterListener = EasyMock.createNiceMock(IsisRouterListener.class);
chidambar babu344dc812016-05-02 19:13:10 +053071 }
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 */
Ray Milkey11ce9302019-02-07 14:41:17 -080090 @Test()
chidambar babu344dc812016-05-02 19:13:10 +053091 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 vk4b5ce002016-05-09 20:18:35 +0530105
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 babu344dc812016-05-02 19:13:10 +0530132}