Package mondrian.tui

Class MockHttpServletResponse

  • All Implemented Interfaces:
    HttpServletResponse, ServletResponse

    public class MockHttpServletResponse
    extends java.lang.Object
    implements HttpServletResponse
    This is a partial implementation of the HttpServletResponse 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 Detail

      • DATE_FORMAT_HEADER

        public static final java.lang.String DATE_FORMAT_HEADER
        See Also:
        Constant Field Values
    • Constructor Detail

      • MockHttpServletResponse

        public MockHttpServletResponse()
    • Method Detail

      • getCharacterEncoding

        public java.lang.String getCharacterEncoding()
        Returns the name of the charset used for the MIME body sent in this response.
        Specified by:
        getCharacterEncoding in interface ServletResponse
      • getOutputStream

        public ServletOutputStream getOutputStream()
                                            throws java.io.IOException
        Returns a ServletOutputStream suitable for writing binary data in the response.
        Specified by:
        getOutputStream in interface ServletResponse
        Throws:
        java.io.IOException
      • getWriter

        public java.io.PrintWriter getWriter()
                                      throws java.io.IOException
        Returns a PrintWriter object that can send character text to the client.
        Specified by:
        getWriter in interface ServletResponse
        Throws:
        java.io.IOException
      • setContentLength

        public void setContentLength​(int len)
        Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.
        Specified by:
        setContentLength in interface ServletResponse
      • setContentType

        public void setContentType​(java.lang.String contentType)
        Sets the content type of the response being sent to the client.
        Specified by:
        setContentType in interface ServletResponse
      • setBufferSize

        public void setBufferSize​(int size)
        Sets the preferred buffer size for the body of the response.
        Specified by:
        setBufferSize in interface ServletResponse
      • getBufferSize

        public int getBufferSize()
        Returns the actual buffer size used for the response.
        Specified by:
        getBufferSize in interface ServletResponse
      • flushBuffer

        public void flushBuffer()
                         throws java.io.IOException
        Forces any content in the buffer to be written to the client.
        Specified by:
        flushBuffer in interface ServletResponse
        Throws:
        java.io.IOException
      • isCommitted

        public boolean isCommitted()
        Returns a boolean indicating if the response has been committed.
        Specified by:
        isCommitted in interface ServletResponse
      • reset

        public void reset()
        Clears any data that exists in the buffer as well as the status code and headers.
        Specified by:
        reset in interface ServletResponse
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.
        Specified by:
        setLocale in interface ServletResponse
      • getLocale

        public java.util.Locale getLocale()
        Returns the locale assigned to the response.
        Specified by:
        getLocale in interface ServletResponse
      • containsHeader

        public boolean containsHeader​(java.lang.String name)
        Returns a boolean indicating whether the named response header has already been set.
        Specified by:
        containsHeader in interface HttpServletResponse
      • encodeURL

        public java.lang.String encodeURL​(java.lang.String url)
        Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
        Specified by:
        encodeURL in interface HttpServletResponse
      • encodeRedirectURL

        public java.lang.String encodeRedirectURL​(java.lang.String url)
        Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.
        Specified by:
        encodeRedirectURL in interface HttpServletResponse
      • encodeUrl

        public java.lang.String encodeUrl​(java.lang.String s)
        Deprecated.
        Method encodeUrl is deprecated
        Specified by:
        encodeUrl in interface HttpServletResponse
      • encodeRedirectUrl

        public java.lang.String encodeRedirectUrl​(java.lang.String s)
        Deprecated.
        Method encodeRedirectUrl is deprecated
        Specified by:
        encodeRedirectUrl in interface HttpServletResponse
      • sendError

        public void sendError​(int code,
                              java.lang.String msg)
                       throws java.io.IOException
        Sends an error response to the client using the specified status code and descriptive message.
        Specified by:
        sendError in interface HttpServletResponse
        Throws:
        java.io.IOException
      • sendError

        public void sendError​(int code)
                       throws java.io.IOException
        Sends an error response to the client using the specified status.
        Specified by:
        sendError in interface HttpServletResponse
        Throws:
        java.io.IOException
      • sendRedirect

        public void sendRedirect​(java.lang.String location)
                          throws java.io.IOException
        Sends a temporary redirect response to the client using the specified redirect location URL.
        Specified by:
        sendRedirect in interface HttpServletResponse
        Throws:
        java.io.IOException
      • setDateHeader

        public void setDateHeader​(java.lang.String name,
                                  long date)
        Sets a response header with the given name and date-value.
        Specified by:
        setDateHeader in interface HttpServletResponse
      • addDateHeader

        public void addDateHeader​(java.lang.String name,
                                  long date)
        Adds a response header with the given name and date-value.
        Specified by:
        addDateHeader in interface HttpServletResponse
      • setHeader

        public void setHeader​(java.lang.String name,
                              java.lang.String value)
        Sets a response header with the given name and value.
        Specified by:
        setHeader in interface HttpServletResponse
      • addHeader

        public void addHeader​(java.lang.String name,
                              java.lang.String value)
        Adds a response header with the given name and value.
        Specified by:
        addHeader in interface HttpServletResponse
      • setIntHeader

        public void setIntHeader​(java.lang.String name,
                                 int value)
        Sets a response header with the given name and integer value.
        Specified by:
        setIntHeader in interface HttpServletResponse
      • addIntHeader

        public void addIntHeader​(java.lang.String name,
                                 int value)
        Adds a response header with the given name and integer value.
        Specified by:
        addIntHeader in interface HttpServletResponse
      • setStatus

        public void setStatus​(int status)
        Sets the status code for this response.
        Specified by:
        setStatus in interface HttpServletResponse
      • setStatus

        public void setStatus​(int status,
                              java.lang.String s)
        Deprecated.
        Method setStatus is deprecated Deprecated. As of version 2.1, due to ambiguous meaning of the message parameter. To set a status code use setStatus(int), to send an error with a description use sendError(int, String). Sets the status code and message for this response.
        Specified by:
        setStatus in interface HttpServletResponse
      • toByteArray

        public byte[] toByteArray()
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • getHeaderList

        public java.util.List<java.lang.String> getHeaderList​(java.lang.String name)
      • getStatusCode

        public int getStatusCode()
      • getErrorCode

        public int getErrorCode()
      • getCookies

        public java.util.List getCookies()
      • wasErrorSent

        public boolean wasErrorSent()
      • wasRedirectSent

        public boolean wasRedirectSent()
      • encode

        protected java.lang.String encode​(java.lang.String s)
      • getHeaders

        public java.util.Collection<java.lang.String> getHeaders​(java.lang.String name)
        Specified by:
        getHeaders in interface HttpServletResponse