|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.servlet.MockResponse
public class MockResponse
Mock implementation of HttpServletResponse
.
Field Summary |
---|
Constructor Summary | |
---|---|
MockResponse()
Create the response object. |
Method Summary | |
---|---|
void |
addCookie(Cookie cookie)
Add a cookie to the response. |
void |
addDateHeader(String name,
long l)
Add a date header. |
void |
addHeader(String name,
String value)
Add the given header value, including an additional entry if one already exists. |
void |
addIntHeader(String name,
int i)
Add an int header value. |
static void |
append2digits(StringBuffer buf,
int i)
Append two digits if specified int is less than 100. |
boolean |
containsHeader(String name)
Check if the response contains the given header name. |
String |
encodeRedirectUrl(String url)
Encode the redirectUrl. |
String |
encodeRedirectURL(String url)
Encode the redirectUrl. |
String |
encodeUrl(String url)
Encode thr URL. |
String |
encodeURL(String url)
Encode thr URL. |
void |
flushBuffer()
Flush the buffer. |
static String |
formatDate(long value)
Formats the specified long value as a date. |
static void |
formatDate(StringBuffer buf,
Calendar calendar,
boolean cookie)
Format HTTP date "EEE, dd MMM yyyy HH:mm:ss 'GMT'" or "EEE, dd-MMM-yy HH:mm:ss 'GMT'" for cookies. |
byte[] |
getBinaryContent()
Get the binary content that was written to the servlet stream. |
int |
getBufferSize()
Return the current buffer size. |
String |
getCharacterEncoding()
Get the character encoding of the response. |
int |
getCode()
Get the response code for this request. |
String |
getContentType()
Return the response content type. |
Collection<Cookie> |
getCookies()
Get all of the cookies that have been added to the response. |
String |
getDocument()
Get the text document that was written as part of this response. |
String |
getErrorMessage()
Get the error message. |
String |
getHeader(String name)
Return the value of the given named header. |
Set<String> |
getHeaderNames()
Get the names of all of the headers. |
Locale |
getLocale()
Get the encoded locale. |
ServletOutputStream |
getOutputStream()
Get the output stream for writing binary data from the servlet. |
String |
getRedirectUrl()
Get the location that was redirected to. |
int |
getStatus()
Get the status code. |
PrintWriter |
getWriter()
Get the print writer for writing text output for this response. |
void |
initialize()
Reset the response ready for reuse. |
boolean |
isCommitted()
Always returns false. |
boolean |
isError()
Return whether the servlet returned an error code or not. |
boolean |
isRedirect()
Check whether the response was redirected or not. |
void |
reset()
Delegate to initialise method. |
void |
resetBuffer()
Clears the buffer. |
void |
sendError(int code)
Send an error code. |
void |
sendError(int code,
String msg)
Send an error code. |
void |
sendRedirect(String url)
Indicate sending of a redirectUrl to a particular named resource. |
void |
setBufferSize(int size)
Method ignored. |
void |
setCharacterEncoding(String characterEncoding)
Set the character encoding. |
void |
setContentLength(int length)
Set the content length. |
void |
setContentType(String type)
Set the content type. |
void |
setDateHeader(String name,
long l)
Set a date header. |
void |
setHeader(String name,
String value)
Set the given header value. |
void |
setIntHeader(String name,
int i)
Set an int header value. |
void |
setLocale(Locale locale)
Set the locale in the response header. |
void |
setStatus(int status)
Set the status for this response. |
void |
setStatus(int status,
String msg)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockResponse()
Method Detail |
---|
public void addCookie(Cookie cookie)
addCookie
in interface HttpServletResponse
cookie
- The cookie to addpublic void addDateHeader(String name, long l)
addDateHeader
in interface HttpServletResponse
name
- The header valuel
- The long valuepublic void addHeader(String name, String value)
addHeader
in interface HttpServletResponse
name
- The name for the headervalue
- The value for the headerpublic void addIntHeader(String name, int i)
addIntHeader
in interface HttpServletResponse
name
- The header namei
- The valuepublic boolean containsHeader(String name)
containsHeader
in interface HttpServletResponse
name
- The name to check
public String encodeRedirectUrl(String url)
encodeRedirectUrl
in interface HttpServletResponse
url
- The url to encode
public String encodeRedirectURL(String url)
encodeRedirectURL
in interface HttpServletResponse
url
- The url to encode
public String encodeUrl(String url)
encodeUrl
in interface HttpServletResponse
url
- The url to encode
public String encodeURL(String url)
encodeURL
in interface HttpServletResponse
url
- The url to encode
public void flushBuffer() throws IOException
flushBuffer
in interface ServletResponse
IOException
- if exception occurs during flushpublic byte[] getBinaryContent()
public int getBufferSize()
getBufferSize
in interface ServletResponse
public String getCharacterEncoding()
getCharacterEncoding
in interface ServletResponse
public int getCode()
public Collection<Cookie> getCookies()
public String getDocument()
public String getErrorMessage()
public String getHeader(String name)
name
- The header name
public Set<String> getHeaderNames()
public Locale getLocale()
getLocale
in interface ServletResponse
public ServletOutputStream getOutputStream()
getOutputStream
in interface ServletResponse
public String getRedirectUrl()
public int getStatus()
public PrintWriter getWriter() throws IOException
getWriter
in interface ServletResponse
IOException
- - if an input or output exception occurred
IllegalStateException
- - if the getOutputStream method has
already been called for this response objectpublic void initialize()
public void reset()
reset
in interface ServletResponse
public boolean isCommitted()
isCommitted
in interface ServletResponse
public boolean isError()
public boolean isRedirect()
public void resetBuffer()
resetBuffer
in interface ServletResponse
public void sendError(int code) throws IOException
sendError
in interface HttpServletResponse
code
- The code
IOException
- Not usedpublic void sendError(int code, String msg) throws IOException
sendError
in interface HttpServletResponse
code
- The error codemsg
- The error message
IOException
- Not usedpublic void sendRedirect(String url) throws IOException
sendRedirect
in interface HttpServletResponse
url
- The url to set redirectUrl to
IOException
- Not usedpublic void setBufferSize(int size)
setBufferSize
in interface ServletResponse
size
- The sizepublic void setCharacterEncoding(String characterEncoding)
characterEncoding
- The character encodingpublic void setContentLength(int length)
setContentLength
in interface ServletResponse
length
- The lengthpublic void setContentType(String type)
setContentType
in interface ServletResponse
type
- The content typepublic String getContentType()
public void setDateHeader(String name, long l)
setDateHeader
in interface HttpServletResponse
name
- The header namel
- The long valuepublic static String formatDate(long value)
value
- the specified long value to format
public static void formatDate(StringBuffer buf, Calendar calendar, boolean cookie)
buf
- the buffer to render to formatted date tocalendar
- the date to formatcookie
- should date be formatted for usage in a cookiepublic static void append2digits(StringBuffer buf, int i)
buf
- the buffer to add 2 digits toi
- the digits to addpublic void setHeader(String name, String value)
setHeader
in interface HttpServletResponse
name
- The name for the headervalue
- The value for the headerpublic void setIntHeader(String name, int i)
setIntHeader
in interface HttpServletResponse
name
- The header namei
- The valuepublic void setLocale(Locale locale)
setLocale
in interface ServletResponse
locale
- The localepublic void setStatus(int status)
setStatus
in interface HttpServletResponse
status
- The statuspublic void setStatus(int status, String msg)
setStatus
in interface HttpServletResponse
status
- The statusmsg
- The message
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |