2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.openecomp.sdnc.sli;
24 import java.io.BufferedReader;
25 import java.io.ByteArrayInputStream;
26 import java.io.InputStream;
27 import java.io.InputStreamReader;
28 import java.util.Enumeration;
29 import java.util.Properties;
31 import javax.xml.parsers.DocumentBuilder;
32 import javax.xml.parsers.DocumentBuilderFactory;
34 import org.openecomp.sdnc.sli.SvcLogicContext;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
37 import org.w3c.dom.Document;
39 import junit.framework.TestCase;
41 public class SvcLogicContextTest extends TestCase {
42 private static final Logger LOG = LoggerFactory
43 .getLogger(SvcLogicContext.class);
45 public void testMerge() {
48 InputStream testStr = getClass().getResourceAsStream("/mergetest.xml");
49 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
50 DocumentBuilder db = dbf.newDocumentBuilder();
52 Document theDocument = db.parse(testStr);
53 SvcLogicContext ctx = new SvcLogicContext();
54 ctx.mergeDocument("test-merge", theDocument);
55 Properties props = ctx.toProperties();
56 LOG.info("SvcLogicContext contains the following : ");
57 for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) {
58 String propName = (String) e.nextElement();
59 LOG.info(propName+" = "+props.getProperty(propName));
62 } catch (Exception e) {
63 LOG.error("Caught exception trying to merge", e);
64 fail("Caught exception trying to merge");