|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.springframework.mock.web.MockHttpServletRequest
Mock implementation of the HttpServletRequest interface.
Used for testing the web framework; also useful for testing application controllers.
| Field Summary | |
static String |
DEFAULT_PROTOCOL
|
static String |
DEFAULT_REMOTE_ADDR
|
static String |
DEFAULT_REMOTE_HOST
|
static String |
DEFAULT_SERVER_NAME
|
static int |
DEFAULT_SERVER_PORT
|
| Fields inherited from interface javax.servlet.http.HttpServletRequest |
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
| Constructor Summary | |
MockHttpServletRequest()
Create a new MockHttpServletRequest with a MockServletContext. |
|
MockHttpServletRequest(ServletContext servletContext)
Create a new MockHttpServletRequest. |
|
MockHttpServletRequest(ServletContext servletContext,
String method,
String requestURI)
Create a new MockHttpServletRequest. |
|
MockHttpServletRequest(String method,
String requestURI)
Create a new MockHttpServletRequest with a MockServletContext. |
|
| 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_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 MockHttpServletRequest(ServletContext servletContext)
servletContext - the ServletContext that the request runs in
public MockHttpServletRequest(ServletContext servletContext,
String method,
String requestURI)
servletContext - the ServletContext that the request runs inmethod - the request methodrequestURI - the request URIsetMethod(java.lang.String),
setRequestURI(java.lang.String)public MockHttpServletRequest()
MockServletContext
public MockHttpServletRequest(String method,
String requestURI)
method - the request methodrequestURI - the request URIsetMethod(java.lang.String),
setRequestURI(java.lang.String),
MockServletContext| Method Detail |
public Object getAttribute(String name)
getAttribute in interface ServletRequestpublic Enumeration getAttributeNames()
getAttributeNames in interface ServletRequestpublic String getCharacterEncoding()
getCharacterEncoding in interface ServletRequestpublic void setCharacterEncoding(String characterEncoding)
setCharacterEncoding in interface ServletRequestpublic void setContent(byte[] content)
public int getContentLength()
getContentLength in interface ServletRequestpublic void setContentType(String contentType)
public String getContentType()
getContentType in interface ServletRequestpublic ServletInputStream getInputStream()
getInputStream in interface ServletRequest
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 String getParameter(String name)
getParameter in interface ServletRequestpublic Enumeration getParameterNames()
getParameterNames in interface ServletRequestpublic String[] getParameterValues(String name)
getParameterValues in interface ServletRequestpublic Map getParameterMap()
getParameterMap in interface ServletRequestpublic void setProtocol(String protocol)
public String getProtocol()
getProtocol in interface ServletRequestpublic void setScheme(String scheme)
public String getScheme()
getScheme in interface ServletRequestpublic void setServerName(String serverName)
public String getServerName()
getServerName in interface ServletRequestpublic void setServerPort(int serverPort)
public int getServerPort()
getServerPort in interface ServletRequest
public BufferedReader getReader()
throws UnsupportedEncodingException
getReader in interface ServletRequestUnsupportedEncodingExceptionpublic void setRemoteAddr(String remoteAddr)
public String getRemoteAddr()
getRemoteAddr in interface ServletRequestpublic void setRemoteHost(String remoteHost)
public String getRemoteHost()
getRemoteHost in interface ServletRequest
public void setAttribute(String name,
Object value)
setAttribute in interface ServletRequestpublic void removeAttribute(String name)
removeAttribute in interface ServletRequestpublic void addPreferredLocale(Locale locale)
public Locale getLocale()
getLocale in interface ServletRequestpublic Enumeration getLocales()
getLocales in interface ServletRequestpublic void setSecure(boolean secure)
public boolean isSecure()
isSecure in interface ServletRequestpublic RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher in interface ServletRequestpublic String getRealPath(String path)
getRealPath in interface ServletRequestpublic void setAuthType(String authType)
public String getAuthType()
getAuthType in interface HttpServletRequestpublic void setCookies(Cookie[] cookies)
public Cookie[] getCookies()
getCookies in interface HttpServletRequest
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(java.lang.String),
getDateHeader(java.lang.String),
getIntHeader(java.lang.String)public long getDateHeader(String name)
getDateHeader in interface HttpServletRequestpublic String getHeader(String name)
getHeader in interface HttpServletRequestpublic Enumeration getHeaders(String name)
getHeaders in interface HttpServletRequestpublic Enumeration getHeaderNames()
getHeaderNames in interface HttpServletRequestpublic int getIntHeader(String name)
getIntHeader in interface HttpServletRequestpublic void setMethod(String method)
public String getMethod()
getMethod in interface HttpServletRequestpublic void setPathInfo(String pathInfo)
public String getPathInfo()
getPathInfo in interface HttpServletRequestpublic String getPathTranslated()
getPathTranslated in interface HttpServletRequestpublic void setContextPath(String contextPath)
public String getContextPath()
getContextPath in interface HttpServletRequestpublic void setQueryString(String queryString)
public String getQueryString()
getQueryString in interface HttpServletRequestpublic void setRemoteUser(String remoteUser)
public String getRemoteUser()
getRemoteUser in interface HttpServletRequestpublic void addRole(String role)
public boolean isUserInRole(String role)
isUserInRole in interface HttpServletRequestpublic void setUserPrincipal(Principal userPrincipal)
public Principal getUserPrincipal()
getUserPrincipal in interface HttpServletRequestpublic String getRequestedSessionId()
getRequestedSessionId in interface HttpServletRequestpublic void setRequestURI(String requestURI)
public String getRequestURI()
getRequestURI in interface HttpServletRequestpublic StringBuffer getRequestURL()
getRequestURL in interface HttpServletRequestpublic void setServletPath(String servletPath)
public String getServletPath()
getServletPath in interface HttpServletRequestpublic void setSession(HttpSession session)
public HttpSession getSession(boolean create)
getSession in interface HttpServletRequestpublic HttpSession getSession()
getSession in interface HttpServletRequestpublic void setRequestedSessionIdValid(boolean requestedSessionIdValid)
public boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface HttpServletRequestpublic void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface HttpServletRequestpublic void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
public boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface HttpServletRequest
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||