@Test public void should_load_properties_from_classpath() throws Exception { Properties userProperties = loader.loadUserConfiguration(); assertThat(userProperties).hasSize(1); assertThat(userProperties.getProperty("asset.locations.resolution.strategy")).isEqualTo("webapp,remote"); }
public Properties loadUserConfiguration() { logger.debug("Loading user configuration..."); Properties userProperties = null; String activeRawProfile = Profile.getActiveRawProfile(); String dandelionBasePath = System.getProperty(DANDELION_CONFIGURATION); String dandelionFileName = null; if (StringUtils.isBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + ".properties"; } else if (StringUtils.isNotBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + "_" + activeRawProfile + ".properties"; } String dandelionFilePath = null; if (StringUtils.isNotBlank(dandelionBasePath)) { if (!dandelionBasePath.endsWith(String.valueOf(File.separatorChar))) { dandelionBasePath += File.separator; } dandelionFilePath = dandelionBasePath + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromFileSystem(dandelionFilePath, "UTF-8"); } catch (Exception e) { StringBuilder error = new StringBuilder("No file \""); error.append(dandelionFileName); error.append("\" was found in \""); error.append(dandelionBasePath); error.append("\"."); if (StringUtils.isNotBlank(activeRawProfile)) { throw new DandelionException(error.toString()); } else { logger.warn("No file \"{}\" was found in \"{}\". The default configuration will be used.", dandelionFileName, dandelionBasePath); } } } if (userProperties == null) { dandelionFilePath = "dandelion/" + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromClasspath(dandelionFilePath, "UTF-8"); } catch (Exception e) { logger.warn("No file \"dandelion.properties\" was found in \"" + dandelionFilePath + "\" (classpath). The default configuration will be used."); } } logger.debug("User configuration loaded"); return userProperties; }
StandardConfigurationLoader implements ConfigurationLoader { public Properties loadUserConfiguration() { logger.debug("Loading user configuration..."); Properties userProperties = null; String activeRawProfile = Profile.getActiveRawProfile(); String dandelionBasePath = System.getProperty(DANDELION_CONFIGURATION); String dandelionFileName = null; if (StringUtils.isBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + ".properties"; } else if (StringUtils.isNotBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + "_" + activeRawProfile + ".properties"; } String dandelionFilePath = null; if (StringUtils.isNotBlank(dandelionBasePath)) { if (!dandelionBasePath.endsWith(String.valueOf(File.separatorChar))) { dandelionBasePath += File.separator; } dandelionFilePath = dandelionBasePath + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromFileSystem(dandelionFilePath, "UTF-8"); } catch (Exception e) { StringBuilder error = new StringBuilder("No file \""); error.append(dandelionFileName); error.append("\" was found in \""); error.append(dandelionBasePath); error.append("\"."); if (StringUtils.isNotBlank(activeRawProfile)) { throw new DandelionException(error.toString()); } else { logger.warn("No file \"{}\" was found in \"{}\". The default configuration will be used.", dandelionFileName, dandelionBasePath); } } } if (userProperties == null) { dandelionFilePath = "dandelion/" + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromClasspath(dandelionFilePath, "UTF-8"); } catch (Exception e) { logger.warn("No file \"dandelion.properties\" was found in \"" + dandelionFilePath + "\" (classpath). The default configuration will be used."); } } logger.debug("User configuration loaded"); return userProperties; } }
StandardConfigurationLoader implements ConfigurationLoader { public Properties loadUserConfiguration() { logger.debug("Loading user configuration..."); Properties userProperties = null; String activeRawProfile = Profile.getActiveRawProfile(); String dandelionBasePath = System.getProperty(DANDELION_CONFIGURATION); String dandelionFileName = null; if (StringUtils.isBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + ".properties"; } else if (StringUtils.isNotBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + "_" + activeRawProfile + ".properties"; } String dandelionFilePath = null; if (StringUtils.isNotBlank(dandelionBasePath)) { if (!dandelionBasePath.endsWith(String.valueOf(File.separatorChar))) { dandelionBasePath += File.separator; } dandelionFilePath = dandelionBasePath + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromFileSystem(dandelionFilePath, "UTF-8"); } catch (Exception e) { StringBuilder error = new StringBuilder("No file \""); error.append(dandelionFileName); error.append("\" was found in \""); error.append(dandelionBasePath); error.append("\"."); if (StringUtils.isNotBlank(activeRawProfile)) { throw new DandelionException(error.toString()); } else { logger.warn("No file \"{}\" was found in \"{}\". The default configuration will be used.", dandelionFileName, dandelionBasePath); } } } if (userProperties == null) { dandelionFilePath = "dandelion/" + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromClasspath(dandelionFilePath, "UTF-8"); } catch (Exception e) { logger.warn("No file \"dandelion.properties\" was found in \"" + dandelionFilePath + "\" (classpath). The default configuration will be used."); } } logger.debug("User configuration loaded"); return userProperties; }  }
StandardConfigurationLoader implements ConfigurationLoader { public Properties loadUserConfiguration() { logger.debug("Loading user configuration..."); Properties userProperties = null; String activeRawProfile = Profile.getActiveRawProfile(); String dandelionBasePath = System.getProperty(DANDELION_CONFIGURATION); String dandelionFileName = null; if (StringUtils.isBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + ".properties"; } else if (StringUtils.isNotBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + "_" + activeRawProfile + ".properties"; } String dandelionFilePath = null; if (StringUtils.isNotBlank(dandelionBasePath)) { if (!dandelionBasePath.endsWith(String.valueOf(File.separatorChar))) { dandelionBasePath += File.separator; } dandelionFilePath = dandelionBasePath + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromFileSystem(dandelionFilePath, "UTF-8"); } catch (Exception e) { StringBuilder error = new StringBuilder("No file \""); error.append(dandelionFileName); error.append("\" was found in \""); error.append(dandelionBasePath); error.append("\"."); if (StringUtils.isNotBlank(activeRawProfile)) { throw new DandelionException(error.toString()); } else { logger.warn("No file \"{}\" was found in \"{}\". The default configuration will be used.", dandelionFileName, dandelionBasePath); } } } if (userProperties == null) { dandelionFilePath = "dandelion/" + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromClasspath(dandelionFilePath, "UTF-8"); } catch (Exception e) { logger.warn("No file \"dandelion.properties\" was found in \"" + dandelionFilePath + "\" (classpath). The default configuration will be used."); } } logger.debug("User configuration loaded"); return userProperties; }  Properties loadUserConfiguration(); }
StandardConfigurationLoader implements ConfigurationLoader { public Properties loadUserConfiguration() { logger.debug("Loading user configuration..."); Properties userProperties = null; String activeRawProfile = Profile.getActiveRawProfile(); String dandelionBasePath = System.getProperty(DANDELION_CONFIGURATION); String dandelionFileName = null; if (StringUtils.isBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + ".properties"; } else if (StringUtils.isNotBlank(activeRawProfile)) { dandelionFileName = DANDELION_USER_PROPERTIES + "_" + activeRawProfile + ".properties"; } String dandelionFilePath = null; if (StringUtils.isNotBlank(dandelionBasePath)) { if (!dandelionBasePath.endsWith(String.valueOf(File.separatorChar))) { dandelionBasePath += File.separator; } dandelionFilePath = dandelionBasePath + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromFileSystem(dandelionFilePath, "UTF-8"); } catch (Exception e) { StringBuilder error = new StringBuilder("No file \""); error.append(dandelionFileName); error.append("\" was found in \""); error.append(dandelionBasePath); error.append("\"."); if (StringUtils.isNotBlank(activeRawProfile)) { throw new DandelionException(error.toString()); } else { logger.warn("No file \"{}\" was found in \"{}\". The default configuration will be used.", dandelionFileName, dandelionBasePath); } } } if (userProperties == null) { dandelionFilePath = "dandelion/" + dandelionFileName; logger.debug("Trying to load the configuration from \"{}\"", dandelionFilePath); try { userProperties = PropertiesUtils.loadFromClasspath(dandelionFilePath, "UTF-8"); } catch (Exception e) { logger.warn("No file \"dandelion.properties\" was found in \"" + dandelionFilePath + "\" (classpath). The default configuration will be used."); } } logger.debug("User configuration loaded"); return userProperties; }  Properties loadUserConfiguration(); static final String DANDELION_USER_PROPERTIES; static final String DANDELION_CONFIGURATION; }