use of org.springframework.context.support.StaticMessageSource in project spring-boot by spring-projects.
the class YamlConfigurationFactoryTests method createFoo.
private Foo createFoo(final String yaml) throws Exception {
YamlConfigurationFactory<Foo> factory = new YamlConfigurationFactory<>(Foo.class);
factory.setYaml(yaml);
factory.setPropertyAliases(this.aliases);
factory.setValidator(this.validator);
factory.setMessageSource(new StaticMessageSource());
factory.afterPropertiesSet();
return factory.getObject();
}
use of org.springframework.context.support.StaticMessageSource in project spring-boot by spring-projects.
the class PropertiesConfigurationFactoryMapTests method setupFactory.
private void setupFactory() throws IOException {
this.factory = new PropertiesConfigurationFactory<>(Foo.class);
this.factory.setValidator(this.validator);
this.factory.setTargetName(this.targetName);
this.factory.setIgnoreUnknownFields(this.ignoreUnknownFields);
this.factory.setMessageSource(new StaticMessageSource());
}
use of org.springframework.context.support.StaticMessageSource in project spring-boot by spring-projects.
the class PropertiesConfigurationFactoryPerformanceTests method setupFactory.
private void setupFactory() throws IOException {
this.factory = new PropertiesConfigurationFactory<>(Foo.class);
this.factory.setValidator(this.validator);
this.factory.setTargetName(this.targetName);
this.factory.setIgnoreUnknownFields(this.ignoreUnknownFields);
this.factory.setMessageSource(new StaticMessageSource());
}
use of org.springframework.context.support.StaticMessageSource in project spring-framework by spring-projects.
the class ResponseStatusExceptionResolverTests method statusCodeAndReasonMessage.
@Test
public void statusCodeAndReasonMessage() {
Locale locale = Locale.CHINESE;
LocaleContextHolder.setLocale(locale);
try {
StaticMessageSource messageSource = new StaticMessageSource();
messageSource.addMessage("gone.reason", locale, "Gone reason message");
exceptionResolver.setMessageSource(messageSource);
StatusCodeAndReasonMessageException ex = new StatusCodeAndReasonMessageException();
exceptionResolver.resolveException(request, response, null, ex);
assertEquals("Invalid status reason", "Gone reason message", response.getErrorMessage());
} finally {
LocaleContextHolder.resetLocaleContext();
}
}
use of org.springframework.context.support.StaticMessageSource in project spring-boot by spring-projects.
the class YamlConfigurationFactoryTests method createJee.
private Jee createJee(final String yaml) throws Exception {
YamlConfigurationFactory<Jee> factory = new YamlConfigurationFactory<>(Jee.class);
factory.setYaml(yaml);
factory.setPropertyAliases(this.aliases);
factory.setValidator(this.validator);
factory.setMessageSource(new StaticMessageSource());
factory.afterPropertiesSet();
return factory.getObject();
}
Aggregations