Search in sources :

Example 1 with StaticMessageSource

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();
}
Also used : StaticMessageSource(org.springframework.context.support.StaticMessageSource)

Example 2 with StaticMessageSource

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());
}
Also used : StaticMessageSource(org.springframework.context.support.StaticMessageSource)

Example 3 with 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());
}
Also used : StaticMessageSource(org.springframework.context.support.StaticMessageSource)

Example 4 with 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();
    }
}
Also used : Locale(java.util.Locale) StaticMessageSource(org.springframework.context.support.StaticMessageSource) Test(org.junit.Test)

Example 5 with StaticMessageSource

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();
}
Also used : StaticMessageSource(org.springframework.context.support.StaticMessageSource)

Aggregations

StaticMessageSource (org.springframework.context.support.StaticMessageSource)9 Test (org.junit.Test)3 Locale (java.util.Locale)1 DerivedTestBean (org.springframework.tests.sample.beans.DerivedTestBean)1 ITestBean (org.springframework.tests.sample.beans.ITestBean)1 IndexedTestBean (org.springframework.tests.sample.beans.IndexedTestBean)1 TestBean (org.springframework.tests.sample.beans.TestBean)1 BindingResult (org.springframework.validation.BindingResult)1 FieldError (org.springframework.validation.FieldError)1