XmlSettingsReader { public boolean getBooleanProperty(String xPathExp, String tagName, boolean defaultVal) { return getElementByXPath(xPathExp, tagName, node -> { try { return Boolean.parseBoolean(node.getTextContent()); } catch (NumberFormatException e) { return defaultVal; } }, defaultVal); } XmlSettingsReader(String xmlString); int getIntProperty(String xPathExp, String tagName, int defaultVal); String getStringPropertyByXPath(String xPathExp, String tagName); String getStringPropertyByXPath(String xPathExp, String tagName, String defaultVal); boolean getBooleanProperty(String xPathExp, String tagName, boolean defaultVal); String getStringProperty(String tagName); File getFileProperty(String tagName); String getStringProperty(String tagName, String defaultValue); List<String> getStringListProperty(String tagName); Map<String, Boolean> getStringKeyedBooleanMapProperty(String tagName); Map<String, T> getStringKeyedMapProperty(String tagName, Function<String, T> mapFunction); T getComplexType(String tagName, Class<T> targetClass);  }
@Test public void readSimpleBooleanProperty() throws Exception { String simpleBooleanXml = prepareElement(BOOL_TAG, String.valueOf(booleanValue)); xsr = new XmlSettingsReader(simpleBooleanXml); boolean readBooleanProperty = xsr.getBooleanProperty("/", BOOL_TAG, DEFAULT_BOOL); assertEquals(booleanValue, readBooleanProperty); }