2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.sdnc.config.audit.node;
27 import java.io.IOException;
28 import java.util.HashMap;
29 import org.junit.Test;
30 import org.onap.sdnc.config.audit.node.CompareNode;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
35 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
37 public class TestCompareNodeXml {
38 private static final Logger log = LoggerFactory.getLogger(TestCompareNodeXml.class);
41 public void TestCompareExtactXML() throws SvcLogicException {
42 log.debug("TestCompareNode.TestCompareExtactXML()");
43 SvcLogicContext ctx = new SvcLogicContext();
44 HashMap<String, String> testMap = new HashMap<String, String>();
45 CompareNode cmp = new CompareNode();
46 String s = "<configuration xmlns=" + "\"http://xml.juniper.net/xnm/1.1/xnm\"" + " junos:commit-seconds="
47 + "\"1473957536\" " + "junos:commit-localtime=" + "\"2016-09-15 16:38:56 UTC\" " + "junos:commit-user="
48 + "\"root\"" + "><name>Test</name></configuration>";
50 String t = "<configuration xmlns=" + "\"http://xml.juniper.net/xnm/1.1/xnm\"" + " junos:commit-seconds="
51 + "\"1473957536\" " + "junos:commit-localtime=" + "\"2016-09-15 16:38:56 UTC\" " + "junos:commit-user="
52 + "\"root\"" + "><name>Test</name></configuration>";
53 testMap.put("compareDataType", "RESTCONF-XML");
54 testMap.put("requestIdentifier", "123");
55 testMap.put("sourceData", s);
56 testMap.put("targetData", t);
57 cmp.compare(testMap, ctx);
58 assert (ctx.getAttribute("123." + "STATUS").equals("SUCCESS"));
62 public void TestCompareforAttributeOrder() throws IOException, SvcLogicException {
63 log.debug("TestCompareNode.TestCompareforAttributeOrder()");
64 SvcLogicContext ctx = new SvcLogicContext();
65 HashMap<String, String> testMap = new HashMap<String, String>();
66 CompareNode cmp = new CompareNode();
67 testMap.put("compareDataType", "XML");
68 testMap.put("sourceData",
69 "<SipIfTermination><id>2</id><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort></SipIfTermination>");
70 testMap.put("targetData",
71 "<SipIfTermination><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort><id>2</id></SipIfTermination>");
72 cmp.compare(testMap, ctx);
73 assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
77 public void TestCompareForComments() throws SvcLogicException {
78 log.debug("TestCompareNode.TestCompareForComments()");
79 SvcLogicContext ctx = new SvcLogicContext();
80 HashMap<String, String> testMap = new HashMap<String, String>();
81 CompareNode cmp = new CompareNode();
82 testMap.put("compareDataType", "XML");
83 testMap.put("sourceData", "<SipIfTermination><id>2</id><!--this is a commnect --></SipIfTermination>");
84 testMap.put("targetData", "<SipIfTermination><id>2</id></SipIfTermination>");
85 cmp.compare(testMap, ctx);
86 assert (ctx.getAttribute("STATUS").equals("SUCCESS"));