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 theBodyContentclass. 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 voidclear()voidclearBuffer()voidclose()ReadergetReader()intgetRemaining()StringgetString()voidnewLine()voidprint(boolean value)voidprint(char value)voidprint(char[] value)voidprint(double value)voidprint(float value)voidprint(int value)voidprint(long value)voidprint(Object value)voidprint(String value)voidprintln()voidprintln(boolean value)voidprintln(char value)voidprintln(char[] value)voidprintln(double value)voidprintln(float value)voidprintln(int value)voidprintln(long value)voidprintln(Object value)voidprintln(String value)voidwrite(char[] value, int offset, int length)voidwriteOut(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:
getReaderin classBodyContent
getString
public String getString()
- Specified by:
getStringin classBodyContent
writeOut
public void writeOut(Writer writer) throws IOException
- Specified by:
writeOutin classBodyContent- Throws:
IOException
clear
public void clear() throws IOException
- Specified by:
clearin classJspWriter- Throws:
IOException
clearBuffer
public void clearBuffer() throws IOException
- Specified by:
clearBufferin classJspWriter- Throws:
IOException
close
public void close() throws IOException
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classJspWriter- Throws:
IOException
getRemaining
public int getRemaining()
- Specified by:
getRemainingin classJspWriter
newLine
public void newLine() throws IOException
- Specified by:
newLinein classJspWriter- Throws:
IOException
write
public void write(char[] value, int offset, int length) throws IOException
- Specified by:
writein classWriter- Throws:
IOException
print
public void print(boolean value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
print
public void print(char value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
print
public void print(char[] value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
print
public void print(double value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
print
public void print(float value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
print
public void print(int value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
print
public void print(long value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
print
public void print(Object value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
print
public void print(String value) throws IOException
- Specified by:
printin classJspWriter- Throws:
IOException
println
public void println() throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(boolean value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(char value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(char[] value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(double value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(float value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(int value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(long value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(Object value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException
println
public void println(String value) throws IOException
- Specified by:
printlnin classJspWriter- Throws:
IOException