|
70 | 70 | import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter; |
71 | 71 | import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfigurationTests.OrderedControllerAdviceBeansConfiguration.HighestOrderedControllerAdvice; |
72 | 72 | import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfigurationTests.OrderedControllerAdviceBeansConfiguration.LowestOrderedControllerAdvice; |
| 73 | +import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfigurationTests.WebMcvResourceHandlerCustomizersConfiguration.TestWebMcvResourceHandlerRegistryCustomizer; |
73 | 74 | import org.springframework.context.ApplicationContext; |
74 | 75 | import org.springframework.context.annotation.Bean; |
75 | 76 | import org.springframework.context.annotation.Configuration; |
@@ -1196,6 +1197,18 @@ void registersRuntimeHintsForValidatorCreation() { |
1196 | 1197 | assertThat(RuntimeHintsPredicates.reflection().onType(ValidatorAdapter.class)).accepts(hints); |
1197 | 1198 | } |
1198 | 1199 |
|
| 1200 | + @Test |
| 1201 | + void resourceHandlerRegistryCustomizerIsInvoked() { |
| 1202 | + this.contextRunner |
| 1203 | + .withUserConfiguration(WebMcvResourceHandlerCustomizersConfiguration.class) |
| 1204 | + .run((context) -> { |
| 1205 | + WebMvcResourceHandlerRegistryCustomizer customizer = |
| 1206 | + context.getBean(WebMvcResourceHandlerRegistryCustomizer.class); |
| 1207 | + |
| 1208 | + assertThat(((TestWebMcvResourceHandlerRegistryCustomizer) customizer).invoked).isTrue(); |
| 1209 | + }); |
| 1210 | + } |
| 1211 | + |
1199 | 1212 | private void assertResourceHttpRequestHandler(AssertableWebApplicationContext context, |
1200 | 1213 | Consumer<ResourceHttpRequestHandler> handlerConsumer) { |
1201 | 1214 | Map<String, Object> handlerMap = getHandlerMap(context.getBean("resourceHandlerMapping", HandlerMapping.class)); |
@@ -1805,6 +1818,25 @@ ServerHttpMessageConvertersCustomizer customizer3() { |
1805 | 1818 |
|
1806 | 1819 | } |
1807 | 1820 |
|
| 1821 | + @Configuration(proxyBeanMethods = false) |
| 1822 | + static class WebMcvResourceHandlerCustomizersConfiguration { |
| 1823 | + |
| 1824 | + @Bean |
| 1825 | + WebMvcResourceHandlerRegistryCustomizer customizer() { |
| 1826 | + return new WebMvcAutoConfigurationTests.WebMcvResourceHandlerCustomizersConfiguration.TestWebMcvResourceHandlerRegistryCustomizer(); |
| 1827 | + } |
| 1828 | + |
| 1829 | + static class TestWebMcvResourceHandlerRegistryCustomizer implements WebMvcResourceHandlerRegistryCustomizer { |
| 1830 | + |
| 1831 | + public boolean invoked; |
| 1832 | + |
| 1833 | + @Override |
| 1834 | + public void customize(ResourceHandlerRegistry registry) { |
| 1835 | + this.invoked = true; |
| 1836 | + } |
| 1837 | + } |
| 1838 | + } |
| 1839 | + |
1808 | 1840 | static class FormattedDate { |
1809 | 1841 |
|
1810 | 1842 | @DateTimeFormat(pattern = "${my.date.format}") |
|
0 commit comments