@Test public void method() throws Exception { Method method = SimpleController.class.getMethod("handle"); this.mockMvc.perform(get("/")).andExpect(handler().method(method)); }
@Test public void handlerType() throws Exception { this.mockMvc.perform(get("/")).andExpect(handler().handlerType(SimpleController.class)); }
@Test public void methodName() throws Exception { this.mockMvc.perform(get("/")).andExpect(handler().methodName("handle")); }
@Test public void methodCallOnNonMock() throws Exception { exception.expect(AssertionError.class); exception.expectMessage("The supplied object [bogus] is not an instance of"); exception.expectMessage(MvcUriComponentsBuilder.MethodInvocationInfo.class.getName()); exception.expectMessage("Ensure that you invoke the handler method via MvcUriComponentsBuilder.on()"); this.mockMvc.perform(get("/")).andExpect(handler().methodCall("bogus")); }
@Test public void resourcesViaDefaultServlet() throws Exception { this.mockMvc.perform(get("/unknown/resource")) .andExpect(handler().handlerType(DefaultServletHttpRequestHandler.class)) .andExpect(forwardedUrl("default")); }
@Test public void methodCall() throws Exception { this.mockMvc.perform(get("/")).andExpect(handler().methodCall(on(SimpleController.class).handle())); }
@Test public void testIntegrationGraphGet() throws Exception { this.mockMvc.perform(get("/testIntegration") .header(HttpHeaders.ORIGIN, "http://foo.bar.com") .accept(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(status().isOk()) .andExpect(content().contentType("application/json;charset=UTF-8")) .andExpect(handler().handlerType(IntegrationGraphController.class)) .andExpect(handler().methodName("getGraph")) .andExpect(jsonPath("$.nodes..name") .value(Matchers.containsInAnyOrder("nullChannel", "errorChannel", "_org.springframework.integration.errorLogger"))) // .andDo(print()) .andExpect(jsonPath("$.contentDescriptor.name").value("testApplication")) .andExpect(jsonPath("$.links").exists()); }