|
|
|
@ -17,7 +17,7 @@ |
|
|
|
package org.springframework.web.servlet.config.annotation; |
|
|
|
package org.springframework.web.servlet.config.annotation; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Before; |
|
|
|
@ -89,10 +89,10 @@ public class DelegatingWebMvcConfigurationTests { |
|
|
|
delegatingConfig = new DelegatingWebMvcConfiguration(); |
|
|
|
delegatingConfig = new DelegatingWebMvcConfiguration(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void requestMappingHandlerAdapter() throws Exception { |
|
|
|
public void requestMappingHandlerAdapter() throws Exception { |
|
|
|
|
|
|
|
delegatingConfig.setConfigurers(Collections.singletonList(webMvcConfigurer)); |
|
|
|
delegatingConfig.setConfigurers(Arrays.asList(webMvcConfigurer)); |
|
|
|
|
|
|
|
RequestMappingHandlerAdapter adapter = delegatingConfig.requestMappingHandlerAdapter(); |
|
|
|
RequestMappingHandlerAdapter adapter = delegatingConfig.requestMappingHandlerAdapter(); |
|
|
|
|
|
|
|
|
|
|
|
ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) adapter.getWebBindingInitializer(); |
|
|
|
ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) adapter.getWebBindingInitializer(); |
|
|
|
@ -141,7 +141,7 @@ public class DelegatingWebMvcConfigurationTests { |
|
|
|
public void getCustomValidator() { |
|
|
|
public void getCustomValidator() { |
|
|
|
given(webMvcConfigurer.getValidator()).willReturn(new LocalValidatorFactoryBean()); |
|
|
|
given(webMvcConfigurer.getValidator()).willReturn(new LocalValidatorFactoryBean()); |
|
|
|
|
|
|
|
|
|
|
|
delegatingConfig.setConfigurers(Arrays.asList(webMvcConfigurer)); |
|
|
|
delegatingConfig.setConfigurers(Collections.singletonList(webMvcConfigurer)); |
|
|
|
delegatingConfig.mvcValidator(); |
|
|
|
delegatingConfig.mvcValidator(); |
|
|
|
|
|
|
|
|
|
|
|
verify(webMvcConfigurer).getValidator(); |
|
|
|
verify(webMvcConfigurer).getValidator(); |
|
|
|
@ -151,7 +151,7 @@ public class DelegatingWebMvcConfigurationTests { |
|
|
|
public void getCustomMessageCodesResolver() { |
|
|
|
public void getCustomMessageCodesResolver() { |
|
|
|
given(webMvcConfigurer.getMessageCodesResolver()).willReturn(new DefaultMessageCodesResolver()); |
|
|
|
given(webMvcConfigurer.getMessageCodesResolver()).willReturn(new DefaultMessageCodesResolver()); |
|
|
|
|
|
|
|
|
|
|
|
delegatingConfig.setConfigurers(Arrays.asList(webMvcConfigurer)); |
|
|
|
delegatingConfig.setConfigurers(Collections.singletonList(webMvcConfigurer)); |
|
|
|
delegatingConfig.getMessageCodesResolver(); |
|
|
|
delegatingConfig.getMessageCodesResolver(); |
|
|
|
|
|
|
|
|
|
|
|
verify(webMvcConfigurer).getMessageCodesResolver(); |
|
|
|
verify(webMvcConfigurer).getMessageCodesResolver(); |
|
|
|
@ -159,8 +159,7 @@ public class DelegatingWebMvcConfigurationTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void handlerExceptionResolver() throws Exception { |
|
|
|
public void handlerExceptionResolver() throws Exception { |
|
|
|
|
|
|
|
delegatingConfig.setConfigurers(Collections.singletonList(webMvcConfigurer)); |
|
|
|
delegatingConfig.setConfigurers(Arrays.asList(webMvcConfigurer)); |
|
|
|
|
|
|
|
delegatingConfig.handlerExceptionResolver(); |
|
|
|
delegatingConfig.handlerExceptionResolver(); |
|
|
|
|
|
|
|
|
|
|
|
verify(webMvcConfigurer).configureMessageConverters(converters.capture()); |
|
|
|
verify(webMvcConfigurer).configureMessageConverters(converters.capture()); |
|
|
|
@ -186,7 +185,7 @@ public class DelegatingWebMvcConfigurationTests { |
|
|
|
delegatingConfig.setConfigurers(configurers); |
|
|
|
delegatingConfig.setConfigurers(configurers); |
|
|
|
|
|
|
|
|
|
|
|
HandlerExceptionResolverComposite composite = |
|
|
|
HandlerExceptionResolverComposite composite = |
|
|
|
(HandlerExceptionResolverComposite) delegatingConfig.handlerExceptionResolver(); |
|
|
|
(HandlerExceptionResolverComposite) delegatingConfig.handlerExceptionResolver(); |
|
|
|
assertEquals("Only one custom converter is expected", 1, composite.getExceptionResolvers().size()); |
|
|
|
assertEquals("Only one custom converter is expected", 1, composite.getExceptionResolvers().size()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -200,9 +199,9 @@ public class DelegatingWebMvcConfigurationTests { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void configurePathMatch(PathMatchConfigurer configurer) { |
|
|
|
public void configurePathMatch(PathMatchConfigurer configurer) { |
|
|
|
configurer.setUseRegisteredSuffixPatternMatch(true) |
|
|
|
configurer.setUseRegisteredSuffixPatternMatch(true) |
|
|
|
.setUseTrailingSlashMatch(false) |
|
|
|
.setUseTrailingSlashMatch(false) |
|
|
|
.setUrlPathHelper(pathHelper) |
|
|
|
.setUrlPathHelper(pathHelper) |
|
|
|
.setPathMatcher(pathMatcher); |
|
|
|
.setPathMatcher(pathMatcher); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
delegatingConfig.setConfigurers(configurers); |
|
|
|
delegatingConfig.setConfigurers(configurers); |
|
|
|
|