Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9859

Add first class support for testing Spring MVC applications

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: 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"));
      
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rstoya05-aop Rossen Stoyanchev
                Reporter:
                rstoya05-aop 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:
                  5 years, 37 weeks, 6 days ago