Class MockBodyContent
java.lang.Object
java.io.Writer
jakarta.servlet.jsp.JspWriter
jakarta.servlet.jsp.tagext.BodyContent
org.springframework.mock.web.MockBodyContent
- All Implemented Interfaces:
- Closeable, Flushable, Appendable, AutoCloseable
public class MockBodyContent
extends jakarta.servlet.jsp.tagext.BodyContent
Mock implementation of the 
BodyContent class.
Only necessary for testing applications when testing custom JSP tags.- Since:
- 2.5
- Author:
- Juergen Hoeller
- 
Field SummaryFields inherited from class jakarta.servlet.jsp.JspWriterautoFlush, bufferSize, DEFAULT_BUFFER, NO_BUFFER, UNBOUNDED_BUFFER
- 
Constructor SummaryConstructorsConstructorDescriptionMockBodyContent(String content, @Nullable jakarta.servlet.http.HttpServletResponse response, @Nullable Writer targetWriter) Create a MockBodyContent for the given response.MockBodyContent(String content, jakarta.servlet.http.HttpServletResponse response) Create a MockBodyContent for the given response.MockBodyContent(String content, Writer targetWriter) Create a MockBodyContent for the given response.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()voidvoidclose()intvoidnewLine()voidprint(boolean value) voidprint(char value) voidprint(char[] value) voidprint(double value) voidprint(float value) voidprint(int value) voidprint(long value) voidvoidvoidprintln()voidprintln(boolean value) voidprintln(char value) voidprintln(char[] value) voidprintln(double value) voidprintln(float value) voidprintln(int value) voidprintln(long value) voidvoidvoidwrite(char[] value, int offset, int length) voidMethods inherited from class jakarta.servlet.jsp.tagext.BodyContentclearBody, flush, getEnclosingWriterMethods inherited from class jakarta.servlet.jsp.JspWritergetBufferSize, isAutoFlush
- 
Constructor Details- 
MockBodyContentCreate a MockBodyContent for the given response.- Parameters:
- content- the body content to expose
- response- the servlet response to wrap
 
- 
MockBodyContent
- 
MockBodyContentpublic MockBodyContent(String content, @Nullable jakarta.servlet.http.HttpServletResponse response, @Nullable 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 Details- 
getReader- Specified by:
- getReaderin class- jakarta.servlet.jsp.tagext.BodyContent
 
- 
getString- Specified by:
- getStringin class- jakarta.servlet.jsp.tagext.BodyContent
 
- 
writeOut- Specified by:
- writeOutin class- jakarta.servlet.jsp.tagext.BodyContent
- Throws:
- IOException
 
- 
clear- Specified by:
- clearin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
clearBuffer- Specified by:
- clearBufferin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
getRemainingpublic int getRemaining()- Specified by:
- getRemainingin class- jakarta.servlet.jsp.JspWriter
 
- 
newLine- Specified by:
- newLinein class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
write- Specified by:
- writein class- Writer
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
print- Specified by:
- printin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
- 
println- Specified by:
- printlnin class- jakarta.servlet.jsp.JspWriter
- Throws:
- IOException
 
 
-