Apply PathPatternParser also to BeanNameUrlHandlerMapping

Closes gh-26414
This commit is contained in:
Rossen Stoyanchev
2021-01-22 15:22:51 +00:00
parent 9d8910d869
commit e4566c11b8
2 changed files with 21 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
import org.springframework.web.servlet.handler.HandlerExceptionResolverComposite;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver;
@@ -332,6 +333,14 @@ public class DelegatingWebMvcConfigurationTests {
assertThat(mapping.getPatternParser()).isSameAs(patternParser);
configAssertion.accept(mapping.getUrlPathHelper(), mapping.getPathMatcher());
BeanNameUrlHandlerMapping beanNameMapping = webMvcConfig.beanNameHandlerMapping(
webMvcConfig.mvcConversionService(),
webMvcConfig.mvcResourceUrlProvider());
assertThat(beanNameMapping).isNotNull();
assertThat(beanNameMapping.getPatternParser()).isSameAs(patternParser);
configAssertion.accept(beanNameMapping.getUrlPathHelper(), mapping.getPathMatcher());
assertThat(webMvcConfig.mvcResourceUrlProvider().getUrlPathHelper()).isSameAs(pathHelper);
assertThat(webMvcConfig.mvcResourceUrlProvider().getPathMatcher()).isSameAs(pathMatcher);
}