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
  • Field Details

  • Constructor Details

    • MockHttpServletRequest

      public MockHttpServletRequest()
    • MockHttpServletRequest

      public MockHttpServletRequest(byte[] bytes)
    • MockHttpServletRequest

      public MockHttpServletRequest(String bodyContent)
  • Method Details

    • getAttribute

      public Object getAttribute(String name)
      Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
      Specified by:
      getAttribute in interface jakarta.servlet.ServletRequest
    • getAttributeNames

      public Enumeration getAttributeNames()
      to this request.
      Specified by:
      getAttributeNames in interface jakarta.servlet.ServletRequest
    • getCharacterEncoding

      public String getCharacterEncoding()
      Returns the name of the character encoding used in the body of this request.
      Specified by:
      getCharacterEncoding in interface jakarta.servlet.ServletRequest
    • setCharacterEncoding

      public void setCharacterEncoding(String charEncoding) throws UnsupportedEncodingException
      Specified by:
      setCharacterEncoding in interface jakarta.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 interface jakarta.servlet.ServletRequest
    • getContentLengthLong

      public long getContentLengthLong()
      Specified by:
      getContentLengthLong in interface jakarta.servlet.ServletRequest
    • getContentType

      public String getContentType()
      Returns the MIME type of the body of the request, or null if the type is not known.
      Specified by:
      getContentType in interface jakarta.servlet.ServletRequest
    • getInputStream

      public jakarta.servlet.ServletInputStream getInputStream() throws IOException
      Retrieves the body of the request as binary data using a ServletInputStream.
      Specified by:
      getInputStream in interface jakarta.servlet.ServletRequest
      Throws:
      IOException
    • getParameter

      public String getParameter(String name)
      Returns the value of a request parameter as a String, or null if the parameter does not exist.
      Specified by:
      getParameter in interface jakarta.servlet.ServletRequest
    • getParameterNames

      public Enumeration getParameterNames()
      Returns an Enumeration of String objects containing the names of the parameters contained in this request.
      Specified by:
      getParameterNames in interface jakarta.servlet.ServletRequest
    • getParameterValues

      public 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.
      Specified by:
      getParameterValues in interface jakarta.servlet.ServletRequest
    • getProtocol

      public String 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 interface jakarta.servlet.ServletRequest
    • getScheme

      public String getScheme()
      Returns the name of the scheme used to make this request, for example, http, https, or ftp.
      Specified by:
      getScheme in interface jakarta.servlet.ServletRequest
    • getServerName

      public String getServerName()
      Returns the host name of the server that received the request.
      Specified by:
      getServerName in interface jakarta.servlet.ServletRequest
    • getServerPort

      public int getServerPort()
      Returns the port number on which this request was received.
      Specified by:
      getServerPort in interface jakarta.servlet.ServletRequest
    • getReader

      public BufferedReader getReader() throws IOException
      Retrieves the body of the request as character data using a BufferedReader.
      Specified by:
      getReader in interface jakarta.servlet.ServletRequest
      Throws:
      IOException
    • getRemoteAddr

      public String getRemoteAddr()
      Returns the Internet Protocol (IP) address of the client that sent the request.
      Specified by:
      getRemoteAddr in interface jakarta.servlet.ServletRequest
    • getRemoteHost

      public String 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 interface jakarta.servlet.ServletRequest
    • setAttribute

      public void setAttribute(String name, Object obj)
      Stores an attribute in this request.
      Specified by:
      setAttribute in interface jakarta.servlet.ServletRequest
    • removeAttribute

      public void removeAttribute(String name)
      Removes an attribute from this request.
      Specified by:
      removeAttribute in interface jakarta.servlet.ServletRequest
    • getLocale

      public Locale getLocale()
      Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
      Specified by:
      getLocale in interface jakarta.servlet.ServletRequest
    • getLocales

      public Enumeration 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 interface jakarta.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 interface jakarta.servlet.ServletRequest
    • getRequestDispatcher

      public jakarta.servlet.RequestDispatcher getRequestDispatcher(String path)
      Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
      Specified by:
      getRequestDispatcher in interface jakarta.servlet.ServletRequest
    • getRealPath

      public String getRealPath(String path)
      Deprecated.
      Method getRealPath is deprecated
      Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead.
    • getRemotePort

      public int getRemotePort()
      Specified by:
      getRemotePort in interface jakarta.servlet.ServletRequest
    • getLocalName

      public String getLocalName()
      Specified by:
      getLocalName in interface jakarta.servlet.ServletRequest
    • getLocalAddr

      public String getLocalAddr()
      Specified by:
      getLocalAddr in interface jakarta.servlet.ServletRequest
    • getLocalPort

      public int getLocalPort()
      Specified by:
      getLocalPort in interface jakarta.servlet.ServletRequest
    • getServletContext

      public jakarta.servlet.ServletContext getServletContext()
      Specified by:
      getServletContext in interface jakarta.servlet.ServletRequest
    • startAsync

      public jakarta.servlet.AsyncContext startAsync() throws IllegalStateException
      Specified by:
      startAsync in interface jakarta.servlet.ServletRequest
      Throws:
      IllegalStateException
    • getServletConnection

      public jakarta.servlet.ServletConnection getServletConnection()
      Specified by:
      getServletConnection in interface jakarta.servlet.ServletRequest
    • getProtocolRequestId

      public String getProtocolRequestId()
      Specified by:
      getProtocolRequestId in interface jakarta.servlet.ServletRequest
    • getRequestId

      public String getRequestId()
      Specified by:
      getRequestId in interface jakarta.servlet.ServletRequest
    • startAsync

      public jakarta.servlet.AsyncContext startAsync(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse) throws IllegalStateException
      Specified by:
      startAsync in interface jakarta.servlet.ServletRequest
      Throws:
      IllegalStateException
    • isAsyncStarted

      public boolean isAsyncStarted()
      Specified by:
      isAsyncStarted in interface jakarta.servlet.ServletRequest
    • isAsyncSupported

      public boolean isAsyncSupported()
      Specified by:
      isAsyncSupported in interface jakarta.servlet.ServletRequest
    • getAsyncContext

      public jakarta.servlet.AsyncContext getAsyncContext()
      Specified by:
      getAsyncContext in interface jakarta.servlet.ServletRequest
    • getDispatcherType

      public jakarta.servlet.DispatcherType getDispatcherType()
      Specified by:
      getDispatcherType in interface jakarta.servlet.ServletRequest
    • getAuthType

      public String 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 interface jakarta.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:
      getCookies in interface jakarta.servlet.http.HttpServletRequest
    • getDateHeader

      public long getDateHeader(String name)
      Returns the value of the specified request header as a long value that represents a Date object.
      Specified by:
      getDateHeader in interface jakarta.servlet.http.HttpServletRequest
    • getHeader

      public String getHeader(String name)
      Returns the value of the specified request header as a String.
      Specified by:
      getHeader in interface jakarta.servlet.http.HttpServletRequest
    • getHeaders

      public Enumeration getHeaders(String name)
      Returns all the values of the specified request header as an Enumeration of String objects.
      Specified by:
      getHeaders in interface jakarta.servlet.http.HttpServletRequest
    • getHeaderNames

      public Enumeration getHeaderNames()
      Returns an enumeration of all the header names this request contains.
      Specified by:
      getHeaderNames in interface jakarta.servlet.http.HttpServletRequest
    • getIntHeader

      public int getIntHeader(String name)
      Returns the value of the specified request header as an int.
      Specified by:
      getIntHeader in interface jakarta.servlet.http.HttpServletRequest
    • getMethod

      public String getMethod()
      Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
      Specified by:
      getMethod in interface jakarta.servlet.http.HttpServletRequest
    • getPathInfo

      public String getPathInfo()
      Returns any extra path information associated with the URL the client sent when it made this request.
      Specified by:
      getPathInfo in interface jakarta.servlet.http.HttpServletRequest
    • getPathTranslated

      public String 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 interface jakarta.servlet.http.HttpServletRequest
    • getContextPath

      public String getContextPath()
      Returns the portion of the request URI that indicates the context of the request.
      Specified by:
      getContextPath in interface jakarta.servlet.http.HttpServletRequest
    • getQueryString

      public String getQueryString()
      Returns the query string that is contained in the request URL after the path.
      Specified by:
      getQueryString in interface jakarta.servlet.http.HttpServletRequest
    • getRemoteUser

      public String 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 interface jakarta.servlet.http.HttpServletRequest
    • isUserInRole

      public boolean isUserInRole(String role)
      Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
      Specified by:
      isUserInRole in interface jakarta.servlet.http.HttpServletRequest
    • getUserPrincipal

      public Principal getUserPrincipal()
      Returns a java.security.Principal object containing the name of the current authenticated user.
      Specified by:
      getUserPrincipal in interface jakarta.servlet.http.HttpServletRequest
    • getRequestedSessionId

      public String getRequestedSessionId()
      Returns the session ID specified by the client.
      Specified by:
      getRequestedSessionId in interface jakarta.servlet.http.HttpServletRequest
    • getRequestURI

      public String 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 interface jakarta.servlet.http.HttpServletRequest
    • getRequestURL

      public StringBuffer getRequestURL()
      Specified by:
      getRequestURL in interface jakarta.servlet.http.HttpServletRequest
    • getServletPath

      public String getServletPath()
      Returns the part of this request's URL that calls the servlet.
      Specified by:
      getServletPath in interface jakarta.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:
      getSession in interface jakarta.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:
      getSession in interface jakarta.servlet.http.HttpServletRequest
    • changeSessionId

      public String changeSessionId()
      Specified by:
      changeSessionId in interface jakarta.servlet.http.HttpServletRequest
    • isRequestedSessionIdValid

      public boolean isRequestedSessionIdValid()
      Checks whether the requested session ID is still valid.
      Specified by:
      isRequestedSessionIdValid in interface jakarta.servlet.http.HttpServletRequest
    • isRequestedSessionIdFromCookie

      public boolean isRequestedSessionIdFromCookie()
      Checks whether the requested session ID came in as a cookie.
      Specified by:
      isRequestedSessionIdFromCookie in interface jakarta.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 interface jakarta.servlet.http.HttpServletRequest
    • isRequestedSessionIdFromUrl

      public boolean isRequestedSessionIdFromUrl()
    • authenticate

      public boolean authenticate(jakarta.servlet.http.HttpServletResponse httpServletResponse) throws IOException, jakarta.servlet.ServletException
      Specified by:
      authenticate in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      IOException
      jakarta.servlet.ServletException
    • login

      public void login(String s, String s1) throws jakarta.servlet.ServletException
      Specified by:
      login in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      jakarta.servlet.ServletException
    • logout

      public void logout() throws jakarta.servlet.ServletException
      Specified by:
      logout in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      jakarta.servlet.ServletException
    • getParts

      public Collection<jakarta.servlet.http.Part> getParts() throws IOException, jakarta.servlet.ServletException
      Specified by:
      getParts in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      IOException
      jakarta.servlet.ServletException
    • getPart

      public jakarta.servlet.http.Part getPart(String s) throws IOException, jakarta.servlet.ServletException
      Specified by:
      getPart in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      IOException
      jakarta.servlet.ServletException
    • upgrade

      public <T extends jakarta.servlet.http.HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, jakarta.servlet.ServletException
      Specified by:
      upgrade in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      IOException
      jakarta.servlet.ServletException
    • getParameterMap

      public Map getParameterMap()
      Specified by:
      getParameterMap in interface jakarta.servlet.ServletRequest
    • setServerName

      public void setServerName(String serverName)
    • setRemoteHost

      public void setRemoteHost(String remoteHost)
    • setRemoteAddr

      public void setRemoteAddr(String remoteAddr)
    • setMethod

      public void setMethod(String method)
    • setPathInfo

      public void setPathInfo(String pathInfo)
    • setPathTranslated

      public void setPathTranslated(String pathTranslated)
    • setContextPath

      public void setContextPath(String contextPath)
    • setQueryString

      public void setQueryString(String queryString)
    • setRemoteUser

      public void setRemoteUser(String remoteUser)
    • setRequestedSessionId

      public void setRequestedSessionId(String requestedSessionId)
    • setRequestURI

      public void setRequestURI(String requestedURI)
    • setServletPath

      public void setServletPath(String servletPath)
    • setLocalName

      public void setLocalName(String localName)
    • setLocalAddr

      public void setLocalAddr(String localAddr)
    • setAuthType

      public void setAuthType(String authType)
    • setProtocol

      public void setProtocol(String protocol)
    • setScheme

      public void setScheme(String schema)
    • setRemotePort

      public void setRemotePort(int remotePort)
    • setLocalPort

      public void setLocalPort(int localPort)
    • setServerPort

      public void setServerPort(int serverPort)
    • setContentType

      public void setContentType(String contentType)
    • setHeader

      public void setHeader(String name, String value)
    • clearParameters

      public void clearParameters()
    • setupAddParameter

      public void setupAddParameter(String key, String[] values)
    • setupAddParameter

      public void setupAddParameter(String key, String value)
    • clearAttributes

      public void clearAttributes()
    • setSession

      public void setSession(jakarta.servlet.http.HttpSession session)
    • getRequestDispatcherMap

      public Map<String,jakarta.servlet.RequestDispatcher> getRequestDispatcherMap()
    • setRequestDispatcher

      public void setRequestDispatcher(String path, jakarta.servlet.RequestDispatcher dispatcher)
    • addLocale

      public void addLocale(Locale locale)
    • addLocales

      public void addLocales(List<Locale> localeList)
    • addHeader

      public void addHeader(String key, String value)
    • clearHeader

      public void clearHeader(String key)
    • setRequestURL

      public void setRequestURL(String requestUrl)
    • setUserPrincipal

      public void setUserPrincipal(Principal principal)
    • addCookie

      public void addCookie(jakarta.servlet.http.Cookie cookie)
    • setRequestedSessionIdFromCookie

      public void setRequestedSessionIdFromCookie(boolean requestedSessionIdIsFromCookie)
    • setUserInRole

      public void setUserInRole(String role, boolean isInRole)
    • setBodyContent

      public void setBodyContent(byte[] data)
    • setBodyContent

      public void setBodyContent(String bodyContent)