Class MockHttpServletRequest
- java.lang.Object
-
- com.helger.servlet.mock.MockHttpServletRequest
-
- All Implemented Interfaces:
com.helger.commons.locale.IHasLocale,jakarta.servlet.http.HttpServletRequest,jakarta.servlet.ServletRequest
- Direct Known Subclasses:
OfflineHttpServletRequest
@NotThreadSafe public class MockHttpServletRequest extends Object implements jakarta.servlet.http.HttpServletRequest, com.helger.commons.locale.IHasLocale
Mock implementation ofHttpServletRequest.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_INVOKE_HTTP_LISTENERstatic com.helger.commons.http.EHttpMethodDEFAULT_METHODThe default HTTP method: GETstatic StringDEFAULT_PROTOCOLstatic StringDEFAULT_REMOTE_ADDRstatic StringDEFAULT_REMOTE_HOSTstatic StringDEFAULT_SCHEMEstatic StringDEFAULT_SERVER_ADDRstatic StringDEFAULT_SERVER_NAMEstatic intDEFAULT_SERVER_PORT
-
Constructor Summary
Constructors Constructor Description MockHttpServletRequest()Create a new MockHttpServletRequest with a defaultMockServletContext.MockHttpServletRequest(jakarta.servlet.ServletContext aServletContext)Create a new MockHttpServletRequest.MockHttpServletRequest(jakarta.servlet.ServletContext aServletContext, com.helger.commons.http.EHttpMethod eMethod)Create a new MockHttpServletRequest.MockHttpServletRequest(jakarta.servlet.ServletContext aServletContext, com.helger.commons.http.EHttpMethod eMethod, boolean bInvokeHttpListeners)Create a new MockHttpServletRequest.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MockHttpServletRequestaddHeader(String sName, String aValue)Add a header entry for the given name.MockHttpServletRequestaddParameter(String sName, String sValue)Add a single value for the specified HTTP parameter.MockHttpServletRequestaddParameter(String sName, String[] aValues)Add an array of values for the specified HTTP parameter.MockHttpServletRequestaddParameters(List<? extends com.helger.commons.url.URLParameter> aParams)Adds all provided parameters without replacing any existing values.MockHttpServletRequestaddPreferredLocale(Locale aLocale)Add a new preferred locale, before any existing locales.MockHttpServletRequestaddUserRole(String sRole)booleanauthenticate(jakarta.servlet.http.HttpServletResponse response)StringchangeSessionId()protected voidcheckActive()Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.MockHttpServletRequestclearAttributes()Clear all of this request's attributes.voidclose()Mark this request as completed, keeping its state.jakarta.servlet.AsyncContextgetAsyncContext()ObjectgetAttribute(String sName)Enumeration<String>getAttributeNames()StringgetAuthType()StringgetCharacterEncoding()CharsetgetCharacterEncodingObj()CharsetgetCharacterEncodingObjOrDefault()intgetContentLength()longgetContentLengthLong()StringgetContentType()StringgetContextPath()jakarta.servlet.http.Cookie[]getCookies()longgetDateHeader(String sName)Deprecated.jakarta.servlet.DispatcherTypegetDispatcherType()StringgetHeader(String sName)Enumeration<String>getHeaderNames()Enumeration<String>getHeaders(String sName)jakarta.servlet.ServletInputStreamgetInputStream()Note: do not change the content viasetContent(byte[]), while an input stream is open, because this may lead to indeterministic results!intgetIntHeader(String sName)Deprecated.StringgetLocalAddr()LocalegetLocale()Enumeration<Locale>getLocales()StringgetLocalName()intgetLocalPort()StringgetMethod()com.helger.commons.http.EHttpMethodgetMethodEnum()StringgetParameter(String sName)com.helger.commons.collection.impl.ICommonsOrderedMap<String,String[]>getParameterMap()Enumeration<String>getParameterNames()String[]getParameterValues(String sName)jakarta.servlet.http.PartgetPart(String name)com.helger.commons.collection.impl.ICommonsCollection<jakarta.servlet.http.Part>getParts()StringgetPathInfo()StringgetPathTranslated()StringgetProtocol()StringgetQueryString()BufferedReadergetReader()StringgetRealPath(String sPath)Deprecated.StringgetRemoteAddr()StringgetRemoteHost()intgetRemotePort()StringgetRemoteUser()MockRequestDispatchergetRequestDispatcher(String sPath)StringgetRequestedSessionId()StringgetRequestURI()StringBuffergetRequestURL()StringgetScheme()StringgetServerName()intgetServerPort()jakarta.servlet.ServletContextgetServletContext()StringgetServletPath()jakarta.servlet.http.HttpSessiongetSession()jakarta.servlet.http.HttpSessiongetSession(boolean bCreate)StringgetSessionID()PrincipalgetUserPrincipal()voidinvalidate()Invalidate this request, clearing its state and invoking all HTTP event listener.booleanisActive()booleanisAsyncStarted()booleanisAsyncSupported()booleanisRequestedSessionIdFromCookie()booleanisRequestedSessionIdFromUrl()Deprecated.booleanisRequestedSessionIdFromURL()booleanisRequestedSessionIdValid()booleanisSecure()booleanisUserInRole(String sRole)voidlogin(String username, String password)voidlogout()MockHttpServletRequestremoveAllParameters()Removes all existing parameters.voidremoveAttribute(String sName)MockHttpServletRequestremoveHeader(String sName)MockHttpServletRequestremoveParameter(String sName)Remove already registered values for the specified HTTP parameter, if any.MockHttpServletRequestsetAllPaths(String sRequestURL)Set all path related members to the value to be deduced from the request URI.voidsetAttribute(String sName, Object aValue)MockHttpServletRequestsetAuthType(String sAuthType)voidsetCharacterEncoding(String sCharacterEncoding)voidsetCharacterEncoding(Charset aCharacterEncoding)MockHttpServletRequestsetContent(byte[] aContent)MockHttpServletRequestsetContentType(com.helger.commons.mime.IMimeType aContentType)MockHttpServletRequestsetContentType(String sContentType)MockHttpServletRequestsetContextPath(String sContextPath)MockHttpServletRequestsetCookies(jakarta.servlet.http.Cookie[] aCookies)MockHttpServletRequestsetLocalAddr(String sLocalAddr)MockHttpServletRequestsetLocalName(String sLocalName)MockHttpServletRequestsetLocalPort(int nLocalPort)MockHttpServletRequestsetMethod(com.helger.commons.http.EHttpMethod eMethod)MockHttpServletRequestsetParameter(String sName, String sValue)Set a single value for the specified HTTP parameter.MockHttpServletRequestsetParameter(String sName, String[] aValues)Set an array of values for the specified HTTP parameter.MockHttpServletRequestsetParameters(List<? extends com.helger.commons.url.URLParameter> aParams)Sets all provided parameters replacing any existing values for the provided parameter names.MockHttpServletRequestsetPathInfo(String sPathInfo)MockHttpServletRequestsetProtocol(String sProtocol)MockHttpServletRequestsetQueryString(String sQueryString)MockHttpServletRequestsetRemoteAddr(String sRemoteAddr)MockHttpServletRequestsetRemoteHost(String sRemoteHost)MockHttpServletRequestsetRemotePort(int nRemotePort)MockHttpServletRequestsetRemoteUser(String sRemoteUser)MockHttpServletRequestsetRequestedSessionIdFromCookie(boolean bRequestedSessionIdFromCookie)MockHttpServletRequestsetRequestedSessionIdFromURL(boolean bRequestedSessionIdFromURL)MockHttpServletRequestsetRequestedSessionIdValid(boolean bRequestedSessionIdValid)MockHttpServletRequestsetRequestURI(String sRequestURI)MockHttpServletRequestsetScheme(String sScheme)MockHttpServletRequestsetSecure(boolean bSecure)MockHttpServletRequestsetServerName(String sServerName)MockHttpServletRequestsetServerPort(int nServerPort)MockHttpServletRequestsetServletPath(String sServletPath)MockHttpServletRequestsetSession(jakarta.servlet.http.HttpSession aHttpSession)MockHttpServletRequestsetSessionID(String sSessionID)Define the session ID to be used when creating a new sessionMockHttpServletRequestsetUserPrincipal(Principal aUserPrincipal)jakarta.servlet.AsyncContextstartAsync()jakarta.servlet.AsyncContextstartAsync(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse)<T extends jakarta.servlet.http.HttpUpgradeHandler>
Tupgrade(Class<T> handlerClass)
-
-
-
Field Detail
-
DEFAULT_INVOKE_HTTP_LISTENER
public static final boolean DEFAULT_INVOKE_HTTP_LISTENER
- See Also:
- Constant Field Values
-
DEFAULT_PROTOCOL
public static final String DEFAULT_PROTOCOL
-
DEFAULT_SCHEME
public static final String DEFAULT_SCHEME
- See Also:
- Constant Field Values
-
DEFAULT_SERVER_ADDR
public static final String DEFAULT_SERVER_ADDR
- See Also:
- Constant Field Values
-
DEFAULT_SERVER_NAME
public static final String DEFAULT_SERVER_NAME
- See Also:
- Constant Field Values
-
DEFAULT_SERVER_PORT
public static final int DEFAULT_SERVER_PORT
-
DEFAULT_REMOTE_ADDR
public static final String DEFAULT_REMOTE_ADDR
- See Also:
- Constant Field Values
-
DEFAULT_REMOTE_HOST
public static final String DEFAULT_REMOTE_HOST
- See Also:
- Constant Field Values
-
DEFAULT_METHOD
public static final com.helger.commons.http.EHttpMethod DEFAULT_METHOD
The default HTTP method: GET
-
-
Constructor Detail
-
MockHttpServletRequest
public MockHttpServletRequest()
Create a new MockHttpServletRequest with a defaultMockServletContext.- See Also:
MockServletContext
-
MockHttpServletRequest
public MockHttpServletRequest(@Nullable jakarta.servlet.ServletContext aServletContext)
Create a new MockHttpServletRequest.- Parameters:
aServletContext- the ServletContext that the request runs in (may benullto use a default MockServletContext)- See Also:
MockServletContext
-
MockHttpServletRequest
public MockHttpServletRequest(@Nullable jakarta.servlet.ServletContext aServletContext, @Nullable com.helger.commons.http.EHttpMethod eMethod)
Create a new MockHttpServletRequest.- Parameters:
aServletContext- the ServletContext that the request runs in (may benullto use a default MockServletContext)eMethod- the request method (may benull)- See Also:
MockServletContext
-
MockHttpServletRequest
public MockHttpServletRequest(@Nullable jakarta.servlet.ServletContext aServletContext, @Nullable com.helger.commons.http.EHttpMethod eMethod, boolean bInvokeHttpListeners)
Create a new MockHttpServletRequest.- Parameters:
aServletContext- the ServletContext that the request runs in (may benullto use a default MockServletContext)eMethod- the request method (may benull)bInvokeHttpListeners- iftruethan the HTTP request event listeners fromMockHttpListenerare triggered- See Also:
setMethod(com.helger.commons.http.EHttpMethod),MockServletContext
-
-
Method Detail
-
getServletContext
@Nonnull public final jakarta.servlet.ServletContext getServletContext()
- Specified by:
getServletContextin interfacejakarta.servlet.ServletRequest- Returns:
- the ServletContext that this request is associated with. (Not
available in the standard HttpServletRequest interface for some
reason.). Never
null.
-
isActive
public boolean isActive()
- Returns:
- whether this request is still active (that is, not completed yet).
-
close
public void close()
Mark this request as completed, keeping its state.
-
invalidate
public void invalidate()
Invalidate this request, clearing its state and invoking all HTTP event listener.- See Also:
close(),clearAttributes()
-
checkActive
protected void checkActive()
Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.
-
getAttribute
@Nullable public Object getAttribute(@Nullable String sName)
- Specified by:
getAttributein interfacejakarta.servlet.ServletRequest
-
getAttributeNames
@Nonnull public Enumeration<String> getAttributeNames()
- Specified by:
getAttributeNamesin interfacejakarta.servlet.ServletRequest
-
setCharacterEncoding
public void setCharacterEncoding(@Nullable String sCharacterEncoding)
- Specified by:
setCharacterEncodingin interfacejakarta.servlet.ServletRequest
-
getCharacterEncoding
@Nullable public String getCharacterEncoding()
- Specified by:
getCharacterEncodingin interfacejakarta.servlet.ServletRequest
-
setContent
@Nonnull public MockHttpServletRequest setContent(@Nullable byte[] aContent)
-
getContentLength
@CheckForSigned public int getContentLength()
- Specified by:
getContentLengthin interfacejakarta.servlet.ServletRequest
-
setContentType
@Nonnull public MockHttpServletRequest setContentType(@Nullable com.helger.commons.mime.IMimeType aContentType)
-
setContentType
@Nonnull public MockHttpServletRequest setContentType(@Nullable String sContentType)
-
getContentType
@Nullable public String getContentType()
- Specified by:
getContentTypein interfacejakarta.servlet.ServletRequest
-
getInputStream
@Nullable public jakarta.servlet.ServletInputStream getInputStream()
Note: do not change the content viasetContent(byte[]), while an input stream is open, because this may lead to indeterministic results!- Specified by:
getInputStreamin interfacejakarta.servlet.ServletRequest- Returns:
nullif no content is present. If non-nullthe caller is responsible for closing theInputStream.
-
setParameter
@Nonnull public MockHttpServletRequest setParameter(@Nonnull String sName, @Nullable String sValue)
Set a single value for the specified HTTP parameter.If there are already one or more values registered for the given parameter name, they will be replaced.
- Parameters:
sName- Parameter namesValue- Parameter value- Returns:
- this
-
setParameter
@Nonnull public MockHttpServletRequest setParameter(@Nonnull String sName, @Nullable String[] aValues)
Set an array of values for the specified HTTP parameter.If there are already one or more values registered for the given parameter name, they will be replaced.
- Parameters:
sName- Parameter nameaValues- Parameter values- Returns:
- this
-
setParameters
@Nonnull public MockHttpServletRequest setParameters(@Nullable List<? extends com.helger.commons.url.URLParameter> aParams)
Sets all provided parameters replacing any existing values for the provided parameter names. To add without replacing existing values, useaddParameters(List).- Parameters:
aParams- Parameter name value map. May benull.- Returns:
- this
-
addParameter
@Nonnull public final MockHttpServletRequest addParameter(@Nonnull String sName, @Nullable String sValue)
Add a single value for the specified HTTP parameter.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.
- Parameters:
sName- Parameter namesValue- Parameter value- Returns:
- this
-
addParameter
@Nonnull public final MockHttpServletRequest addParameter(@Nonnull String sName, @Nullable String[] aValues)
Add an array of values for the specified HTTP parameter.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.
- Parameters:
sName- Parameter nameaValues- Parameter values- Returns:
- this
-
addParameters
@Nonnull public MockHttpServletRequest addParameters(@Nullable List<? extends com.helger.commons.url.URLParameter> aParams)
Adds all provided parameters without replacing any existing values. To replace existing values, usesetParameters(List).- Parameters:
aParams- Parameter name value map- Returns:
- this
-
removeParameter
@Nonnull public MockHttpServletRequest removeParameter(@Nonnull String sName)
Remove already registered values for the specified HTTP parameter, if any.- Parameters:
sName- Parameter name- Returns:
- this
-
removeAllParameters
@Nonnull public MockHttpServletRequest removeAllParameters()
Removes all existing parameters.- Returns:
- this
-
getParameter
@Nullable public String getParameter(@Nonnull String sName)
- Specified by:
getParameterin interfacejakarta.servlet.ServletRequest
-
getParameterNames
@Nonnull public Enumeration<String> getParameterNames()
- Specified by:
getParameterNamesin interfacejakarta.servlet.ServletRequest
-
getParameterValues
@Nullable @ReturnsMutableCopy public String[] getParameterValues(@Nonnull String sName)
- Specified by:
getParameterValuesin interfacejakarta.servlet.ServletRequest
-
getParameterMap
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedMap<String,String[]> getParameterMap()
- Specified by:
getParameterMapin interfacejakarta.servlet.ServletRequest
-
setProtocol
@Nonnull public MockHttpServletRequest setProtocol(@Nullable String sProtocol)
-
getProtocol
@Nullable public String getProtocol()
- Specified by:
getProtocolin interfacejakarta.servlet.ServletRequest
-
setScheme
@Nonnull public MockHttpServletRequest setScheme(@Nullable String sScheme)
-
getScheme
@Nullable public String getScheme()
- Specified by:
getSchemein interfacejakarta.servlet.ServletRequest
-
setServerName
@Nonnull public MockHttpServletRequest setServerName(@Nullable String sServerName)
-
getServerName
@Nullable public String getServerName()
- Specified by:
getServerNamein interfacejakarta.servlet.ServletRequest
-
setServerPort
@Nonnull public MockHttpServletRequest setServerPort(int nServerPort)
-
getServerPort
public int getServerPort()
- Specified by:
getServerPortin interfacejakarta.servlet.ServletRequest
-
getReader
@Nullable public BufferedReader getReader()
- Specified by:
getReaderin interfacejakarta.servlet.ServletRequest
-
setRemoteAddr
@Nonnull public MockHttpServletRequest setRemoteAddr(@Nullable String sRemoteAddr)
-
getRemoteAddr
@Nullable public String getRemoteAddr()
- Specified by:
getRemoteAddrin interfacejakarta.servlet.ServletRequest
-
setRemoteHost
@Nonnull public MockHttpServletRequest setRemoteHost(@Nullable String sRemoteHost)
-
getRemoteHost
@Nullable public String getRemoteHost()
- Specified by:
getRemoteHostin interfacejakarta.servlet.ServletRequest
-
setAttribute
public void setAttribute(@Nonnull String sName, @Nullable Object aValue)
- Specified by:
setAttributein interfacejakarta.servlet.ServletRequest
-
removeAttribute
public void removeAttribute(@Nonnull String sName)
- Specified by:
removeAttributein interfacejakarta.servlet.ServletRequest
-
clearAttributes
@Nonnull public MockHttpServletRequest clearAttributes()
Clear all of this request's attributes.- Returns:
- this
-
addPreferredLocale
@Nonnull public MockHttpServletRequest addPreferredLocale(@Nonnull Locale aLocale)
Add a new preferred locale, before any existing locales.- Parameters:
aLocale- preferred locale- Returns:
- this
-
getLocale
@Nonnull public Locale getLocale()
- Specified by:
getLocalein interfacecom.helger.commons.locale.IHasLocale- Specified by:
getLocalein interfacejakarta.servlet.ServletRequest
-
getLocales
@Nonnull @Nonempty public Enumeration<Locale> getLocales()
- Specified by:
getLocalesin interfacejakarta.servlet.ServletRequest
-
setSecure
@Nonnull public MockHttpServletRequest setSecure(boolean bSecure)
-
isSecure
public boolean isSecure()
- Specified by:
isSecurein interfacejakarta.servlet.ServletRequest
-
getRequestDispatcher
@Nonnull public MockRequestDispatcher getRequestDispatcher(@Nonnull String sPath)
- Specified by:
getRequestDispatcherin interfacejakarta.servlet.ServletRequest
-
getRealPath
@Deprecated(forRemoval=false) public String getRealPath(@Nonnull String sPath)
Deprecated.- Specified by:
getRealPathin interfacejakarta.servlet.ServletRequest
-
setRemotePort
@Nonnull public MockHttpServletRequest setRemotePort(int nRemotePort)
-
getRemotePort
public int getRemotePort()
- Specified by:
getRemotePortin interfacejakarta.servlet.ServletRequest
-
setLocalName
@Nonnull public MockHttpServletRequest setLocalName(@Nullable String sLocalName)
-
getLocalName
@Nullable public String getLocalName()
- Specified by:
getLocalNamein interfacejakarta.servlet.ServletRequest
-
setLocalAddr
@Nonnull public MockHttpServletRequest setLocalAddr(@Nullable String sLocalAddr)
-
getLocalAddr
@Nullable public String getLocalAddr()
- Specified by:
getLocalAddrin interfacejakarta.servlet.ServletRequest
-
setLocalPort
@Nonnull public MockHttpServletRequest setLocalPort(int nLocalPort)
-
getLocalPort
public int getLocalPort()
- Specified by:
getLocalPortin interfacejakarta.servlet.ServletRequest
-
setAuthType
@Nonnull public MockHttpServletRequest setAuthType(@Nullable String sAuthType)
-
getAuthType
@Nullable public String getAuthType()
- Specified by:
getAuthTypein interfacejakarta.servlet.http.HttpServletRequest
-
setCookies
@Nonnull public MockHttpServletRequest setCookies(@Nullable jakarta.servlet.http.Cookie[] aCookies)
-
getCookies
@Nullable public jakarta.servlet.http.Cookie[] getCookies()
- Specified by:
getCookiesin interfacejakarta.servlet.http.HttpServletRequest
-
addHeader
@Nonnull public final MockHttpServletRequest addHeader(@Nullable String sName, @Nullable String aValue)
Add a header entry for the given name.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
getHeadersaccessor). As alternative to repeatedaddHeadercalls for individual elements, you can use a single call with an entire array or Collection of values as parameter.- Parameters:
sName- header nameaValue- header value- Returns:
- this
- See Also:
getHeaderNames(),getHeader(java.lang.String),getHeaders(java.lang.String),getDateHeader(java.lang.String),getIntHeader(java.lang.String)
-
removeHeader
@Nonnull public MockHttpServletRequest removeHeader(@Nullable String sName)
-
getDateHeader
@UnsupportedOperation @Deprecated(forRemoval=false) public long getDateHeader(@Nullable String sName)
Deprecated.- Specified by:
getDateHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getIntHeader
@UnsupportedOperation @Deprecated(forRemoval=false) public int getIntHeader(@Nullable String sName)
Deprecated.- Specified by:
getIntHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getHeader
@Nullable public String getHeader(@Nullable String sName)
- Specified by:
getHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getHeaders
@Nonnull public Enumeration<String> getHeaders(@Nullable String sName)
- Specified by:
getHeadersin interfacejakarta.servlet.http.HttpServletRequest
-
getHeaderNames
@Nonnull public Enumeration<String> getHeaderNames()
- Specified by:
getHeaderNamesin interfacejakarta.servlet.http.HttpServletRequest
-
setMethod
@Nonnull public final MockHttpServletRequest setMethod(@Nullable com.helger.commons.http.EHttpMethod eMethod)
-
getMethodEnum
@Nullable public com.helger.commons.http.EHttpMethod getMethodEnum()
-
getMethod
@Nullable public String getMethod()
- Specified by:
getMethodin interfacejakarta.servlet.http.HttpServletRequest
-
setPathInfo
@Nonnull public MockHttpServletRequest setPathInfo(@Nullable String sPathInfo)
-
getPathInfo
@Nullable public String getPathInfo()
- Specified by:
getPathInfoin interfacejakarta.servlet.http.HttpServletRequest
-
getPathTranslated
@Nullable public String getPathTranslated()
- Specified by:
getPathTranslatedin interfacejakarta.servlet.http.HttpServletRequest
-
setContextPath
@Nonnull public MockHttpServletRequest setContextPath(@Nullable String sContextPath)
-
getContextPath
@Nullable public String getContextPath()
- Specified by:
getContextPathin interfacejakarta.servlet.http.HttpServletRequest
-
setQueryString
@Nonnull public MockHttpServletRequest setQueryString(@Nullable String sQueryString)
-
getQueryString
@Nullable public String getQueryString()
- Specified by:
getQueryStringin interfacejakarta.servlet.http.HttpServletRequest
-
setRemoteUser
@Nonnull public MockHttpServletRequest setRemoteUser(@Nullable String sRemoteUser)
-
getRemoteUser
@Nullable public String getRemoteUser()
- Specified by:
getRemoteUserin interfacejakarta.servlet.http.HttpServletRequest
-
addUserRole
@Nonnull public MockHttpServletRequest addUserRole(@Nullable String sRole)
-
isUserInRole
public boolean isUserInRole(@Nullable String sRole)
- Specified by:
isUserInRolein interfacejakarta.servlet.http.HttpServletRequest
-
setUserPrincipal
@Nonnull public MockHttpServletRequest setUserPrincipal(@Nullable Principal aUserPrincipal)
-
getUserPrincipal
@Nullable public Principal getUserPrincipal()
- Specified by:
getUserPrincipalin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestedSessionId
@Nullable public String getRequestedSessionId()
- Specified by:
getRequestedSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
setRequestURI
@Nonnull public MockHttpServletRequest setRequestURI(@Nullable String sRequestURI)
-
getRequestURI
@Nullable public String getRequestURI()
- Specified by:
getRequestURIin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestURL
@Nonnull public StringBuffer getRequestURL()
- Specified by:
getRequestURLin interfacejakarta.servlet.http.HttpServletRequest
-
setServletPath
@Nonnull public MockHttpServletRequest setServletPath(@Nullable String sServletPath)
-
getServletPath
@Nullable public String getServletPath()
- Specified by:
getServletPathin interfacejakarta.servlet.http.HttpServletRequest
-
setSessionID
@Nonnull public MockHttpServletRequest setSessionID(@Nullable String sSessionID)
Define the session ID to be used when creating a new session- Parameters:
sSessionID- The session ID to be used. If it isnulla unique session ID is generated.- Returns:
- this
-
getSessionID
@Nullable public String getSessionID()
- Returns:
- The session ID to use or
nullif a new session ID should be generated!
-
setSession
@Nonnull public MockHttpServletRequest setSession(@Nullable jakarta.servlet.http.HttpSession aHttpSession)
-
getSession
@Nullable public jakarta.servlet.http.HttpSession getSession(boolean bCreate)
- Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
getSession
@Nonnull public jakarta.servlet.http.HttpSession getSession()
- Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
setRequestedSessionIdValid
@Nonnull public MockHttpServletRequest setRequestedSessionIdValid(boolean bRequestedSessionIdValid)
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
- Specified by:
isRequestedSessionIdValidin interfacejakarta.servlet.http.HttpServletRequest
-
setRequestedSessionIdFromCookie
@Nonnull public MockHttpServletRequest setRequestedSessionIdFromCookie(boolean bRequestedSessionIdFromCookie)
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
- Specified by:
isRequestedSessionIdFromCookiein interfacejakarta.servlet.http.HttpServletRequest
-
setRequestedSessionIdFromURL
@Nonnull public MockHttpServletRequest setRequestedSessionIdFromURL(boolean bRequestedSessionIdFromURL)
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()
- Specified by:
isRequestedSessionIdFromURLin interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromUrl
@Deprecated(forRemoval=false) public boolean isRequestedSessionIdFromUrl()
Deprecated.- Specified by:
isRequestedSessionIdFromUrlin interfacejakarta.servlet.http.HttpServletRequest
-
startAsync
@UnsupportedOperation public jakarta.servlet.AsyncContext startAsync()
- Specified by:
startAsyncin interfacejakarta.servlet.ServletRequest
-
startAsync
@UnsupportedOperation public jakarta.servlet.AsyncContext startAsync(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse)- Specified by:
startAsyncin interfacejakarta.servlet.ServletRequest
-
isAsyncStarted
@UnsupportedOperation public boolean isAsyncStarted()
- Specified by:
isAsyncStartedin interfacejakarta.servlet.ServletRequest
-
isAsyncSupported
public boolean isAsyncSupported()
- Specified by:
isAsyncSupportedin interfacejakarta.servlet.ServletRequest
-
getAsyncContext
@UnsupportedOperation public jakarta.servlet.AsyncContext getAsyncContext()
- Specified by:
getAsyncContextin interfacejakarta.servlet.ServletRequest
-
getDispatcherType
public jakarta.servlet.DispatcherType getDispatcherType()
- Specified by:
getDispatcherTypein interfacejakarta.servlet.ServletRequest
-
authenticate
@UnsupportedOperation public boolean authenticate(jakarta.servlet.http.HttpServletResponse response) throws IOException, jakarta.servlet.ServletException- Specified by:
authenticatein interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
login
@UnsupportedOperation public void login(String username, String password) throws jakarta.servlet.ServletException
- Specified by:
loginin interfacejakarta.servlet.http.HttpServletRequest- Throws:
jakarta.servlet.ServletException
-
logout
@UnsupportedOperation public void logout() throws jakarta.servlet.ServletException- Specified by:
logoutin interfacejakarta.servlet.http.HttpServletRequest- Throws:
jakarta.servlet.ServletException
-
getParts
@UnsupportedOperation public com.helger.commons.collection.impl.ICommonsCollection<jakarta.servlet.http.Part> getParts() throws IOException, jakarta.servlet.ServletException- Specified by:
getPartsin interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
getPart
@UnsupportedOperation public jakarta.servlet.http.Part getPart(String name) throws IOException, jakarta.servlet.ServletException
- Specified by:
getPartin interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
setAllPaths
@Nonnull public MockHttpServletRequest setAllPaths(@Nullable String sRequestURL)
Set all path related members to the value to be deduced from the request URI.- Parameters:
sRequestURL- The request URL to parse and set correctly. If it isnullor empty, all methods are set tonull.- Returns:
- this
- See Also:
setScheme(String),setServerName(String),setServerPort(int),setContextPath(String),setServletPath(String),setPathInfo(String),setQueryString(String),setParameters(List)
-
getContentLengthLong
public long getContentLengthLong()
- Specified by:
getContentLengthLongin interfacejakarta.servlet.ServletRequest
-
changeSessionId
public String changeSessionId()
- Specified by:
changeSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
upgrade
public <T extends jakarta.servlet.http.HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, jakarta.servlet.ServletException
- Specified by:
upgradein interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
-