public class MockHttpServletResponse extends ObjectSE implements HttpServletResponseEE
HttpServletResponseEE インターフェースのモック実装。Spring 5.0 以降、このモックのセットは Servlet 4.0 ベースラインに基づいて設計されています。
SC_ACCEPTEDEE, SC_BAD_GATEWAYEE, SC_BAD_REQUESTEE, SC_CONFLICTEE, SC_CONTINUEEE, SC_CREATEDEE, SC_EXPECTATION_FAILEDEE, SC_FORBIDDENEE, SC_FOUNDEE, SC_GATEWAY_TIMEOUTEE, SC_GONEEE, SC_HTTP_VERSION_NOT_SUPPORTEDEE, SC_INTERNAL_SERVER_ERROREE, SC_LENGTH_REQUIREDEE, SC_METHOD_NOT_ALLOWEDEE, SC_MOVED_PERMANENTLYEE, SC_MOVED_TEMPORARILYEE, SC_MULTIPLE_CHOICESEE, SC_NO_CONTENTEE, SC_NON_AUTHORITATIVE_INFORMATIONEE, SC_NOT_ACCEPTABLEEE, SC_NOT_FOUNDEE, SC_NOT_IMPLEMENTEDEE, SC_NOT_MODIFIEDEE, SC_OKEE, SC_PARTIAL_CONTENTEE, SC_PAYMENT_REQUIREDEE, SC_PRECONDITION_FAILEDEE, SC_PROXY_AUTHENTICATION_REQUIREDEE, SC_REQUEST_ENTITY_TOO_LARGEEE, SC_REQUEST_TIMEOUTEE, SC_REQUEST_URI_TOO_LONGEE, SC_REQUESTED_RANGE_NOT_SATISFIABLEEE, SC_RESET_CONTENTEE, SC_SEE_OTHEREE, SC_SERVICE_UNAVAILABLEEE, SC_SWITCHING_PROTOCOLSEE, SC_TEMPORARY_REDIRECTEE, SC_UNAUTHORIZEDEE, SC_UNSUPPORTED_MEDIA_TYPEEE, SC_USE_PROXYEE| コンストラクターと説明 |
|---|
MockHttpServletResponse() |
| 修飾子と型 | メソッドと説明 |
|---|---|
void | addCookie(CookieEE cookie) |
void | addDateHeader(StringSE name, long value) |
void | addHeader(StringSE name, StringSE value) |
void | addIncludedUrl(StringSE includedUrl) |
void | addIntHeader(StringSE name, int value) |
boolean | containsHeader(StringSE name) |
StringSE | encodeRedirectUrl(StringSE url) 使用すべきではありません。 |
StringSE | encodeRedirectURL(StringSE url) デフォルトの実装は encodeURL(java.lang.String) に委譲し、指定された URL 文字列をそのまま返します。 |
StringSE | encodeUrl(StringSE url) 使用すべきではありません。 |
StringSE | encodeURL(StringSE url) デフォルトの実装は、指定された URL 文字列をそのまま返します。 |
void | flushBuffer() |
int | getBufferSize() |
StringSE | getCharacterEncoding() |
byte[] | getContentAsByteArray() |
StringSE | getContentAsString() アプリケーションによってレスポンスに指定された文字セットを使用して、 HttpServletResponseEE メソッドまたは Content-Type の文字セットパラメーターを介して、レスポンス本文のコンテンツを String として取得します。 |
StringSE | getContentAsString(CharsetSE fallbackCharset) 文字セットが明示的に定義されていない場合は提供された fallbackCharset を使用し、それ以外の場合は HttpServletResponseEE メソッドまたは Content-Type の文字セットパラメーターを使用してアプリケーションによってレスポンスに指定された文字セットを使用して、レスポンス本文のコンテンツを String として取得します。 |
int | getContentLength() |
long | getContentLengthLong() |
StringSE | getContentType() |
CookieEE | getCookie(StringSE name) |
CookieEE[] | getCookies() |
long | getDateHeader(StringSE name) |
StringSE | getErrorMessage() |
StringSE | getForwardedUrl() |
StringSE | getHeader(StringSE name) 指定されたヘッダーのプライマリ値を String として返します(存在する場合)。 |
CollectionSE<StringSE> | getHeaderNames() 指定されたすべてのヘッダーの名前を文字列のセットとして返します。 |
ListSE<StringSE> | getHeaders(StringSE name) 指定されたヘッダーのすべての値を文字列のリストとして返します。 |
ObjectSE | getHeaderValue(StringSE name) 存在する場合、指定されたヘッダーのプライマリ値を返します。 |
ListSE<ObjectSE> | getHeaderValues(StringSE name) 指定されたヘッダーのすべての値を値オブジェクトのリストとして返します。 |
StringSE | getIncludedUrl() |
ListSE<StringSE> | getIncludedUrls() |
LocaleSE | getLocale() |
ServletOutputStreamEE | getOutputStream() |
StringSE | getRedirectedUrl() |
int | getStatus() |
PrintWriterSE | getWriter() |
boolean | isCharset() 文字エンコードが HttpServletResponseEE メソッドを介して明示的に設定されているか、Content-Type の charset パラメーターを介して明示的に設定されているかを判別します。 |
boolean | isCommitted() |
boolean | isOutputStreamAccessAllowed()getOutputStream() アクセスが許可されているかどうかを返します。 |
boolean | isWriterAccessAllowed()getOutputStream() アクセスが許可されているかどうかを返します。 |
void | reset() |
void | resetBuffer() |
void | sendError(int status) |
void | sendError(int status, StringSE errorMessage) |
void | sendRedirect(StringSE url) |
void | setBufferSize(int bufferSize) |
void | setCharacterEncoding(StringSE characterEncoding) |
void | setCommitted(boolean committed) |
void | setContentLength(int contentLength) |
void | setContentLengthLong(long contentLength) |
void | setContentType(StringSE contentType) |
void | setDateHeader(StringSE name, long value) |
void | setDefaultCharacterEncoding(StringSE characterEncoding) レスポンスのデフォルトの文字エンコードを設定します。 |
void | setForwardedUrl(StringSE forwardedUrl) |
void | setHeader(StringSE name, StringSE value) |
void | setIncludedUrl(StringSE includedUrl) |
void | setIntHeader(StringSE name, int value) |
void | setLocale(LocaleSE locale) |
void | setOutputStreamAccessAllowed(boolean outputStreamAccessAllowed)getOutputStream() アクセスを許可するかどうかを設定します。 |
void | setStatus(int status) |
void | setStatus(int status, StringSE errorMessage) 使用すべきではありません。 |
void | setWriterAccessAllowed(boolean writerAccessAllowed)getWriter() アクセスを許可するかどうかを設定します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEgetTrailerFieldsEE, setTrailerFieldsEEpublic void setOutputStreamAccessAllowed(boolean outputStreamAccessAllowed)
getOutputStream() アクセスを許可するかどうかを設定します。 デフォルトは true です。
public boolean isOutputStreamAccessAllowed()
getOutputStream() アクセスが許可されているかどうかを返します。public void setWriterAccessAllowed(boolean writerAccessAllowed)
getWriter() アクセスを許可するかどうかを設定します。 デフォルトは true です。
public boolean isWriterAccessAllowed()
getOutputStream() アクセスが許可されているかどうかを返します。public void setDefaultCharacterEncoding(StringSE characterEncoding)
このメソッドが呼び出されない場合、ISO-8859-1 がデフォルトの文字エンコードとして使用されます。
レスポンスの文字エンコードが setCharacterEncoding(String) または setContentType(String) を介して明示的に設定されていない場合、レスポンスの文字エンコードは指定されたデフォルトの文字エンコードに設定されます。
characterEncoding - デフォルトの文字エンコード setCharacterEncoding(String), setContentType(String)public boolean isCharset()
HttpServletResponseEE メソッドを介して明示的に設定されているか、Content-Type の charset パラメーターを介して明示的に設定されているかを判別します。false の場合、getCharacterEncoding() はデフォルトの文字エンコードを返します。
public void setCharacterEncoding(StringSE characterEncoding)
ServletResponseEE 内の setCharacterEncodingEE public StringSE getCharacterEncoding()
ServletResponseEE 内の getCharacterEncodingEE public ServletOutputStreamEE getOutputStream()
ServletResponseEE 内の getOutputStreamEE public PrintWriterSE getWriter() throws UnsupportedEncodingExceptionSE
ServletResponseEE 内の getWriterEE UnsupportedEncodingExceptionSEpublic byte[] getContentAsByteArray()
public StringSE getContentAsString() throws UnsupportedEncodingExceptionSE
HttpServletResponseEE メソッドまたは Content-Type の charset パラメーターのいずれかを介して、アプリケーションによってレスポンスに指定された文字セットを使用して、レスポンス本文のコンテンツを String として取得します。文字セットが明示的に定義されていない場合は、デフォルトの文字エンコードが使用されます。String としてのコンテンツ UnsupportedEncodingExceptionSE - 文字エンコードがサポートされていない場合 getContentAsString(Charset), setCharacterEncoding(String), setContentType(String)public StringSE getContentAsString(CharsetSE fallbackCharset) throws UnsupportedEncodingExceptionSE
fallbackCharset を使用し、それ以外の場合は HttpServletResponseEE メソッドまたは Content-Type の文字セットパラメーターを使用してアプリケーションによってレスポンスに指定された文字セットを使用して、レスポンス本文のコンテンツを String として取得します。String としてのコンテンツ UnsupportedEncodingExceptionSE - 文字エンコードがサポートされていない場合 getContentAsString(), setCharacterEncoding(String), setContentType(String)public void setContentLength(int contentLength)
ServletResponseEE 内の setContentLengthEE public int getContentLength()
public void setContentLengthLong(long contentLength)
ServletResponseEE 内の setContentLengthLongEE public long getContentLengthLong()
public void setContentType(@Nullable StringSE contentType)
ServletResponseEE 内の setContentTypeEE @Nullable public StringSE getContentType()
ServletResponseEE 内の getContentTypeEE public void setBufferSize(int bufferSize)
ServletResponseEE 内の setBufferSizeEE public int getBufferSize()
ServletResponseEE 内の getBufferSizeEE public void flushBuffer()
ServletResponseEE 内の flushBufferEE public void resetBuffer()
ServletResponseEE 内の resetBufferEE public void setCommitted(boolean committed)
public boolean isCommitted()
ServletResponseEE 内の isCommittedEE public void reset()
ServletResponseEE 内の resetEE public void setLocale(@Nullable LocaleSE locale)
ServletResponseEE 内の setLocaleEE public LocaleSE getLocale()
ServletResponseEE 内の getLocaleEE public void addCookie(CookieEE cookie)
HttpServletResponseEE 内の addCookieEE public CookieEE[] getCookies()
public boolean containsHeader(StringSE name)
HttpServletResponseEE 内の containsHeaderEE public CollectionSE<StringSE> getHeaderNames()
Servlet 3.0 以降、このメソッドは HttpServletResponseEE でも定義されています。
HttpServletResponseEE 内の getHeaderNamesEE Strings の Set、ない場合は空の Set @Nullable public StringSE getHeader(StringSE name)
Servlet 3.0 の時点で、このメソッドは HttpServletResponseEE でも定義されています。Spring 3.1 では、Servlet 3.0 互換性のために文字列化された値を返します。生のオブジェクトアクセスに getHeaderValue(String) を使用することを検討してください。
HttpServletResponseEE 内の getHeaderEE name - ヘッダーの名前 null public ListSE<StringSE> getHeaders(StringSE name)
Servlet 3.0 の時点で、このメソッドは HttpServletResponseEE でも定義されています。Spring 3.1 の時点で、Servlet 3.0 互換性のために文字列化された値のリストを返します。生のオブジェクトアクセスに getHeaderValues(String) を使用することを検討してください。
HttpServletResponseEE 内の getHeadersEE name - ヘッダーの名前 @Nullable public ObjectSE getHeaderValue(StringSE name)
複数の値の場合、最初の値を返します。
name - ヘッダーの名前 null public ListSE<ObjectSE> getHeaderValues(StringSE name)
name - ヘッダーの名前 public StringSE encodeURL(StringSE url)
サブクラスでオーバーライドでき、セッション ID などを追加します。
HttpServletResponseEE 内の encodeURLEE public StringSE encodeRedirectURL(StringSE url)
encodeURL(java.lang.String) に委譲し、指定された URL 文字列をそのまま返します。 サブクラスでオーバーライドでき、リダイレクト固有の方法でセッション ID などを追加できます。一般的な URL エンコーディングルールについては、代わりに一般的な encodeURL(java.lang.String) メソッドをオーバーライドし、一般的な URL だけでなくリダイレクト URL にも適用します。
HttpServletResponseEE 内の encodeRedirectURLEE @DeprecatedSE public StringSE encodeUrl(StringSE url)
HttpServletResponseEE 内の encodeUrlEE @DeprecatedSE public StringSE encodeRedirectUrl(StringSE url)
HttpServletResponseEE 内の encodeRedirectUrlEE public void sendError(int status,
StringSE errorMessage)
throws IOExceptionSEHttpServletResponseEE 内の sendErrorEE IOExceptionSEpublic void sendError(int status)
throws IOExceptionSEHttpServletResponseEE 内の sendErrorEE IOExceptionSEpublic void sendRedirect(StringSE url) throws IOExceptionSE
HttpServletResponseEE 内の sendRedirectEE IOExceptionSEpublic void setDateHeader(StringSE name, long value)
HttpServletResponseEE 内の setDateHeaderEE public void addDateHeader(StringSE name, long value)
HttpServletResponseEE 内の addDateHeaderEE public long getDateHeader(StringSE name)
public void setHeader(StringSE name, @Nullable StringSE value)
HttpServletResponseEE 内の setHeaderEE public void addHeader(StringSE name, @Nullable StringSE value)
HttpServletResponseEE 内の addHeaderEE public void setIntHeader(StringSE name, int value)
HttpServletResponseEE 内の setIntHeaderEE public void addIntHeader(StringSE name, int value)
HttpServletResponseEE 内の addIntHeaderEE public void setStatus(int status)
HttpServletResponseEE 内の setStatusEE @DeprecatedSE public void setStatus(int status, StringSE errorMessage)
HttpServletResponseEE 内の setStatusEE public int getStatus()
HttpServletResponseEE 内の getStatusEE public void addIncludedUrl(StringSE includedUrl)