@Test public void testConfigPorts() throws ParserConfigurationException, SAXException, XPathExpressionException, IOException, ClassNotFoundException { logger.info("ConfigUtil.getConfigValues(String, String): Ports"); final String documentName = "test.xml"; final String query = "/config/ports/port"; final Map<String, List<String>> expResult = new HashMap<>(); expResult.put("app1", Arrays.asList(new String[]{"1"})); expResult.put("app2", Arrays.asList(new String[]{"2"})); final Map<String, List<String>> result = ConfigUtil.getConfigData(documentName, query); assertEquals(expResult, result); }
public static Map<String, List<String>> getConfigData(final String documentName, final String query) { Map<String, Map<String, List<String>>> documentData = configDataMap.get(documentName); if (documentData == null) { documentData = new HashMap<>(); configDataMap.put(documentName, documentData); } Map<String, List<String>> queryData = documentData.get(query); if (queryData == null) { try { queryData = getDataFromConfFile(documentName, query); documentData.put(query, queryData); } catch (SAXException | IOException | XPathExpressionException | ParserConfigurationException ex) { final String message = "Error while attempting to read \"" + documentName + "\" for query \"" + query + "\""; logger.error(message, ex); throw new RuntimeException(message, ex); } } return queryData; }
ConfigUtil { public static Map<String, List<String>> getConfigData(final String documentName, final String query) { Map<String, Map<String, List<String>>> documentData = configDataMap.get(documentName); if (documentData == null) { documentData = new HashMap<>(); configDataMap.put(documentName, documentData); } Map<String, List<String>> queryData = documentData.get(query); if (queryData == null) { try { queryData = getDataFromConfFile(documentName, query); documentData.put(query, queryData); } catch (SAXException | IOException | XPathExpressionException | ParserConfigurationException ex) { final String message = "Error while attempting to read \"" + documentName + "\" for query \"" + query + "\""; logger.error(message, ex); throw new RuntimeException(message, ex); } } return queryData; } }
ConfigUtil { public static Map<String, List<String>> getConfigData(final String documentName, final String query) { Map<String, Map<String, List<String>>> documentData = configDataMap.get(documentName); if (documentData == null) { documentData = new HashMap<>(); configDataMap.put(documentName, documentData); } Map<String, List<String>> queryData = documentData.get(query); if (queryData == null) { try { queryData = getDataFromConfFile(documentName, query); documentData.put(query, queryData); } catch (SAXException | IOException | XPathExpressionException | ParserConfigurationException ex) { final String message = "Error while attempting to read \"" + documentName + "\" for query \"" + query + "\""; logger.error(message, ex); throw new RuntimeException(message, ex); } } return queryData; }  }
ConfigUtil { public static Map<String, List<String>> getConfigData(final String documentName, final String query) { Map<String, Map<String, List<String>>> documentData = configDataMap.get(documentName); if (documentData == null) { documentData = new HashMap<>(); configDataMap.put(documentName, documentData); } Map<String, List<String>> queryData = documentData.get(query); if (queryData == null) { try { queryData = getDataFromConfFile(documentName, query); documentData.put(query, queryData); } catch (SAXException | IOException | XPathExpressionException | ParserConfigurationException ex) { final String message = "Error while attempting to read \"" + documentName + "\" for query \"" + query + "\""; logger.error(message, ex); throw new RuntimeException(message, ex); } } return queryData; }  static Map<String, List<String>> getConfigData(final String documentName, final String query); }
ConfigUtil { public static Map<String, List<String>> getConfigData(final String documentName, final String query) { Map<String, Map<String, List<String>>> documentData = configDataMap.get(documentName); if (documentData == null) { documentData = new HashMap<>(); configDataMap.put(documentName, documentData); } Map<String, List<String>> queryData = documentData.get(query); if (queryData == null) { try { queryData = getDataFromConfFile(documentName, query); documentData.put(query, queryData); } catch (SAXException | IOException | XPathExpressionException | ParserConfigurationException ex) { final String message = "Error while attempting to read \"" + documentName + "\" for query \"" + query + "\""; logger.error(message, ex); throw new RuntimeException(message, ex); } } return queryData; }  static Map<String, List<String>> getConfigData(final String documentName, final String query);  }