org.springframework.test.web.servlet.result

Class PrintingResultHandler

  • java.lang.Object
    • org.springframework.test.web.servlet.result.PrintingResultHandler
  • All Implemented Interfaces:
    ResultHandler


    public class PrintingResultHandler
    extends java.lang.Object
    implements 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
    • Method Detail

      • handle

        public final void handle(MvcResult result)
                          throws java.lang.Exception
        Print MvcResult details.
        Specified by:
        handle in interface ResultHandler
        Parameters:
        result - the result of the executed request
        Throws:
        java.lang.Exception - if a failure occurs
      • printRequest

        protected void printRequest(MockHttpServletRequest request)
                             throws java.lang.Exception
        Print the request.
        Throws:
        java.lang.Exception
      • getSessionAttributes

        protected final java.util.Map<java.lang.String,java.lang.Object> getSessionAttributes(MockHttpServletRequest request)
      • printAsyncResult

        protected void printAsyncResult(MvcResult result)
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • printHandler

        protected void printHandler(@Nullable
                                    java.lang.Object handler,
                                    @Nullable
                                    HandlerInterceptor[] interceptors)
                             throws java.lang.Exception
        Print the handler.
        Throws:
        java.lang.Exception
      • printResolvedException

        protected void printResolvedException(@Nullable
                                              java.lang.Exception resolvedException)
                                       throws java.lang.Exception
        Print exceptions resolved through a HandlerExceptionResolver.
        Throws:
        java.lang.Exception
      • printModelAndView

        protected void printModelAndView(@Nullable
                                         ModelAndView mav)
                                  throws java.lang.Exception
        Print the ModelAndView.
        Throws:
        java.lang.Exception
      • printFlashMap

        protected void printFlashMap(FlashMap flashMap)
                              throws java.lang.Exception
        Print "output" flash attributes.
        Throws:
        java.lang.Exception
      • printResponse

        protected void printResponse(MockHttpServletResponse response)
                              throws java.lang.Exception
        Print the response.
        Throws:
        java.lang.Exception