Skip to content

Commit 9432ee6

Browse files
committed
Polish
1 parent 124574e commit 9432ee6

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
import org.springframework.boot.context.properties.ConfigurationProperties;
2020

2121
/**
22-
* Properties used to configure resource handling0
22+
* Properties used to configure resource handling.
23+
*
24+
* @author Phillip Webb
25+
* @since 1.1.0
2326
*/
2427
@ConfigurationProperties(prefix = "spring.resources", ignoreUnknownFields = false)
2528
public class ResourceProperties {

spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,15 @@
6363
import org.springframework.util.ReflectionUtils;
6464
import org.springframework.util.StringUtils;
6565

66-
import static org.hamcrest.Matchers.*;
67-
import static org.junit.Assert.*;
66+
import static org.hamcrest.Matchers.contains;
67+
import static org.hamcrest.Matchers.containsInAnyOrder;
68+
import static org.hamcrest.Matchers.equalTo;
69+
import static org.hamcrest.Matchers.not;
70+
import static org.hamcrest.Matchers.notNullValue;
71+
import static org.hamcrest.Matchers.nullValue;
72+
import static org.junit.Assert.assertEquals;
73+
import static org.junit.Assert.assertThat;
74+
import static org.junit.Assert.assertTrue;
6875

6976
/**
7077
* Tests for {@link ConfigFileApplicationListener}.
@@ -362,7 +369,8 @@ public void profilesAddedToEnvironmentAndViaProperty() throws Exception {
362369
"spring.profiles.active:other");
363370
this.environment.addActiveProfile("dev");
364371
this.initializer.onApplicationEvent(this.event);
365-
assertThat(Arrays.asList(this.environment.getActiveProfiles()), containsInAnyOrder("dev", "other"));
372+
assertThat(Arrays.asList(this.environment.getActiveProfiles()),
373+
containsInAnyOrder("dev", "other"));
366374
assertThat(this.environment.getProperty("my.property"),
367375
equalTo("fromotherpropertiesfile"));
368376
validateProfilePrecedence(null, "dev", "other");
@@ -374,39 +382,48 @@ public void profilesAddedToEnvironmentAndViaPropertyDuplicate() throws Exception
374382
"spring.profiles.active:dev,other");
375383
this.environment.addActiveProfile("dev");
376384
this.initializer.onApplicationEvent(this.event);
377-
assertThat(Arrays.asList(this.environment.getActiveProfiles()), containsInAnyOrder("dev", "other"));
385+
assertThat(Arrays.asList(this.environment.getActiveProfiles()),
386+
containsInAnyOrder("dev", "other"));
378387
assertThat(this.environment.getProperty("my.property"),
379388
equalTo("fromotherpropertiesfile"));
380389
validateProfilePrecedence(null, "dev", "other");
381390
}
382391

383392
@Test
384-
public void profilesAddedToEnvironmentAndViaPropertyDuplicateEnvironmentWins() throws Exception {
393+
public void profilesAddedToEnvironmentAndViaPropertyDuplicateEnvironmentWins()
394+
throws Exception {
385395
EnvironmentTestUtils.addEnvironment(this.environment,
386396
"spring.profiles.active:other,dev");
387397
this.environment.addActiveProfile("other");
388398
this.initializer.onApplicationEvent(this.event);
389-
assertThat(Arrays.asList(this.environment.getActiveProfiles()), containsInAnyOrder("dev", "other"));
399+
assertThat(Arrays.asList(this.environment.getActiveProfiles()),
400+
containsInAnyOrder("dev", "other"));
390401
assertThat(this.environment.getProperty("my.property"),
391402
equalTo("fromdevpropertiesfile"));
392403
validateProfilePrecedence(null, "other", "dev");
393404
}
394405

395406
private void validateProfilePrecedence(String... profiles) {
396-
this.initializer.onApplicationEvent(new ApplicationPreparedEvent(
397-
new SpringApplication(), new String[0], new AnnotationConfigApplicationContext()));
407+
ApplicationPreparedEvent event = new ApplicationPreparedEvent(
408+
new SpringApplication(), new String[0],
409+
new AnnotationConfigApplicationContext());
410+
this.initializer.onApplicationEvent(event);
398411
String log = this.out.toString();
399412

400413
// First make sure that each profile got processed only once
401414
for (String profile : profiles) {
402-
assertThat("Wrong number of occurrences for profile '" + profile + "' --> " + log,
403-
StringUtils.countOccurrencesOf(log, createLogForProfile(profile)), equalTo(1));
415+
String reason = "Wrong number of occurrences for profile '" + profile
416+
+ "' --> " + log;
417+
assertThat(reason,
418+
StringUtils.countOccurrencesOf(log, createLogForProfile(profile)),
419+
equalTo(1));
404420
}
405421
// Make sure the order of loading is the right one
406422
for (String profile : profiles) {
407423
String line = createLogForProfile(profile);
408424
int index = log.indexOf(line);
409-
assertTrue("Loading profile '" + profile + "' not found in '" + log + "'", index != -1);
425+
assertTrue("Loading profile '" + profile + "' not found in '" + log + "'",
426+
index != -1);
410427
log = log.substring(index + line.length(), log.length());
411428
}
412429
}

0 commit comments

Comments
 (0)