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