Package mondrian.tui
Class MockHttpServletResponse
- java.lang.Object
-
- mondrian.tui.MockHttpServletResponse
-
- All Implemented Interfaces:
javax.servlet.http.HttpServletResponse,javax.servlet.ServletResponse
public class MockHttpServletResponse extends Object implements javax.servlet.http.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 Summary
Fields Modifier and Type Field Description static StringDATE_FORMAT_HEADER-
Fields inherited from interface javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
-
-
Constructor Summary
Constructors Constructor Description MockHttpServletResponse()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCookie(javax.servlet.http.Cookie cookie)Adds the specified cookie to the response.voidaddDateHeader(String name, long date)Adds a response header with the given name and date-value.voidaddHeader(String name, String value)Adds a response header with the given name and value.voidaddIntHeader(String name, int value)Adds a response header with the given name and integer value.booleancontainsHeader(String name)Returns a boolean indicating whether the named response header has already been set.protected Stringencode(String s)StringencodeRedirectUrl(String s)Deprecated.Method encodeRedirectUrl is deprecatedStringencodeRedirectURL(String url)Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.StringencodeUrl(String s)Deprecated.Method encodeUrl is deprecatedStringencodeURL(String url)Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.voidflushBuffer()Forces any content in the buffer to be written to the client.intgetBufferSize()Returns the actual buffer size used for the response.StringgetCharacterEncoding()Returns the name of the charset used for the MIME body sent in this response.StringgetContentType()ListgetCookies()intgetErrorCode()StringgetHeader(String name)List<String>getHeaderList(String name)LocalegetLocale()Returns the locale assigned to the response.javax.servlet.ServletOutputStreamgetOutputStream()Returns a ServletOutputStream suitable for writing binary data in the response.intgetStatusCode()PrintWritergetWriter()Returns a PrintWriter object that can send character text to the client.booleanisCommitted()Returns a boolean indicating if the response has been committed.voidreset()Clears any data that exists in the buffer as well as the status code and headers.voidresetBuffer()voidsendError(int code)Sends an error response to the client using the specified status.voidsendError(int code, String msg)Sends an error response to the client using the specified status code and descriptive message.voidsendRedirect(String location)Sends a temporary redirect response to the client using the specified redirect location URL.voidsetBufferSize(int size)Sets the preferred buffer size for the body of the response.voidsetCharacterEncoding(String charEncoding)voidsetContentLength(int len)Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.voidsetContentType(String contentType)Sets the content type of the response being sent to the client.voidsetDateHeader(String name, long date)Sets a response header with the given name and date-value.voidsetHeader(String name, String value)Sets a response header with the given name and value.voidsetIntHeader(String name, int value)Sets a response header with the given name and integer value.voidsetLocale(Locale locale)Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.voidsetStatus(int status)Sets the status code for this response.voidsetStatus(int status, String s)Deprecated.Method setStatus is deprecated Deprecated.byte[]toByteArray()booleanwasErrorSent()booleanwasRedirectSent()
-
-
-
Field Detail
-
DATE_FORMAT_HEADER
public static final String DATE_FORMAT_HEADER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCharacterEncoding
public String getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response.- Specified by:
getCharacterEncodingin interfacejavax.servlet.ServletResponse
-
getOutputStream
public javax.servlet.ServletOutputStream getOutputStream() throws IOExceptionReturns a ServletOutputStream suitable for writing binary data in the response.- Specified by:
getOutputStreamin interfacejavax.servlet.ServletResponse- Throws:
IOException
-
getWriter
public PrintWriter getWriter() throws IOException
Returns a PrintWriter object that can send character text to the client.- Specified by:
getWriterin interfacejavax.servlet.ServletResponse- Throws:
IOException
-
setCharacterEncoding
public void setCharacterEncoding(String charEncoding)
- Specified by:
setCharacterEncodingin interfacejavax.servlet.ServletResponse
-
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:
setContentLengthin interfacejavax.servlet.ServletResponse
-
setContentType
public void setContentType(String contentType)
Sets the content type of the response being sent to the client.- Specified by:
setContentTypein interfacejavax.servlet.ServletResponse
-
setBufferSize
public void setBufferSize(int size)
Sets the preferred buffer size for the body of the response.- Specified by:
setBufferSizein interfacejavax.servlet.ServletResponse
-
getBufferSize
public int getBufferSize()
Returns the actual buffer size used for the response.- Specified by:
getBufferSizein interfacejavax.servlet.ServletResponse
-
flushBuffer
public void flushBuffer() throws IOExceptionForces any content in the buffer to be written to the client.- Specified by:
flushBufferin interfacejavax.servlet.ServletResponse- Throws:
IOException
-
resetBuffer
public void resetBuffer()
- Specified by:
resetBufferin interfacejavax.servlet.ServletResponse
-
isCommitted
public boolean isCommitted()
Returns a boolean indicating if the response has been committed.- Specified by:
isCommittedin interfacejavax.servlet.ServletResponse
-
reset
public void reset()
Clears any data that exists in the buffer as well as the status code and headers.- Specified by:
resetin interfacejavax.servlet.ServletResponse
-
setLocale
public void setLocale(Locale locale)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.- Specified by:
setLocalein interfacejavax.servlet.ServletResponse
-
getLocale
public Locale getLocale()
Returns the locale assigned to the response.- Specified by:
getLocalein interfacejavax.servlet.ServletResponse
-
addCookie
public void addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response.- Specified by:
addCookiein interfacejavax.servlet.http.HttpServletResponse
-
containsHeader
public boolean containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set.- Specified by:
containsHeaderin interfacejavax.servlet.http.HttpServletResponse
-
encodeURL
public String encodeURL(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:
encodeURLin interfacejavax.servlet.http.HttpServletResponse
-
encodeRedirectURL
public String encodeRedirectURL(String url)
Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.- Specified by:
encodeRedirectURLin interfacejavax.servlet.http.HttpServletResponse
-
encodeUrl
public String encodeUrl(String s)
Deprecated.Method encodeUrl is deprecated- Specified by:
encodeUrlin interfacejavax.servlet.http.HttpServletResponse
-
encodeRedirectUrl
public String encodeRedirectUrl(String s)
Deprecated.Method encodeRedirectUrl is deprecated- Specified by:
encodeRedirectUrlin interfacejavax.servlet.http.HttpServletResponse
-
sendError
public void sendError(int code, String msg) throws IOExceptionSends an error response to the client using the specified status code and descriptive message.- Specified by:
sendErrorin interfacejavax.servlet.http.HttpServletResponse- Throws:
IOException
-
sendError
public void sendError(int code) throws IOExceptionSends an error response to the client using the specified status.- Specified by:
sendErrorin interfacejavax.servlet.http.HttpServletResponse- Throws:
IOException
-
sendRedirect
public void sendRedirect(String location) throws IOException
Sends a temporary redirect response to the client using the specified redirect location URL.- Specified by:
sendRedirectin interfacejavax.servlet.http.HttpServletResponse- Throws:
IOException
-
setDateHeader
public void setDateHeader(String name, long date)
Sets a response header with the given name and date-value.- Specified by:
setDateHeaderin interfacejavax.servlet.http.HttpServletResponse
-
addDateHeader
public void addDateHeader(String name, long date)
Adds a response header with the given name and date-value.- Specified by:
addDateHeaderin interfacejavax.servlet.http.HttpServletResponse
-
setHeader
public void setHeader(String name, String value)
Sets a response header with the given name and value.- Specified by:
setHeaderin interfacejavax.servlet.http.HttpServletResponse
-
addHeader
public void addHeader(String name, String value)
Adds a response header with the given name and value.- Specified by:
addHeaderin interfacejavax.servlet.http.HttpServletResponse
-
setIntHeader
public void setIntHeader(String name, int value)
Sets a response header with the given name and integer value.- Specified by:
setIntHeaderin interfacejavax.servlet.http.HttpServletResponse
-
addIntHeader
public void addIntHeader(String name, int value)
Adds a response header with the given name and integer value.- Specified by:
addIntHeaderin interfacejavax.servlet.http.HttpServletResponse
-
setStatus
public void setStatus(int status)
Sets the status code for this response.- Specified by:
setStatusin interfacejavax.servlet.http.HttpServletResponse
-
setStatus
public void setStatus(int status, 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:
setStatusin interfacejavax.servlet.http.HttpServletResponse
-
toByteArray
public byte[] toByteArray() throws IOException- Throws:
IOException
-
getContentType
public String getContentType()
- Specified by:
getContentTypein interfacejavax.servlet.ServletResponse
-
getStatusCode
public int getStatusCode()
-
getErrorCode
public int getErrorCode()
-
getCookies
public List getCookies()
-
wasErrorSent
public boolean wasErrorSent()
-
wasRedirectSent
public boolean wasRedirectSent()
-
-