@Test public void loadServerConfigurationExternal() throws Exception { ConfigurationLoader loader = new ConfigurationLoader(); InputStream configFile = this.getClass().getResourceAsStream("/" + EXTERNAL_CONFIG); Path path = Files.createTempFile(EXTERNAL_CONFIG, EXTERNAL_CONFIG); Files.copy(configFile, path, StandardCopyOption.REPLACE_EXISTING); Properties serverConfiguration = loader.loadServerConfiguration(path.toString()); Assert.assertTrue(serverConfiguration != null); Assert.assertEquals(String.format(SERVER_URL, EXTERNAL_PORT), serverConfiguration.getProperty(SERVER_URL_PROPERTY)); }
public Properties loadServerConfiguration(final String configFile) { if (configFile != null && !configFile.isEmpty()) { File extConfig = new File(configFile); if (extConfig.exists()) { return getPropertiesFromFile(extConfig); } } try { File extProps = getConfigFile(); if (extProps.exists()) { return getPropertiesFromFile(extProps); } } catch (UnsupportedEncodingException | ApplicationException e) { LOGGER.debug(e.getMessage(), e); } LOGGER.error("Using default properties"); return loadProperties(SERVER_PROPERTIES); }
ConfigurationLoader { public Properties loadServerConfiguration(final String configFile) { if (configFile != null && !configFile.isEmpty()) { File extConfig = new File(configFile); if (extConfig.exists()) { return getPropertiesFromFile(extConfig); } } try { File extProps = getConfigFile(); if (extProps.exists()) { return getPropertiesFromFile(extProps); } } catch (UnsupportedEncodingException | ApplicationException e) { LOGGER.debug(e.getMessage(), e); } LOGGER.error("Using default properties"); return loadProperties(SERVER_PROPERTIES); } }
ConfigurationLoader { public Properties loadServerConfiguration(final String configFile) { if (configFile != null && !configFile.isEmpty()) { File extConfig = new File(configFile); if (extConfig.exists()) { return getPropertiesFromFile(extConfig); } } try { File extProps = getConfigFile(); if (extProps.exists()) { return getPropertiesFromFile(extProps); } } catch (UnsupportedEncodingException | ApplicationException e) { LOGGER.debug(e.getMessage(), e); } LOGGER.error("Using default properties"); return loadProperties(SERVER_PROPERTIES); } ConfigurationLoader(); }
ConfigurationLoader { public Properties loadServerConfiguration(final String configFile) { if (configFile != null && !configFile.isEmpty()) { File extConfig = new File(configFile); if (extConfig.exists()) { return getPropertiesFromFile(extConfig); } } try { File extProps = getConfigFile(); if (extProps.exists()) { return getPropertiesFromFile(extProps); } } catch (UnsupportedEncodingException | ApplicationException e) { LOGGER.debug(e.getMessage(), e); } LOGGER.error("Using default properties"); return loadProperties(SERVER_PROPERTIES); } ConfigurationLoader(); Properties loadServerConfiguration(final String configFile); Properties loadCommandProperties(); CommandConfiguration loadCommandConfiguration(String fullCommand); File getConfigFile(); }
ConfigurationLoader { public Properties loadServerConfiguration(final String configFile) { if (configFile != null && !configFile.isEmpty()) { File extConfig = new File(configFile); if (extConfig.exists()) { return getPropertiesFromFile(extConfig); } } try { File extProps = getConfigFile(); if (extProps.exists()) { return getPropertiesFromFile(extProps); } } catch (UnsupportedEncodingException | ApplicationException e) { LOGGER.debug(e.getMessage(), e); } LOGGER.error("Using default properties"); return loadProperties(SERVER_PROPERTIES); } ConfigurationLoader(); Properties loadServerConfiguration(final String configFile); Properties loadCommandProperties(); CommandConfiguration loadCommandConfiguration(String fullCommand); File getConfigFile();  }