|
Fish & Chips Club 4.7.1.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objecthirondelle.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 ServletRequestpublic Enumeration getAttributeNames()
getAttributeNames in interface ServletRequest
public void setAttribute(String aName,
Object aObject)
setAttribute in interface ServletRequestpublic void removeAttribute(String aName)
removeAttribute in interface ServletRequestpublic String getCharacterEncoding()
getCharacterEncoding in interface ServletRequest
public void setCharacterEncoding(String aEncoding)
throws UnsupportedEncodingException
setCharacterEncoding in interface ServletRequestUnsupportedEncodingExceptionpublic int getContentLength()
getContentLength in interface ServletRequestpublic String getContentType()
getContentType in interface ServletRequestpublic String getParameter(String aName)
getParameter in interface ServletRequestpublic Enumeration getParameterNames()
getParameterNames in interface ServletRequestpublic String[] getParameterValues(String aName)
getParameterValues in interface ServletRequestpublic Map getParameterMap()
getParameterMap in interface ServletRequestpublic String getProtocol()
getProtocol in interface ServletRequestpublic String getScheme()
getScheme in interface ServletRequestpublic String getServerName()
getServerName in interface ServletRequestpublic int getServerPort()
getServerPort in interface ServletRequestpublic String getLocalAddr()
getLocalAddr in interface ServletRequestpublic String getLocalName()
getLocalName in interface ServletRequestpublic int getLocalPort()
getLocalPort in interface ServletRequestpublic String getRemoteAddr()
getRemoteAddr in interface ServletRequestpublic String getRemoteHost()
getRemoteHost in interface ServletRequestpublic int getRemotePort()
getRemotePort in interface ServletRequestpublic Locale getLocale()
getLocale in interface ServletRequestpublic Enumeration getLocales()
getLocales in interface ServletRequestpublic boolean isSecure()
isSecure in interface ServletRequestpublic RequestDispatcher getRequestDispatcher(String aPath)
getRequestDispatcher in interface ServletRequestpublic String getRealPath(String aPath)
getRealPath in interface ServletRequest
public ServletInputStream getInputStream()
throws IOException
getInputStream in interface ServletRequestIOException
public BufferedReader getReader()
throws IOException
getReader in interface ServletRequestIOExceptionpublic String getAuthType()
getAuthType in interface HttpServletRequestpublic Cookie[] getCookies()
getCookies in interface HttpServletRequestpublic long getDateHeader(String aName)
getDateHeader in interface HttpServletRequestpublic String getHeader(String aName)
getHeader in interface HttpServletRequestpublic Enumeration getHeaders(String aName)
getHeaders in interface HttpServletRequestpublic Enumeration getHeaderNames()
getHeaderNames in interface HttpServletRequestpublic int getIntHeader(String aName)
getIntHeader in interface HttpServletRequestpublic String getMethod()
getMethod in interface HttpServletRequestpublic String getPathInfo()
getPathInfo in interface HttpServletRequestpublic String getPathTranslated()
getPathTranslated in interface HttpServletRequestpublic String getContextPath()
getContextPath in interface HttpServletRequestpublic String getQueryString()
getQueryString in interface HttpServletRequestpublic String getRemoteUser()
getRemoteUser in interface HttpServletRequestpublic boolean isUserInRole(String aRole)
isUserInRole in interface HttpServletRequestpublic Principal getUserPrincipal()
getUserPrincipal in interface HttpServletRequestpublic String getRequestURI()
getRequestURI in interface HttpServletRequestpublic StringBuffer getRequestURL()
getRequestURL in interface HttpServletRequestpublic String getServletPath()
getServletPath in interface HttpServletRequestpublic String getRequestedSessionId()
getRequestedSessionId in interface HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface HttpServletRequestpublic boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface HttpServletRequestpublic HttpSession getSession(boolean aCreateNew)
getSession in interface HttpServletRequestpublic HttpSession getSession()
getSession in interface HttpServletRequest
|
Fish & Chips Club 4.7.1.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||