Search in sources :

Example 6 with MockFilterChain

use of org.springframework.mock.web.test.MockFilterChain in project spring-framework by spring-projects.

the class HttpPutFormContentFilterTests method wrapFormEncodedOnly.

@Test
public void wrapFormEncodedOnly() throws Exception {
    request.setContent("".getBytes("ISO-8859-1"));
    String[] contentTypes = new String[] { "text/plain", "multipart/form-data" };
    for (String contentType : contentTypes) {
        request.setContentType(contentType);
        filterChain = new MockFilterChain();
        filter.doFilter(request, response, filterChain);
        assertSame("Should not wrap for content type " + contentType, request, filterChain.getRequest());
    }
}
Also used : MockFilterChain(org.springframework.mock.web.test.MockFilterChain) Test(org.junit.Test)

Example 7 with MockFilterChain

use of org.springframework.mock.web.test.MockFilterChain in project spring-framework by spring-projects.

the class ResourceUrlProviderJavaConfigTests method setup.

@Before
@SuppressWarnings("resource")
public void setup() throws Exception {
    this.filterChain = new MockFilterChain(this.servlet, new ResourceUrlEncodingFilter());
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    context.register(WebConfig.class);
    context.refresh();
    this.request = new MockHttpServletRequest("GET", "/");
    this.request.setContextPath("/myapp");
    this.response = new MockHttpServletResponse();
    Object urlProvider = context.getBean(ResourceUrlProvider.class);
    this.request.setAttribute(ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR, urlProvider);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) MockFilterChain(org.springframework.mock.web.test.MockFilterChain) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) MockServletContext(org.springframework.mock.web.test.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.test.MockHttpServletResponse) Before(org.junit.Before)

Aggregations

MockFilterChain (org.springframework.mock.web.test.MockFilterChain)7 Before (org.junit.Before)3 Test (org.junit.Test)3 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)3 HttpServlet (javax.servlet.http.HttpServlet)2 FilterChain (javax.servlet.FilterChain)1 HttpMethod (org.springframework.http.HttpMethod)1 MockServletContext (org.springframework.mock.web.test.MockServletContext)1 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)1