Search in sources :

Example 16 with UrlPathHelper

use of org.springframework.web.util.UrlPathHelper in project spring-boot by spring-projects.

the class WebMvcAutoConfigurationTests method urlPathHelperUsesFullPathByDefault.

@Test
void urlPathHelperUsesFullPathByDefault() {
    this.contextRunner.run((context) -> {
        UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.class);
        assertThat(urlPathHelper).extracting("alwaysUseFullPath").isEqualTo(true);
    });
}
Also used : UrlPathHelper(org.springframework.web.util.UrlPathHelper) Test(org.junit.jupiter.api.Test)

Example 17 with UrlPathHelper

use of org.springframework.web.util.UrlPathHelper in project spring-boot by spring-projects.

the class WebMvcAutoConfigurationTests method urlPathHelperDoesNotUseFullPathWithAdditionalDispatcherServlet.

@Test
void urlPathHelperDoesNotUseFullPathWithAdditionalDispatcherServlet() {
    this.contextRunner.withUserConfiguration(AdditionalDispatcherServletConfiguration.class).run((context) -> {
        UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.class);
        assertThat(urlPathHelper).extracting("alwaysUseFullPath").isEqualTo(false);
    });
}
Also used : UrlPathHelper(org.springframework.web.util.UrlPathHelper) Test(org.junit.jupiter.api.Test)

Example 18 with UrlPathHelper

use of org.springframework.web.util.UrlPathHelper in project spring-boot by spring-projects.

the class WebMvcAutoConfigurationTests method urlPathHelperDoesNotUseFullPathWithServletMapping.

@Test
void urlPathHelperDoesNotUseFullPathWithServletMapping() {
    this.contextRunner.withPropertyValues("spring.mvc.servlet.path=/test/").run((context) -> {
        UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.class);
        assertThat(urlPathHelper).extracting("alwaysUseFullPath").isEqualTo(false);
    });
}
Also used : UrlPathHelper(org.springframework.web.util.UrlPathHelper) Test(org.junit.jupiter.api.Test)

Example 19 with UrlPathHelper

use of org.springframework.web.util.UrlPathHelper in project CzechIdMng by bcvsolutions.

the class WebConfig method configurePathMatch.

/**
 * Whether to use suffix pattern match (".*") when matching patterns to
 * requests. If enabled a method mapped to "/users" also matches to
 * "/users.*".
 * <p>
 * By default this is set to {@code true}.
 */
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
    // enable encoded slash in path parameters
    UrlPathHelper urlPathHelper = new UrlPathHelper();
    urlPathHelper.setUrlDecode(false);
    configurer.setUrlPathHelper(urlPathHelper);
    // 
    // disable extension suffixes
    configurer.setUseSuffixPatternMatch(Boolean.FALSE);
// 
// this will be useful in future ...
// configurer.setUseRegisteredSuffixPatternMatch(true);
}
Also used : UrlPathHelper(org.springframework.web.util.UrlPathHelper)

Example 20 with UrlPathHelper

use of org.springframework.web.util.UrlPathHelper in project tutorials by eugenp.

the class WebConfig method configurePathMatch.

@Override
public void configurePathMatch(final PathMatchConfigurer configurer) {
    final UrlPathHelper urlPathHelper = new UrlPathHelper();
    urlPathHelper.setRemoveSemicolonContent(false);
    configurer.setUrlPathHelper(urlPathHelper);
}
Also used : UrlPathHelper(org.springframework.web.util.UrlPathHelper)

Aggregations

UrlPathHelper (org.springframework.web.util.UrlPathHelper)32 Test (org.junit.jupiter.api.Test)10 PathMatcher (org.springframework.util.PathMatcher)5 Map (java.util.Map)4 Test (org.junit.Test)4 MultiValueMap (org.springframework.util.MultiValueMap)4 RequestMappingHandlerMapping (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping)4 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)4 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)3 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)3 PathPatternsParameterizedTest (org.springframework.web.servlet.handler.PathPatternsParameterizedTest)3 SimpleUrlHandlerMapping (org.springframework.web.servlet.handler.SimpleUrlHandlerMapping)3 MockServletContext (org.springframework.web.testfixture.servlet.MockServletContext)3 Collections (java.util.Collections)2 List (java.util.List)2 BiConsumer (java.util.function.BiConsumer)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)2 ArgumentCaptor (org.mockito.ArgumentCaptor)2 BDDMockito.given (org.mockito.BDDMockito.given)2