public class DefaultResultActions extends Object implements ResultActions
ResultActions.| 构造器和说明 |
|---|
DefaultResultActions(HttpResult httpResult) |
| 限定符和类型 | 方法和说明 |
|---|---|
ResultActions |
andDo(ResultHandler handler)
Provide a general action.
|
ResultActions |
andExpect(ResultMatcher matcher)
Provide an expectation.
|
HttpResult |
andReturn()
Return the result of the executed request for direct access to the results.
|
<T> T |
andTransform(ResultTransform<T> transformer)
Provide a transformation of the result.
|
public DefaultResultActions(HttpResult httpResult)
public ResultActions andExpect(ResultMatcher matcher) throws Exception
static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*
mockMvc.perform(get("/person/1"))
.andExpect(status().isOk())
.andExpect(content().mimeType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.person.name").equalTo("Jason"));
mockMvc.perform(post("/form"))
.andExpect(status().isOk())
.andExpect(redirectedUrl("/person/1"))
.andExpect(model().size(1))
.andExpect(model().attributeExists("person"))
.andExpect(flash().attributeCount(1))
.andExpect(flash().attribute("message", "success!"));
andExpect 在接口中 ResultActionsmatcher - matcher for assertionExceptionpublic ResultActions andDo(ResultHandler handler) throws Exception
static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*
mockMvc.perform(get("/form")).andDo(print());
andDo 在接口中 ResultActionshandler - handler for processing response dataExceptionpublic <T> T andTransform(ResultTransform<T> transformer) throws Exception
andTransform 在接口中 ResultActionsExceptionpublic HttpResult andReturn() throws Exception
andReturn 在接口中 ResultActionsExceptionCopyright © 2016. All rights reserved.