Update groupId to org.onap.ccsdk.sli
[ccsdk/sli/core.git] / sli / common / src / test / java / org / onap / ccsdk / sli / core / sli / SvcLogicContextTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : CCSDK
4  * ================================================================================
5  * Copyright (C) 2017 ONAP
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.ccsdk.sli.core.sli;
22
23 import java.io.BufferedReader;
24 import java.io.ByteArrayInputStream;
25 import java.io.InputStream;
26 import java.io.InputStreamReader;
27 import java.util.Enumeration;
28 import java.util.Properties;
29
30 import javax.xml.parsers.DocumentBuilder;
31 import javax.xml.parsers.DocumentBuilderFactory;
32
33 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36 import org.w3c.dom.Document;
37
38 import junit.framework.TestCase;
39
40 public class SvcLogicContextTest extends TestCase {
41         private static final Logger LOG = LoggerFactory
42                         .getLogger(SvcLogicContext.class);
43         
44         public void testMerge() {
45                 
46                 try {
47                         InputStream testStr = getClass().getResourceAsStream("/mergetest.xml");
48                         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
49                         DocumentBuilder db = dbf.newDocumentBuilder();
50
51                         Document theDocument = db.parse(testStr);
52                         SvcLogicContext ctx = new SvcLogicContext();
53                         ctx.mergeDocument("test-merge", theDocument);
54                         Properties props = ctx.toProperties();
55                         LOG.info("SvcLogicContext contains the following : ");
56                         for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) {
57                                 String propName = (String) e.nextElement();
58                                 LOG.info(propName+" = "+props.getProperty(propName));
59                                 
60                         }
61                 } catch (Exception e) {
62                         LOG.error("Caught exception trying to merge", e);
63                         fail("Caught exception trying to merge");
64                 }
65                 
66         }
67
68 }