org.apache.wicket.mock
Class MockWebResponse

java.lang.Object
  extended by org.apache.wicket.request.Response
      extended by org.apache.wicket.request.http.WebResponse
          extended by org.apache.wicket.mock.MockWebResponse

public class MockWebResponse
extends WebResponse

Mocked WebResponse.

Author:
Matej Knopp

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.request.http.WebResponse
WebResponse.CacheScope
 
Field Summary
 
Fields inherited from class org.apache.wicket.request.http.WebResponse
MAX_CACHE_DURATION
 
Constructor Summary
MockWebResponse()
          Construct.
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Add a cookie to the web response
 void addHeader(java.lang.String name, java.lang.String value)
          Add a value to the servlet response stream.
 void clearCookie(javax.servlet.http.Cookie cookie)
          Convenience method for clearing a cookie.
 java.lang.String encodeRedirectURL(java.lang.CharSequence url)
          Encodes urls used to redirect.
 java.lang.String encodeURL(java.lang.CharSequence url)
          Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
 void flush()
          Flushes the response.
 byte[] getBinaryResponse()
           
 java.lang.Object getContainerResponse()
          Provides access to the low-level container response object that implementaion of this Response delegate to.
 java.lang.Long getContentLength()
           
 java.lang.String getContentType()
           
 java.util.List<javax.servlet.http.Cookie> getCookies()
           
 Time getDateHeader(java.lang.String name)
           
 java.lang.String getErrorMessage()
           
 java.lang.String getHeader(java.lang.String name)
           
 java.util.Set<java.lang.String> getHeaderNames()
           
 java.lang.String getRedirectUrl()
           
 java.lang.Integer getStatus()
           
 java.lang.CharSequence getTextResponse()
           
 boolean hasHeader(java.lang.String name)
           
 boolean isRedirect()
           
 void reset()
          Called when the Response needs to reset itself.
 void sendError(int sc, java.lang.String msg)
          Send error status code with optional message.
 void sendRedirect(java.lang.String url)
          Redirects the response to specified URL.
 void setContentLength(long length)
          Set the content length on the response, if appropriate in the subclass.
 void setContentType(java.lang.String mimeType)
          Set the content type on the response, if appropriate in the subclass.
 void setDateHeader(java.lang.String name, Time date)
          Set a header to the date value in the servlet response stream.
 void setHeader(java.lang.String name, java.lang.String value)
          Set a header to the string value in the servlet response stream.
 void setStatus(int sc)
          Sets the status code for this response.
 void write(byte[] array)
          Writes the buffer to output.
 void write(java.lang.CharSequence sequence)
          Writes the CharSequence to output.
 
Methods inherited from class org.apache.wicket.request.http.WebResponse
disableCaching, enableCaching, setAttachmentHeader, setInlineHeader, setLastModifiedTime
 
Methods inherited from class org.apache.wicket.request.Response
close
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockWebResponse

public MockWebResponse()
Construct.

Method Detail

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Description copied from class: WebResponse
Add a cookie to the web response

Specified by:
addCookie in class WebResponse

clearCookie

public void clearCookie(javax.servlet.http.Cookie cookie)
Description copied from class: WebResponse
Convenience method for clearing a cookie.

Specified by:
clearCookie in class WebResponse
Parameters:
cookie - The cookie to set
See Also:
WebResponse.addCookie(Cookie)

getCookies

public java.util.List<javax.servlet.http.Cookie> getCookies()
Returns:
cookies set in this response

sendRedirect

public void sendRedirect(java.lang.String url)
Description copied from class: WebResponse
Redirects the response to specified URL. The implementation is responsible for properly encoding the URL. Implementations of this method should run passed in url parameters throu the #encodeRedirectURL(String) method.

Specified by:
sendRedirect in class WebResponse

getRedirectUrl

public java.lang.String getRedirectUrl()
Returns:
redirect URL or null if sendRedirect(String) was not called.

