|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.fish.test.doubles.FakeRequest
public final class FakeRequest
Fake implementation of HttpServletRequest
, used
only for testing outside of the regular runtime environment.
Various methods have been added to make testing more convenient.
The logInAuthenticatedUser(String, List)
method allows you
to mimic an authenticated user.
Nested Class Summary | |
---|---|
static class |
FakeRequest.HttpMethod
Used by factory methods to distinguish between GET and POST requests. |
Field Summary |
---|
Fields inherited from interface HttpServletRequest |
---|
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
Constructor Summary | |
---|---|
FakeRequest(String aScheme,
String aServerName,
Integer aServerPort,
String aContextPath,
String aServletMatchingPath,
String aExtraPath,
String aQueryString,
FakeRequest.HttpMethod aMethod)
Full constructor. |
Method Summary | |
---|---|
void |
addCookie(String aName,
String aValue)
Method added for testing. |
void |
addHeader(String aName,
String aValue)
Date/time headers must use RFC 1123 format. |
void |
addParameter(String aName,
String aValue)
Method added for testing. |
static FakeRequest |
forGET(String aServletMatchingPath,
String aQueryString)
Factory method for GET requests . |
static FakeRequest |
forPOST(String aServletMatchingPath,
String aQueryString)
Factory method for POST requests . |
Object |
getAttribute(String aName)
|
Enumeration |
getAttributeNames()
|
String |
getAuthType()
Returns null - not authenticated. |
String |
getCharacterEncoding()
Default value 'UTF-8'. |
int |
getContentLength()
Default value 0. |
String |
getContentType()
Default value 'text/html'. |
String |
getContextPath()
|
Cookie[] |
getCookies()
|
long |
getDateHeader(String aName)
|
String |
getHeader(String aName)
|
Enumeration |
getHeaderNames()
|
Enumeration |
getHeaders(String aName)
|
ServletInputStream |
getInputStream()
Returns null - not implemented. |
int |
getIntHeader(String aName)
|
String |
getLocalAddr()
Default value '127.0.0.1'. |
Locale |
getLocale()
Default value Locale.ENGLISH. |
Enumeration |
getLocales()
Returns only one Locale. |
String |
getLocalName()
Default value '127.0.0.1'. |
int |
getLocalPort()
Default value 8080. |
String |
getMethod()
|
String |
getParameter(String aName)
|
Map |
getParameterMap()
|
Enumeration |
getParameterNames()
|
String[] |
getParameterValues(String aName)
|
String |
getPathInfo()
|
String |
getPathTranslated()
Returns null - not implemented. |
String |
getProtocol()
|
String |
getQueryString()
Created from the given request parameters. |
BufferedReader |
getReader()
Returns null - not implemented. |
String |
getRealPath(String aPath)
Returns null - deprecated. |
String |
getRemoteAddr()
Default value '127.0.0.1'. |
String |
getRemoteHost()
Default value '127.0.0.1'. |
int |
getRemotePort()
Default value '80'. |
String |
getRemoteUser()
|
RequestDispatcher |
getRequestDispatcher(String aPath)
Returns null - not implemented. |
String |
getRequestedSessionId()
|
String |
getRequestURI()
|
StringBuffer |
getRequestURL()
|
String |
getScheme()
Default value 'http'. |
String |
getServerName()
Default value 'Test Double'. |
int |
getServerPort()
Default value 8080. |
String |
getServletPath()
|
HttpSession |
getSession()
|
HttpSession |
getSession(boolean aCreateNew)
|
Principal |
getUserPrincipal()
|
boolean |
isRequestedSessionIdFromCookie()
Hard-code to true. |
boolean |
isRequestedSessionIdFromUrl()
Hard-code to false. |
boolean |
isRequestedSessionIdFromURL()
Hard-code to false. |
boolean |
isRequestedSessionIdValid()
|
boolean |
isSecure()
|
boolean |
isUserInRole(String aRole)
|
void |
logInAuthenticatedUser(String aUserName,
List<String> aRoles)
Method added for testing. |
void |
removeAttribute(String aName)
|
void |
setAttribute(String aName,
Object aObject)
|
void |
setCharacterEncoding(String aEncoding)
|
void |
setContentLength(int aContentLength)
Method added for testing. |
void |
setContentType(String aContentType)
Method added for testing. |
void |
setIsSecure(boolean aIsSecure)
Method added for testing. |
void |
setLocale(Locale aLocale)
Method added for testing. |
void |
setProtocol(String aProtocol)
Method added for testing. |
void |
setRemoteAddr(String aRemoteAddr)
Method added for testing. |
void |
setRemoteHost(String aRemoteHost)
Method added for testing. |
void |
setRemotePort(int aRemotePort)
Method added for testing. |
void |
setRequestedSessionId(String aSessionId)
Method added for testing. |
void |
setScheme(String aScheme)
Method added for testing. |
void |
setServerName(String aServerName)
Method added for testing. |
void |
setServerPort(int aServerPort)
Method added for testing. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FakeRequest(String aScheme, String aServerName, Integer aServerPort, String aContextPath, String aServletMatchingPath, String aExtraPath, String aQueryString, FakeRequest.HttpMethod aMethod)
Method Detail |
---|
public static FakeRequest forGET(String aServletMatchingPath, String aQueryString)
public static FakeRequest forPOST(String aServletMatchingPath, String aQueryString)
public void setContentType(String aContentType)
public void setContentLength(int aContentLength)
public void setProtocol(String aProtocol)
public void setScheme(String aScheme)
public void setServerName(String aServerName)
public void setServerPort(int aServerPort)
public void setRemoteAddr(String aRemoteAddr)
public void setRemoteHost(String aRemoteHost)
public void setIsSecure(boolean aIsSecure)
public void setRemotePort(int aRemotePort)
public void setLocale(Locale aLocale)
public void addCookie(String aName, String aValue)
public void addParameter(String aName, String aValue)
public void addHeader(String aName, String aValue)
public void logInAuthenticatedUser(String aUserName, List<String> aRoles)
public void setRequestedSessionId(String aSessionId)
public Object getAttribute(String aName)
getAttribute
in interface ServletRequest
public Enumeration getAttributeNames()
getAttributeNames
in interface ServletRequest
public void setAttribute(String aName, Object aObject)
setAttribute
in interface ServletRequest
public void removeAttribute(String aName)
removeAttribute
in interface ServletRequest
public String getCharacterEncoding()
getCharacterEncoding
in interface ServletRequest
public void setCharacterEncoding(String aEncoding) throws UnsupportedEncodingException
setCharacterEncoding
in interface ServletRequest
UnsupportedEncodingException
public int getContentLength()
getContentLength
in interface ServletRequest
public String getContentType()
getContentType
in interface ServletRequest
public String getParameter(String aName)
getParameter
in interface ServletRequest
public Enumeration getParameterNames()
getParameterNames
in interface ServletRequest
public String[] getParameterValues(String aName)
getParameterValues
in interface ServletRequest
public Map getParameterMap()
getParameterMap
in interface ServletRequest
public String getProtocol()
getProtocol
in interface ServletRequest
public String getScheme()
getScheme
in interface ServletRequest
public String getServerName()
getServerName
in interface ServletRequest
public int getServerPort()
getServerPort
in interface ServletRequest
public String getLocalAddr()
getLocalAddr
in interface ServletRequest
public String getLocalName()
getLocalName
in interface ServletRequest
public int getLocalPort()
getLocalPort
in interface ServletRequest
public String getRemoteAddr()
getRemoteAddr
in interface ServletRequest
public String getRemoteHost()
getRemoteHost
in interface ServletRequest
public int getRemotePort()
getRemotePort
in interface ServletRequest
public Locale getLocale()
getLocale
in interface ServletRequest
public Enumeration getLocales()
getLocales
in interface ServletRequest
public boolean isSecure()
isSecure
in interface ServletRequest
public RequestDispatcher getRequestDispatcher(String aPath)
getRequestDispatcher
in interface ServletRequest
public String getRealPath(String aPath)
getRealPath
in interface ServletRequest
public ServletInputStream getInputStream() throws IOException
getInputStream
in interface ServletRequest
IOException
public BufferedReader getReader() throws IOException
getReader
in interface ServletRequest
IOException
public String getAuthType()
getAuthType
in interface HttpServletRequest
public Cookie[] getCookies()
getCookies
in interface HttpServletRequest
public long getDateHeader(String aName)
getDateHeader
in interface HttpServletRequest
public String getHeader(String aName)
getHeader
in interface HttpServletRequest
public Enumeration getHeaders(String aName)
getHeaders
in interface HttpServletRequest
public Enumeration getHeaderNames()
getHeaderNames
in interface HttpServletRequest
public int getIntHeader(String aName)
getIntHeader
in interface HttpServletRequest
public String getMethod()
getMethod
in interface HttpServletRequest
public String getPathInfo()
getPathInfo
in interface HttpServletRequest
public String getPathTranslated()
getPathTranslated
in interface HttpServletRequest
public String getContextPath()
getContextPath
in interface HttpServletRequest
public String getQueryString()
getQueryString
in interface HttpServletRequest
public String getRemoteUser()
getRemoteUser
in interface HttpServletRequest
public boolean isUserInRole(String aRole)
isUserInRole
in interface HttpServletRequest
public Principal getUserPrincipal()
getUserPrincipal
in interface HttpServletRequest
public String getRequestURI()
getRequestURI
in interface HttpServletRequest
public StringBuffer getRequestURL()
getRequestURL
in interface HttpServletRequest
public String getServletPath()
getServletPath
in interface HttpServletRequest
public String getRequestedSessionId()
getRequestedSessionId
in interface HttpServletRequest
public boolean isRequestedSessionIdValid()
isRequestedSessionIdValid
in interface HttpServletRequest
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie
in interface HttpServletRequest
public boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL
in interface HttpServletRequest
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl
in interface HttpServletRequest
public HttpSession getSession(boolean aCreateNew)
getSession
in interface HttpServletRequest
public HttpSession getSession()
getSession
in interface HttpServletRequest
|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |