com.appium.utils.ConfigFileManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of AppiumTestDistribution Show documentation
Show all versions of AppiumTestDistribution Show documentation
A tool run Android and iOS test in parallel across devices
package com.appium.utils;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
/**
* ConfigFileManager - Read config file statically into configFileMap
*/
public class ConfigFileManager {
public static Map configFileMap = new HashMap();
private static Properties prop = new Properties();
private static ConfigFileManager instance;
private static final Logger LOGGER = Logger.getLogger(ConfigFileManager.class.getSimpleName());
private ConfigFileManager(String configFile) throws IOException {
FileInputStream inputStream = new FileInputStream(configFile);
prop.load(inputStream);
}
public static ConfigFileManager getInstance() {
if (instance == null) {
String configFile = "config.properties";
try {
if (System.getenv().containsKey("CONFIG_FILE")) {
configFile = System.getenv().get("CONFIG_FILE");
LOGGER.info("Using config file from " + configFile);
}
instance = new ConfigFileManager(configFile);
Enumeration keys = prop.propertyNames();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
String value = (null == System.getenv(key))
? prop.getProperty(key) : System.getenv(key);
configFileMap.put(key, value);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return instance;
}
public String getProperty(String object) {
return configFileMap.get(object);
}
public String getProperty(String key,String value) {
return configFileMap.getOrDefault(key,value);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy