@ConsumerType
public class MockSlingHttpServletRequest
extends org.apache.sling.api.adapter.SlingAdaptable
implements org.apache.sling.api.SlingHttpServletRequest
SlingHttpServletRequest
implementation.Modifier and Type | Field and Description |
---|---|
protected static java.util.ResourceBundle |
EMPTY_RESOURCE_BUNDLE |
Constructor and Description |
---|
MockSlingHttpServletRequest(org.apache.sling.api.resource.ResourceResolver resourceResolver) |
Modifier and Type | Method and Description |
---|---|
<AdapterType> |
adaptTo(java.lang.Class<AdapterType> type) |
void |
addCookie(javax.servlet.http.Cookie cookie)
Set cookie
|
void |
addDateHeader(java.lang.String name,
long date)
Add header, keep existing ones with same name.
|
void |
addHeader(java.lang.String name,
java.lang.String value)
Add header, keep existing ones with same name.
|
void |
addIntHeader(java.lang.String name,
int value)
Add header, keep existing ones with same name.
|
void |
addRequestParameter(java.lang.String name,
byte[] content,
java.lang.String contentType)
Add a request parameter that emulates a file upload field.
|
void |
addRequestParameter(java.lang.String name,
byte[] content,
java.lang.String contentType,
java.lang.String filename)
Add a request parameter that emulates a file upload field with a filename
associated with it.
|
void |
addRequestParameter(java.lang.String name,
java.lang.String value)
Add a request parameter that consists of a simple name/value pair.
|
boolean |
authenticate(javax.servlet.http.HttpServletResponse response) |
java.lang.String |
changeSessionId() |
javax.servlet.AsyncContext |
getAsyncContext() |
java.lang.Object |
getAttribute(java.lang.String name) |
java.util.Enumeration<java.lang.String> |
getAttributeNames() |
java.lang.String |
getAuthType() |
java.lang.String |
getCharacterEncoding() |
int |
getContentLength() |
long |
getContentLengthLong() |
java.lang.String |
getContentType() |
java.lang.String |
getContextPath() |
javax.servlet.http.Cookie |
getCookie(java.lang.String name) |
javax.servlet.http.Cookie[] |
getCookies() |
long |
getDateHeader(java.lang.String name) |
javax.servlet.DispatcherType |
getDispatcherType() |
java.lang.String |
getHeader(java.lang.String name) |
java.util.Enumeration<java.lang.String> |
getHeaderNames() |
java.util.Enumeration<java.lang.String> |
getHeaders(java.lang.String name) |
javax.servlet.ServletInputStream |
getInputStream() |
int |
getIntHeader(java.lang.String name) |
java.lang.String |
getLocalAddr() |
java.util.Locale |
getLocale() |
java.util.Enumeration<java.util.Locale> |
getLocales() |
java.lang.String |
getLocalName() |
int |
getLocalPort() |
java.lang.String |
getMethod() |
java.lang.String |
getParameter(java.lang.String name) |
java.util.Map<java.lang.String,java.lang.String[]> |
getParameterMap() |
java.util.Enumeration<java.lang.String> |
getParameterNames() |
java.lang.String[] |
getParameterValues(java.lang.String name) |
javax.servlet.http.Part |
getPart(java.lang.String name) |
java.util.Collection<javax.servlet.http.Part> |
getParts() |
java.lang.String |
getPathInfo() |
java.lang.String |
getPathTranslated() |
java.lang.String |
getProtocol() |
java.lang.String |
getQueryString() |
java.io.BufferedReader |
getReader() |
java.lang.String |
getRealPath(java.lang.String path) |
java.lang.String |
getRemoteAddr() |
java.lang.String |
getRemoteHost() |
int |
getRemotePort() |
java.lang.String |
getRemoteUser() |
javax.servlet.RequestDispatcher |
getRequestDispatcher(org.apache.sling.api.resource.Resource resource) |
javax.servlet.RequestDispatcher |
getRequestDispatcher(org.apache.sling.api.resource.Resource resource,
org.apache.sling.api.request.RequestDispatcherOptions options) |
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String path) |
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String path,
org.apache.sling.api.request.RequestDispatcherOptions options) |
java.lang.String |
getRequestedSessionId() |
org.apache.sling.api.request.RequestParameter |
getRequestParameter(java.lang.String name) |
java.util.List<org.apache.sling.api.request.RequestParameter> |
getRequestParameterList() |
org.apache.sling.api.request.RequestParameterMap |
getRequestParameterMap() |
org.apache.sling.api.request.RequestParameter[] |
getRequestParameters(java.lang.String name) |
org.apache.sling.api.request.RequestPathInfo |
getRequestPathInfo() |
org.apache.sling.api.request.RequestProgressTracker |
getRequestProgressTracker() |
java.lang.String |
getRequestURI() |
java.lang.StringBuffer |
getRequestURL() |
org.apache.sling.api.resource.Resource |
getResource() |
java.util.ResourceBundle |
getResourceBundle(java.util.Locale locale) |
java.util.ResourceBundle |
getResourceBundle(java.lang.String baseName,
java.util.Locale locale) |
org.apache.sling.api.resource.ResourceResolver |
getResourceResolver() |
java.lang.String |
getResponseContentType() |
java.util.Enumeration<java.lang.String> |
getResponseContentTypes() |
java.lang.String |
getScheme() |
java.lang.String |
getServerName() |
int |
getServerPort() |
javax.servlet.ServletContext |
getServletContext() |
java.lang.String |
getServletPath() |
javax.servlet.http.HttpSession |
getSession() |
javax.servlet.http.HttpSession |
getSession(boolean create) |
java.security.Principal |
getUserPrincipal() |
boolean |
isAsyncStarted() |
boolean |
isAsyncSupported() |
boolean |
isRequestedSessionIdFromCookie() |
boolean |
isRequestedSessionIdFromUrl() |
boolean |
isRequestedSessionIdFromURL() |
boolean |
isRequestedSessionIdValid() |
boolean |
isSecure() |
boolean |
isUserInRole(java.lang.String role) |
void |
login(java.lang.String pUsername,
java.lang.String password) |
void |
logout() |
protected MockHttpSession |
newMockHttpSession() |
protected MockRequestPathInfo |
newMockRequestPathInfo() |
void |
removeAttribute(java.lang.String name) |
void |
setAttribute(java.lang.String name,
java.lang.Object object) |
void |
setAuthType(java.lang.String authType) |
void |
setCharacterEncoding(java.lang.String charset) |
void |
setContent(byte[] content) |
void |
setContentType(java.lang.String type) |
void |
setContextPath(java.lang.String contextPath) |
void |
setDateHeader(java.lang.String name,
long date)
Set header, overwrite existing ones with same name.
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Set header, overwrite existing ones with same name.
|
void |
setIntHeader(java.lang.String name,
int value)
Set header, overwrite existing ones with same name.
|
void |
setLocale(java.util.Locale loc) |
void |
setMethod(java.lang.String method) |
void |
setParameterMap(java.util.Map<java.lang.String,java.lang.Object> parameterMap) |
void |
setPathInfo(java.lang.String pathInfo) |
void |
setQueryString(java.lang.String queryString) |
void |
setRemoteAddr(java.lang.String remoteAddr) |
void |
setRemoteHost(java.lang.String remoteHost) |
void |
setRemotePort(int remotePort) |
void |
setRemoteUser(java.lang.String remoteUser) |
void |
setRequestDispatcherFactory(MockRequestDispatcherFactory requestDispatcherFactory) |
void |
setResource(org.apache.sling.api.resource.Resource resource) |
void |
setResponseContentType(java.lang.String responseContentType) |
void |
setScheme(java.lang.String scheme) |
void |
setServerName(java.lang.String serverName) |
void |
setServerPort(int serverPort) |
void |
setServletPath(java.lang.String servletPath) |
javax.servlet.AsyncContext |
startAsync() |
javax.servlet.AsyncContext |
startAsync(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse) |
<T extends javax.servlet.http.HttpUpgradeHandler> |
upgrade(java.lang.Class<T> handlerClass) |
protected static final java.util.ResourceBundle EMPTY_RESOURCE_BUNDLE
public MockSlingHttpServletRequest(org.apache.sling.api.resource.ResourceResolver resourceResolver)
resourceResolver
- Resource resolverprotected MockHttpSession newMockHttpSession()
protected MockRequestPathInfo newMockRequestPathInfo()
public org.apache.sling.api.resource.ResourceResolver getResourceResolver()
getResourceResolver
in interface org.apache.sling.api.SlingHttpServletRequest
public javax.servlet.http.HttpSession getSession()
getSession
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.http.HttpSession getSession(boolean create)
getSession
in interface javax.servlet.http.HttpServletRequest
public org.apache.sling.api.request.RequestPathInfo getRequestPathInfo()
getRequestPathInfo
in interface org.apache.sling.api.SlingHttpServletRequest
public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface javax.servlet.ServletRequest
public java.util.Enumeration<java.lang.String> getAttributeNames()
getAttributeNames
in interface javax.servlet.ServletRequest
public void removeAttribute(java.lang.String name)
removeAttribute
in interface javax.servlet.ServletRequest
public void setAttribute(java.lang.String name, java.lang.Object object)
setAttribute
in interface javax.servlet.ServletRequest
public org.apache.sling.api.resource.Resource getResource()
getResource
in interface org.apache.sling.api.SlingHttpServletRequest
public void setResource(org.apache.sling.api.resource.Resource resource)
public java.lang.String getParameter(java.lang.String name)
getParameter
in interface javax.servlet.ServletRequest
public java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
getParameterMap
in interface javax.servlet.ServletRequest
public java.util.Enumeration<java.lang.String> getParameterNames()
getParameterNames
in interface javax.servlet.ServletRequest
public java.lang.String[] getParameterValues(java.lang.String name)
getParameterValues
in interface javax.servlet.ServletRequest
public void setParameterMap(java.util.Map<java.lang.String,java.lang.Object> parameterMap)
parameterMap
- Map of parameterspublic java.util.Locale getLocale()
getLocale
in interface javax.servlet.ServletRequest
public void setLocale(java.util.Locale loc)
loc
- Request localepublic java.lang.String getContextPath()
getContextPath
in interface javax.servlet.http.HttpServletRequest
public void setContextPath(java.lang.String contextPath)
contextPath
- Webapp context pathpublic void setQueryString(java.lang.String queryString)
queryString
- Query string (with proper URL encoding)public java.lang.String getQueryString()
getQueryString
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getScheme()
getScheme
in interface javax.servlet.ServletRequest
public void setScheme(java.lang.String scheme)
public java.lang.String getServerName()
getServerName
in interface javax.servlet.ServletRequest
public void setServerName(java.lang.String serverName)
public int getServerPort()
getServerPort
in interface javax.servlet.ServletRequest
public void setServerPort(int serverPort)
public boolean isSecure()
isSecure
in interface javax.servlet.ServletRequest
public java.lang.String getMethod()
getMethod
in interface javax.servlet.http.HttpServletRequest
public void setMethod(java.lang.String method)
public long getDateHeader(java.lang.String name)
getDateHeader
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getHeader(java.lang.String name)
getHeader
in interface javax.servlet.http.HttpServletRequest
public java.util.Enumeration<java.lang.String> getHeaderNames()
getHeaderNames
in interface javax.servlet.http.HttpServletRequest
public java.util.Enumeration<java.lang.String> getHeaders(java.lang.String name)
getHeaders
in interface javax.servlet.http.HttpServletRequest
public int getIntHeader(java.lang.String name)
getIntHeader
in interface javax.servlet.http.HttpServletRequest
public void addHeader(java.lang.String name, java.lang.String value)
name
- Header namevalue
- Header valuepublic void addIntHeader(java.lang.String name, int value)
name
- Header namevalue
- Header valuepublic void addDateHeader(java.lang.String name, long date)
name
- Header namedate
- Header valuepublic void setHeader(java.lang.String name, java.lang.String value)
name
- Header namevalue
- Header valuepublic void setIntHeader(java.lang.String name, int value)
name
- Header namevalue
- Header valuepublic void setDateHeader(java.lang.String name, long date)
name
- Header namedate
- Header valuepublic javax.servlet.http.Cookie getCookie(java.lang.String name)
getCookie
in interface org.apache.sling.api.SlingHttpServletRequest
public javax.servlet.http.Cookie[] getCookies()
getCookies
in interface javax.servlet.http.HttpServletRequest
public void addCookie(javax.servlet.http.Cookie cookie)
cookie
- Cookiepublic java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
getResourceBundle
in interface org.apache.sling.api.SlingHttpServletRequest
public java.util.ResourceBundle getResourceBundle(java.lang.String baseName, java.util.Locale locale)
getResourceBundle
in interface org.apache.sling.api.SlingHttpServletRequest
public org.apache.sling.api.request.RequestParameter getRequestParameter(java.lang.String name)
getRequestParameter
in interface org.apache.sling.api.SlingHttpServletRequest
public org.apache.sling.api.request.RequestParameterMap getRequestParameterMap()
getRequestParameterMap
in interface org.apache.sling.api.SlingHttpServletRequest
public org.apache.sling.api.request.RequestParameter[] getRequestParameters(java.lang.String name)
getRequestParameters
in interface org.apache.sling.api.SlingHttpServletRequest
public java.util.List<org.apache.sling.api.request.RequestParameter> getRequestParameterList()
getRequestParameterList
in interface org.apache.sling.api.SlingHttpServletRequest
public void addRequestParameter(java.lang.String name, java.lang.String value)
name
- field namevalue
- field valuepublic void addRequestParameter(java.lang.String name, byte[] content, java.lang.String contentType)
name
- field namecontent
- file contentcontentType
- mime type of content in the fieldpublic void addRequestParameter(java.lang.String name, byte[] content, java.lang.String contentType, java.lang.String filename)
name
- field namecontent
- file contentcontentType
- mime type of content in the fieldfilename
- filename associated with contentpublic java.lang.String getCharacterEncoding()
getCharacterEncoding
in interface javax.servlet.ServletRequest
public void setCharacterEncoding(java.lang.String charset)
setCharacterEncoding
in interface javax.servlet.ServletRequest
public java.lang.String getContentType()
getContentType
in interface javax.servlet.ServletRequest
public void setContentType(java.lang.String type)
public javax.servlet.ServletInputStream getInputStream()
getInputStream
in interface javax.servlet.ServletRequest
public int getContentLength()
getContentLength
in interface javax.servlet.ServletRequest
public void setContent(byte[] content)
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
getRequestDispatcher
in interface javax.servlet.ServletRequest
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path, org.apache.sling.api.request.RequestDispatcherOptions options)
getRequestDispatcher
in interface org.apache.sling.api.SlingHttpServletRequest
public javax.servlet.RequestDispatcher getRequestDispatcher(org.apache.sling.api.resource.Resource resource)
getRequestDispatcher
in interface org.apache.sling.api.SlingHttpServletRequest
public javax.servlet.RequestDispatcher getRequestDispatcher(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.request.RequestDispatcherOptions options)
getRequestDispatcher
in interface org.apache.sling.api.SlingHttpServletRequest
public void setRequestDispatcherFactory(MockRequestDispatcherFactory requestDispatcherFactory)
public java.lang.String getRemoteUser()
getRemoteUser
in interface javax.servlet.http.HttpServletRequest
public void setRemoteUser(java.lang.String remoteUser)
public java.lang.String getRemoteAddr()
getRemoteAddr
in interface javax.servlet.ServletRequest
public void setRemoteAddr(java.lang.String remoteAddr)
public java.lang.String getRemoteHost()
getRemoteHost
in interface javax.servlet.ServletRequest
public void setRemoteHost(java.lang.String remoteHost)
public int getRemotePort()
getRemotePort
in interface javax.servlet.ServletRequest
public void setRemotePort(int remotePort)
public java.lang.String getServletPath()
getServletPath
in interface javax.servlet.http.HttpServletRequest
public void setServletPath(java.lang.String servletPath)
public java.lang.String getPathInfo()
getPathInfo
in interface javax.servlet.http.HttpServletRequest
public void setPathInfo(java.lang.String pathInfo)
public java.lang.String getRequestURI()
getRequestURI
in interface javax.servlet.http.HttpServletRequest
public java.lang.StringBuffer getRequestURL()
getRequestURL
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getAuthType()
getAuthType
in interface javax.servlet.http.HttpServletRequest
public void setAuthType(java.lang.String authType)
public <AdapterType> AdapterType adaptTo(java.lang.Class<AdapterType> type)
adaptTo
in interface org.apache.sling.api.adapter.Adaptable
adaptTo
in class org.apache.sling.api.adapter.SlingAdaptable
public java.lang.String getResponseContentType()
getResponseContentType
in interface org.apache.sling.api.SlingHttpServletRequest
public void setResponseContentType(java.lang.String responseContentType)
public java.util.Enumeration<java.lang.String> getResponseContentTypes()
getResponseContentTypes
in interface org.apache.sling.api.SlingHttpServletRequest
public java.io.BufferedReader getReader()
getReader
in interface javax.servlet.ServletRequest
public org.apache.sling.api.request.RequestProgressTracker getRequestProgressTracker()
getRequestProgressTracker
in interface org.apache.sling.api.SlingHttpServletRequest
public java.lang.String getPathTranslated()
getPathTranslated
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getRequestedSessionId()
getRequestedSessionId
in interface javax.servlet.http.HttpServletRequest
public java.security.Principal getUserPrincipal()
getUserPrincipal
in interface javax.servlet.http.HttpServletRequest
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 isUserInRole(java.lang.String role)
isUserInRole
in interface javax.servlet.http.HttpServletRequest
public 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 java.util.Enumeration<java.util.Locale> getLocales()
getLocales
in interface javax.servlet.ServletRequest
public java.lang.String getProtocol()
getProtocol
in interface javax.servlet.ServletRequest
public java.lang.String getRealPath(java.lang.String path)
getRealPath
in interface javax.servlet.ServletRequest
public boolean authenticate(javax.servlet.http.HttpServletResponse response)
authenticate
in interface javax.servlet.http.HttpServletRequest
public void login(java.lang.String pUsername, java.lang.String password)
login
in interface javax.servlet.http.HttpServletRequest
public void logout() throws javax.servlet.ServletException
logout
in interface javax.servlet.http.HttpServletRequest
javax.servlet.ServletException
public java.util.Collection<javax.servlet.http.Part> getParts()
getParts
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.http.Part getPart(java.lang.String name)
getPart
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.ServletContext getServletContext()
getServletContext
in interface javax.servlet.ServletRequest
public javax.servlet.AsyncContext startAsync()
startAsync
in interface javax.servlet.ServletRequest
public javax.servlet.AsyncContext startAsync(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse)
startAsync
in interface javax.servlet.ServletRequest
public boolean isAsyncStarted()
isAsyncStarted
in interface javax.servlet.ServletRequest
public boolean isAsyncSupported()
isAsyncSupported
in interface javax.servlet.ServletRequest
public javax.servlet.AsyncContext getAsyncContext()
getAsyncContext
in interface javax.servlet.ServletRequest
public javax.servlet.DispatcherType getDispatcherType()
getDispatcherType
in interface javax.servlet.ServletRequest
public java.lang.String changeSessionId()
changeSessionId
in interface javax.servlet.http.HttpServletRequest
public <T extends javax.servlet.http.HttpUpgradeHandler> T upgrade(java.lang.Class<T> handlerClass) throws java.io.IOException, javax.servlet.ServletException
upgrade
in interface javax.servlet.http.HttpServletRequest
java.io.IOException
javax.servlet.ServletException
public long getContentLengthLong()
getContentLengthLong
in interface javax.servlet.ServletRequest
Copyright © 2014–2021 wcm.io. All rights reserved.