Package mondrian.tui
Class MockHttpServletRequest
java.lang.Object
mondrian.tui.MockHttpServletRequest
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletRequest,jakarta.servlet.ServletRequest
public class MockHttpServletRequest
extends Object
implements jakarta.servlet.http.HttpServletRequest
Partial implementation of the
HttpServletRequest where just
enough is present to allow for communication between Mondrian's
XMLA code and other code in the same JVM.
Currently it is used in both the CmdRunner and in XMLA JUnit tests. If you need to add to this implementation, please do so.
- Author:
- Richard M. Emberson
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from interface jakarta.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
ConstructorsConstructorDescriptionMockHttpServletRequest(byte[] bytes) MockHttpServletRequest(String bodyContent) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(jakarta.servlet.http.Cookie cookie) voidvoidvoidaddLocales(List<Locale> localeList) booleanauthenticate(jakarta.servlet.http.HttpServletResponse httpServletResponse) voidvoidclearHeader(String key) voidjakarta.servlet.AsyncContextgetAttribute(String name) Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.to this request.Returns the name of the authentication scheme used to protect the servlet, for example, "BASIC" or "SSL," or null if the servlet was not protected.Returns the name of the character encoding used in the body of this request.intReturns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.longReturns the MIME type of the body of the request, or null if the type is not known.Returns the portion of the request URI that indicates the context of the request.jakarta.servlet.http.Cookie[]Returns an array containing all of the Cookie objects the client sent with this request.longgetDateHeader(String name) Returns the value of the specified request header as a long value that represents a Date object.jakarta.servlet.DispatcherTypeReturns the value of the specified request header as a String.Returns an enumeration of all the header names this request contains.getHeaders(String name) Returns all the values of the specified request header as an Enumeration of String objects.jakarta.servlet.ServletInputStreamRetrieves the body of the request as binary data using a ServletInputStream.intgetIntHeader(String name) Returns the value of the specified request header as an int.Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.intReturns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.getParameter(String name) Returns the value of a request parameter as a String, or null if the parameter does not exist.Returns an Enumeration of String objects containing the names of the parameters contained in this request.String[]getParameterValues(String name) Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.jakarta.servlet.http.PartCollection<jakarta.servlet.http.Part> getParts()Returns any extra path information associated with the URL the client sent when it made this request.Returns any extra path information after the servlet name but before the query string, and translates it to a real path.Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.Returns the query string that is contained in the request URL after the path.Retrieves the body of the request as character data using a BufferedReader.getRealPath(String path) Deprecated.Method getRealPath is deprecatedReturns the Internet Protocol (IP) address of the client that sent the request.Returns the fully qualified name of the client that sent the request, or the IP address of the client if the name cannot be determined.intReturns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.jakarta.servlet.RequestDispatchergetRequestDispatcher(String path) Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.Returns the session ID specified by the client.Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.Returns the name of the scheme used to make this request, for example, http, https, or ftp.Returns the host name of the server that received the request.intReturns the port number on which this request was received.jakarta.servlet.ServletConnectionjakarta.servlet.ServletContextReturns the part of this request's URL that calls the servlet.jakarta.servlet.http.HttpSessionReturns the current session associated with this request, or if the request does not have a session, creates one.jakarta.servlet.http.HttpSessiongetSession(boolean create) Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.Returns a java.security.Principal object containing the name of the current authenticated user.booleanbooleanbooleanChecks whether the requested session ID came in as a cookie.booleanbooleanChecks whether the requested session ID came in as part of the request URL.booleanChecks whether the requested session ID is still valid.booleanisSecure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.booleanisUserInRole(String role) Returns a boolean indicating whether the authenticated user is included in the specified logical "role".voidvoidlogout()voidremoveAttribute(String name) Removes an attribute from this request.voidsetAttribute(String name, Object obj) Stores an attribute in this request.voidsetAuthType(String authType) voidsetBodyContent(byte[] data) voidsetBodyContent(String bodyContent) voidsetCharacterEncoding(String charEncoding) voidsetContentType(String contentType) voidsetContextPath(String contextPath) voidvoidsetLocalAddr(String localAddr) voidsetLocalName(String localName) voidsetLocalPort(int localPort) voidvoidsetPathInfo(String pathInfo) voidsetPathTranslated(String pathTranslated) voidsetProtocol(String protocol) voidsetQueryString(String queryString) voidsetRemoteAddr(String remoteAddr) voidsetRemoteHost(String remoteHost) voidsetRemotePort(int remotePort) voidsetRemoteUser(String remoteUser) voidsetRequestDispatcher(String path, jakarta.servlet.RequestDispatcher dispatcher) voidsetRequestedSessionId(String requestedSessionId) voidsetRequestedSessionIdFromCookie(boolean requestedSessionIdIsFromCookie) voidsetRequestURI(String requestedURI) voidsetRequestURL(String requestUrl) voidvoidsetServerName(String serverName) voidsetServerPort(int serverPort) voidsetServletPath(String servletPath) voidsetSession(jakarta.servlet.http.HttpSession session) voidsetupAddParameter(String key, String value) voidsetupAddParameter(String key, String[] values) voidsetUserInRole(String role, boolean isInRole) voidsetUserPrincipal(Principal principal) jakarta.servlet.AsyncContextjakarta.servlet.AsyncContextstartAsync(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse) <T extends jakarta.servlet.http.HttpUpgradeHandler>
TMethods 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, newPushBuilder
-
Field Details
-
AUTHORIZATION
-
DATE_FORMAT_HEADER
- See Also:
-
-
Constructor Details
-
MockHttpServletRequest
public MockHttpServletRequest() -
MockHttpServletRequest
public MockHttpServletRequest(byte[] bytes) -
MockHttpServletRequest
-
-
Method Details
-
getAttribute
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.- Specified by:
getAttributein interfacejakarta.servlet.ServletRequest
-
getAttributeNames
to this request.- Specified by:
getAttributeNamesin interfacejakarta.servlet.ServletRequest
-
getCharacterEncoding
Returns the name of the character encoding used in the body of this request.- Specified by:
getCharacterEncodingin interfacejakarta.servlet.ServletRequest
-
setCharacterEncoding
- Specified by:
setCharacterEncodingin interfacejakarta.servlet.ServletRequest- Throws:
UnsupportedEncodingException
-
getContentLength
public int getContentLength()Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.- Specified by:
getContentLengthin interfacejakarta.servlet.ServletRequest
-
getContentLengthLong
public long getContentLengthLong()- Specified by:
getContentLengthLongin interfacejakarta.servlet.ServletRequest
-
getContentType
Returns the MIME type of the body of the request, or null if the type is not known.- Specified by:
getContentTypein interfacejakarta.servlet.ServletRequest
-
getInputStream
Retrieves the body of the request as binary data using a ServletInputStream.- Specified by:
getInputStreamin interfacejakarta.servlet.ServletRequest- Throws:
IOException
-
getParameter
Returns the value of a request parameter as a String, or null if the parameter does not exist.- Specified by:
getParameterin interfacejakarta.servlet.ServletRequest
-
getParameterNames
Returns an Enumeration of String objects containing the names of the parameters contained in this request.- Specified by:
getParameterNamesin interfacejakarta.servlet.ServletRequest
-
getParameterValues
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.- Specified by:
getParameterValuesin interfacejakarta.servlet.ServletRequest
-
getProtocol
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.- Specified by:
getProtocolin interfacejakarta.servlet.ServletRequest
-
getScheme
Returns the name of the scheme used to make this request, for example, http, https, or ftp.- Specified by:
getSchemein interfacejakarta.servlet.ServletRequest
-
getServerName
Returns the host name of the server that received the request.- Specified by:
getServerNamein interfacejakarta.servlet.ServletRequest
-
getServerPort
public int getServerPort()Returns the port number on which this request was received.- Specified by:
getServerPortin interfacejakarta.servlet.ServletRequest
-
getReader
Retrieves the body of the request as character data using a BufferedReader.- Specified by:
getReaderin interfacejakarta.servlet.ServletRequest- Throws:
IOException
-
getRemoteAddr
Returns the Internet Protocol (IP) address of the client that sent the request.- Specified by:
getRemoteAddrin interfacejakarta.servlet.ServletRequest
-
getRemoteHost
Returns the fully qualified name of the client that sent the request, or the IP address of the client if the name cannot be determined.- Specified by:
getRemoteHostin interfacejakarta.servlet.ServletRequest
-
setAttribute
Stores an attribute in this request.- Specified by:
setAttributein interfacejakarta.servlet.ServletRequest
-
removeAttribute
Removes an attribute from this request.- Specified by:
removeAttributein interfacejakarta.servlet.ServletRequest
-
getLocale
Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.- Specified by:
getLocalein interfacejakarta.servlet.ServletRequest
-
getLocales
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.- Specified by:
getLocalesin interfacejakarta.servlet.ServletRequest
-
isSecure
public boolean isSecure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.- Specified by:
isSecurein interfacejakarta.servlet.ServletRequest
-
getRequestDispatcher
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.- Specified by:
getRequestDispatcherin interfacejakarta.servlet.ServletRequest
-
getRealPath
Deprecated.Method getRealPath is deprecatedDeprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead. -
getRemotePort
public int getRemotePort()- Specified by:
getRemotePortin interfacejakarta.servlet.ServletRequest
-
getLocalName
- Specified by:
getLocalNamein interfacejakarta.servlet.ServletRequest
-
getLocalAddr
- Specified by:
getLocalAddrin interfacejakarta.servlet.ServletRequest
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin interfacejakarta.servlet.ServletRequest
-
getServletContext
public jakarta.servlet.ServletContext getServletContext()- Specified by:
getServletContextin interfacejakarta.servlet.ServletRequest
-
startAsync
- Specified by:
startAsyncin interfacejakarta.servlet.ServletRequest- Throws:
IllegalStateException
-
getServletConnection
public jakarta.servlet.ServletConnection getServletConnection()- Specified by:
getServletConnectionin interfacejakarta.servlet.ServletRequest
-
getProtocolRequestId
- Specified by:
getProtocolRequestIdin interfacejakarta.servlet.ServletRequest
-
getRequestId
- Specified by:
getRequestIdin interfacejakarta.servlet.ServletRequest
-
startAsync
public jakarta.servlet.AsyncContext startAsync(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse) throws IllegalStateException - Specified by:
startAsyncin interfacejakarta.servlet.ServletRequest- Throws:
IllegalStateException
-
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
-
getAuthType
Returns the name of the authentication scheme used to protect the servlet, for example, "BASIC" or "SSL," or null if the servlet was not protected.- Specified by:
getAuthTypein interfacejakarta.servlet.http.HttpServletRequest
-
getCookies
public jakarta.servlet.http.Cookie[] getCookies()Returns an array containing all of the Cookie objects the client sent with this request.- Specified by:
getCookiesin interfacejakarta.servlet.http.HttpServletRequest
-
getDateHeader
Returns the value of the specified request header as a long value that represents a Date object.- Specified by:
getDateHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getHeader
Returns the value of the specified request header as a String.- Specified by:
getHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getHeaders
Returns all the values of the specified request header as an Enumeration of String objects.- Specified by:
getHeadersin interfacejakarta.servlet.http.HttpServletRequest
-
getHeaderNames
Returns an enumeration of all the header names this request contains.- Specified by:
getHeaderNamesin interfacejakarta.servlet.http.HttpServletRequest
-
getIntHeader
Returns the value of the specified request header as an int.- Specified by:
getIntHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getMethod
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.- Specified by:
getMethodin interfacejakarta.servlet.http.HttpServletRequest
-
getPathInfo
Returns any extra path information associated with the URL the client sent when it made this request.- Specified by:
getPathInfoin interfacejakarta.servlet.http.HttpServletRequest
-
getPathTranslated
Returns any extra path information after the servlet name but before the query string, and translates it to a real path.- Specified by:
getPathTranslatedin interfacejakarta.servlet.http.HttpServletRequest
-
getContextPath
Returns the portion of the request URI that indicates the context of the request.- Specified by:
getContextPathin interfacejakarta.servlet.http.HttpServletRequest
-
getQueryString
Returns the query string that is contained in the request URL after the path.- Specified by:
getQueryStringin interfacejakarta.servlet.http.HttpServletRequest
-
getRemoteUser
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.- Specified by:
getRemoteUserin interfacejakarta.servlet.http.HttpServletRequest
-
isUserInRole
Returns a boolean indicating whether the authenticated user is included in the specified logical "role".- Specified by:
isUserInRolein interfacejakarta.servlet.http.HttpServletRequest
-
getUserPrincipal
Returns a java.security.Principal object containing the name of the current authenticated user.- Specified by:
getUserPrincipalin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestedSessionId
Returns the session ID specified by the client.- Specified by:
getRequestedSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestURI
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.- Specified by:
getRequestURIin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestURL
- Specified by:
getRequestURLin interfacejakarta.servlet.http.HttpServletRequest
-
getServletPath
Returns the part of this request's URL that calls the servlet.- Specified by:
getServletPathin interfacejakarta.servlet.http.HttpServletRequest
-
getSession
public jakarta.servlet.http.HttpSession getSession(boolean create) Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.- Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
getSession
public jakarta.servlet.http.HttpSession getSession()Returns the current session associated with this request, or if the request does not have a session, creates one.- Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
changeSessionId
- Specified by:
changeSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()Checks whether the requested session ID is still valid.- Specified by:
isRequestedSessionIdValidin interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()Checks whether the requested session ID came in as a cookie.- Specified by:
isRequestedSessionIdFromCookiein interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()Checks whether the requested session ID came in as part of the request URL.- Specified by:
isRequestedSessionIdFromURLin interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl() -
authenticate
public boolean authenticate(jakarta.servlet.http.HttpServletResponse httpServletResponse) throws IOException, jakarta.servlet.ServletException - Specified by:
authenticatein interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
login
- Specified by:
loginin interfacejakarta.servlet.http.HttpServletRequest- Throws:
jakarta.servlet.ServletException
-
logout
public void logout() throws jakarta.servlet.ServletException- Specified by:
logoutin interfacejakarta.servlet.http.HttpServletRequest- Throws:
jakarta.servlet.ServletException
-
getParts
public Collection<jakarta.servlet.http.Part> getParts() throws IOException, jakarta.servlet.ServletException- Specified by:
getPartsin interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
getPart
public jakarta.servlet.http.Part getPart(String s) throws IOException, jakarta.servlet.ServletException - Specified by:
getPartin interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
upgrade
public <T extends jakarta.servlet.http.HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, jakarta.servlet.ServletException - Specified by:
upgradein interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
getParameterMap
- Specified by:
getParameterMapin interfacejakarta.servlet.ServletRequest
-
setServerName
-
setRemoteHost
-
setRemoteAddr
-
setMethod
-
setPathInfo
-
setPathTranslated
-
setContextPath
-
setQueryString
-
setRemoteUser
-
setRequestedSessionId
-
setRequestURI
-
setServletPath
-
setLocalName
-
setLocalAddr
-
setAuthType
-
setProtocol
-
setScheme
-
setRemotePort
public void setRemotePort(int remotePort) -
setLocalPort
public void setLocalPort(int localPort) -
setServerPort
public void setServerPort(int serverPort) -
setContentType
-
setHeader
-
clearParameters
public void clearParameters() -
setupAddParameter
-
setupAddParameter
-
clearAttributes
public void clearAttributes() -
setSession
public void setSession(jakarta.servlet.http.HttpSession session) -
getRequestDispatcherMap
-
setRequestDispatcher
-
addLocale
-
addLocales
-
addHeader
-
clearHeader
-
setRequestURL
-
setUserPrincipal
-
addCookie
public void addCookie(jakarta.servlet.http.Cookie cookie) -
setRequestedSessionIdFromCookie
public void setRequestedSessionIdFromCookie(boolean requestedSessionIdIsFromCookie) -
setUserInRole
-
setBodyContent
public void setBodyContent(byte[] data) -
setBodyContent
-