|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object servletunit.HttpServletResponseSimulator
Constructor Summary | |
HttpServletResponseSimulator()
|
Method Summary | |
void |
addCookie(Cookie cookie)
Add a cookie to this response, which will then be stored in the browser. |
void |
addDateHeader(java.lang.String name,
long date)
This method is not supported. |
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a response header with the given name and value. |
void |
addIntHeader(java.lang.String name,
int value)
Adds a response header with the given name and integer value. |
boolean |
containsHeader(java.lang.String name)
returns true if a header with the given name has already been set |
java.lang.String |
encodeRedirectUrl(java.lang.String url)
Returns the given URL unmodified |
java.lang.String |
encodeRedirectURL(java.lang.String url)
Returns the given URL unmodified. |
java.lang.String |
encodeUrl(java.lang.String url)
Returns the given URL unmodified. |
java.lang.String |
encodeURL(java.lang.String url)
Returns the given URL unmodified |
Cookie |
findCookie(java.lang.String name)
Returns a cookie with a given, or null if this cookie has not been added to the repsonse. |
void |
flushBuffer()
This method is not supported. |
int |
getBufferSize()
This method is not supported. |
java.lang.String |
getCharacterEncoding()
This method is not supported. |
int |
getContentLength()
returns the content length previously set in setContentLength() |
java.lang.String |
getContentType()
returns the content type previously set in setContentType() |
java.lang.String |
getHeader(java.lang.String name)
Returns a given header field, or null if this header has not been set. |
java.util.Locale |
getLocale()
Returns the locale assigned to the response. |
java.lang.String |
getMessage()
|
ServletOutputStream |
getOutputStream()
Returns a ServletOutputStream suitable for writing binary
data in the response. |
int |
getStatusCode()
Returns the status code for this response, which is useful for testing expected errors. |
java.io.PrintWriter |
getWriter()
Returns a PrintWriter object that
can send character text to the client. |
java.lang.StringBuffer |
getWriterBuffer()
Use this method to pick up the string buffer which will hold the contents of the string buffer. |
boolean |
isCommitted()
|
void |
removeHeader(java.lang.String name)
Removes a given header |
void |
reset()
Reinitializes all local variables. |
void |
resetBuffer()
This method is not supported. |
void |
sendError(int sc)
Sends an error response to the client using the specified status clearing the buffer. |
void |
sendError(int sc,
java.lang.String msg)
Sends an error response to the client using the specified status clearing the buffer. |
void |
sendRedirect(java.lang.String location)
Resets the response and sets the appropriate redirect headers. |
void |
setBufferSize(int size)
This method is not supported. |
void |
setCharacterEncoding(java.lang.String charEncoding)
|
void |
setContentLength(int len)
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header. |
void |
setContentType(java.lang.String type)
Sets the content type of the response being sent to the client. |
void |
setDateHeader(java.lang.String name,
long date)
This method is not supported. |
void |
setHeader(java.lang.String name,
java.lang.String value)
adds the name/value pair to the headers |
void |
setIntHeader(java.lang.String name,
int value)
Adds the given name/value pair to the headers collection. |
void |
setIsCommitted(boolean isCommitted)
|
void |
setLocale(java.util.Locale loc)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. |
void |
setOutputStream(java.io.OutputStream out)
The default action of calling the getOutputStream method
is to return a javax.servlet.ServletOutputStream object
that sends the data to System.out . |
void |
setStatus(int sc)
Sets the given status code. |
void |
setStatus(int sc,
java.lang.String sm)
Sets the given status and an associated message. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SC_CONTINUE
public static final int SC_SWITCHING_PROTOCOLS
public static final int SC_OK
public static final int SC_CREATED
public static final int SC_ACCEPTED
public static final int SC_NON_AUTHORITATIVE_INFORMATION
public static final int SC_NO_CONTENT
public static final int SC_RESET_CONTENT
public static final int SC_PARTIAL_CONTENT
public static final int SC_MULTIPLE_CHOICES
public static final int SC_MOVED_PERMANENTLY
public static final int SC_MOVED_TEMPORARILY
public static final int SC_SEE_OTHER
public static final int SC_NOT_MODIFIED
public static final int SC_USE_PROXY
public static final int SC_BAD_REQUEST
public static final int SC_UNAUTHORIZED
public static final int SC_PAYMENT_REQUIRED
public static final int SC_FORBIDDEN
public static final int SC_NOT_FOUND
public static final int SC_METHOD_NOT_ALLOWED
public static final int SC_NOT_ACCEPTABLE
public static final int SC_PROXY_AUTHENTICATION_REQUIRED
public static final int SC_REQUEST_TIMEOUT
public static final int SC_CONFLICT
public static final int SC_GONE
public static final int SC_LENGTH_REQUIRED
public static final int SC_PRECONDITION_FAILED
public static final int SC_REQUEST_ENTITY_TOO_LARGE
public static final int SC_REQUEST_URI_TOO_LONG
public static final int SC_UNSUPPORTED_MEDIA_TYPE
public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE
public static final int SC_EXPECTATION_FAILED
public static final int SC_INTERNAL_SERVER_ERROR
public static final int SC_NOT_IMPLEMENTED
public static final int SC_BAD_GATEWAY
public static final int SC_SERVICE_UNAVAILABLE
public static final int SC_GATEWAY_TIMEOUT
public static final int SC_HTTP_VERSION_NOT_SUPPORTED
Constructor Detail |
public HttpServletResponseSimulator()
Method Detail |
public void addCookie(Cookie cookie)
public Cookie findCookie(java.lang.String name)
public void addDateHeader(java.lang.String name, long date)
public void addHeader(java.lang.String name, java.lang.String value)
public java.lang.String getHeader(java.lang.String name)
public void addIntHeader(java.lang.String name, int value)
public boolean containsHeader(java.lang.String name)
public java.lang.String encodeRedirectUrl(java.lang.String url)
public java.lang.String encodeRedirectURL(java.lang.String url)
public java.lang.String encodeUrl(java.lang.String url)
public java.lang.String encodeURL(java.lang.String url)
public void flushBuffer() throws java.io.IOException
java.io.IOException
public int getBufferSize()
public java.lang.String getCharacterEncoding()
public java.util.Locale getLocale()
setLocale(java.util.Locale)
public ServletOutputStream getOutputStream() throws java.io.IOException
ServletOutputStream
suitable for writing binary
data in the response. The servlet container does not encode the
binary data.
Calling flush() on the ServletOutputStream commits the response.
Either this method or getWriter()
may
be called to write the body, not both.
ServletOutputStream
for writing binary data
java.lang.IllegalStateException
- if the getWriter
method
has been called on this response
java.io.IOException
- if an input or output exception occurredgetWriter()
public java.io.PrintWriter getWriter() throws java.io.IOException
PrintWriter
object that
can send character text to the client.
The character encoding used is the one specified
in the charset=
property of the
setContentType(java.lang.String)
method, which must be called
before calling this method for the charset to take effect.
If necessary, the MIME type of the response is modified to reflect the character encoding used.
Calling flush() on the PrintWriter commits the response.
Either this method or getOutputStream()
may be called
to write the body, not both.
PrintWriter
object that
can return character data to the client
java.io.UnsupportedEncodingException
- if the charset specified in
setContentType
cannot be
used
java.lang.IllegalStateException
- if the getOutputStream
method has already been called for this
response object
java.io.IOException
- if an input or output exception occurredgetOutputStream()
,
setContentType(java.lang.String)
public java.lang.StringBuffer getWriterBuffer()
public boolean isCommitted()
public void setIsCommitted(boolean isCommitted)
public void reset()
public void resetBuffer()
public void sendError(int sc) throws java.io.IOException
sc
- the error status code
java.io.IOException
public void sendError(int sc, java.lang.String msg) throws java.io.IOException
sc
- the error status codemsg
- the descriptive message
java.io.IOException
public void sendRedirect(java.lang.String location) throws java.io.IOException
java.io.IOException
public void setBufferSize(int size)
public void setContentLength(int len)
len
- an integer specifying the length of the
content being returned to the client; sets
the Content-Length headerpublic int getContentLength()
public void setContentType(java.lang.String type)
text/html; charset=ISO-8859-4
.
If obtaining a PrintWriter
, this method should be
called first.
type
- a String
specifying the MIME
type of the contentgetOutputStream()
,
getWriter()
public java.lang.String getContentType()
public void setDateHeader(java.lang.String name, long date)
public void setHeader(java.lang.String name, java.lang.String value)
public void removeHeader(java.lang.String name)
public void setIntHeader(java.lang.String name, int value)
public void setLocale(java.util.Locale loc)
getWriter()
. By default, the response locale
is the default locale for the server.
loc
- the locale of the responsegetLocale()
public void setOutputStream(java.io.OutputStream out)
getOutputStream
method
is to return a javax.servlet.ServletOutputStream
object
that sends the data to System.out
. If you don't want
the output sent to System.out
you can use this method to
set where the output will go. Please note, subsequent calls to
getOutputStream
will reset the output path to
System.out
. This prevents the OutputStream returned by
calling getOutputStream from writing to a closed stream
out
- The java.io.OutputStream
that represents
the real path of the output.public void setStatus(int sc)
public void setStatus(int sc, java.lang.String sm)
public int getStatusCode()
public void setCharacterEncoding(java.lang.String charEncoding)
public java.lang.String getMessage()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |