|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.slim3.struts.test.MockHttpServletResponse
public class MockHttpServletResponse
A mock implementation for MockHttpServletResponse
.
Field Summary | |
---|---|
protected int |
bufferSize
The buffer size. |
protected String |
characterEncoding
The character encoding. |
protected boolean |
committed
The committed flag. |
protected List<Cookie> |
cookieList
The list for Cookie . |
protected boolean |
getOutputStreamCalled
Whether getOutputStream method is called. |
protected boolean |
getWriterCalled
Whether getWriter method is called. |
protected Map<String,List<String>> |
headerMap
The map for the response header. |
protected Locale |
locale
The locale. |
protected String |
message
The message. |
protected ServletOutputStream |
outputStream
The output stream. |
protected ByteArrayOutputStream |
sourceOutput
The source output. |
protected int |
status
The status. |
protected PrintWriter |
writer
The writer. |
Constructor Summary | |
---|---|
MockHttpServletResponse()
Constructor. |
Method Summary | |
---|---|
void |
addCookie(Cookie cookie)
|
void |
addDateHeader(String name,
long value)
|
void |
addHeader(String name,
String value)
|
void |
addIntHeader(String name,
int value)
|
protected void |
assertNotCommitted()
Asserts this response is not committed. |
boolean |
containsHeader(String name)
|
String |
encodeRedirectUrl(String url)
|
String |
encodeRedirectURL(String url)
|
String |
encodeUrl(String url)
|
String |
encodeURL(String url)
|
void |
flushBuffer()
|
int |
getBufferSize()
|
String |
getCharacterEncoding()
|
int |
getContentLength()
Returns the content length. |
String |
getContentType()
|
Cookie[] |
getCookies()
Returns the cookies. |
long |
getDateHeader(String name)
Returns the header as date. |
String |
getHeader(String name)
Returns the header as string. |
protected List<String> |
getHeaderList(String name)
Returns the header as list. |
Enumeration<String> |
getHeaderNames()
Returns the header names. |
Enumeration<String> |
getHeaders(String name)
Returns the header as Enumeration . |
int |
getIntHeader(String name)
Returns the header as int. |
Locale |
getLocale()
|
String |
getMessage()
Returns the message. |
byte[] |
getOutputAsByteArray()
Returns the output as array of bytes. |
String |
getOutputAsString()
Returns the output as string. |
ServletOutputStream |
getOutputStream()
|
protected String |
getResponseStatusMessage(int status)
Returns the response status message. |
int |
getStatus()
Returns the status. |
PrintWriter |
getWriter()
|
boolean |
isCommitted()
|
void |
reset()
|
void |
resetBuffer()
|
void |
sendError(int status)
|
void |
sendError(int status,
String message)
|
void |
sendRedirect(String path)
|
void |
setBufferSize(int bufferSize)
|
void |
setCharacterEncoding(String characterEncoding)
|
void |
setContentLength(int contentLength)
|
void |
setContentType(String contentType)
|
void |
setDateHeader(String name,
long value)
|
void |
setHeader(String name,
String value)
|
void |
setIntHeader(String name,
int value)
|
void |
setLocale(Locale locale)
|
void |
setStatus(int status)
|
void |
setStatus(int status,
String message)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected List<Cookie> cookieList
Cookie
.
protected Map<String,List<String>> headerMap
protected boolean committed
protected int status
protected String message
protected Locale locale
protected String characterEncoding
protected ByteArrayOutputStream sourceOutput
protected PrintWriter writer
protected ServletOutputStream outputStream
protected boolean getWriterCalled
protected boolean getOutputStreamCalled
protected int bufferSize
Constructor Detail |
---|
public MockHttpServletResponse()
Method Detail |
---|
public Cookie[] getCookies()
public void addCookie(Cookie cookie)
addCookie
in interface HttpServletResponse
public boolean containsHeader(String name)
containsHeader
in interface HttpServletResponse
public String encodeURL(String url)
encodeURL
in interface HttpServletResponse
public String encodeRedirectURL(String url)
encodeRedirectURL
in interface HttpServletResponse
public String encodeUrl(String url)
encodeUrl
in interface HttpServletResponse
public String encodeRedirectUrl(String url)
encodeRedirectUrl
in interface HttpServletResponse
public int getStatus()
public void setStatus(int status, String message)
setStatus
in interface HttpServletResponse
public void setStatus(int status)
setStatus
in interface HttpServletResponse
protected String getResponseStatusMessage(int status)
status
- the status
protected void assertNotCommitted()
public String getMessage()
public void sendError(int status, String message) throws IOException
sendError
in interface HttpServletResponse
IOException
public void sendError(int status) throws IOException
sendError
in interface HttpServletResponse
IOException
public void sendRedirect(String path) throws IOException
sendRedirect
in interface HttpServletResponse
IOException
public Enumeration<String> getHeaders(String name)
Enumeration
.
name
- the name
public String getHeader(String name)
name
- the name
public long getDateHeader(String name)
name
- the name
public int getIntHeader(String name)
name
- the name
protected List<String> getHeaderList(String name)
name
- the name
public Enumeration<String> getHeaderNames()
public void setHeader(String name, String value)
setHeader
in interface HttpServletResponse
public void addHeader(String name, String value)
addHeader
in interface HttpServletResponse
public void setDateHeader(String name, long value)
setDateHeader
in interface HttpServletResponse
public void addDateHeader(String name, long value)
addDateHeader
in interface HttpServletResponse
public void setIntHeader(String name, int value)
setIntHeader
in interface HttpServletResponse
public void addIntHeader(String name, int value)
addIntHeader
in interface HttpServletResponse
public int getContentLength()
public void setContentLength(int contentLength)
setContentLength
in interface ServletResponse
public String getContentType()
getContentType
in interface ServletResponse
public void setContentType(String contentType)
setContentType
in interface ServletResponse
public String getCharacterEncoding()
getCharacterEncoding
in interface ServletResponse
public void setCharacterEncoding(String characterEncoding)
setCharacterEncoding
in interface ServletResponse
public ServletOutputStream getOutputStream() throws IOException
getOutputStream
in interface ServletResponse
IOException
public PrintWriter getWriter() throws IOException
getWriter
in interface ServletResponse
IOException
public byte[] getOutputAsByteArray() throws IOException
IOException
- if IOException
is encounteredpublic String getOutputAsString() throws IOException
IOException
- if IOException
is encounteredpublic int getBufferSize()
getBufferSize
in interface ServletResponse
public void setBufferSize(int bufferSize)
setBufferSize
in interface ServletResponse
public void flushBuffer() throws IOException
flushBuffer
in interface ServletResponse
IOException
public void resetBuffer()
resetBuffer
in interface ServletResponse
public boolean isCommitted()
isCommitted
in interface ServletResponse
public void reset()
reset
in interface ServletResponse
public void setLocale(Locale locale)
setLocale
in interface ServletResponse
public Locale getLocale()
getLocale
in interface ServletResponse
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |