Introduce new MockMvcBuilderSupport base class that instantiates MockMvc and the TestDispatcherServlet with AbstractMockMvcBuilder sub-class actually implements the MockMvcBuilders interface. Replace ResultHandler classes for printing debug information with just one PrintingResultHandler base class. Javadoc updates.
Currently MockMvcBuilders.webApplicationContextSetup returns MockMvcBuilder rather than InitializedContextMockMvcBuilder. This is problematic for anyone wanting to add a Filter which is defined on the AbstractMockMvcBuilder. This update changes MockMvcBuilders.webApplicationContextSetup to return InitializedContextMockMvcBuilder which allows adding a Filter and is more consistent with the other factory methods.MockMvcBuilders should return InitializedContextMockMvcBuilder
This change changes the version of hamcrest we build with to match the one packaged inside JUnit 4.10. It is also the version that the Spring Framework is built against.
Before this change, the pathInfo was determined automatically. After the change, the pathInfo can be specified, and if so the value is used as-is, i.e. without validating that: requestUri = contextPath + servletPath + pathInfo The assumption is that if the test chooses to specify the pathInfo explicitly, it is targetting a specific scenario. For example, simulating a welcome file where for requestUri "/", the servletPath is "/index.html"
The URI scheme, host, and port are now correctly extracted from the URI template and set on the MockHttpServlet request. Various fixed to the algorithm for contextPath, servletPath, and PathInfo matching to the Servlet spec. Add more assertions and tests. The method cookie(Cookie... cookies) now adds rather than sets cookies.
The new implementations are similar to MockHttpServletRequest/Response but are for the client and server-side HTTP abstractions in the org.springframework.http package. Currently implemented are MockHttpInputMessage, MockHttpOutputMessage, MockClientHttpRequest, and MockClientHttpResponse. The client-side Spring MVC Test support has been refactored to use the new abstractions
This change introduces new ways to define expectations on the body of the request including options for using XPath and JSONPath expressions, match XML content with XMLUnit, and expanded use of Hamcrest matchers. Similar options already exist for the server side. Further updates include sample tests, improved unit test coverage, comrehensive javadoc, and general polish.
…rn itself and package-private was keeping the builder methods from being visible/usable in test classes.
…, String) to actually use the given HttpStatus instead of a hard-coded HttpStatus.OK.
This change adds the methods session(MockHttpSession) and sessionAttrs(Map) for adding attributes or re-using a session across several requests.