List of usage examples for org.springframework.web.method HandlerMethod toString
@Override
public String toString()
From source file:org.cloudifysource.rest.AttributesContollerTest.java
private void testRequest(final MockHttpServletRequest reqeust, final HandlerMethod expectedHandlerMethod, final String expectedResponseContent) throws Exception { final MockHttpServletResponse response = new MockHttpServletResponse(); final Object handler = getHandlerToRequest(reqeust); Assert.assertEquals("Wrong handler selected for request uri: " + reqeust.getRequestURI(), expectedHandlerMethod.toString(), handler.toString()); // handle the request handlerAdapter.handle(reqeust, response, handler); // validate the response Assert.assertTrue("Wrong response status: " + response.getStatus(), response.getStatus() == HttpStatus.OK.value()); Assert.assertEquals("Wrong content type in response: " + response.getContentType(), JSON_CONTENT_TYPE, response.getContentType());/*from w w w . j av a 2s . c om*/ Assert.assertEquals("Wrong response content: " + response.getContentAsString(), expectedResponseContent, response.getContentAsString()); }
From source file:org.cloudifysource.rest.ControllerTest.java
private MockHttpServletResponse testRequest(final MockHttpServletRequest request, final HandlerMethod expectedHandlerMethod) throws Exception { final MockHttpServletResponse response = new MockHttpServletResponse(); final HandlerExecutionChain handlerExecutionChain = getHandlerToRequest(request); Object handler = handlerExecutionChain.getHandler(); Assert.assertEquals("Wrong handler selected for request uri: " + request.getRequestURI(), expectedHandlerMethod.toString(), handler.toString()); HandlerInterceptor[] interceptors = handlerExecutionChain.getInterceptors(); // pre handle for (HandlerInterceptor handlerInterceptor : interceptors) { handlerInterceptor.preHandle(request, response, handler); }//from w w w .ja va 2 s. c o m // handle the request ModelAndView modelAndView = handlerAdapter.handle(request, response, handler); // post handle for (HandlerInterceptor handlerInterceptor : interceptors) { handlerInterceptor.postHandle(request, response, handler, modelAndView); } // validate the response Assert.assertTrue("Wrong response status: " + response.getStatus(), response.getStatus() == HttpStatus.OK.value()); Assert.assertTrue(response.getContentType().contains(MediaType.APPLICATION_JSON)); return response; }