|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.protocol.http.MockHttpServletRequest
public class MockHttpServletRequest
Mock servlet request. Implements all of the methods from the standard HttpServletRequest class plus helper methods to aid setting up a request.
Field Summary |
---|
Fields inherited from interface javax.servlet.http.HttpServletRequest |
---|
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
Constructor Summary | |
---|---|
MockHttpServletRequest(Application application,
javax.servlet.http.HttpSession session,
javax.servlet.ServletContext context)
Create the request using the supplied session object. |
Method Summary | |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Add a new cookie. |
void |
addCookies(java.util.Collection cookies)
|
void |
addFile(java.lang.String fieldName,
File file,
java.lang.String contentType)
Add an uploaded file to the request. |
void |
addHeader(java.lang.String name,
java.lang.String value)
Add a header to the request. |
java.lang.Object |
getAttribute(java.lang.String name)
Get an attribute. |
java.util.Enumeration |
getAttributeNames()
Get the names of all of the values. |
java.lang.String |
getAuthType()
Get the auth type. |
java.lang.String |
getCharacterEncoding()
Get the current character encoding. |
int |
getContentLength()
Return the length of the content. |
java.lang.String |
getContentType()
If useMultiPartContentType set as true return the correct content-type. |
java.lang.String |
getContextPath()
Get the context path. |
javax.servlet.http.Cookie[] |
getCookies()
Get all of the cookies for this request. |
long |
getDateHeader(java.lang.String name)
Get the given header as a date. |
java.lang.String |
getHeader(java.lang.String name)
Get the given header value. |
java.util.Enumeration |
getHeaderNames()
Get the names of all of the headers. |
java.util.Enumeration |
getHeaders(java.lang.String name)
Get enumeration of all header values with the given name. |
javax.servlet.ServletInputStream |
getInputStream()
Returns an input stream if there has been added some uploaded files. |
int |
getIntHeader(java.lang.String name)
Get the given header as an int. |
java.lang.String |
getLocalAddr()
|
java.util.Locale |
getLocale()
Get the locale of the request. |
java.util.Enumeration |
getLocales()
Return all the accepted locales. |
java.lang.String |
getLocalName()
|
int |
getLocalPort()
|
java.lang.String |
getMethod()
Get the method. |
java.lang.String |
getParameter(java.lang.String name)
Get the request parameter with the given name. |
java.util.Map |
getParameterMap()
Get the map of all of the parameters. |
java.util.Enumeration |
getParameterNames()
Get the names of all of the parameters. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Get the values for the given parameter. |
java.lang.String |
getPathInfo()
Get the path info. |
java.lang.String |
getPathTranslated()
Always returns null. |
java.lang.String |
getProtocol()
Get the protocol. |
java.lang.String |
getQueryString()
Get the query string part of the request. |
java.io.BufferedReader |
getReader()
This feature is not implemented at this time as we are not supporting binary servlet input. |
java.lang.String |
getRealPath(java.lang.String name)
Deprecated. Use ServletContext.getRealPath(String) instead. |
java.lang.String |
getRemoteAddr()
Get the remote address of the client. |
java.lang.String |
getRemoteHost()
Get the remote host. |
int |
getRemotePort()
|
java.lang.String |
getRemoteUser()
Get the name of the remote user from the REMOTE_USER header. |
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String name)
Return a dummy dispatcher that just records that dispatch has occurred without actually doing anything. |
java.lang.String |
getRequestedSessionId()
Get the requested session id. |
java.lang.String |
getRequestURI()
Returns context path and servlet path concatenated, typically /applicationClassName/applicationClassName |
java.lang.StringBuffer |
getRequestURL()
Try to build a rough URL. |
java.lang.String |
getScheme()
Get the scheme. |
java.lang.String |
getServerName()
Get the server name. |
int |
getServerPort()
Get the server port. |
java.lang.String |
getServletPath()
The servlet path may either be the application name or /. |
javax.servlet.http.HttpSession |
getSession()
Get the sessions. |
javax.servlet.http.HttpSession |
getSession(boolean b)
Get the session. |
java.security.Principal |
getUserPrincipal()
Get the user principal. |
boolean |
hasUploadedFiles()
|
void |
initialize()
Reset the request back to a default state. |
boolean |
isRequestedSessionIdFromCookie()
Check whether session id is from a cookie. |
boolean |
isRequestedSessionIdFromUrl()
Check whether session id is from a url rewrite. |
boolean |
isRequestedSessionIdFromURL()
Check whether session id is from a url rewrite. |
boolean |
isRequestedSessionIdValid()
Check whether the session id is valid. |
boolean |
isSecure()
Always returns false. |
boolean |
isUserInRole(java.lang.String name)
NOT IMPLEMENTED. |
void |
removeAttribute(java.lang.String name)
Remove the given attribute. |
void |
setAttribute(java.lang.String name,
java.lang.Object o)
Set the given attribute. |
void |
setAuthType(java.lang.String authType)
Set the auth type. |
void |
setCharacterEncoding(java.lang.String encoding)
Set the character encoding. |
void |
setCookies(javax.servlet.http.Cookie[] theCookies)
Set the cookies. |
void |
setMethod(java.lang.String method)
Set the method. |
void |
setParameter(java.lang.String name,
java.lang.String value)
Set a parameter. |
void |
setParameters(java.util.Map parameters)
Sets a map of parameters. |
void |
setPath(java.lang.String path)
Set the path that this request is supposed to be serving. |
void |
setRequestToBookmarkablePage(Page page,
java.util.Map params)
Initialize the request parameters to point to the given bookmarkable page. |
void |
setRequestToComponent(Component component)
Initialize the request parameters to point to the given component. |
void |
setRequestToFormComponent(Form form,
java.util.Map values)
Initialize the request parameters to point to the given form component. |
void |
setRequestToRedirectString(java.lang.String redirect)
Initialize the request parameters from the given redirect string that redirects back to a particular component for display. |
void |
setURL(java.lang.String url)
Set the complete url for this request. |
void |
setUseMultiPartContentType(boolean useMultiPartContentType)
true will force Request generate multiPart ContentType and ContentLength |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockHttpServletRequest(Application application, javax.servlet.http.HttpSession session, javax.servlet.ServletContext context)
MockHttpSession
application
- The application that this request is forsession
- The session objectcontext
- The current servlet contextMethod Detail |
---|
public void addCookie(javax.servlet.http.Cookie cookie)
cookie
- The cookiepublic void addCookies(java.util.Collection cookies)
public void addFile(java.lang.String fieldName, File file, java.lang.String contentType)
fieldName
- The fieldname of the upload field.file
- The file to upload.contentType
- The content type of the file. Must be a correct mimetype.public void addHeader(java.lang.String name, java.lang.String value)
name
- The name of the header to addvalue
- The valuepublic java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface javax.servlet.ServletRequest
name
- The attribute name
public java.util.Enumeration getAttributeNames()
getAttributeNames
in interface javax.servlet.ServletRequest
public java.lang.String getAuthType()
getAuthType
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getCharacterEncoding()
getCharacterEncoding
in interface javax.servlet.ServletRequest
public void setUseMultiPartContentType(boolean useMultiPartContentType)
useMultiPartContentType
- public int getContentLength()
getContentLength
in interface javax.servlet.ServletRequest
public java.lang.String getContentType()
getContentType
in interface javax.servlet.ServletRequest
public java.lang.String getContextPath()
getContextPath
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.http.Cookie[] getCookies()
getCookies
in interface javax.servlet.http.HttpServletRequest
public long getDateHeader(java.lang.String name) throws java.lang.IllegalArgumentException
getDateHeader
in interface javax.servlet.http.HttpServletRequest
name
- The header name
java.lang.IllegalArgumentException
- If the header cannot be convertedpublic java.lang.String getHeader(java.lang.String name)
getHeader
in interface javax.servlet.http.HttpServletRequest
name
- The header name
public java.util.Enumeration getHeaderNames()
getHeaderNames
in interface javax.servlet.http.HttpServletRequest
public java.util.Enumeration getHeaders(java.lang.String name)
getHeaders
in interface javax.servlet.http.HttpServletRequest
name
- The name
public javax.servlet.ServletInputStream getInputStream() throws java.io.IOException
addFile(String, File, String)
to add some uploaded files.
getInputStream
in interface javax.servlet.ServletRequest
java.io.IOException
- If an I/O related problem occurspublic int getIntHeader(java.lang.String name)
getIntHeader
in interface javax.servlet.http.HttpServletRequest
name
- The header name
java.lang.NumberFormatException
- If the header is not formatted correctlypublic java.util.Locale getLocale()
getLocale
in interface javax.servlet.ServletRequest
public java.util.Enumeration getLocales()
getLocales
in interface javax.servlet.ServletRequest
public java.lang.String getMethod()
getMethod
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getParameter(java.lang.String name)
getParameter
in interface javax.servlet.ServletRequest
name
- The parameter name
public java.util.Map getParameterMap()
getParameterMap
in interface javax.servlet.ServletRequest
public java.util.Enumeration getParameterNames()
getParameterNames
in interface javax.servlet.ServletRequest
public java.lang.String[] getParameterValues(java.lang.String name)
getParameterValues
in interface javax.servlet.ServletRequest
name
- The name of the parameter
public java.lang.String getPathInfo()
getPathInfo
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getPathTranslated()
getPathTranslated
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getProtocol()
getProtocol
in interface javax.servlet.ServletRequest
public java.lang.String getQueryString()
getQueryString
in interface javax.servlet.http.HttpServletRequest
public java.io.BufferedReader getReader() throws java.io.IOException
getReader
in interface javax.servlet.ServletRequest
java.io.IOException
- If an I/O related problem occurspublic java.lang.String getRealPath(java.lang.String name)
getRealPath
in interface javax.servlet.ServletRequest
name
- The name
public java.lang.String getRemoteAddr()
getRemoteAddr
in interface javax.servlet.ServletRequest
public java.lang.String getRemoteHost()
getRemoteHost
in interface javax.servlet.ServletRequest
public java.lang.String getRemoteUser()
getRemoteUser
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String name)
getRequestDispatcher
in interface javax.servlet.ServletRequest
name
- The name to dispatch to
public java.lang.String getRequestedSessionId()
getRequestedSessionId
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getRequestURI()
getRequestURI
in interface javax.servlet.http.HttpServletRequest
HttpServletRequest.getRequestURI()
public java.lang.StringBuffer getRequestURL()
getRequestURL
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getScheme()
getScheme
in interface javax.servlet.ServletRequest
public java.lang.String getServerName()
getServerName
in interface javax.servlet.ServletRequest
public int getServerPort()
getServerPort
in interface javax.servlet.ServletRequest
public java.lang.String getServletPath()
getServletPath
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.http.HttpSession getSession()
getSession
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.http.HttpSession getSession(boolean b)
getSession
in interface javax.servlet.http.HttpServletRequest
b
- Ignored, there is always a session
public java.security.Principal getUserPrincipal()
getUserPrincipal
in interface javax.servlet.http.HttpServletRequest
public boolean hasUploadedFiles()
addFile(String, File, String)
public void initialize()
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie
in interface javax.servlet.http.HttpServletRequest
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl
in interface javax.servlet.http.HttpServletRequest
public boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL
in interface javax.servlet.http.HttpServletRequest
public boolean isRequestedSessionIdValid()
isRequestedSessionIdValid
in interface javax.servlet.http.HttpServletRequest
public boolean isSecure()
isSecure
in interface javax.servlet.ServletRequest
public boolean isUserInRole(java.lang.String name)
isUserInRole
in interface javax.servlet.http.HttpServletRequest
name
- The role name
public void removeAttribute(java.lang.String name)
removeAttribute
in interface javax.servlet.ServletRequest
name
- The name of the attributepublic void setAttribute(java.lang.String name, java.lang.Object o)
setAttribute
in interface javax.servlet.ServletRequest
name
- The attribute nameo
- The value to setpublic void setAuthType(java.lang.String authType)
authType
- The auth typepublic void setCharacterEncoding(java.lang.String encoding) throws java.io.UnsupportedEncodingException
setCharacterEncoding
in interface javax.servlet.ServletRequest
encoding
- The character encoding
java.io.UnsupportedEncodingException
- If encoding not supportedpublic void setCookies(javax.servlet.http.Cookie[] theCookies)
theCookies
- The cookiespublic void setMethod(java.lang.String method)
method
- The methodpublic void setParameter(java.lang.String name, java.lang.String value)
name
- The namevalue
- The valuepublic void setParameters(java.util.Map parameters)
parameters
- the parameters to setpublic void setPath(java.lang.String path)
path
- public void setURL(java.lang.String url)
url
- public void setRequestToBookmarkablePage(Page page, java.util.Map params)
page
- The page to point toparams
- Additional parameterspublic void setRequestToComponent(Component component)
component
- The componentpublic void setRequestToFormComponent(Form form, java.util.Map values)
form
- The for to send the request tovalues
- The values for each of the form componentspublic void setRequestToRedirectString(java.lang.String redirect)
redirect
- The redirect string to display frompublic java.lang.String getLocalAddr()
getLocalAddr
in interface javax.servlet.ServletRequest
public java.lang.String getLocalName()
getLocalName
in interface javax.servlet.ServletRequest
public int getLocalPort()
getLocalPort
in interface javax.servlet.ServletRequest
public int getRemotePort()
getRemotePort
in interface javax.servlet.ServletRequest
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |