|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.seam.mock.EnhancedMockHttpServletRequest
public class EnhancedMockHttpServletRequest
Mock implementation of the HttpServletRequest
interface. Supports the Servlet 2.4 API level.
Used for testing the web framework; also useful for testing application controllers.
| Field Summary | |
|---|---|
static String |
DEFAULT_PROTOCOL
The default protocol: 'http'. |
static String |
DEFAULT_REMOTE_ADDR
The default remote address: '127.0.0.1'. |
static String |
DEFAULT_REMOTE_HOST
The default remote host: 'localhost'. |
static String |
DEFAULT_SERVER_ADDR
The default server address: '127.0.0.1'. |
static String |
DEFAULT_SERVER_NAME
The default server name: 'localhost'. |
static int |
DEFAULT_SERVER_PORT
The default server port: '80'. |
| Fields inherited from interface javax.servlet.http.HttpServletRequest |
|---|
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
| Constructor Summary | |
|---|---|
EnhancedMockHttpServletRequest()
Create a new MockHttpServletRequest with a default MockServletContext. |
|
EnhancedMockHttpServletRequest(javax.servlet.http.HttpSession session)
|
|
EnhancedMockHttpServletRequest(javax.servlet.http.HttpSession session,
String principalName,
Set<String> principalRoles)
|
|
EnhancedMockHttpServletRequest(javax.servlet.http.HttpSession session,
String principalName,
Set<String> principalRoles,
javax.servlet.http.Cookie[] cookies,
String method)
|
|
EnhancedMockHttpServletRequest(javax.servlet.ServletContext servletContext)
Create a new MockHttpServletRequest. |
|
EnhancedMockHttpServletRequest(javax.servlet.ServletContext servletContext,
String method,
String requestURI)
Create a new MockHttpServletRequest. |
|
EnhancedMockHttpServletRequest(String method,
String requestURI)
Create a new MockHttpServletRequest with a default MockServletContext. |
|
| Method Summary | |
|---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
|
void |
addHeader(String name,
Object value)
Add a header entry for the given name. |
void |
addParameter(String name,
String value)
Add a single value for the specified HTTP parameter. |
void |
addParameter(String name,
String[] values)
Add an array of values for the specified HTTP parameter. |
void |
addParameters(Map params)
Adds all provided parameters |
void |
addPreferredLocale(Locale locale)
Add a new preferred locale, before any existing locales. |
void |
addQueryParameter(String name,
String value)
Add a query parameter that will be appended to the URI query string. |
void |
addRole(String role)
Deprecated. in favor of addUserRole |
void |
addUserRole(String role)
|
protected void |
checkActive()
Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore. |
void |
clearAttributes()
Clear all of this request's attributes. |
void |
close()
Mark this request as completed, keeping its state. |
Object |
getAttribute(String name)
|
Enumeration |
getAttributeNames()
|
String |
getAuthType()
|
String |
getCharacterEncoding()
|
int |
getContentLength()
|
String |
getContentType()
|
String |
getContextPath()
|
javax.servlet.http.Cookie[] |
getCookies()
|
long |
getDateHeader(String name)
|
String |
getHeader(String name)
|
Enumeration |
getHeaderNames()
|
Map<String,String[]> |
getHeaders()
|
Enumeration |
getHeaders(String name)
|
javax.servlet.ServletInputStream |
getInputStream()
|
int |
getIntHeader(String name)
|
String |
getLocalAddr()
|
Locale |
getLocale()
|
Enumeration |
getLocales()
|
String |
getLocalName()
|
int |
getLocalPort()
|
String |
getMethod()
|
String |
getParameter(String name)
|
Map |
getParameterMap()
|
Enumeration |
getParameterNames()
|
Map<String,String[]> |
getParameters()
|
String[] |
getParameterValues(String name)
|
String |
getPathInfo()
|
String |
getPathTranslated()
|
String |
getProtocol()
|
Map<String,String> |
getQueryParameters()
|
String |
getQueryString()
|
BufferedReader |
getReader()
|
String |
getRealPath(String path)
|
String |
getRemoteAddr()
|
String |
getRemoteHost()
|
int |
getRemotePort()
|
String |
getRemoteUser()
|
javax.servlet.RequestDispatcher |
getRequestDispatcher(String path)
|
String |
getRequestedSessionId()
|
String |
getRequestURI()
|
StringBuffer |
getRequestURL()
|
String |
getScheme()
|
String |
getServerName()
|
int |
getServerPort()
|
javax.servlet.ServletContext |
getServletContext()
Return the ServletContext that this request is associated with. |
String |
getServletPath()
|
javax.servlet.http.HttpSession |
getSession()
|
javax.servlet.http.HttpSession |
getSession(boolean create)
|
Principal |
getUserPrincipal()
|
void |
invalidate()
Invalidate this request, clearing its state. |
boolean |
isActive()
Return whether this request is still active (that is, not completed yet). |
boolean |
isAllParametersInQueryString()
|
boolean |
isRequestedSessionIdFromCookie()
|
boolean |
isRequestedSessionIdFromUrl()
|
boolean |
isRequestedSessionIdFromURL()
|
boolean |
isRequestedSessionIdValid()
|
boolean |
isSecure()
|
boolean |
isUserInRole(String role)
|
void |
removeAllParameters()
Removes all existing parameters. |
void |
removeAttribute(String name)
|
void |
removeParameter(String name)
Remove already registered values for the specified HTTP parameter, if any. |
void |
removeQueryParameter(String name)
|
void |
setAttribute(String name,
Object value)
|
void |
setAuthType(String authType)
|
void |
setCharacterEncoding(String characterEncoding)
|
void |
setContent(byte[] content)
|
void |
setContentType(String contentType)
|
void |
setContextPath(String contextPath)
|
void |
setCookies(javax.servlet.http.Cookie[] cookies)
|
void |
setLocalAddr(String localAddr)
|
void |
setLocalName(String localName)
|
void |
setLocalPort(int localPort)
|
void |
setMethod(String method)
|
void |
setParameter(String name,
String value)
Set a single value for the specified HTTP parameter. |
void |
setParameter(String name,
String[] values)
Set an array of values for the specified HTTP parameter. |
void |
setParameters(Map params)
Sets all provided parameters |
void |
setPathInfo(String pathInfo)
|
void |
setProtocol(String protocol)
|
void |
setQueryString(String queryString)
|
void |
setRemoteAddr(String remoteAddr)
|
void |
setRemoteHost(String remoteHost)
|
void |
setRemotePort(int remotePort)
|
void |
setRemoteUser(String remoteUser)
|
void |
setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)
|
void |
setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
|
void |
setRequestedSessionIdValid(boolean requestedSessionIdValid)
|
void |
setRequestURI(String requestURI)
|
void |
setScheme(String scheme)
|
void |
setSecure(boolean secure)
|
void |
setServerName(String serverName)
|
void |
setServerPort(int serverPort)
|
void |
setServletPath(String servletPath)
|
void |
setSession(javax.servlet.http.HttpSession session)
|
void |
setUserPrincipal(Principal userPrincipal)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_PROTOCOL
public static final String DEFAULT_SERVER_ADDR
public static final String DEFAULT_SERVER_NAME
public static final int DEFAULT_SERVER_PORT
public static final String DEFAULT_REMOTE_ADDR
public static final String DEFAULT_REMOTE_HOST
| Constructor Detail |
|---|
public EnhancedMockHttpServletRequest()
MockServletContext.
MockServletContext
public EnhancedMockHttpServletRequest(String method,
String requestURI)
MockServletContext.
method - the request method (may be null)requestURI - the request URI (may be null)setMethod(java.lang.String),
setRequestURI(java.lang.String),
MockServletContextpublic EnhancedMockHttpServletRequest(javax.servlet.ServletContext servletContext)
servletContext - the ServletContext that the request runs in
(may be null to use a default MockServletContext)MockServletContext
public EnhancedMockHttpServletRequest(javax.servlet.ServletContext servletContext,
String method,
String requestURI)
servletContext - the ServletContext that the request runs in
(may be null to use a default MockServletContext)method - the request method (may be null)requestURI - the request URI (may be null)setMethod(java.lang.String),
setRequestURI(java.lang.String),
MockServletContextpublic EnhancedMockHttpServletRequest(javax.servlet.http.HttpSession session)
public EnhancedMockHttpServletRequest(javax.servlet.http.HttpSession session,
String principalName,
Set<String> principalRoles)
public EnhancedMockHttpServletRequest(javax.servlet.http.HttpSession session,
String principalName,
Set<String> principalRoles,
javax.servlet.http.Cookie[] cookies,
String method)
| Method Detail |
|---|
public javax.servlet.ServletContext getServletContext()
public boolean isActive()
public void close()
public void invalidate()
protected void checkActive()
throws IllegalStateException
IllegalStateExceptionpublic Object getAttribute(String name)
getAttribute in interface javax.servlet.ServletRequestpublic Enumeration getAttributeNames()
getAttributeNames in interface javax.servlet.ServletRequestpublic String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletRequestpublic void setCharacterEncoding(String characterEncoding)
setCharacterEncoding in interface javax.servlet.ServletRequestpublic void setContent(byte[] content)
public int getContentLength()
getContentLength in interface javax.servlet.ServletRequestpublic void setContentType(String contentType)
public String getContentType()
getContentType in interface javax.servlet.ServletRequest
public javax.servlet.ServletInputStream getInputStream()
throws IOException
getInputStream in interface javax.servlet.ServletRequestIOException
public void setParameter(String name,
String value)
If there are already one or more values registered for the given parameter name, they will be replaced.
public void setParameter(String name,
String[] values)
If there are already one or more values registered for the given parameter name, they will be replaced.
public void setParameters(Map params)
addParameters(java.util.Map).
public void addParameter(String name,
String value)
If there are already one or more values registered for the given parameter name, the given value will be added to the end of the list.
public void addParameter(String name,
String[] values)
If there are already one or more values registered for the given parameter name, the given values will be added to the end of the list.
public void addParameters(Map params)
setParameters(java.util.Map).
public void removeParameter(String name)
public void removeAllParameters()
public String getParameter(String name)
getParameter in interface javax.servlet.ServletRequestpublic Enumeration getParameterNames()
getParameterNames in interface javax.servlet.ServletRequestpublic String[] getParameterValues(String name)
getParameterValues in interface javax.servlet.ServletRequestpublic Map getParameterMap()
getParameterMap in interface javax.servlet.ServletRequestpublic Map<String,String[]> getParameters()
public void addQueryParameter(String name,
String value)
public void removeQueryParameter(String name)
public Map<String,String> getQueryParameters()
public void setProtocol(String protocol)
public String getProtocol()
getProtocol in interface javax.servlet.ServletRequestpublic void setScheme(String scheme)
public String getScheme()
getScheme in interface javax.servlet.ServletRequestpublic void setServerName(String serverName)
public String getServerName()
getServerName in interface javax.servlet.ServletRequestpublic void setServerPort(int serverPort)
public int getServerPort()
getServerPort in interface javax.servlet.ServletRequest
public BufferedReader getReader()
throws UnsupportedEncodingException
getReader in interface javax.servlet.ServletRequestUnsupportedEncodingExceptionpublic void setRemoteAddr(String remoteAddr)
public String getRemoteAddr()
getRemoteAddr in interface javax.servlet.ServletRequestpublic void setRemoteHost(String remoteHost)
public String getRemoteHost()
getRemoteHost in interface javax.servlet.ServletRequest
public void setAttribute(String name,
Object value)
setAttribute in interface javax.servlet.ServletRequestpublic void removeAttribute(String name)
removeAttribute in interface javax.servlet.ServletRequestpublic void clearAttributes()
public void addPreferredLocale(Locale locale)
public Locale getLocale()
getLocale in interface javax.servlet.ServletRequestpublic Enumeration getLocales()
getLocales in interface javax.servlet.ServletRequestpublic void setSecure(boolean secure)
public boolean isSecure()
isSecure in interface javax.servlet.ServletRequestpublic javax.servlet.RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher in interface javax.servlet.ServletRequestpublic String getRealPath(String path)
getRealPath in interface javax.servlet.ServletRequestpublic void setRemotePort(int remotePort)
public int getRemotePort()
getRemotePort in interface javax.servlet.ServletRequestpublic void setLocalName(String localName)
public String getLocalName()
getLocalName in interface javax.servlet.ServletRequestpublic void setLocalAddr(String localAddr)
public String getLocalAddr()
getLocalAddr in interface javax.servlet.ServletRequestpublic void setLocalPort(int localPort)
public int getLocalPort()
getLocalPort in interface javax.servlet.ServletRequestpublic void setAuthType(String authType)
public String getAuthType()
getAuthType in interface javax.servlet.http.HttpServletRequestpublic void setCookies(javax.servlet.http.Cookie[] cookies)
public javax.servlet.http.Cookie[] getCookies()
getCookies in interface javax.servlet.http.HttpServletRequestpublic void addCookie(javax.servlet.http.Cookie cookie)
public void addHeader(String name,
Object value)
If there was no entry for that header name before, the value will be used as-is. In case of an existing entry, a String array will be created, adding the given value (more specifically, its toString representation) as further element.
Multiple values can only be stored as list of Strings,
following the Servlet spec (see getHeaders accessor).
As alternative to repeated addHeader calls for
individual elements, you can use a single call with an entire
array or Collection of values as parameter.
getHeaderNames(),
getHeader(java.lang.String),
getHeaders(),
getDateHeader(java.lang.String),
getIntHeader(java.lang.String)public long getDateHeader(String name)
getDateHeader in interface javax.servlet.http.HttpServletRequestpublic String getHeader(String name)
getHeader in interface javax.servlet.http.HttpServletRequestpublic Map<String,String[]> getHeaders()
public Enumeration getHeaders(String name)
getHeaders in interface javax.servlet.http.HttpServletRequestpublic Enumeration getHeaderNames()
getHeaderNames in interface javax.servlet.http.HttpServletRequestpublic int getIntHeader(String name)
getIntHeader in interface javax.servlet.http.HttpServletRequestpublic void setMethod(String method)
public String getMethod()
getMethod in interface javax.servlet.http.HttpServletRequestpublic void setPathInfo(String pathInfo)
public String getPathInfo()
getPathInfo in interface javax.servlet.http.HttpServletRequestpublic String getPathTranslated()
getPathTranslated in interface javax.servlet.http.HttpServletRequestpublic void setContextPath(String contextPath)
public String getContextPath()
getContextPath in interface javax.servlet.http.HttpServletRequestpublic void setQueryString(String queryString)
public String getQueryString()
getQueryString in interface javax.servlet.http.HttpServletRequestpublic void setRemoteUser(String remoteUser)
public String getRemoteUser()
getRemoteUser in interface javax.servlet.http.HttpServletRequestpublic void addRole(String role)
addUserRole(java.lang.String)public void addUserRole(String role)
public boolean isUserInRole(String role)
isUserInRole in interface javax.servlet.http.HttpServletRequestpublic void setUserPrincipal(Principal userPrincipal)
public Principal getUserPrincipal()
getUserPrincipal in interface javax.servlet.http.HttpServletRequestpublic String getRequestedSessionId()
getRequestedSessionId in interface javax.servlet.http.HttpServletRequestpublic void setRequestURI(String requestURI)
public String getRequestURI()
getRequestURI in interface javax.servlet.http.HttpServletRequestpublic StringBuffer getRequestURL()
getRequestURL in interface javax.servlet.http.HttpServletRequestpublic void setServletPath(String servletPath)
public String getServletPath()
getServletPath in interface javax.servlet.http.HttpServletRequestpublic void setSession(javax.servlet.http.HttpSession session)
public javax.servlet.http.HttpSession getSession(boolean create)
getSession in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession()
getSession in interface javax.servlet.http.HttpServletRequestpublic void setRequestedSessionIdValid(boolean requestedSessionIdValid)
public boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequestpublic void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequestpublic void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
public boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequestpublic boolean isAllParametersInQueryString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||