Class PrintingResultHandler
java.lang.Object
org.springframework.test.web.servlet.result.PrintingResultHandler
- All Implemented Interfaces:
ResultHandler
Result handler that prints
MvcResult
details to a given output
stream — for example: System.out
, System.err
, a
custom java.io.PrintWriter
, etc.
An instance of this class is typically accessed via one of the
print
or log
methods in MockMvcResultHandlers
.
- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
A contract for how to actually write result information. -
Constructor Summary
ModifierConstructorDescriptionprotected
Protected constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected PrintingResultHandler.ResultValuePrinter
Return the result value printer.protected final org.springframework.http.HttpHeaders
getRequestHeaders
(MockHttpServletRequest request) protected final org.springframework.http.HttpHeaders
getResponseHeaders
(MockHttpServletResponse response) final void
PrintMvcResult
details.protected void
printAsyncResult
(MvcResult result) protected void
printFlashMap
(org.springframework.web.servlet.FlashMap flashMap) Print "output" flash attributes.protected void
printHandler
(Object handler, org.springframework.web.servlet.HandlerInterceptor[] interceptors) Print the handler.protected void
printModelAndView
(org.springframework.web.servlet.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 Details
-
PrintingResultHandler
Protected constructor.- Parameters:
printer
- aPrintingResultHandler.ResultValuePrinter
to do the actual writing
-
-
Method Details
-
getPrinter
Return the result value printer.- Returns:
- the printer
-
handle
PrintMvcResult
details.- Specified by:
handle
in interfaceResultHandler
- Parameters:
result
- the result of the executed request- Throws:
Exception
- if a failure occurs
-
printRequest
Print the request.- Throws:
Exception
-
getRequestHeaders
protected final org.springframework.http.HttpHeaders getRequestHeaders(MockHttpServletRequest request) -
getParamsMultiValueMap
protected final org.springframework.util.MultiValueMap<String,String> getParamsMultiValueMap(MockHttpServletRequest request) -
getSessionAttributes
-
printAsyncResult
- Throws:
Exception
-
printHandler
protected void printHandler(@Nullable Object handler, @Nullable org.springframework.web.servlet.HandlerInterceptor[] interceptors) throws Exception Print the handler.- Throws:
Exception
-
printResolvedException
Print exceptions resolved through a HandlerExceptionResolver.- Throws:
Exception
-
printModelAndView
protected void printModelAndView(@Nullable org.springframework.web.servlet.ModelAndView mav) throws Exception Print the ModelAndView.- Throws:
Exception
-
printFlashMap
Print "output" flash attributes.- Throws:
Exception
-
printResponse
Print the response.- Throws:
Exception
-
getResponseHeaders
protected final org.springframework.http.HttpHeaders getResponseHeaders(MockHttpServletResponse response)
-