Class Overview
Mock implementation of the javax.servlet.http.HttpServletResponse
interface. Supports the Servlet 2.5 API level.
Used for testing the web framework; also useful for testing
application controllers.
Summary
[Expand]
Inherited Constants |
From interface
javax.servlet.http.HttpServletResponse
int |
SC_ACCEPTED |
|
int |
SC_BAD_GATEWAY |
|
int |
SC_BAD_REQUEST |
|
int |
SC_CONFLICT |
|
int |
SC_CONTINUE |
|
int |
SC_CREATED |
|
int |
SC_EXPECTATION_FAILED |
|
int |
SC_FORBIDDEN |
|
int |
SC_FOUND |
|
int |
SC_GATEWAY_TIMEOUT |
|
int |
SC_GONE |
|
int |
SC_HTTP_VERSION_NOT_SUPPORTED |
|
int |
SC_INTERNAL_SERVER_ERROR |
|
int |
SC_LENGTH_REQUIRED |
|
int |
SC_METHOD_NOT_ALLOWED |
|
int |
SC_MOVED_PERMANENTLY |
|
int |
SC_MOVED_TEMPORARILY |
|
int |
SC_MULTIPLE_CHOICES |
|
int |
SC_NON_AUTHORITATIVE_INFORMATION |
|
int |
SC_NOT_ACCEPTABLE |
|
int |
SC_NOT_FOUND |
|
int |
SC_NOT_IMPLEMENTED |
|
int |
SC_NOT_MODIFIED |
|
int |
SC_NO_CONTENT |
|
int |
SC_OK |
|
int |
SC_PARTIAL_CONTENT |
|
int |
SC_PAYMENT_REQUIRED |
|
int |
SC_PRECONDITION_FAILED |
|
int |
SC_PROXY_AUTHENTICATION_REQUIRED |
|
int |
SC_REQUESTED_RANGE_NOT_SATISFIABLE |
|
int |
SC_REQUEST_ENTITY_TOO_LARGE |
|
int |
SC_REQUEST_TIMEOUT |
|
int |
SC_REQUEST_URI_TOO_LONG |
|
int |
SC_RESET_CONTENT |
|
int |
SC_SEE_OTHER |
|
int |
SC_SERVICE_UNAVAILABLE |
|
int |
SC_SWITCHING_PROTOCOLS |
|
int |
SC_TEMPORARY_REDIRECT |
|
int |
SC_UNAUTHORIZED |
|
int |
SC_UNSUPPORTED_MEDIA_TYPE |
|
int |
SC_USE_PROXY |
|
|
Public Methods |
void
|
addCookie(Cookie cookie)
|
void
|
addDateHeader(String name, long value)
|
void
|
addHeader(String name, String value)
|
void
|
addIncludedUrl(String includedUrl)
|
void
|
addIntHeader(String name, int value)
|
boolean
|
containsHeader(String name)
|
String
|
encodeRedirectURL(String url)
The default implementation delegates to encodeURL(String) ,
returning the given URL String as-is.
|
String
|
encodeRedirectUrl(String url)
|
String
|
encodeURL(String url)
The default implementation returns the given URL String as-is.
|
String
|
encodeUrl(String url)
|
void
|
flushBuffer()
|
int
|
getBufferSize()
|
String
|
getCharacterEncoding()
|
byte[]
|
getContentAsByteArray()
|
String
|
getContentAsString()
|
int
|
getContentLength()
|
String
|
getContentType()
|
Cookie
|
getCookie(String name)
|
Cookie[]
|
getCookies()
|
String
|
getErrorMessage()
|
String
|
getForwardedUrl()
|
Object
|
getHeader(String name)
Return the primary value for the given header, if any.
|
Set<String>
|
getHeaderNames()
Return the names of all specified headers as a Set of Strings.
|
List<Object>
|
getHeaders(String name)
Return all values for the given header as a List of value objects.
|
String
|
getIncludedUrl()
|
List<String>
|
getIncludedUrls()
|
Locale
|
getLocale()
|
ServletOutputStream
|
getOutputStream()
|
String
|
getRedirectedUrl()
|
int
|
getStatus()
|
PrintWriter
|
getWriter()
|
boolean
|
isCommitted()
|
boolean
|
isOutputStreamAccessAllowed()
|
boolean
|
isWriterAccessAllowed()
|
void
|
reset()
|
void
|
resetBuffer()
|
void
|
sendError(int status)
|
void
|
sendError(int status, String errorMessage)
|
void
|
sendRedirect(String url)
|
void
|
setBufferSize(int bufferSize)
|
void
|
setCharacterEncoding(String characterEncoding)
|
void
|
setCommitted(boolean committed)
|
void
|
setContentLength(int contentLength)
|
void
|
setContentType(String contentType)
|
void
|
setDateHeader(String name, long value)
|
void
|
setForwardedUrl(String forwardedUrl)
|
void
|
setHeader(String name, String value)
|
void
|
setIncludedUrl(String includedUrl)
|
void
|
setIntHeader(String name, int value)
|
void
|
setLocale(Locale locale)
|
void
|
setOutputStreamAccessAllowed(boolean outputStreamAccessAllowed)
|
void
|
setStatus(int status)
|
void
|
setStatus(int status, String errorMessage)
|
void
|
setWriterAccessAllowed(boolean writerAccessAllowed)
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
javax.servlet.ServletResponse
abstract
void
|
flushBuffer()
|
abstract
int
|
getBufferSize()
|
abstract
String
|
getCharacterEncoding()
|
abstract
String
|
getContentType()
|
abstract
Locale
|
getLocale()
|
abstract
ServletOutputStream
|
getOutputStream()
|
abstract
PrintWriter
|
getWriter()
|
abstract
boolean
|
isCommitted()
|
abstract
void
|
reset()
|
abstract
void
|
resetBuffer()
|
abstract
void
|
setBufferSize(int arg0)
|
abstract
void
|
setCharacterEncoding(String arg0)
|
abstract
void
|
setContentLength(int arg0)
|
abstract
void
|
setContentType(String arg0)
|
abstract
void
|
setLocale(Locale arg0)
|
|
From interface
javax.servlet.http.HttpServletResponse
abstract
void
|
addCookie(Cookie arg0)
|
abstract
void
|
addDateHeader(String arg0, long arg1)
|
abstract
void
|
addHeader(String arg0, String arg1)
|
abstract
void
|
addIntHeader(String arg0, int arg1)
|
abstract
boolean
|
containsHeader(String arg0)
|
abstract
String
|
encodeRedirectURL(String arg0)
|
abstract
String
|
encodeRedirectUrl(String arg0)
|
abstract
String
|
encodeURL(String arg0)
|
abstract
String
|
encodeUrl(String arg0)
|
abstract
void
|
sendError(int arg0, String arg1)
|
abstract
void
|
sendError(int arg0)
|
abstract
void
|
sendRedirect(String arg0)
|
abstract
void
|
setDateHeader(String arg0, long arg1)
|
abstract
void
|
setHeader(String arg0, String arg1)
|
abstract
void
|
setIntHeader(String arg0, int arg1)
|
abstract
void
|
setStatus(int arg0)
|
abstract
void
|
setStatus(int arg0, String arg1)
|
|
Constants
public
static
final
int
DEFAULT_SERVER_PORT
Constant Value:
80
(0x00000050)
Public Constructors
public
MockHttpServletResponse
()
Public Methods
public
void
addCookie
(Cookie cookie)
public
void
addDateHeader
(String name, long value)
public
void
addIncludedUrl
(String includedUrl)
public
void
addIntHeader
(String name, int value)
public
boolean
containsHeader
(String name)
public
String
encodeRedirectURL
(String url)
The default implementation delegates to encodeURL(String)
,
returning the given URL String as-is.
Can be overridden in subclasses, appending a session id or the like
in a redirect-specific fashion. For general URL encoding rules,
override the common encodeURL(String)
method instead, appyling
to redirect URLs as well as to general URLs.
The default implementation returns the given URL String as-is.
Can be overridden in subclasses, appending a session id or the like.
public
void
flushBuffer
()
public
int
getBufferSize
()
public
String
getCharacterEncoding
()
public
byte[]
getContentAsByteArray
()
public
String
getContentAsString
()
public
int
getContentLength
()
public
String
getContentType
()
public
Cookie
getCookie
(String name)
public
Cookie[]
getCookies
()
public
String
getErrorMessage
()
public
String
getForwardedUrl
()
public
Object
getHeader
(String name)
Return the primary value for the given header, if any.
Will return the first value in case of multiple values.
Parameters
name
| the name of the header |
Returns
- the associated header value, or
null if none
public
Set<String>
getHeaderNames
()
Return the names of all specified headers as a Set of Strings.
Returns
- the
Set
of header name Strings
, or an empty Set
if none
Return all values for the given header as a List of value objects.
Parameters
name
| the name of the header |
Returns
- the associated header values, or an empty List if none
public
String
getIncludedUrl
()
public
ServletOutputStream
getOutputStream
()
public
String
getRedirectedUrl
()
public
boolean
isCommitted
()
public
boolean
isOutputStreamAccessAllowed
()
public
boolean
isWriterAccessAllowed
()
public
void
resetBuffer
()
public
void
sendError
(int status)
public
void
sendError
(int status, String errorMessage)
public
void
sendRedirect
(String url)
public
void
setBufferSize
(int bufferSize)
public
void
setCharacterEncoding
(String characterEncoding)
public
void
setCommitted
(boolean committed)
public
void
setContentLength
(int contentLength)
public
void
setContentType
(String contentType)
public
void
setDateHeader
(String name, long value)
public
void
setForwardedUrl
(String forwardedUrl)
public
void
setIncludedUrl
(String includedUrl)
public
void
setIntHeader
(String name, int value)
public
void
setLocale
(Locale locale)
public
void
setOutputStreamAccessAllowed
(boolean outputStreamAccessAllowed)
public
void
setStatus
(int status)
public
void
setStatus
(int status, String errorMessage)
public
void
setWriterAccessAllowed
(boolean writerAccessAllowed)
Set whether getWriter()
access is allowed.
Default is true
.