diff --git a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index 4225dbe017..3acac650dd 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -409,7 +409,8 @@ public class ConfigFileApplicationListenerTests { "spring.profiles.active:other"); this.environment.addActiveProfile("dev"); this.initializer.postProcessEnvironment(this.environment, this.application); - assertThat(Arrays.asList(this.environment.getActiveProfiles()), containsInAnyOrder("dev", "other")); + assertThat(Arrays.asList(this.environment.getActiveProfiles()), + containsInAnyOrder("dev", "other")); assertThat(this.environment.getProperty("my.property"), equalTo("fromotherpropertiesfile")); validateProfilePrecedence(null, "dev", "other"); @@ -421,39 +422,48 @@ public class ConfigFileApplicationListenerTests { "spring.profiles.active:dev,other"); this.environment.addActiveProfile("dev"); this.initializer.postProcessEnvironment(this.environment, this.application); - assertThat(Arrays.asList(this.environment.getActiveProfiles()), containsInAnyOrder("dev", "other")); + assertThat(Arrays.asList(this.environment.getActiveProfiles()), + containsInAnyOrder("dev", "other")); assertThat(this.environment.getProperty("my.property"), equalTo("fromotherpropertiesfile")); validateProfilePrecedence(null, "dev", "other"); } @Test - public void profilesAddedToEnvironmentAndViaPropertyDuplicateEnvironmentWins() throws Exception { + public void profilesAddedToEnvironmentAndViaPropertyDuplicateEnvironmentWins() + throws Exception { EnvironmentTestUtils.addEnvironment(this.environment, "spring.profiles.active:other,dev"); this.environment.addActiveProfile("other"); this.initializer.postProcessEnvironment(this.environment, this.application); - assertThat(Arrays.asList(this.environment.getActiveProfiles()), containsInAnyOrder("dev", "other")); + assertThat(Arrays.asList(this.environment.getActiveProfiles()), + containsInAnyOrder("dev", "other")); assertThat(this.environment.getProperty("my.property"), equalTo("fromdevpropertiesfile")); validateProfilePrecedence(null, "other", "dev"); } private void validateProfilePrecedence(String... profiles) { - this.initializer.onApplicationEvent(new ApplicationPreparedEvent( - new SpringApplication(), new String[0], new AnnotationConfigApplicationContext())); + ApplicationPreparedEvent event = new ApplicationPreparedEvent( + new SpringApplication(), new String[0], + new AnnotationConfigApplicationContext()); + this.initializer.onApplicationEvent(event); String log = this.out.toString(); // First make sure that each profile got processed only once for (String profile : profiles) { - assertThat("Wrong number of occurrences for profile '" + profile + "' --> " + log, - StringUtils.countOccurrencesOf(log, createLogForProfile(profile)), equalTo(1)); + String reason = "Wrong number of occurrences for profile '" + profile + + "' --> " + log; + assertThat(reason, + StringUtils.countOccurrencesOf(log, createLogForProfile(profile)), + equalTo(1)); } // Make sure the order of loading is the right one for (String profile : profiles) { String line = createLogForProfile(profile); int index = log.indexOf(line); - assertTrue("Loading profile '" + profile + "' not found in '" + log + "'", index != -1); + assertTrue("Loading profile '" + profile + "' not found in '" + log + "'", + index != -1); log = log.substring(index + line.length(), log.length()); } }