Polish "Adds support for useCodeAsDefaultMessage"

Closes gh-10466
pull/10457/merge
Stephane Nicoll 7 years ago
parent a68ec76bb6
commit 6c826ef0b6

@ -59,7 +59,8 @@ public class MessageSourceProperties {
private boolean alwaysUseMessageFormat = false;
/**
* Set whether to use the message code as default message instead of throwing a NoSuchMessageException.
* Set whether to use the message code as default message instead of throwing a
* "NoSuchMessageException". Recommended during development only.
*/
private boolean useCodeAsDefaultMessage = false;
@ -110,4 +111,5 @@ public class MessageSourceProperties {
public void setUseCodeAsDefaultMessage(final boolean useCodeAsDefaultMessage) {
this.useCodeAsDefaultMessage = useCodeAsDefaultMessage;
}
}

@ -144,14 +144,14 @@ public class MessageSourceAutoConfigurationTests {
}
@Test
public void testUseCodeAsDefaultMessageDefault() throws Exception {
public void testUseCodeAsDefaultMessageDefault() {
load("spring.messages.basename:test/messages");
assertThat(isUseCodeAsDefaultMessage(this.context.getBean(MessageSource.class)))
.isFalse();
}
@Test
public void testUseCodeAsDefaultMessageOn() throws Exception {
public void testUseCodeAsDefaultMessageOn() {
load("spring.messages.basename:test/messages",
"spring.messages.use-code-as-default-message:true");
assertThat(isUseCodeAsDefaultMessage(this.context.getBean(MessageSource.class)))

@ -117,6 +117,7 @@ content into your application; rather pick only the properties that you need.
spring.messages.cache-seconds=-1 # Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles are cached forever.
spring.messages.encoding=UTF-8 # Message bundles encoding.
spring.messages.fallback-to-system-locale=true # Set whether to fall back to the system Locale if no files for a specific Locale have been found.
spring.messages.use-code-as-default-message=false # Set whether to use the message code as default message instead of throwing a "NoSuchMessageException". Recommended during development only.
# OUTPUT
spring.output.ansi.enabled=detect # Configure the ANSI output.

Loading…
Cancel
Save