Spring Framework
  1. Spring Framework
  2. SPR-9859

Add first class support for testing Spring MVC applications

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 3.1.2
    • Fix Version/s: 3.2 RC1
    • Component/s: Test, Web
    • Labels:
    • Last commented by a User:
      false

      Description

      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"));
      
      

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Rossen Stoyanchev
              Reporter:
              Rossen Stoyanchev
              Last updater:
              Chris Beams
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 28 weeks, 5 days ago