Package org.springframework.mock.web
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
Mock implementation of the
BodyContent
class.
Only necessary for testing applications when testing custom JSP tags.- Since:
- 2.5
- Author:
- Juergen Hoeller
-
Field Summary
Fields inherited from class jakarta.servlet.jsp.JspWriter
autoFlush, bufferSize, DEFAULT_BUFFER, NO_BUFFER, UNBOUNDED_BUFFER
-
Constructor Summary
ConstructorDescriptionMockBodyContent
(String content, HttpServletResponse response) Create a MockBodyContent for the given response.MockBodyContent
(String content, HttpServletResponse response, Writer targetWriter) Create a MockBodyContent for the given response.MockBodyContent
(String content, Writer targetWriter) Create a MockBodyContent for the given response. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
void
void
close()
int
void
newLine()
void
print
(boolean value) void
print
(char value) void
print
(char[] value) void
print
(double value) void
print
(float value) void
print
(int value) void
print
(long value) void
void
void
println()
void
println
(boolean value) void
println
(char value) void
println
(char[] value) void
println
(double value) void
println
(float value) void
println
(int value) void
println
(long value) void
void
void
write
(char[] value, int offset, int length) void
Methods inherited from class jakarta.servlet.jsp.tagext.BodyContent
clearBody, flush, getEnclosingWriter
Methods inherited from class jakarta.servlet.jsp.JspWriter
getBufferSize, isAutoFlush
-
Constructor Details
-
MockBodyContent
Create a MockBodyContent for the given response.- Parameters:
content
- the body content to exposeresponse
- the servlet response to wrap
-
MockBodyContent
Create a MockBodyContent for the given response.- Parameters:
content
- the body content to exposetargetWriter
- the target Writer to wrap
-
MockBodyContent
public MockBodyContent(String content, @Nullable HttpServletResponse response, @Nullable Writer targetWriter) Create a MockBodyContent for the given response.- Parameters:
content
- the body content to exposeresponse
- the servlet response to wraptargetWriter
- the target Writer to wrap
-
-
Method Details
-
getReader
- Specified by:
getReader
in classBodyContent
-
getString
- Specified by:
getString
in classBodyContent
-
writeOut
- Specified by:
writeOut
in classBodyContent
- Throws:
IOException
-
clear
- Specified by:
clear
in classJspWriter
- Throws:
IOException
-
clearBuffer
- Specified by:
clearBuffer
in classJspWriter
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classJspWriter
- Throws:
IOException
-
getRemaining
public int getRemaining()- Specified by:
getRemaining
in classJspWriter
-
newLine
- Specified by:
newLine
in classJspWriter
- Throws:
IOException
-
write
- Specified by:
write
in classWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
print
- Specified by:
print
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-
println
- Specified by:
println
in classJspWriter
- Throws:
IOException
-