use of org.springframework.context.support.ResourceBundleMessageSource in project irida by phac-nml.
the class SampleTest method setUp.
@Before
public void setUp() {
Configuration<?> configuration = Validation.byDefaultProvider().configure();
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(MESSAGES_BASENAME);
configuration.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator(MESSAGES_BASENAME)));
ValidatorFactory factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
}
use of org.springframework.context.support.ResourceBundleMessageSource in project irida by phac-nml.
the class UserTest method setUp.
@Before
public void setUp() {
b = ResourceBundle.getBundle(MESSAGES_BASENAME);
Configuration<?> configuration = Validation.byDefaultProvider().configure();
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(MESSAGES_BASENAME);
configuration.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator(MESSAGES_BASENAME)));
ValidatorFactory factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
}
use of org.springframework.context.support.ResourceBundleMessageSource in project irida by phac-nml.
the class GalaxyAccountEmailTest method setUp.
@Before
public void setUp() {
b = ResourceBundle.getBundle(MESSAGES_BASENAME);
Configuration<?> configuration = Validation.byDefaultProvider().configure();
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(MESSAGES_BASENAME);
configuration.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator(MESSAGES_BASENAME)));
ValidatorFactory factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
}
use of org.springframework.context.support.ResourceBundleMessageSource in project cloudbreak by hortonworks.
the class MessagesConfig method messageSource.
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages/messages");
return messageSource;
}
use of org.springframework.context.support.ResourceBundleMessageSource in project spring-framework by spring-projects.
the class DataBinderTests method testBindingErrors.
@Test
void testBindingErrors() {
TestBean rod = new TestBean();
DataBinder binder = new DataBinder(rod, "person");
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "32x");
binder.bind(pvs);
Errors errors = binder.getBindingResult();
FieldError ageError = errors.getFieldError("age");
assertThat(ageError.getCode()).isEqualTo("typeMismatch");
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("org.springframework.validation.messages1");
String msg = messageSource.getMessage(ageError, Locale.getDefault());
assertThat(msg).isEqualTo("Field age did not have correct type");
messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("org.springframework.validation.messages2");
msg = messageSource.getMessage(ageError, Locale.getDefault());
assertThat(msg).isEqualTo("Field Age did not have correct type");
messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("org.springframework.validation.messages3");
msg = messageSource.getMessage(ageError, Locale.getDefault());
assertThat(msg).isEqualTo("Field Person Age did not have correct type");
}
Aggregations