Skip to content

Add first class support for testing Spring MVC applications [SPR-9859] #14492

Closed

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-9859 and commented

This is based on the spring-test-mvc project that has been available on Github, as a separate project, for over a year. The project provides a fluent API for performing requests and verifying expectations on the resulting responses. It executes requests using an instance of DispatcherServlet and passes to it a MockHttpServletRequest and MockHttpServletResponse, i.e. without the need for a running a Servlet container.

WebApplicationContext wac = ...;

MockMvc mockMvc = webAppContextSetup(wac).configureWarRootDir("src/main/webapp", false).build()

mockMvc.perform(get("/form"))
    .andExpect(status().isOk())
    .andExpect(content().mimeType("text/html"))
    .andExpect(forwardedUrl("/WEB-INF/layouts/main.jsp"));

Affects: 3.1.2

Issue Links:

Activity

  1. added
    in: test
    type: enhancement
    in: web
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: testin: webtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions