blob: 4ac6dd9a489c5d24ae159802659323845e7ffc3b [file] [log] [blame]
sunishvkf7c56552016-07-18 16:02:39 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
sunishvkf7c56552016-07-18 16:02:39 +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.ospf.controller.impl;
17
18import com.fasterxml.jackson.databind.JsonNode;
19import com.fasterxml.jackson.databind.ObjectMapper;
20import org.junit.After;
21import org.junit.Before;
Jonathan Hart7c338a42016-08-19 10:21:34 -070022import org.junit.Ignore;
sunishvkf7c56552016-07-18 16:02:39 +053023import org.junit.Test;
24import org.onosproject.ospf.controller.OspfProcess;
25
26import java.util.ArrayList;
27import java.util.List;
28
29import static org.hamcrest.CoreMatchers.is;
30import static org.hamcrest.CoreMatchers.notNullValue;
31import static org.hamcrest.MatcherAssert.assertThat;
32
33/**
34 * Unit test class for OspfJsonParsingUtilTest.
35 */
36public class OspfConfigUtilTest {
37 private ObjectMapper mapper;
38 private JsonNode jsonNode;
39 private List<OspfProcess> ospfProcessList = new ArrayList<>();
40 private String jsonString = "{\n" +
41 "\t\"processes\": {\n" +
42 "\t\t\"areas\": [{\n" +
43 "\t\t\t\"interface\": [{\n" +
44 "\t\t\t\t\"interfaceIndex\": \"2\",\n" +
45 "\n" +
46 "\t\t\t\t\"helloIntervalTime\": \"10\",\n" +
47 "\n" +
48 "\t\t\t\t\"routerDeadIntervalTime\": \"40\",\n" +
49 "\n" +
50 "\t\t\t\t\"interfaceType\": \"2\",\n" +
51 "\n" +
52 "\t\t\t\t\"reTransmitInterval\": \"5\"\n" +
53 "\t\t\t}],\n" +
54 "\t\t\t\"areaId\": \"5.5.5.5\",\n" +
55 "\n" +
56 "\t\t\t\"routerId\": \"7.7.7.7\",\n" +
57 "\n" +
58 "\t\t\t\"isOpaqueEnable\": \"false\",\n" +
59 "\n" +
60 "\t\t\t\"externalRoutingCapability\": \"true\"\n" +
61 "\t\t}]\n" +
62 "\t}\n" +
63 "}";
64
65 @Before
66 public void setUp() throws Exception {
67 mapper = new ObjectMapper();
68 jsonNode = mapper.readTree(jsonString);
69 mapper = new ObjectMapper();
70 }
71
72 @After
73 public void tearDown() throws Exception {
74
75 }
76
77 @Test
Jonathan Hart7c338a42016-08-19 10:21:34 -070078 @Ignore
79 // Disabling because it seems to have an external dependency that can cause
80 // it to fail in some environments.
sunishvkf7c56552016-07-18 16:02:39 +053081 public void testProcesses() throws Exception {
82 jsonNode.path("areas");
83 ospfProcessList = OspfConfigUtil.processes(jsonNode);
84 assertThat(ospfProcessList, is(notNullValue()));
85 }
86}