Package org.springframework.mock.web
Class MockBodyContent
- java.lang.Object
- java.io.Writer
- javax.servlet.jsp.JspWriter
- javax.servlet.jsp.tagext.BodyContent
- org.springframework.mock.web.MockBodyContent
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public class MockBodyContent extends BodyContent
Mock implementation of theBodyContent
class. Only necessary for testing applications when testing custom JSP tags.- Since:
- 2.5
- Author:
- Juergen Hoeller
Field Summary
Fields inherited from class javax.servlet.jsp.JspWriter
autoFlush, bufferSize, DEFAULT_BUFFER, NO_BUFFER, UNBOUNDED_BUFFER
Constructor Summary
Constructors Constructor Description MockBodyContent(String content, Writer targetWriter)
Create a MockBodyContent for the given response.MockBodyContent(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.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
clearBuffer()
void
close()
Reader
getReader()
int
getRemaining()
String
getString()
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
print(Object value)
void
print(String value)
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
println(Object value)
void
println(String value)
void
write(char[] value, int offset, int length)
void
writeOut(Writer writer)
Methods inherited from class javax.servlet.jsp.tagext.BodyContent
clearBody, flush, getEnclosingWriter
Methods inherited from class javax.servlet.jsp.JspWriter
getBufferSize, isAutoFlush
Constructor Detail
MockBodyContent
public MockBodyContent(String content, HttpServletResponse response)
Create a MockBodyContent for the given response.- Parameters:
content
- the body content to exposeresponse
- the servlet response to wrap
MockBodyContent
public MockBodyContent(String content, Writer targetWriter)
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 Detail
getReader
public Reader getReader()
- Specified by:
getReader
in classBodyContent
getString
public String getString()
- Specified by:
getString
in classBodyContent
writeOut
public void writeOut(Writer writer) throws IOException
- Specified by:
writeOut
in classBodyContent
- Throws:
IOException
clear
public void clear() throws IOException
- Specified by:
clear
in classJspWriter
- Throws:
IOException
clearBuffer
public void clearBuffer() throws IOException
- Specified by:
clearBuffer
in classJspWriter
- Throws:
IOException
close
public void close() throws IOException
- 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
public void newLine() throws IOException
- Specified by:
newLine
in classJspWriter
- Throws:
IOException
write
public void write(char[] value, int offset, int length) throws IOException
- Specified by:
write
in classWriter
- Throws:
IOException
print
public void print(boolean value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
print
public void print(char value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
print
public void print(char[] value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
print
public void print(double value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
print
public void print(float value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
print
public void print(int value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
print
public void print(long value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
print
public void print(Object value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
print
public void print(String value) throws IOException
- Specified by:
print
in classJspWriter
- Throws:
IOException
println
public void println() throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(boolean value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(char value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(char[] value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(double value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(float value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(int value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(long value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(Object value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException
println
public void println(String value) throws IOException
- Specified by:
println
in classJspWriter
- Throws:
IOException