Package mondrian.tui
Class MockHttpServletRequest
java.lang.Object
mondrian.tui.MockHttpServletRequest
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest
,javax.servlet.ServletRequest
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
-
Field Summary
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
-
Constructor Summary
ConstructorDescriptionMockHttpServletRequest
(byte[] bytes) MockHttpServletRequest
(String bodyContent) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCookie
(javax.servlet.http.Cookie cookie) void
void
void
addLocales
(List<Locale> localeList) void
void
clearHeader
(String key) void
getAttribute
(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.int
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.Returns 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.javax.servlet.http.Cookie[]
Returns an array containing all of the Cookie objects the client sent with this request.long
getDateHeader
(String name) Returns the value of the specified request header as a long value that represents a Date object.Returns 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.javax.servlet.ServletInputStream
Retrieves the body of the request as binary data using a ServletInputStream.int
getIntHeader
(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.int
Returns 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.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.int
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.javax.servlet.RequestDispatcher
getRequestDispatcher
(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.int
Returns the port number on which this request was received.Returns the part of this request's URL that calls the servlet.javax.servlet.http.HttpSession
Returns the current session associated with this request, or if the request does not have a session, creates one.javax.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.Returns a java.security.Principal object containing the name of the current authenticated user.boolean
Checks whether the requested session ID came in as a cookie.boolean
boolean
Checks whether the requested session ID came in as part of the request URL.boolean
Checks whether the requested session ID is still valid.boolean
isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.boolean
isUserInRole
(String role) Returns a boolean indicating whether the authenticated user is included in the specified logical "role".void
removeAttribute
(String name) Removes an attribute from this request.void
setAttribute
(String name, Object obj) Stores an attribute in this request.void
setAuthType
(String authType) void
setBodyContent
(byte[] data) void
setBodyContent
(String bodyContent) void
setCharacterEncoding
(String charEncoding) void
setContentType
(String contentType) void
setContextPath
(String contextPath) void
void
setLocalAddr
(String localAddr) void
setLocalName
(String localName) void
setLocalPort
(int localPort) void
void
setPathInfo
(String pathInfo) void
setPathTranslated
(String pathTranslated) void
setProtocol
(String protocol) void
setQueryString
(String queryString) void
setRemoteAddr
(String remoteAddr) void
setRemoteHost
(String remoteHost) void
setRemotePort
(int remotePort) void
setRemoteUser
(String remoteUser) void
setRequestDispatcher
(String path, javax.servlet.RequestDispatcher dispatcher) void
setRequestedSessionId
(String requestedSessionId) void
setRequestedSessionIdFromCookie
(boolean requestedSessionIdIsFromCookie) void
setRequestURI
(String requestedURI) void
setRequestURL
(String requestUrl) void
void
setServerName
(String serverName) void
setServerPort
(int serverPort) void
setServletPath
(String servletPath) void
setSession
(javax.servlet.http.HttpSession session) void
setupAddParameter
(String key, String value) void
setupAddParameter
(String key, String[] values) void
setUserInRole
(String role, boolean isInRole) void
setUserPrincipal
(Principal principal)
-
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:
getAttribute
in interfacejavax.servlet.ServletRequest
-
getAttributeNames
to this request.- Specified by:
getAttributeNames
in interfacejavax.servlet.ServletRequest
-
getCharacterEncoding
Returns the name of the character encoding used in the body of this request.- Specified by:
getCharacterEncoding
in interfacejavax.servlet.ServletRequest
-
setCharacterEncoding
- Specified by:
setCharacterEncoding
in interfacejavax.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:
getContentLength
in interfacejavax.servlet.ServletRequest
-
getContentType
Returns the MIME type of the body of the request, or null if the type is not known.- Specified by:
getContentType
in interfacejavax.servlet.ServletRequest
-
getInputStream
Retrieves the body of the request as binary data using a ServletInputStream.- Specified by:
getInputStream
in interfacejavax.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:
getParameter
in interfacejavax.servlet.ServletRequest
-
getParameterNames
Returns an Enumeration of String objects containing the names of the parameters contained in this request.- Specified by:
getParameterNames
in interfacejavax.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:
getParameterValues
in interfacejavax.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:
getProtocol
in interfacejavax.servlet.ServletRequest
-
getScheme
Returns the name of the scheme used to make this request, for example, http, https, or ftp.- Specified by:
getScheme
in interfacejavax.servlet.ServletRequest
-
getServerName
Returns the host name of the server that received the request.- Specified by:
getServerName
in interfacejavax.servlet.ServletRequest
-
getServerPort
public int getServerPort()Returns the port number on which this request was received.- Specified by:
getServerPort
in interfacejavax.servlet.ServletRequest
-
getReader
Retrieves the body of the request as character data using a BufferedReader.- Specified by:
getReader
in interfacejavax.servlet.ServletRequest
- Throws:
IOException
-
getRemoteAddr
Returns the Internet Protocol (IP) address of the client that sent the request.- Specified by:
getRemoteAddr
in interfacejavax.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:
getRemoteHost
in interfacejavax.servlet.ServletRequest
-
setAttribute
Stores an attribute in this request.- Specified by:
setAttribute
in interfacejavax.servlet.ServletRequest
-
removeAttribute
Removes an attribute from this request.- Specified by:
removeAttribute
in interfacejavax.servlet.ServletRequest
-
getLocale
Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.- Specified by:
getLocale
in interfacejavax.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:
getLocales
in interfacejavax.servlet.ServletRequest
-
isSecure
public boolean isSecure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.- Specified by:
isSecure
in interfacejavax.servlet.ServletRequest
-
getRequestDispatcher
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.- Specified by:
getRequestDispatcher
in interfacejavax.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.- Specified by:
getRealPath
in interfacejavax.servlet.ServletRequest
-
getRemotePort
public int getRemotePort()- Specified by:
getRemotePort
in interfacejavax.servlet.ServletRequest
-
getLocalName
- Specified by:
getLocalName
in interfacejavax.servlet.ServletRequest
-
getLocalAddr
- Specified by:
getLocalAddr
in interfacejavax.servlet.ServletRequest
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPort
in interfacejavax.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:
getAuthType
in interfacejavax.servlet.http.HttpServletRequest
-
getCookies
public javax.servlet.http.Cookie[] getCookies()Returns an array containing all of the Cookie objects the client sent with this request.- Specified by:
getCookies
in interfacejavax.servlet.http.HttpServletRequest
-
getDateHeader
Returns the value of the specified request header as a long value that represents a Date object.- Specified by:
getDateHeader
in interfacejavax.servlet.http.HttpServletRequest
-
getHeader
Returns the value of the specified request header as a String.- Specified by:
getHeader
in interfacejavax.servlet.http.HttpServletRequest
-
getHeaders
Returns all the values of the specified request header as an Enumeration of String objects.- Specified by:
getHeaders
in interfacejavax.servlet.http.HttpServletRequest
-
getHeaderNames
Returns an enumeration of all the header names this request contains.- Specified by:
getHeaderNames
in interfacejavax.servlet.http.HttpServletRequest
-
getIntHeader
Returns the value of the specified request header as an int.- Specified by:
getIntHeader
in interfacejavax.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:
getMethod
in interfacejavax.servlet.http.HttpServletRequest
-
getPathInfo
Returns any extra path information associated with the URL the client sent when it made this request.- Specified by:
getPathInfo
in interfacejavax.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:
getPathTranslated
in interfacejavax.servlet.http.HttpServletRequest
-
getContextPath
Returns the portion of the request URI that indicates the context of the request.- Specified by:
getContextPath
in interfacejavax.servlet.http.HttpServletRequest
-
getQueryString
Returns the query string that is contained in the request URL after the path.- Specified by:
getQueryString
in interfacejavax.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:
getRemoteUser
in interfacejavax.servlet.http.HttpServletRequest
-
isUserInRole
Returns a boolean indicating whether the authenticated user is included in the specified logical "role".- Specified by:
isUserInRole
in interfacejavax.servlet.http.HttpServletRequest
-
getUserPrincipal
Returns a java.security.Principal object containing the name of the current authenticated user.- Specified by:
getUserPrincipal
in interfacejavax.servlet.http.HttpServletRequest
-
getRequestedSessionId
Returns the session ID specified by the client.- Specified by:
getRequestedSessionId
in interfacejavax.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:
getRequestURI
in interfacejavax.servlet.http.HttpServletRequest
-
getRequestURL
- Specified by:
getRequestURL
in interfacejavax.servlet.http.HttpServletRequest
-
getServletPath
Returns the part of this request's URL that calls the servlet.- Specified by:
getServletPath
in interfacejavax.servlet.http.HttpServletRequest
-
getSession
public javax.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:
getSession
in interfacejavax.servlet.http.HttpServletRequest
-
getSession
public javax.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:
getSession
in interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()Checks whether the requested session ID is still valid.- Specified by:
isRequestedSessionIdValid
in interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()Checks whether the requested session ID came in as a cookie.- Specified by:
isRequestedSessionIdFromCookie
in interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()Checks whether the requested session ID came in as part of the request URL.- Specified by:
isRequestedSessionIdFromURL
in interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()- Specified by:
isRequestedSessionIdFromUrl
in interfacejavax.servlet.http.HttpServletRequest
-
getParameterMap
- Specified by:
getParameterMap
in interfacejavax.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(javax.servlet.http.HttpSession session) -
getRequestDispatcherMap
-
setRequestDispatcher
-
addLocale
-
addLocales
-
addHeader
-
clearHeader
-
setRequestURL
-
setUserPrincipal
-
addCookie
public void addCookie(javax.servlet.http.Cookie cookie) -
setRequestedSessionIdFromCookie
public void setRequestedSessionIdFromCookie(boolean requestedSessionIdIsFromCookie) -
setUserInRole
-
setBodyContent
public void setBodyContent(byte[] data) -
setBodyContent
-