2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdnc.config.audit.node;
23 import java.io.IOException;
24 import java.util.HashMap;
25 import java.util.Properties;
27 import org.junit.Test;
28 import org.openecomp.sdnc.config.audit.node.CompareNode;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 import org.openecomp.sdnc.sli.SvcLogicContext;
33 import org.openecomp.sdnc.sli.SvcLogicException;
36 public class TestCompareNodeXml
38 private static final Logger log = LoggerFactory.getLogger(TestCompareNodeXml.class);
41 public void TestCompareExtactXML()
43 log.debug("TestCompareNode.TestCompareExtactXML()");
44 SvcLogicContext ctx = new SvcLogicContext();
45 HashMap<String, String> testMap = new HashMap<String, String>();
46 CompareNode cmp = new CompareNode();
49 String s="<configuration xmlns="
50 + "\"http://xml.juniper.net/xnm/1.1/xnm\""
51 + " junos:commit-seconds="
53 +"junos:commit-localtime="
54 +"\"2016-09-15 16:38:56 UTC\" "
55 + "junos:commit-user="
57 +"><name>Test</name></configuration>";
59 String t ="<configuration xmlns="
60 + "\"http://xml.juniper.net/xnm/1.1/xnm\""
61 + " junos:commit-seconds="
63 +"junos:commit-localtime="
64 +"\"2016-09-15 16:38:56 UTC\" "
65 + "junos:commit-user="
67 +"><name>Test</name></configuration>";
69 System.out.println("s=" + s);
71 testMap.put("compareDataType", "RESTCONF-XML");
72 testMap.put("requestIdentifier", "123");
73 testMap.put("sourceData", s);
74 testMap.put("targetData", t);
75 cmp.compare(testMap, ctx);
76 assert(ctx.getAttribute("123." + "STATUS").equals("SUCCESS"));
78 catch (SvcLogicException e)
80 // TODO Auto-generated catch block
85 public void TestCompareforAttributeOrder() throws IOException
87 log.debug("TestCompareNode.TestCompareforAttributeOrder()");
88 SvcLogicContext ctx = new SvcLogicContext();
89 HashMap<String, String> testMap = new HashMap<String, String>();
90 CompareNode cmp = new CompareNode();
91 testMap.put("compareDataType", "XML");
92 testMap.put("sourceData", "<SipIfTermination><id>2</id><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort></SipIfTermination>");
93 testMap.put("targetData", "<SipIfTermination><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort><id>2</id></SipIfTermination>");
96 cmp.compare(testMap, ctx);
98 catch (SvcLogicException e)
102 assert(ctx.getAttribute("STATUS").equals("SUCCESS"));
106 public void TestCompareForComments()
108 log.debug("TestCompareNode.TestCompareForComments()");
109 SvcLogicContext ctx = new SvcLogicContext();
110 HashMap<String, String> testMap = new HashMap<String, String>();
111 CompareNode cmp = new CompareNode();
115 testMap.put("compareDataType", "XML");
116 testMap.put("sourceData", "<SipIfTermination><id>2</id><!--this is a commnect --></SipIfTermination>");
117 testMap.put("targetData", "<SipIfTermination><id>2</id></SipIfTermination>");
118 cmp.compare(testMap, ctx);
119 assert(ctx.getAttribute("STATUS").equals("SUCCESS"));
121 catch (SvcLogicException e)