Package org.apache.sling.servlethelpers
Class MockSlingJakartaHttpServletRequest
java.lang.Object
org.apache.sling.api.adapter.SlingAdaptable
org.apache.sling.servlethelpers.MockSlingJakartaHttpServletRequest
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletRequest,jakarta.servlet.ServletRequest,org.apache.sling.api.adapter.Adaptable,org.apache.sling.api.SlingJakartaHttpServletRequest
@ConsumerType
public class MockSlingJakartaHttpServletRequest
extends org.apache.sling.api.adapter.SlingAdaptable
implements org.apache.sling.api.SlingJakartaHttpServletRequest
Mock
SlingJakartaHttpServletRequest implementation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ResourceBundleprotected static final StringFields inherited from interface jakarta.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
ConstructorsConstructorDescriptionMockSlingJakartaHttpServletRequest(org.apache.sling.api.resource.ResourceResolver resourceResolver) -
Method Summary
Modifier and TypeMethodDescription<T> TvoidaddCookie(jakarta.servlet.http.Cookie cookie) Set cookievoidaddDateHeader(String name, long date) Add header, keep existing ones with same name.voidAdd header, keep existing ones with same name.voidaddIntHeader(String name, int value) Add header, keep existing ones with same name.voidaddPart(jakarta.servlet.http.Part part) voidaddRequestParameter(String name, byte[] content, String contentType) Add a request parameter that emulates a file upload field.voidaddRequestParameter(String name, byte[] content, String contentType, String filename) Add a request parameter that emulates a file upload field with a filename associated with it.voidaddRequestParameter(String name, String value) Add a request parameter that consists of a simple name/value pair.booleanauthenticate(jakarta.servlet.http.HttpServletResponse response) jakarta.servlet.AsyncContextgetAttribute(String name) intlongjakarta.servlet.http.Cookiejakarta.servlet.http.Cookie[]longgetDateHeader(String name) jakarta.servlet.DispatcherTypegetHeaders(String name) jakarta.servlet.ServletInputStreamintgetIntHeader(String name) intgetParameter(String name) String[]getParameterValues(String name) jakarta.servlet.http.PartCollection<jakarta.servlet.http.Part>getParts()intjakarta.servlet.RequestDispatchergetRequestDispatcher(String path) jakarta.servlet.RequestDispatchergetRequestDispatcher(String path, org.apache.sling.api.request.RequestDispatcherOptions options) jakarta.servlet.RequestDispatchergetRequestDispatcher(org.apache.sling.api.resource.Resource resource) jakarta.servlet.RequestDispatchergetRequestDispatcher(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.request.RequestDispatcherOptions options) org.apache.sling.api.request.RequestParametergetRequestParameter(String name) List<org.apache.sling.api.request.RequestParameter>org.apache.sling.api.request.RequestParameterMaporg.apache.sling.api.request.RequestParameter[]getRequestParameters(String name) org.apache.sling.api.request.RequestPathInfoorg.apache.sling.api.request.RequestProgressTrackerorg.apache.sling.api.resource.ResourcegetResourceBundle(String baseName, Locale locale) getResourceBundle(Locale locale) org.apache.sling.api.resource.ResourceResolverintjakarta.servlet.ServletConnectionjakarta.servlet.ServletContextjakarta.servlet.http.HttpSessionjakarta.servlet.http.HttpSessiongetSession(boolean create) booleanbooleanbooleanbooleanbooleanbooleanisSecure()booleanisUserInRole(String role) voidvoidlogout()protected MockJakartaHttpSessionprotected MockRequestPathInfovoidremoveAttribute(String name) voidsetAttribute(String name, Object object) voidsetAuthType(String authType) voidsetCharacterEncoding(String charset) voidsetContent(byte[] content) voidsetContentType(String type) voidsetContextPath(String contextPath) voidsetDateHeader(String name, long date) Set header, overwrite existing ones with same name.voidSet header, overwrite existing ones with same name.voidsetIntHeader(String name, int value) Set header, overwrite existing ones with same name.voidvoidvoidsetParameterMap(Map<String, Object> parameterMap) voidsetPathInfo(String pathInfo) voidsetQueryString(String queryString) voidsetRemoteAddr(String remoteAddr) voidsetRemoteHost(String remoteHost) voidsetRemotePort(int remotePort) voidsetRemoteUser(String remoteUser) voidsetRequestDispatcherFactory(MockJakartaRequestDispatcherFactory requestDispatcherFactory) voidsetResource(org.apache.sling.api.resource.Resource resource) voidsetResponseContentType(String responseContentType) voidvoidsetServerName(String serverName) voidsetServerPort(int serverPort) voidsetServletPath(String servletPath) jakarta.servlet.AsyncContextjakarta.servlet.AsyncContextstartAsync(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse) <T extends jakarta.servlet.http.HttpUpgradeHandler>
TMethods inherited from class org.apache.sling.api.adapter.SlingAdaptable
setAdapterManager, unsetAdapterManagerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.http.HttpServletRequest
getHttpServletMapping, getTrailerFields, isTrailerFieldsReady, newPushBuilderMethods inherited from interface jakarta.servlet.ServletRequest
setCharacterEncoding
-
Field Details
-
PLEASE_PROVDIDE_REQUEST_DISPATCHER_FACTORY
- See Also:
-
EMPTY_RESOURCE_BUNDLE
-
-
Constructor Details
-
MockSlingJakartaHttpServletRequest
public MockSlingJakartaHttpServletRequest(org.apache.sling.api.resource.ResourceResolver resourceResolver) - Parameters:
resourceResolver- Resource resolver
-
-
Method Details
-
newMockHttpSession
-
newMockRequestPathInfo
-
getResourceResolver
public org.apache.sling.api.resource.ResourceResolver getResourceResolver()- Specified by:
getResourceResolverin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getSession
public jakarta.servlet.http.HttpSession getSession()- Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
getSession
public jakarta.servlet.http.HttpSession getSession(boolean create) - Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestPathInfo
public org.apache.sling.api.request.RequestPathInfo getRequestPathInfo()- Specified by:
getRequestPathInfoin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getAttribute
- Specified by:
getAttributein interfacejakarta.servlet.ServletRequest
-
getAttributeNames
- Specified by:
getAttributeNamesin interfacejakarta.servlet.ServletRequest
-
removeAttribute
- Specified by:
removeAttributein interfacejakarta.servlet.ServletRequest
-
setAttribute
- Specified by:
setAttributein interfacejakarta.servlet.ServletRequest
-
getResource
public org.apache.sling.api.resource.Resource getResource()- Specified by:
getResourcein interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
setResource
public void setResource(org.apache.sling.api.resource.Resource resource) -
getParameter
- Specified by:
getParameterin interfacejakarta.servlet.ServletRequest
-
getParameterMap
- Specified by:
getParameterMapin interfacejakarta.servlet.ServletRequest
-
getParameterNames
- Specified by:
getParameterNamesin interfacejakarta.servlet.ServletRequest
-
getParameterValues
- Specified by:
getParameterValuesin interfacejakarta.servlet.ServletRequest
-
setParameterMap
- Parameters:
parameterMap- Map of parameters
-
getLocale
- Specified by:
getLocalein interfacejakarta.servlet.ServletRequest
-
setLocale
- Parameters:
loc- Request locale
-
getContextPath
- Specified by:
getContextPathin interfacejakarta.servlet.http.HttpServletRequest
-
setContextPath
- Parameters:
contextPath- Webapp context path
-
setQueryString
- Parameters:
queryString- Query string (with proper URL encoding)
-
getQueryString
- Specified by:
getQueryStringin interfacejakarta.servlet.http.HttpServletRequest
-
getScheme
- Specified by:
getSchemein interfacejakarta.servlet.ServletRequest
-
setScheme
-
getServerName
- Specified by:
getServerNamein interfacejakarta.servlet.ServletRequest
-
setServerName
-
getServerPort
public int getServerPort()- Specified by:
getServerPortin interfacejakarta.servlet.ServletRequest
-
setServerPort
public void setServerPort(int serverPort) -
isSecure
public boolean isSecure()- Specified by:
isSecurein interfacejakarta.servlet.ServletRequest
-
getMethod
- Specified by:
getMethodin interfacejakarta.servlet.http.HttpServletRequest
-
setMethod
-
getDateHeader
- Specified by:
getDateHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getHeader
- Specified by:
getHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getHeaderNames
- Specified by:
getHeaderNamesin interfacejakarta.servlet.http.HttpServletRequest
-
getHeaders
- Specified by:
getHeadersin interfacejakarta.servlet.http.HttpServletRequest
-
getIntHeader
- Specified by:
getIntHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
addHeader
Add header, keep existing ones with same name.- Parameters:
name- Header namevalue- Header value
-
addIntHeader
Add header, keep existing ones with same name.- Parameters:
name- Header namevalue- Header value
-
addDateHeader
Add header, keep existing ones with same name.- Parameters:
name- Header namedate- Header value
-
setHeader
Set header, overwrite existing ones with same name.- Parameters:
name- Header namevalue- Header value
-
setIntHeader
Set header, overwrite existing ones with same name.- Parameters:
name- Header namevalue- Header value
-
setDateHeader
Set header, overwrite existing ones with same name.- Parameters:
name- Header namedate- Header value
-
getCookie
- Specified by:
getCookiein interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getCookies
public jakarta.servlet.http.Cookie[] getCookies()- Specified by:
getCookiesin interfacejakarta.servlet.http.HttpServletRequest
-
addCookie
public void addCookie(jakarta.servlet.http.Cookie cookie) Set cookie- Parameters:
cookie- Cookie
-
getResourceBundle
- Specified by:
getResourceBundlein interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getResourceBundle
- Specified by:
getResourceBundlein interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getRequestParameter
- Specified by:
getRequestParameterin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getRequestParameterMap
public org.apache.sling.api.request.RequestParameterMap getRequestParameterMap()- Specified by:
getRequestParameterMapin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getRequestParameters
- Specified by:
getRequestParametersin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getRequestParameterList
- Specified by:
getRequestParameterListin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
addRequestParameter
Add a request parameter that consists of a simple name/value pair. This emulates a simple form field.- Parameters:
name- field namevalue- field value
-
addRequestParameter
Add a request parameter that emulates a file upload field.- Parameters:
name- field namecontent- file contentcontentType- mime type of content in the field
-
addRequestParameter
Add a request parameter that emulates a file upload field with a filename associated with it.- Parameters:
name- field namecontent- file contentcontentType- mime type of content in the fieldfilename- filename associated with content
-
getCharacterEncoding
- Specified by:
getCharacterEncodingin interfacejakarta.servlet.ServletRequest
-
setCharacterEncoding
- Specified by:
setCharacterEncodingin interfacejakarta.servlet.ServletRequest
-
getContentType
- Specified by:
getContentTypein interfacejakarta.servlet.ServletRequest
-
setContentType
-
getInputStream
public jakarta.servlet.ServletInputStream getInputStream()- Specified by:
getInputStreamin interfacejakarta.servlet.ServletRequest
-
getContentLength
public int getContentLength()- Specified by:
getContentLengthin interfacejakarta.servlet.ServletRequest
-
setContent
public void setContent(byte[] content) -
getRequestDispatcher
- Specified by:
getRequestDispatcherin interfacejakarta.servlet.ServletRequest
-
getRequestDispatcher
public jakarta.servlet.RequestDispatcher getRequestDispatcher(String path, org.apache.sling.api.request.RequestDispatcherOptions options) - Specified by:
getRequestDispatcherin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getRequestDispatcher
public jakarta.servlet.RequestDispatcher getRequestDispatcher(org.apache.sling.api.resource.Resource resource) - Specified by:
getRequestDispatcherin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getRequestDispatcher
public jakarta.servlet.RequestDispatcher getRequestDispatcher(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.request.RequestDispatcherOptions options) - Specified by:
getRequestDispatcherin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
setRequestDispatcherFactory
public void setRequestDispatcherFactory(MockJakartaRequestDispatcherFactory requestDispatcherFactory) -
getRemoteUser
- Specified by:
getRemoteUserin interfacejakarta.servlet.http.HttpServletRequest- Specified by:
getRemoteUserin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
setRemoteUser
-
getRemoteAddr
- Specified by:
getRemoteAddrin interfacejakarta.servlet.ServletRequest
-
setRemoteAddr
-
getRemoteHost
- Specified by:
getRemoteHostin interfacejakarta.servlet.ServletRequest
-
setRemoteHost
-
getRemotePort
public int getRemotePort()- Specified by:
getRemotePortin interfacejakarta.servlet.ServletRequest
-
setRemotePort
public void setRemotePort(int remotePort) -
getServletPath
- Specified by:
getServletPathin interfacejakarta.servlet.http.HttpServletRequest
-
setServletPath
-
getPathInfo
- Specified by:
getPathInfoin interfacejakarta.servlet.http.HttpServletRequest
-
setPathInfo
-
getRequestURI
- Specified by:
getRequestURIin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestURL
- Specified by:
getRequestURLin interfacejakarta.servlet.http.HttpServletRequest
-
getAuthType
- Specified by:
getAuthTypein interfacejakarta.servlet.http.HttpServletRequest- Specified by:
getAuthTypein interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
setAuthType
-
adaptTo
- Specified by:
adaptToin interfaceorg.apache.sling.api.adapter.Adaptable- Overrides:
adaptToin classorg.apache.sling.api.adapter.SlingAdaptable
-
getResponseContentType
- Specified by:
getResponseContentTypein interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
setResponseContentType
-
getResponseContentTypes
- Specified by:
getResponseContentTypesin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getReader
- Specified by:
getReaderin interfacejakarta.servlet.ServletRequest
-
getRequestProgressTracker
public org.apache.sling.api.request.RequestProgressTracker getRequestProgressTracker()- Specified by:
getRequestProgressTrackerin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
addPart
public void addPart(jakarta.servlet.http.Part part) -
getParts
- Specified by:
getPartsin interfacejakarta.servlet.http.HttpServletRequest
-
getPart
- Specified by:
getPartin interfacejakarta.servlet.http.HttpServletRequest
-
getUserPrincipal
- Specified by:
getUserPrincipalin interfacejakarta.servlet.http.HttpServletRequest- Specified by:
getUserPrincipalin interfaceorg.apache.sling.api.SlingJakartaHttpServletRequest
-
getPathTranslated
- Specified by:
getPathTranslatedin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestedSessionId
- Specified by:
getRequestedSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()- Specified by:
isRequestedSessionIdFromCookiein interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()- Specified by:
isRequestedSessionIdFromURLin interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()- Specified by:
isRequestedSessionIdValidin interfacejakarta.servlet.http.HttpServletRequest
-
isUserInRole
- Specified by:
isUserInRolein interfacejakarta.servlet.http.HttpServletRequest
-
getLocalAddr
- Specified by:
getLocalAddrin interfacejakarta.servlet.ServletRequest
-
getLocalName
- Specified by:
getLocalNamein interfacejakarta.servlet.ServletRequest
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin interfacejakarta.servlet.ServletRequest
-
getLocales
- Specified by:
getLocalesin interfacejakarta.servlet.ServletRequest
-
getProtocol
- Specified by:
getProtocolin interfacejakarta.servlet.ServletRequest
-
authenticate
public boolean authenticate(jakarta.servlet.http.HttpServletResponse response) - Specified by:
authenticatein interfacejakarta.servlet.http.HttpServletRequest
-
login
- Specified by:
loginin interfacejakarta.servlet.http.HttpServletRequest
-
logout
public void logout() throws jakarta.servlet.ServletException- Specified by:
logoutin interfacejakarta.servlet.http.HttpServletRequest- Throws:
jakarta.servlet.ServletException
-
getServletContext
public jakarta.servlet.ServletContext getServletContext()- Specified by:
getServletContextin interfacejakarta.servlet.ServletRequest
-
startAsync
public jakarta.servlet.AsyncContext startAsync()- Specified by:
startAsyncin interfacejakarta.servlet.ServletRequest
-
startAsync
public jakarta.servlet.AsyncContext startAsync(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse) - Specified by:
startAsyncin interfacejakarta.servlet.ServletRequest
-
isAsyncStarted
public boolean isAsyncStarted()- Specified by:
isAsyncStartedin interfacejakarta.servlet.ServletRequest
-
isAsyncSupported
public boolean isAsyncSupported()- Specified by:
isAsyncSupportedin interfacejakarta.servlet.ServletRequest
-
getAsyncContext
public jakarta.servlet.AsyncContext getAsyncContext()- Specified by:
getAsyncContextin interfacejakarta.servlet.ServletRequest
-
getDispatcherType
public jakarta.servlet.DispatcherType getDispatcherType()- Specified by:
getDispatcherTypein interfacejakarta.servlet.ServletRequest
-
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
-
getContentLengthLong
public long getContentLengthLong()- Specified by:
getContentLengthLongin interfacejakarta.servlet.ServletRequest
-
getRequestId
- Specified by:
getRequestIdin interfacejakarta.servlet.ServletRequest
-
getProtocolRequestId
- Specified by:
getProtocolRequestIdin interfacejakarta.servlet.ServletRequest
-
getServletConnection
public jakarta.servlet.ServletConnection getServletConnection()- Specified by:
getServletConnectionin interfacejakarta.servlet.ServletRequest
-