|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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.lang.Iterable<javax.servlet.http.Cookie> cookies)
|
void |
addDateHeader(java.lang.String name,
long date)
|
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<java.lang.String> |
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<java.lang.String> |
getHeaderNames()
Get the names of all of the headers. |
java.util.Enumeration<java.lang.String> |
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<java.util.Locale> |
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<java.lang.String,java.lang.Object> |
getParameterMap()
Get the map of all of the parameters. |
java.util.Enumeration<java.lang.String> |
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<java.lang.String,java.lang.String[]> 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<java.lang.String,java.lang.Object> 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<java.lang.String,java.lang.Object> 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 context| Method Detail |
|---|
public void addCookie(javax.servlet.http.Cookie cookie)
cookie - The cookiepublic void addCookies(java.lang.Iterable<javax.servlet.http.Cookie> 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 value
public void addDateHeader(java.lang.String name,
long date)
name - date - public java.lang.Object getAttribute(java.lang.String name)
getAttribute in interface javax.servlet.ServletRequestname - The attribute name
public java.util.Enumeration<java.lang.String> getAttributeNames()
getAttributeNames in interface javax.servlet.ServletRequestpublic java.lang.String getAuthType()
getAuthType in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletRequestpublic void setUseMultiPartContentType(boolean useMultiPartContentType)
useMultiPartContentType - public int getContentLength()
getContentLength in interface javax.servlet.ServletRequestpublic java.lang.String getContentType()
getContentType in interface javax.servlet.ServletRequestpublic java.lang.String getContextPath()
getContextPath in interface javax.servlet.http.HttpServletRequestpublic 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.HttpServletRequestname - 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.HttpServletRequestname - The header name
public java.util.Enumeration<java.lang.String> getHeaderNames()
getHeaderNames in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration<java.lang.String> getHeaders(java.lang.String name)
getHeaders in interface javax.servlet.http.HttpServletRequestname - 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.ServletRequestjava.io.IOException - If an I/O related problem occurspublic int getIntHeader(java.lang.String name)
getIntHeader in interface javax.servlet.http.HttpServletRequestname - The header name
java.lang.NumberFormatException - If the header is not formatted correctlypublic java.util.Locale getLocale()
getLocale in interface javax.servlet.ServletRequestpublic java.util.Enumeration<java.util.Locale> getLocales()
getLocales in interface javax.servlet.ServletRequestpublic java.lang.String getMethod()
getMethod in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getParameter(java.lang.String name)
getParameter in interface javax.servlet.ServletRequestname - The parameter name
public java.util.Map<java.lang.String,java.lang.Object> getParameterMap()
getParameterMap in interface javax.servlet.ServletRequestpublic java.util.Enumeration<java.lang.String> getParameterNames()
getParameterNames in interface javax.servlet.ServletRequestpublic java.lang.String[] getParameterValues(java.lang.String name)
getParameterValues in interface javax.servlet.ServletRequestname - The name of the parameter
public java.lang.String getPathInfo()
getPathInfo in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getPathTranslated()
getPathTranslated in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getProtocol()
getProtocol in interface javax.servlet.ServletRequestpublic 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.ServletRequestjava.io.IOException - If an I/O related problem occurs@Deprecated public java.lang.String getRealPath(java.lang.String name)
getRealPath in interface javax.servlet.ServletRequestname - The name
public java.lang.String getRemoteAddr()
getRemoteAddr in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteHost()
getRemoteHost in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteUser()
getRemoteUser in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String name)
getRequestDispatcher in interface javax.servlet.ServletRequestname - The name to dispatch to
public java.lang.String getRequestedSessionId()
getRequestedSessionId in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getRequestURI()
getRequestURI in interface javax.servlet.http.HttpServletRequestHttpServletRequest.getRequestURI()public java.lang.StringBuffer getRequestURL()
getRequestURL in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getScheme()
getScheme in interface javax.servlet.ServletRequestpublic java.lang.String getServerName()
getServerName in interface javax.servlet.ServletRequestpublic int getServerPort()
getServerPort in interface javax.servlet.ServletRequestpublic java.lang.String getServletPath()
getServletPath in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession()
getSession in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession(boolean b)
getSession in interface javax.servlet.http.HttpServletRequestb - Ignored, there is always a session
public java.security.Principal getUserPrincipal()
getUserPrincipal in interface javax.servlet.http.HttpServletRequestpublic boolean hasUploadedFiles()
addFile(String, File, String)public void initialize()
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequestpublic boolean isSecure()
isSecure in interface javax.servlet.ServletRequestpublic boolean isUserInRole(java.lang.String name)
isUserInRole in interface javax.servlet.http.HttpServletRequestname - The role name
public void removeAttribute(java.lang.String name)
removeAttribute in interface javax.servlet.ServletRequestname - The name of the attribute
public void setAttribute(java.lang.String name,
java.lang.Object o)
setAttribute in interface javax.servlet.ServletRequestname - The attribute nameo - The value to setpublic void setAuthType(java.lang.String authType)
authType - The auth type
public void setCharacterEncoding(java.lang.String encoding)
throws java.io.UnsupportedEncodingException
setCharacterEncoding in interface javax.servlet.ServletRequestencoding - 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 method
public void setParameter(java.lang.String name,
java.lang.String value)
name - The namevalue - The valuepublic void setParameters(java.util.Map<java.lang.String,java.lang.String[]> 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<java.lang.String,java.lang.Object> params)
page - The page to point toparams - Additional parameterspublic void setRequestToComponent(Component component)
component - The component
public void setRequestToFormComponent(Form<?> form,
java.util.Map<java.lang.String,java.lang.Object> 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()
public java.lang.String getLocalName()
public int getLocalPort()
public int getRemotePort()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||