Search in sources :

Example 11 with MockFilterChain

use of org.springframework.web.testfixture.servlet.MockFilterChain in project spring-framework by spring-projects.

the class ServletUriComponentsBuilderTests method adaptFromForwardedHeaders.

// SPR-16668
private HttpServletRequest adaptFromForwardedHeaders(HttpServletRequest request) throws Exception {
    MockFilterChain chain = new MockFilterChain();
    new ForwardedHeaderFilter().doFilter(request, new MockHttpServletResponse(), chain);
    return (HttpServletRequest) chain.getRequest();
}
Also used : HttpServletRequest(jakarta.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.web.testfixture.servlet.MockHttpServletRequest) ForwardedHeaderFilter(org.springframework.web.filter.ForwardedHeaderFilter) MockFilterChain(org.springframework.web.testfixture.servlet.MockFilterChain) MockHttpServletResponse(org.springframework.web.testfixture.servlet.MockHttpServletResponse)

Aggregations

MockFilterChain (org.springframework.web.testfixture.servlet.MockFilterChain)11 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)10 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)7 Test (org.junit.jupiter.api.Test)5 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)4 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ForwardedHeaderFilter (org.springframework.web.filter.ForwardedHeaderFilter)3 HttpServlet (jakarta.servlet.http.HttpServlet)2 HttpServletResponseWrapper (jakarta.servlet.http.HttpServletResponseWrapper)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Configuration (org.springframework.context.annotation.Configuration)1 HttpMethod (org.springframework.http.HttpMethod)1 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)1 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)1 ResourceHandlerRegistry (org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry)1 WebMvcConfigurationSupport (org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport)1 MockServletContext (org.springframework.web.testfixture.servlet.MockServletContext)1