Update groupId to org.onap.ccsdk.sli
[ccsdk/sli/core.git] / sli / common / src / test / java / org / openecomp / sdnc / sli / SvcLogicContextTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
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
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
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=========================================================
20  */
21
22 package org.openecomp.sdnc.sli;
23
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;
30
31 import javax.xml.parsers.DocumentBuilder;
32 import javax.xml.parsers.DocumentBuilderFactory;
33
34 import org.openecomp.sdnc.sli.SvcLogicContext;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
37 import org.w3c.dom.Document;
38
39 import junit.framework.TestCase;
40
41 public class SvcLogicContextTest extends TestCase {
42         private static final Logger LOG = LoggerFactory
43                         .getLogger(SvcLogicContext.class);
44         
45         public void testMerge() {
46                 
47                 try {
48                         InputStream testStr = getClass().getResourceAsStream("/mergetest.xml");
49                         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
50                         DocumentBuilder db = dbf.newDocumentBuilder();
51
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));
60                                 
61                         }
62                 } catch (Exception e) {
63                         LOG.error("Caught exception trying to merge", e);
64                         fail("Caught exception trying to merge");
65                 }
66                 
67         }
68
69 }