isRedirect

public boolean isRedirect()
Specified by:
isRedirect in class WebResponse
Returns:
true if redirect URL was set, false otherwise.

setContentLength

public void setContentLength(long length)
Description copied from class: WebResponse
Set the content length on the response, if appropriate in the subclass. This default implementation does nothing.

Specified by:
setContentLength in class WebResponse
Parameters:
length - The length of the content

getContentLength

public java.lang.Long getContentLength()
Returns:
content length (set by setContentLength(long))

setContentType

public void setContentType(java.lang.String mimeType)
Description copied from class: WebResponse
Set the content type on the response, if appropriate in the subclass. This default implementation does nothing.

Specified by:
setContentType in class WebResponse
Parameters:
mimeType - The mime type

getContentType

public java.lang.String getContentType()
Returns:
content mime type

setDateHeader

public void setDateHeader(java.lang.String name,
                          Time date)
Description copied from class: WebResponse
Set a header to the date value in the servlet response stream.

Specified by:
setDateHeader in class WebResponse

getDateHeader

public Time getDateHeader(java.lang.String name)
Parameters:
name -
Returns:
date header with specified name

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Description copied from class: WebResponse
Set a header to the string value in the servlet response stream.

Specified by:
setHeader in class WebResponse

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Description copied from class: WebResponse
Add a value to the servlet response stream.

Specified by:
addHeader in class WebResponse

getHeader

public java.lang.String getHeader(java.lang.String name)
Parameters:
name -
Returns:
header string with specified name

hasHeader

public boolean hasHeader(java.lang.String name)
Parameters:
name -
Returns:
true if the header was set, false otherwise

getHeaderNames

public java.util.Set<java.lang.String> getHeaderNames()
Returns:
set of all header names

setStatus

public void setStatus(int sc)
Description copied from class: WebResponse
Sets the status code for this response.

Specified by:
setStatus in class WebResponse
Parameters:
sc - status code

getStatus

public java.lang.Integer getStatus()
Returns:
status code or null if status was not set

encodeURL

public java.lang.String encodeURL(java.lang.CharSequence url)
Description copied from class: Response
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.

Specified by:
encodeURL in class Response
Returns:
encoded URL

encodeRedirectURL

public java.lang.String encodeRedirectURL(java.lang.CharSequence url)
Description copied from class: WebResponse
Encodes urls used to redirect. Sometimes rules for encoding URLs for redirecting differ from encoding URLs for links, so this method is broken out away form Response.encodeURL(CharSequence).

Specified by:
encodeRedirectURL in class WebResponse
Returns:
encoded URL

write

public void write(java.lang.CharSequence sequence)
Description copied from class: Response
Writes the CharSequence to output.

Specified by:
write in class Response

getTextResponse

public java.lang.CharSequence getTextResponse()
Returns:
text response

write

public void write(byte[] array)
Description copied from class: Response
Writes the buffer to output.

Specified by:
write in class Response

getBinaryResponse

public byte[] getBinaryResponse()
Returns:
binary response

sendError

public void sendError(int sc,
                      java.lang.String msg)
Description copied from class: WebResponse
Send error status code with optional message.

Specified by:
sendError in class WebResponse

getErrorMessage

public java.lang.String getErrorMessage()
Returns:
error message

flush

public void flush()
Description copied from class: WebResponse
Flushes the response.

Specified by:
flush in class WebResponse

reset

public void reset()
Description copied from class: Response
Called when the Response needs to reset itself. Subclasses can empty there buffer or build up state.

Overrides:
reset in class Response

getContainerResponse

public java.lang.Object getContainerResponse()
Description copied from class: Response
Provides access to the low-level container response object that implementaion of this Response delegate to. This allows users to access features provided by the container response but not by generalized Wicket Response objects.

Specified by:
getContainerResponse in class Response
Returns:
low-level container response object, or null if none


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.