use of org.springframework.validation.Validator in project spring-framework by spring-projects.
the class MessageBrokerConfigurationTests method simpValidatorCustom.
@Test
public void simpValidatorCustom() {
final Validator validator = mock(Validator.class);
AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {
@Override
public Validator getValidator() {
return validator;
}
};
assertSame(validator, config.simpValidator());
}
use of org.springframework.validation.Validator in project spring-boot by spring-projects.
the class WebFluxAnnotationAutoConfigurationTests method validationCustomConfigurerTakesPrecedence.
@Test
public void validationCustomConfigurerTakesPrecedence() {
load(WebFluxValidator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).isEmpty();
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).isEmpty();
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1);
Validator validator = this.context.getBean(Validator.class);
assertThat(validator).isSameAs(this.context.getBean(WebFluxValidator.class).validator);
}
use of org.springframework.validation.Validator in project spring-boot by spring-projects.
the class WebFluxAnnotationAutoConfigurationTests method validationCustomConfigurerTakesPrecedenceAndDoNotExposeJsr303.
@Test
public void validationCustomConfigurerTakesPrecedenceAndDoNotExposeJsr303() {
load(WebFluxJsr303Validator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).isEmpty();
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).isEmpty();
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1);
Validator validator = this.context.getBean(Validator.class);
assertThat(validator).isInstanceOf(SpringValidator.class);
assertThat(((SpringValidator) validator).getTarget()).isSameAs(this.context.getBean(WebFluxJsr303Validator.class).validator);
}
use of org.springframework.validation.Validator in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method validationCustomConfigurerTakesPrecedenceAndDoNotExposeJsr303.
@Test
public void validationCustomConfigurerTakesPrecedenceAndDoNotExposeJsr303() {
load(MvcJsr303Validator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).isEmpty();
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).isEmpty();
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1);
Validator validator = this.context.getBean(Validator.class);
assertThat(validator).isInstanceOf(SpringValidator.class);
assertThat(((SpringValidator) validator).getTarget()).isSameAs(this.context.getBean(MvcJsr303Validator.class).validator);
}
use of org.springframework.validation.Validator in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method validationJsr303CustomValidatorReusedAsSpringValidator.
@Test
public void validationJsr303CustomValidatorReusedAsSpringValidator() {
load(CustomValidator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).hasSize(1);
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).hasSize(1);
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(2);
Validator validator = this.context.getBean("mvcValidator", Validator.class);
assertThat(validator).isInstanceOf(SpringValidator.class);
assertThat(((SpringValidator) validator).getTarget()).isSameAs(this.context.getBean(javax.validation.Validator.class));
}
Aggregations