|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wicket.protocol.http.MockHttpServletResponse
public class MockHttpServletResponse
Mock servlet response. Implements all of the methods from the standard HttpServletResponse class plus helper methods to aid viewing the generated response.
| Field Summary |
|---|
| Fields inherited from interface javax.servlet.http.HttpServletResponse |
|---|
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY |
| Constructor Summary | |
|---|---|
MockHttpServletResponse(MockHttpServletRequest servletRequest)
Create the response object. |
|
| Method Summary | |
|---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Add a cookie to the response. |
void |
addDateHeader(java.lang.String name,
long l)
Add a date header. |
void |
addHeader(java.lang.String name,
java.lang.String value)
Add the given header value, including an additional entry if one already exists. |
void |
addIntHeader(java.lang.String name,
int i)
Add an int header value. |
static void |
append2digits(java.lang.StringBuffer buf,
int i)
|
boolean |
containsHeader(java.lang.String name)
Check if the response contains the given header name. |
java.lang.String |
encodeRedirectUrl(java.lang.String url)
Encode the redirectLocation URL. |
java.lang.String |
encodeRedirectURL(java.lang.String url)
Encode the redirectLocation URL. |
java.lang.String |
encodeUrl(java.lang.String url)
Encode the URL. |
java.lang.String |
encodeURL(java.lang.String url)
Encode the URL. |
void |
flushBuffer()
Flush the buffer. |
static java.lang.String |
formatDate(long l)
|
static void |
formatDate(java.lang.StringBuffer buf,
java.util.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 |
java.lang.String |
getCharacterEncoding()
Get the character encoding of the response. |
int |
getCode()
Get the response code for this request. |
java.lang.String |
getContentType()
|
java.util.Collection<javax.servlet.http.Cookie> |
getCookies()
Get all of the cookies that have been added to the response. |
java.lang.String |
getDocument()
Get the text document that was written as part of this response. |
java.lang.String |
getErrorMessage()
Get the error message. |
java.lang.String |
getHeader(java.lang.String name)
Return the value of the given named header. |
java.util.Set<java.lang.String> |
getHeaderNames()
Get the names of all of the headers. |
java.util.Locale |
getLocale()
Get the encoded locale |
javax.servlet.ServletOutputStream |
getOutputStream()
Get the output stream for writing binary data from the servlet. |
java.lang.String |
getRedirectLocation()
Get the location that was redirected to. |
int |
getStatus()
Get the status code. |
java.io.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 initialize method. |
void |
resetBuffer()
Clears the buffer. |
void |
sendError(int code)
Send an error code. |
void |
sendError(int code,
java.lang.String msg)
Send an error code. |
void |
sendRedirect(java.lang.String location)
Indicate sending of a redirectLocation to a particular named resource. |
void |
setBufferSize(int size)
Method ignored. |
void |
setCharacterEncoding(java.lang.String characterEncoding)
Set the character encoding. |
void |
setContentLength(int length)
Set the content length. |
void |
setContentType(java.lang.String type)
Set the content type. |
void |
setDateHeader(java.lang.String name,
long l)
Set a date header. |
void |
setHeader(java.lang.String name,
java.lang.String value)
Set the given header value. |
void |
setIntHeader(java.lang.String name,
int i)
Set an int header value. |
void |
setLocale(java.util.Locale locale)
Set the locale in the response header. |
void |
setStatus(int status)
Set the status for this response. |
void |
setStatus(int status,
java.lang.String msg)
Deprecated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MockHttpServletResponse(MockHttpServletRequest servletRequest)
servletRequest - | Method Detail |
|---|
public void addCookie(javax.servlet.http.Cookie cookie)
addCookie in interface javax.servlet.http.HttpServletResponsecookie - The cookie to add
public void addDateHeader(java.lang.String name,
long l)
addDateHeader in interface javax.servlet.http.HttpServletResponsename - The header valuel - The long value
public void addHeader(java.lang.String name,
java.lang.String value)
addHeader in interface javax.servlet.http.HttpServletResponsename - The name for the headervalue - The value for the header
public void addIntHeader(java.lang.String name,
int i)
addIntHeader in interface javax.servlet.http.HttpServletResponsename - The header namei - The valuepublic boolean containsHeader(java.lang.String name)
containsHeader in interface javax.servlet.http.HttpServletResponsename - The name to check
public java.lang.String encodeRedirectUrl(java.lang.String url)
encodeRedirectUrl in interface javax.servlet.http.HttpServletResponseurl - The url to encode
public java.lang.String encodeRedirectURL(java.lang.String url)
encodeRedirectURL in interface javax.servlet.http.HttpServletResponseurl - The url to encode
public java.lang.String encodeUrl(java.lang.String url)
encodeUrl in interface javax.servlet.http.HttpServletResponseurl - The url to encode
public java.lang.String encodeURL(java.lang.String url)
encodeURL in interface javax.servlet.http.HttpServletResponseurl - The url to encode
public void flushBuffer()
throws java.io.IOException
flushBuffer in interface javax.servlet.ServletResponsejava.io.IOExceptionpublic byte[] getBinaryContent()
public int getBufferSize()
getBufferSize in interface javax.servlet.ServletResponsepublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletResponsepublic int getCode()
public java.util.Collection<javax.servlet.http.Cookie> getCookies()
public java.lang.String getDocument()
public java.lang.String getErrorMessage()
public java.lang.String getHeader(java.lang.String name)
name - The header name
public java.util.Set<java.lang.String> getHeaderNames()
public java.util.Locale getLocale()
getLocale in interface javax.servlet.ServletResponsepublic javax.servlet.ServletOutputStream getOutputStream()
getOutputStream in interface javax.servlet.ServletResponsepublic java.lang.String getRedirectLocation()
public int getStatus()
public java.io.PrintWriter getWriter()
throws java.io.IOException
getWriter in interface javax.servlet.ServletResponsejava.io.IOException - Not usedpublic void initialize()
public boolean isCommitted()
isCommitted in interface javax.servlet.ServletResponsepublic boolean isError()
public boolean isRedirect()
public void reset()
reset in interface javax.servlet.ServletResponsepublic void resetBuffer()
resetBuffer in interface javax.servlet.ServletResponse
public void sendError(int code)
throws java.io.IOException
sendError in interface javax.servlet.http.HttpServletResponsecode - The code
java.io.IOException - Not used
public void sendError(int code,
java.lang.String msg)
throws java.io.IOException
sendError in interface javax.servlet.http.HttpServletResponsecode - The error codemsg - The error message
java.io.IOException - Not used
public void sendRedirect(java.lang.String location)
throws java.io.IOException
sendRedirect in interface javax.servlet.http.HttpServletResponselocation - The location to redirectLocation to
java.io.IOException - Not usedpublic void setBufferSize(int size)
setBufferSize in interface javax.servlet.ServletResponsesize - The sizepublic void setCharacterEncoding(java.lang.String characterEncoding)
characterEncoding - The character encodingpublic void setContentLength(int length)
setContentLength in interface javax.servlet.ServletResponselength - The lengthpublic void setContentType(java.lang.String type)
setContentType in interface javax.servlet.ServletResponsetype - The content typepublic java.lang.String getContentType()
public void setDateHeader(java.lang.String name,
long l)
setDateHeader in interface javax.servlet.http.HttpServletResponsename - The header namel - The long valuepublic static java.lang.String formatDate(long l)
l -
public static void formatDate(java.lang.StringBuffer buf,
java.util.Calendar calendar,
boolean cookie)
buf - calendar - cookie -
public static void append2digits(java.lang.StringBuffer buf,
int i)
buf - i -
public void setHeader(java.lang.String name,
java.lang.String value)
setHeader in interface javax.servlet.http.HttpServletResponsename - The name for the headervalue - The value for the header
public void setIntHeader(java.lang.String name,
int i)
setIntHeader in interface javax.servlet.http.HttpServletResponsename - The header namei - The valuepublic void setLocale(java.util.Locale locale)
setLocale in interface javax.servlet.ServletResponselocale - The localepublic void setStatus(int status)
setStatus in interface javax.servlet.http.HttpServletResponsestatus - The status
@Deprecated
public void setStatus(int status,
java.lang.String msg)
setStatus in interface javax.servlet.http.HttpServletResponsestatus - The statusmsg - The message
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||