use of org.springframework.web.testfixture.servlet.MockFilterChain in project spring-framework by spring-projects.
the class WebUtilsTests 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();
}
use of org.springframework.web.testfixture.servlet.MockFilterChain in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method adaptRequestFromForwardedHeaders.
// SPR-16668
private void adaptRequestFromForwardedHeaders() throws Exception {
MockFilterChain chain = new MockFilterChain();
new ForwardedHeaderFilter().doFilter(this.request, new MockHttpServletResponse(), chain);
HttpServletRequest adaptedRequest = (HttpServletRequest) chain.getRequest();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(adaptedRequest));
}
use of org.springframework.web.testfixture.servlet.MockFilterChain in project spring-framework by spring-projects.
the class FormContentFilterTests method invalidMediaType.
@Test
public void invalidMediaType() throws Exception {
this.request.setContent("".getBytes("ISO-8859-1"));
this.request.setContentType("foo");
this.filterChain = new MockFilterChain();
this.filter.doFilter(this.request, this.response, this.filterChain);
assertThat(this.filterChain.getRequest()).isSameAs(this.request);
}
use of org.springframework.web.testfixture.servlet.MockFilterChain in project spring-framework by spring-projects.
the class OncePerRequestFilterTests method setup.
@BeforeEach
@SuppressWarnings("serial")
public void setup() throws Exception {
this.request = new MockHttpServletRequest();
this.request.setScheme("http");
this.request.setServerName("localhost");
this.request.setServerPort(80);
this.filterChain = new MockFilterChain(new HttpServlet() {
});
}
use of org.springframework.web.testfixture.servlet.MockFilterChain in project spring-framework by spring-projects.
the class RelativeRedirectFilterTests method sendRedirect.
private void sendRedirect(String location) throws Exception {
MockFilterChain chain = new MockFilterChain();
this.filter.doFilterInternal(new MockHttpServletRequest(), this.response, chain);
HttpServletResponse wrappedResponse = (HttpServletResponse) chain.getResponse();
wrappedResponse.sendRedirect(location);
}
Aggregations