Add methodCall option to HandlerResultMatchers

Issue: SPR-13736
This commit is contained in:
Rossen Stoyanchev
2016-01-15 12:42:05 -05:00
parent 1320da906b
commit 4b1183582a
2 changed files with 45 additions and 5 deletions

View File

@@ -21,17 +21,19 @@ import java.lang.reflect.Method;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import static org.hamcrest.Matchers.*;
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.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.handler;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
import static org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.on;
/**
@@ -53,6 +55,11 @@ public class HandlerAssertionTests {
this.mockMvc.perform(get("/")).andExpect(handler().handlerType(SimpleController.class));
}
@Test
public void testMethodCall() throws Exception {
this.mockMvc.perform(get("/")).andExpect(handler().methodCall(on(SimpleController.class).handle()));
}
@Test
public void testHandlerMethodNameEqualTo() throws Exception {
this.mockMvc.perform(get("/")).andExpect(handler().methodName("handle"));