|
16 | 16 |
|
17 | 17 | package org.springframework.boot.autoconfigure.validation;
|
18 | 18 |
|
19 |
| -import java.util.HashSet; |
20 |
| -import java.util.Set; |
21 |
| - |
22 | 19 | import javax.validation.ConstraintViolationException;
|
23 | 20 | import javax.validation.Validator;
|
24 | 21 | import javax.validation.constraints.Min;
|
|
30 | 27 | import org.junit.rules.ExpectedException;
|
31 | 28 |
|
32 | 29 | import org.springframework.beans.DirectFieldAccessor;
|
33 |
| -import org.springframework.beans.factory.config.BeanPostProcessor; |
34 |
| -import org.springframework.boot.autoconfigure.validation.ValidationAutoConfigurationTests.CustomValidatorConfiguration.TestBeanPostProcessor; |
35 | 30 | import org.springframework.boot.test.util.EnvironmentTestUtils;
|
36 | 31 | import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
37 | 32 | import org.springframework.context.annotation.Bean;
|
38 | 33 | import org.springframework.context.annotation.Configuration;
|
39 | 34 | import org.springframework.context.annotation.Primary;
|
40 | 35 | import org.springframework.validation.annotation.Validated;
|
41 |
| -import org.springframework.validation.beanvalidation.CustomValidatorBean; |
42 | 36 | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
43 | 37 | import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
|
44 | 38 | import org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean;
|
@@ -204,13 +198,6 @@ public void userDefinedMethodValidationPostProcessorTakesPrecedence() {
|
204 | 198 | .getPropertyValue("validator"));
|
205 | 199 | }
|
206 | 200 |
|
207 |
| - @Test |
208 |
| - public void methodValidationPostProcessorValidatorDependencyDoesNotTriggerEarlyInitialization() { |
209 |
| - load(CustomValidatorConfiguration.class); |
210 |
| - assertThat(this.context.getBean(TestBeanPostProcessor.class).postProcessed) |
211 |
| - .contains("someService"); |
212 |
| - } |
213 |
| - |
214 | 201 | private boolean isPrimaryBean(String beanName) {
|
215 | 202 | return this.context.getBeanDefinition(beanName).isPrimary();
|
216 | 203 | }
|
@@ -335,53 +322,4 @@ public MethodValidationPostProcessor testMethodValidationPostProcessor() {
|
335 | 322 |
|
336 | 323 | }
|
337 | 324 |
|
338 |
| - @Configuration |
339 |
| - static class CustomValidatorConfiguration { |
340 |
| - |
341 |
| - CustomValidatorConfiguration(SomeService someService) { |
342 |
| - |
343 |
| - } |
344 |
| - |
345 |
| - @Bean |
346 |
| - Validator customValidator() { |
347 |
| - return new CustomValidatorBean(); |
348 |
| - } |
349 |
| - |
350 |
| - @Bean |
351 |
| - static TestBeanPostProcessor testBeanPostProcessor() { |
352 |
| - return new TestBeanPostProcessor(); |
353 |
| - } |
354 |
| - |
355 |
| - @Configuration |
356 |
| - static class SomeServiceConfiguration { |
357 |
| - |
358 |
| - @Bean |
359 |
| - public SomeService someService() { |
360 |
| - return new SomeService(); |
361 |
| - } |
362 |
| - |
363 |
| - } |
364 |
| - |
365 |
| - static class SomeService { |
366 |
| - |
367 |
| - } |
368 |
| - |
369 |
| - static class TestBeanPostProcessor implements BeanPostProcessor { |
370 |
| - |
371 |
| - private Set<String> postProcessed = new HashSet<String>(); |
372 |
| - |
373 |
| - @Override |
374 |
| - public Object postProcessAfterInitialization(Object bean, String name) { |
375 |
| - this.postProcessed.add(name); |
376 |
| - return bean; |
377 |
| - } |
378 |
| - |
379 |
| - @Override |
380 |
| - public Object postProcessBeforeInitialization(Object bean, String name) { |
381 |
| - return bean; |
382 |
| - } |
383 |
| - |
384 |
| - } |
385 |
| - } |
386 |
| - |
387 | 325 | }
|
0 commit comments