use of org.apache.commons.configuration2.ex.ConfigurationRuntimeException in project selenium-tests by Wikia.
the class XMLReader method getValue.
/**
* method used to get credentials from configuration xml
*/
public static String getValue(File file, String key) {
if (!file.exists() || file.isDirectory()) {
throw new ConfigurationRuntimeException("Cannot find a file with credentials");
}
try {
Parameters params = new Parameters();
FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>(XMLConfiguration.class).configure(params.fileBased().setFile(file));
org.apache.commons.configuration2.Configuration config = builder.getConfiguration();
return config.getString(key);
} catch (ConfigurationException e) {
throw new ConfigurationRuntimeException(e);
}
}
Aggregations