Class MockMvc

java.lang.Object
org.springframework.test.web.servlet.MockMvc

public final class MockMvc extends Object
Main entry point for server-side Spring MVC test support.

Example

 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;

 // ...

 WebApplicationContext wac = ...;

 MockMvc mockMvc = webAppContextSetup(wac).build();

 mockMvc.perform(get("/form"))
     .andExpect(status().isOk())
     .andExpect(content().mimeType("text/html"))
     .andExpect(forwardedUrl("/WEB-INF/layouts/main.jsp"));
 
Since:
3.2
Author:
Rossen Stoyanchev, Rob Winch, Sam Brannen