|
|
|
@ -18,13 +18,13 @@ package org.springframework.boot.autoconfigure.validation;
|
|
|
|
|
|
|
|
|
|
import javax.validation.Validator;
|
|
|
|
|
|
|
|
|
|
import org.junit.After;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
|
import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
|
|
|
|
|
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
|
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
|
|
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
@ -39,20 +39,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
@ClassPathExclusions({ "tomcat-embed-el-*.jar", "el-api-*.jar" })
|
|
|
|
|
public class ValidationAutoConfigurationWithHibernateValidatorMissingElImplTests {
|
|
|
|
|
|
|
|
|
|
private AnnotationConfigApplicationContext context;
|
|
|
|
|
|
|
|
|
|
@After
|
|
|
|
|
public void close() {
|
|
|
|
|
if (this.context != null) {
|
|
|
|
|
this.context.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(ValidationAutoConfiguration.class));
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void missingElDependencyIsTolerated() {
|
|
|
|
|
this.context = new AnnotationConfigApplicationContext(ValidationAutoConfiguration.class);
|
|
|
|
|
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1);
|
|
|
|
|
assertThat(this.context.getBeansOfType(MethodValidationPostProcessor.class)).hasSize(1);
|
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
assertThat(context).hasSingleBean(Validator.class);
|
|
|
|
|
assertThat(context).hasSingleBean(MethodValidationPostProcessor.class);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|