Class PrintingResultHandler
- java.lang.Object
- org.springframework.test.web.servlet.result.PrintingResultHandler
- All Implemented Interfaces:
ResultHandler
public class PrintingResultHandler extends Object implements ResultHandler
Result handler that printsMvcResult
details to a given output stream — for example:System.out
,System.err
, a customjava.io.PrintWriter
, etc.An instance of this class is typically accessed via one of the
print
orlog
methods inMockMvcResultHandlers
.- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
PrintingResultHandler.ResultValuePrinter
A contract for how to actually write result information.
Constructor Summary
Constructors Modifier Constructor Description protected
PrintingResultHandler(PrintingResultHandler.ResultValuePrinter printer)
Protected constructor.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MultiValueMap<String,String>
getParamsMultiValueMap(MockHttpServletRequest request)
protected PrintingResultHandler.ResultValuePrinter
getPrinter()
protected HttpHeaders
getRequestHeaders(MockHttpServletRequest request)
protected HttpHeaders
getResponseHeaders(MockHttpServletResponse response)
void
handle(MvcResult result)
PrintMvcResult
details.protected void
printAsyncResult(MvcResult result)
protected void
printFlashMap(FlashMap flashMap)
Print "output" flash attributes.protected void
printHandler(Object handler, HandlerInterceptor[] interceptors)
Print the handler.protected void
printModelAndView(ModelAndView mav)
Print the ModelAndView.protected void
printRequest(MockHttpServletRequest request)
Print the request.protected void
printResolvedException(Exception resolvedException)
Print exceptions resolved through a HandlerExceptionResolver.protected void
printResponse(MockHttpServletResponse response)
Print the response.
Constructor Detail
PrintingResultHandler
protected PrintingResultHandler(PrintingResultHandler.ResultValuePrinter printer)
Protected constructor.- Parameters:
printer
- aPrintingResultHandler.ResultValuePrinter
to do the actual writing
Method Detail
getPrinter
protected PrintingResultHandler.ResultValuePrinter getPrinter()
- Returns:
- the result value printer
handle
public final void handle(MvcResult result) throws Exception
PrintMvcResult
details.- Specified by:
handle
in interfaceResultHandler
- Parameters:
result
- the result of the executed request- Throws:
Exception
- if a failure occurs
printRequest
protected void printRequest(MockHttpServletRequest request) throws Exception
Print the request.- Throws:
Exception
getRequestHeaders
protected final HttpHeaders getRequestHeaders(MockHttpServletRequest request)
getParamsMultiValueMap
protected final MultiValueMap<String,String> getParamsMultiValueMap(MockHttpServletRequest request)
printAsyncResult
protected void printAsyncResult(MvcResult result) throws Exception
- Throws:
Exception
printHandler
protected void printHandler(Object handler, HandlerInterceptor[] interceptors) throws Exception
Print the handler.- Throws:
Exception
printResolvedException
protected void printResolvedException(Exception resolvedException) throws Exception
Print exceptions resolved through a HandlerExceptionResolver.- Throws:
Exception
printModelAndView
protected void printModelAndView(ModelAndView mav) throws Exception
Print the ModelAndView.- Throws:
Exception
printFlashMap
protected void printFlashMap(FlashMap flashMap) throws Exception
Print "output" flash attributes.- Throws:
Exception
printResponse
protected void printResponse(MockHttpServletResponse response) throws Exception
Print the response.- Throws:
Exception
getResponseHeaders
protected final HttpHeaders getResponseHeaders(MockHttpServletResponse response)