Skip to content

Commit

Permalink
load default property file as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Kaufmann committed Apr 9, 2018
1 parent 92b7753 commit 645d39e
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.FileInputStream;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -13,9 +14,13 @@
import org.aeonbits.owner.ConfigFactory;
import org.aeonbits.owner.Factory;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MultibrowserConfiguration
{
private static final Logger LOGGER = LoggerFactory.getLogger(MultibrowserConfiguration.class);

private static final Map<String, MultibrowserConfiguration> CONFIGURATIONS = Collections.synchronizedMap(new LinkedHashMap<>());

private static final String TEST_ENVIRONMENT_FILE = "./config/credentials.properties";
Expand All @@ -24,6 +29,8 @@ public class MultibrowserConfiguration

private static final String TEST_ENVIRONMENT_PREFIX = BROWSER_PROFILE_PREFIX + "testEnvironment.";

private static final String DEFAULT_BROWSER_PROFILE_FILE = "./config/browser.properties";

private DriverServerPath driverServerPath;

private WebDriverProperties webDriverProperties;
Expand Down Expand Up @@ -141,7 +148,11 @@ private Set<String> getSubkeysForPrefix(Properties properties, String prefix)
public static MultibrowserConfiguration getInstance()
{
if (CONFIGURATIONS.size() == 0)
throw new RuntimeException("No multi browser configuration available. Call getInstance(String configFile) first to create default configuration");
{
LOGGER.debug(MessageFormat.format("No multi-browser configuration loaded. Load default configuration from ''{0}''",
DEFAULT_BROWSER_PROFILE_FILE));
getInstance(DEFAULT_BROWSER_PROFILE_FILE);
}

return CONFIGURATIONS.entrySet().iterator().next().getValue();
}
Expand Down

0 comments on commit 645d39e

Please sign in to comment.