Fish & Chips Club 4.10.0.0

hirondelle.fish.test.doubles
Class FakeResponse

Object
  extended by hirondelle.fish.test.doubles.FakeResponse
All Implemented Interfaces:
HttpServletResponse, ServletResponse

public final class FakeResponse
extends Object
implements HttpServletResponse

Fake implementation of HttpServletResponse, used only for testing outside of the regular runtime environment. Internally, a fake ServletOutputStream is used here, which simply places the response data in a simple byte array held in memory, with no other ultimate destination such as a file or another stream. Thus, flush and close are no-operations, and there is no reason to use buffering with such a stream.

Methods associated with buffering are no-operations.


Nested Class Summary
static class FakeResponse.Header
          Holds simple name-value pairs.
 
Field Summary
 
Fields inherited from interface HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, 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
FakeResponse()
           
 
Method Summary
 void addCookie(Cookie aCookie)
           
 void addDateHeader(String aName, long aValue)
           
 void addHeader(String aName, String aValue)
           
 void addIntHeader(String aName, int aValue)
           
 boolean containsHeader(String aName)
           
 String encodeRedirectUrl(String arg0)
          Deprecated.
 String encodeRedirectURL(String aURL)
          Returns the argument unchanged.
 String encodeUrl(String arg0)
          Deprecated.
 String encodeURL(String aURL)
          Returns the argument unchanged.
 void flushBuffer()
          No-operation.
 int getBufferSize()
           
 String getCharacterEncoding()
           
 String getContentType()
           
 List<Cookie> getCookies()
          Return the cookies that have been passed to this object.
 String getFinalResponse(String aEncoding)
          Return the response as a String.
 byte[] getFinalResponseAsBytes()
          Return the response as a byte[].
 List<FakeResponse.Header> getHeaders()
          Return all headers associated with the response.
 Locale getLocale()
           
 ServletOutputStream getOutputStream()
           
 int getStatus()
          Return the response status code.
 PrintWriter getWriter()
           
 boolean isCommitted()
          Returns true is anything has been written to the in-memory stream.
 void reset()
          No-operation.
 void resetBuffer()
          No-operation.
 void sendError(int aStatusCode)
           
 void sendError(int aStatusCode, String aMessage)
           
 void sendRedirect(String aLocation)
           
 void setBufferSize(int aBufferSize)
           
 void setCharacterEncoding(String aEncoding)
           
 void setContentLength(int aLength)
          No-operation.
 void setContentType(String aContentType)
           
 void setDateHeader(String aName, long aValue)
           
 void setHeader(String aName, String aValue)
           
 void setIntHeader(String aName, int aValue)
           
 void setLocale(Locale aLocale)
          Does not set the character encoding.
 void setStatus(int aStatusCode)
           
 void setStatus(int aStatusCode, String aStatusMessage)
          Not implemented - deprecated.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FakeResponse

public FakeResponse()
Method Detail

getFinalResponse

public String getFinalResponse(String aEncoding)
Return the response as a String. Method added for testing.


getFinalResponseAsBytes

public byte[] getFinalResponseAsBytes()
Return the response as a byte[]. Method added for testing.


getCookies

public List<Cookie> getCookies()
Return the cookies that have been passed to this object. Method added for testing.


getStatus

public int getStatus()
Return the response status code. Method added for testing.


getHeaders

public List<FakeResponse.Header> getHeaders()
Return all headers associated with the response. Method added for testing.


getCharacterEncoding

public String getCharacterEncoding()
Specified by:
getCharacterEncoding in interface ServletResponse

setCharacterEncoding

public void setCharacterEncoding(String aEncoding)
Specified by:
setCharacterEncoding in interface ServletResponse

getContentType

public String getContentType()
Specified by:
getContentType in interface ServletResponse

setContentType

public void setContentType(String aContentType)
Specified by:
setContentType in interface ServletResponse

getLocale

public Locale getLocale()
Specified by:
getLocale in interface ServletResponse

setLocale

public void setLocale(Locale aLocale)
Does not set the character encoding.

Specified by:
setLocale in interface ServletResponse

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws IOException
Specified by:
getOutputStream in interface ServletResponse
Throws:
IOException

getWriter

public PrintWriter getWriter()
                      throws IOException
Specified by:
getWriter in interface ServletResponse
Throws:
IOException

setContentLength

public void setContentLength(int aLength)
No-operation.

Specified by:
setContentLength in interface ServletResponse

getBufferSize

public int getBufferSize()
Specified by:
getBufferSize in interface ServletResponse

setBufferSize

public void setBufferSize(int aBufferSize)
Specified by:
setBufferSize in interface ServletResponse

flushBuffer

public void flushBuffer()
                 throws IOException
No-operation.

Specified by:
flushBuffer in interface ServletResponse
Throws:
IOException

resetBuffer

public void resetBuffer()
No-operation.

Specified by:
resetBuffer in interface ServletResponse

isCommitted

public boolean isCommitted()
Returns true is anything has been written to the in-memory stream.

Specified by:
isCommitted in interface ServletResponse

reset

public void reset()
No-operation.

Specified by:
reset in interface ServletResponse

addCookie

public void addCookie(Cookie aCookie)
Specified by:
addCookie in interface HttpServletResponse

setStatus

public void setStatus(int aStatusCode)
Specified by:
setStatus in interface HttpServletResponse

setStatus

public void setStatus(int aStatusCode,
                      String aStatusMessage)
Not implemented - deprecated.

Specified by:
setStatus in interface HttpServletResponse

containsHeader

public boolean containsHeader(String aName)
Specified by:
containsHeader in interface HttpServletResponse

addHeader

public void addHeader(String aName,
                      String aValue)
Specified by:
addHeader in interface HttpServletResponse

setHeader

public void setHeader(String aName,
                      String aValue)
Specified by:
setHeader in interface HttpServletResponse

addIntHeader

public void addIntHeader(String aName,
                         int aValue)
Specified by:
addIntHeader in interface HttpServletResponse

setIntHeader

public void setIntHeader(String aName,
                         int aValue)
Specified by:
setIntHeader in interface HttpServletResponse

addDateHeader

public void addDateHeader(String aName,
                          long aValue)
Specified by:
addDateHeader in interface HttpServletResponse

setDateHeader

public void setDateHeader(String aName,
                          long aValue)
Specified by:
setDateHeader in interface HttpServletResponse

encodeURL

public String encodeURL(String aURL)
Returns the argument unchanged.

Specified by:
encodeURL in interface HttpServletResponse

encodeRedirectURL

public String encodeRedirectURL(String aURL)
Returns the argument unchanged.

Specified by:
encodeRedirectURL in interface HttpServletResponse

encodeUrl

public String encodeUrl(String arg0)
Deprecated. Returns null.

Specified by:
encodeUrl in interface HttpServletResponse

encodeRedirectUrl

public String encodeRedirectUrl(String arg0)
Deprecated. Returns null.

Specified by:
encodeRedirectUrl in interface HttpServletResponse

sendError

public void sendError(int aStatusCode)
               throws IOException
Specified by:
sendError in interface HttpServletResponse
Throws:
IOException

sendError

public void sendError(int aStatusCode,
                      String aMessage)
               throws IOException
Specified by:
sendError in interface HttpServletResponse
Throws:
IOException

sendRedirect

public void sendRedirect(String aLocation)
                  throws IOException
Specified by:
sendRedirect in interface HttpServletResponse
Throws:
IOException

Fish & Chips Club 4.10.0.0

Copyright Hirondelle Systems - Generated 2013Oct19.12.26