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 printsMvcResultdetails 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
printorlogmethods inMockMvcResultHandlers.- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfacePrintingResultHandler.ResultValuePrinterA contract for how to actually write result information.
Constructor Summary
Constructors Modifier Constructor Description protectedPrintingResultHandler(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.ResultValuePrintergetPrinter()Return the result value printer.protected HttpHeadersgetRequestHeaders(MockHttpServletRequest request)protected HttpHeadersgetResponseHeaders(MockHttpServletResponse response)protected Map<String,Object>getSessionAttributes(MockHttpServletRequest request)voidhandle(MvcResult result)PrintMvcResultdetails.protected voidprintAsyncResult(MvcResult result)protected voidprintFlashMap(FlashMap flashMap)Print "output" flash attributes.protected voidprintHandler(Object handler, HandlerInterceptor[] interceptors)Print the handler.protected voidprintModelAndView(ModelAndView mav)Print the ModelAndView.protected voidprintRequest(MockHttpServletRequest request)Print the request.protected voidprintResolvedException(Exception resolvedException)Print exceptions resolved through a HandlerExceptionResolver.protected voidprintResponse(MockHttpServletResponse response)Print the response.
Constructor Detail
PrintingResultHandler
protected PrintingResultHandler(PrintingResultHandler.ResultValuePrinter printer)
Protected constructor.- Parameters:
printer- aPrintingResultHandler.ResultValuePrinterto do the actual writing
Method Detail
getPrinter
protected PrintingResultHandler.ResultValuePrinter getPrinter()
Return the result value printer.- Returns:
- the printer
handle
public final void handle(MvcResult result) throws Exception
PrintMvcResultdetails.- Specified by:
handlein 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)
getSessionAttributes
protected final Map<String,Object> getSessionAttributes(MockHttpServletRequest request)
printAsyncResult
protected void printAsyncResult(MvcResult result) throws Exception
- Throws:
Exception
printHandler
protected void printHandler(@Nullable Object handler, @Nullable HandlerInterceptor[] interceptors) throws Exception
Print the handler.- Throws:
Exception
printResolvedException
protected void printResolvedException(@Nullable Exception resolvedException) throws Exception
Print exceptions resolved through a HandlerExceptionResolver.- Throws:
Exception
printModelAndView
protected void printModelAndView(@Nullable 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)