Polishing

pull/5488/head
Andy Wilkinson 9 years ago
parent 8a8a06381c
commit 18234ebb26

@ -473,15 +473,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
msg.append("Skipped "); msg.append("Skipped ");
} }
msg.append("config file "); msg.append("config file ");
String resourceDescription; msg.append(getResourceDescription(location, resource));
try {
resourceDescription = String.format("'%s' (%s)",
resource.getURI().toASCIIString(), location);
}
catch (IOException ex) {
resourceDescription = String.format("'%s'", location);
}
msg.append(resourceDescription);
if (StringUtils.hasLength(profile)) { if (StringUtils.hasLength(profile)) {
msg.append(" for profile ").append(profile); msg.append(" for profile ").append(profile);
} }
@ -495,6 +487,25 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
return propertySource; return propertySource;
} }
/**
* @param location
* @param resource
* @return
*/
private String getResourceDescription(String location, Resource resource) {
String resourceDescription = "'" + location + "'";
if (resource != null) {
try {
resourceDescription = String.format("'%s' (%s)",
resource.getURI().toASCIIString(), location);
}
catch (IOException ex) {
// Use the location as the description
}
}
return resourceDescription;
}
private void handleProfileProperties(PropertySource<?> propertySource) { private void handleProfileProperties(PropertySource<?> propertySource) {
Set<String> activeProfiles = getProfilesForValue( Set<String> activeProfiles = getProfilesForValue(
propertySource.getProperty(ACTIVE_PROFILES_PROPERTY)); propertySource.getProperty(ACTIVE_PROFILES_PROPERTY));

@ -467,7 +467,11 @@ public class ConfigFileApplicationListenerTests {
private String createLogForProfile(String profile) { private String createLogForProfile(String profile) {
String suffix = profile != null ? "-" + profile : ""; String suffix = profile != null ? "-" + profile : "";
return "Loaded config file 'classpath:/application" + suffix + ".properties'"; String string = ".properties)";
return "Loaded config file '"
+ new File("target/test-classes/application" + suffix + ".properties")
.getAbsoluteFile().toURI().toString()
+ "' (classpath:/application" + suffix + string;
} }
@Test @Test

Loading…
Cancel
Save