org.springframework.mock.web

Class MockBodyContent

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable


    public class MockBodyContent
    extends BodyContent
    Mock implementation of the BodyContent class. Only necessary for testing applications when testing custom JSP tags.
    Since:
    2.5
    Author:
    Juergen Hoeller
    • Constructor Detail

      • MockBodyContent

        public MockBodyContent(java.lang.String content,
                               HttpServletResponse response)
        Create a MockBodyContent for the given response.
        Parameters:
        content - the body content to expose
        response - the servlet response to wrap
      • MockBodyContent

        public MockBodyContent(java.lang.String content,
                               java.io.Writer targetWriter)
        Create a MockBodyContent for the given response.
        Parameters:
        content - the body content to expose
        targetWriter - the target Writer to wrap
      • MockBodyContent

        public MockBodyContent(java.lang.String content,
                               @Nullable
                               HttpServletResponse response,
                               @Nullable
                               java.io.Writer targetWriter)
        Create a MockBodyContent for the given response.
        Parameters:
        content - the body content to expose
        response - the servlet response to wrap
        targetWriter - the target Writer to wrap
    • Method Detail

      • writeOut

        public void writeOut(java.io.Writer writer)
                      throws java.io.IOException
        Specified by:
        writeOut in class BodyContent
        Throws:
        java.io.IOException
      • clear

        public void clear()
                   throws java.io.IOException
        Specified by:
        clear in class JspWriter
        Throws:
        java.io.IOException
      • clearBuffer

        public void clearBuffer()
                         throws java.io.IOException
        Specified by:
        clearBuffer in class JspWriter
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in class JspWriter
        Throws:
        java.io.IOException
      • newLine

        public void newLine()
                     throws java.io.IOException
        Specified by:
        newLine in class JspWriter
        Throws:
        java.io.IOException
      • write

        public void write(char[] value,
                          int offset,
                          int length)
                   throws java.io.IOException
        Specified by:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • print

        public void print(boolean value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • print

        public void print(char value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • print

        public void print(char[] value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • print

        public void print(double value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • print

        public void print(float value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • print

        public void print(int value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • print

        public void print(long value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • print

        public void print(java.lang.Object value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • print

        public void print(java.lang.String value)
                   throws java.io.IOException
        Specified by:
        print in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println()
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(boolean value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(char value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(char[] value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(double value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(float value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(int value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(long value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(java.lang.Object value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException
      • println

        public void println(java.lang.String value)
                     throws java.io.IOException
        Specified by:
        println in class JspWriter
        Throws:
        java.io.IOException