* ============LICENSE_START=======================================================
* openECOMP : SDN-C
* ================================================================================
- * Copyright (C) 2017 ONAP Intellectual Property. All rights
- * reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public class TestXmlParser {
- private static final Logger log = LoggerFactory.getLogger(TestXmlParser.class);
+ private static final Logger log = LoggerFactory.getLogger(TestXmlParser.class);
- @Test
- public void test() throws Exception {
- BufferedReader in = new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml")));
- String ss = "";
- String line = null;
- while ((line = in.readLine()) != null)
- ss += line + '\n';
+ @Test
+ public void test() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
- Set<String> listNameList = new HashSet<String>();
- listNameList.add("project.dependencies.dependency");
- listNameList.add("project.build.plugins.plugin");
- listNameList.add("project.build.plugins.plugin.executions.execution");
- listNameList.add("project.build.pluginManagement.plugins.plugin");
- listNameList.add(
- "project.build.pluginManagement.plugins.plugin.configuration.lifecycleMappingMetadata.pluginExecutions.pluginExecution");
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("project.dependencies.dependency");
+ listNameList.add("project.build.plugins.plugin");
+ listNameList.add("project.build.plugins.plugin.executions.execution");
+ listNameList.add("project.build.pluginManagement.plugins.plugin");
+ listNameList.add("project.build.pluginManagement." +
+ "plugins.plugin.configuration.lifecycleMappingMetadata.pluginExecutions.pluginExecution");
- Map<String, String> mm = XmlParser.convertToProperties(ss, listNameList);
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+ logProperties(mm);
+ in.close();
+ }
- logProperties(mm);
+ private void logProperties(Map<String, String> mm) {
+ List<String> ll = new ArrayList<>();
+ for (Object o : mm.keySet())
+ ll.add((String) o);
+ Collections.sort(ll);
- in.close();
- }
-
- private void logProperties(Map<String, String> mm) {
- List<String> ll = new ArrayList<>();
- for (Object o : mm.keySet())
- ll.add((String) o);
- Collections.sort(ll);
-
- log.info("Properties:");
- for (String name : ll)
- log.info("--- " + name + ": " + mm.get(name));
- }
+ log.info("Properties:");
+ for (String name : ll)
+ log.info("--- " + name + ": " + mm.get(name));
+ }
}