use of org.springframework.mock.web.test.MockFilterChain in project spring-framework by spring-projects.
the class HttpPutFormContentFilterTests method wrapPutAndPatchOnly.
@Test
public void wrapPutAndPatchOnly() throws Exception {
request.setContent("".getBytes("ISO-8859-1"));
for (HttpMethod method : HttpMethod.values()) {
request.setMethod(method.name());
filterChain = new MockFilterChain();
filter.doFilter(request, response, filterChain);
if (method.equals(HttpMethod.PUT) || method.equals(HttpMethod.PATCH)) {
assertNotSame("Should wrap HTTP method " + method, request, filterChain.getRequest());
} else {
assertSame("Should not wrap for HTTP method " + method, request, filterChain.getRequest());
}
}
}
use of org.springframework.mock.web.test.MockFilterChain in project spring-framework by spring-projects.
the class ForwardedHeaderFilterTests method setUp.
@Before
@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.mock.web.test.MockFilterChain in project spring-framework by spring-projects.
the class ForwardedHeaderFilterTests method doWithFiltersAndGetResponse.
@SuppressWarnings("serial")
private MockHttpServletResponse doWithFiltersAndGetResponse(Filter... filters) throws ServletException, IOException {
MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain filterChain = new MockFilterChain(new HttpServlet() {
}, filters);
filterChain.doFilter(request, response);
return response;
}
use of org.springframework.mock.web.test.MockFilterChain in project spring-framework by spring-projects.
the class HttpPutFormContentFilterTests method setup.
@Before
public void setup() {
filter = new HttpPutFormContentFilter();
request = new MockHttpServletRequest("PUT", "/");
request.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
request.setContentType("application/x-www-form-urlencoded; charset=ISO-8859-1");
response = new MockHttpServletResponse();
filterChain = new MockFilterChain();
}
use of org.springframework.mock.web.test.MockFilterChain in project spring-framework by spring-projects.
the class HttpPutFormContentFilterTests method invalidMediaType.
@Test
public void invalidMediaType() throws Exception {
request.setContent("".getBytes("ISO-8859-1"));
request.setContentType("foo");
filterChain = new MockFilterChain();
filter.doFilter(request, response, filterChain);
assertSame(request, filterChain.getRequest());
}
Aggregations