public final class MockMvc extends Object
Below is an example:
static imports: MockMvcBuilders.*, MockMvcRequestBuilders.*, MockMvcResultMatchers.* 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"));
Modifier and Type | Method and Description |
---|---|
ResultActions |
perform(RequestBuilder requestBuilder)
Perform a request and return a type that allows chaining further
actions, such as asserting expectations, on the result.
|
public ResultActions perform(RequestBuilder requestBuilder) throws Exception
requestBuilder
- used to prepare the request to execute;
see static factory methods in
MockMvcRequestBuilders
ResultActions
; never null
Exception
MockMvcRequestBuilders
,
MockMvcResultMatchers