public final class MockMvc
extends java.lang.Object
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"));
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 java.lang.Exception
requestBuilder
- used to prepare the request to execute;
see static factory methods in
MockMvcRequestBuilders
ResultActions
; never null
java.lang.Exception
MockMvcRequestBuilders
,
MockMvcResultMatchers