public class MockHttpServletRequest extends ObjectSE implements HttpServletRequestEE
HttpServletRequestEE インターフェースのモック実装。 このリクエストによってモックされたサーバーのデフォルトの優先 LocaleSE は Locale.ENGLISHSE です。この値は、addPreferredLocale(java.util.Locale) または setPreferredLocales(java.util.List<java.util.Locale>) を介して変更できます。
Spring Framework 5.0 以降、このモックのセットは Servlet 4.0 ベースラインに基づいて設計されています。
| 修飾子と型 | フィールドと説明 |
|---|---|
static StringSE | DEFAULT_PROTOCOL デフォルトのプロトコル: 'HTTP/1.1'. |
static StringSE | DEFAULT_REMOTE_ADDR デフォルトのリモートアドレス: '127.0.0.1'. |
static StringSE | DEFAULT_REMOTE_HOST デフォルトのリモートホスト: "localhost"。 |
static StringSE | DEFAULT_SCHEME デフォルトのスキーム: "http"。 |
static StringSE | DEFAULT_SERVER_ADDR デフォルトのサーバーアドレス: '127.0.0.1'. |
static StringSE | DEFAULT_SERVER_NAME デフォルトのサーバー名: "localhost"。 |
static int | DEFAULT_SERVER_PORT デフォルトのサーバーポート: '80'. |
BASIC_AUTHEE, CLIENT_CERT_AUTHEE, DIGEST_AUTHEE, FORM_AUTHEE| コンストラクターと説明 |
|---|
MockHttpServletRequest() デフォルトの MockServletContext で新しい MockHttpServletRequest を作成します。 |
MockHttpServletRequest(ServletContextEE servletContext) 提供された ServletContextEE で新しい MockHttpServletRequest を作成します。 |
MockHttpServletRequest(ServletContextEE servletContext, StringSE method, StringSE requestURI) |
MockHttpServletRequest(StringSE method, StringSE requestURI) デフォルトの MockServletContext で新しい MockHttpServletRequest を作成します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic static final StringSE DEFAULT_PROTOCOL
public static final StringSE DEFAULT_SCHEME
public static final StringSE DEFAULT_SERVER_ADDR
public static final StringSE DEFAULT_SERVER_NAME
public static final int DEFAULT_SERVER_PORT
public static final StringSE DEFAULT_REMOTE_ADDR
public MockHttpServletRequest()
MockServletContext で新しい MockHttpServletRequest を作成します。public MockHttpServletRequest(@Nullable StringSE method, @Nullable StringSE requestURI)
MockServletContext で新しい MockHttpServletRequest を作成します。method - リクエストメソッド (null の場合があります)requestURI - リクエスト URI (null の場合があります)setMethod(java.lang.String), setRequestURI(java.lang.String), MockHttpServletRequest(ServletContext, String, String)public MockHttpServletRequest(@Nullable ServletContextEE servletContext)
ServletContextEE で新しい MockHttpServletRequest を作成します。servletContext - リクエストが実行される ServletContext (デフォルトの MockServletContext を使用する null の場合があります)MockHttpServletRequest(ServletContext, String, String)public MockHttpServletRequest(@Nullable ServletContextEE servletContext, @Nullable StringSE method, @Nullable StringSE requestURI)
ServletContextEE、method、requestURI で新しい MockHttpServletRequest を作成します。 優先ロケールは Locale.ENGLISHSE に設定されます。
servletContext - リクエストが実行される ServletContext (デフォルトの MockServletContext を使用する null の場合があります)method - リクエストメソッド (null の場合があります)requestURI - リクエスト URI (null の場合があります)setMethod(java.lang.String), setRequestURI(java.lang.String), setPreferredLocales(java.util.List<java.util.Locale>), MockServletContextpublic ServletContextEE getServletContext()
ServletRequestEE 内の getServletContextEE public boolean isActive()
public void close()
public void invalidate()
protected void checkActive()
throws IllegalStateExceptionSEpublic ObjectSE getAttribute(StringSE name)
ServletRequestEE 内の getAttributeEE public EnumerationSE<StringSE> getAttributeNames()
ServletRequestEE 内の getAttributeNamesEE @Nullable public StringSE getCharacterEncoding()
ServletRequestEE 内の getCharacterEncodingEE public void setCharacterEncoding(@Nullable StringSE characterEncoding)
ServletRequestEE 内の setCharacterEncodingEE public void setContent(@Nullable byte[] content)
指定されたバイト配列が XML や JSON などのテキストを表す場合、character encoding も通常設定する必要があります。
@Nullable public byte[] getContentAsByteArray()
null)setContent(byte[]), getContentAsString()@Nullable public StringSE getContentAsString() throws IllegalStateExceptionSE, UnsupportedEncodingExceptionSE
String としてリクエスト本文のコンテンツを取得します。String としてのコンテンツ、潜在的に nullIllegalStateExceptionSE - 文字エンコーディングが設定されていない場合 UnsupportedEncodingExceptionSE - 文字エンコードがサポートされていない場合 setContent(byte[]), setCharacterEncoding(String), getContentAsByteArray()public int getContentLength()
ServletRequestEE 内の getContentLengthEE public long getContentLengthLong()
ServletRequestEE 内の getContentLengthLongEE @Nullable public StringSE getContentType()
ServletRequestEE 内の getContentTypeEE public ServletInputStreamEE getInputStream()
ServletRequestEE 内の getInputStreamEE public void setParameter(StringSE name, StringSE value)
指定されたパラメーター名にすでに 1 つ以上の値が登録されている場合、置き換えられます。
public void setParameter(StringSE name, StringSE... values)
指定されたパラメーター名にすでに 1 つ以上の値が登録されている場合、置き換えられます。
public void setParameters(MapSE<StringSE,?> params)
addParameters(java.util.Map) を使用します。public void addParameter(StringSE name, @Nullable StringSE value)
指定されたパラメーター名にすでに 1 つ以上の値が登録されている場合、指定された値はリストの最後に追加されます。
public void addParameter(StringSE name, StringSE... values)
指定されたパラメーター名にすでに 1 つ以上の値が登録されている場合、指定された値はリストの最後に追加されます。
public void addParameters(MapSE<StringSE,?> params)
setParameters(java.util.Map) を使用します。public void removeParameter(StringSE name)
public void removeAllParameters()
@Nullable public StringSE getParameter(StringSE name)
ServletRequestEE 内の getParameterEE public EnumerationSE<StringSE> getParameterNames()
ServletRequestEE 内の getParameterNamesEE public StringSE[] getParameterValues(StringSE name)
ServletRequestEE 内の getParameterValuesEE public MapSE<StringSE,StringSE[]> getParameterMap()
ServletRequestEE 内の getParameterMapEE public void setProtocol(StringSE protocol)
public StringSE getProtocol()
ServletRequestEE 内の getProtocolEE public void setScheme(StringSE scheme)
public StringSE getScheme()
ServletRequestEE 内の getSchemeEE public void setServerName(StringSE serverName)
public StringSE getServerName()
ServletRequestEE 内の getServerNameEE public void setServerPort(int serverPort)
public int getServerPort()
ServletRequestEE 内の getServerPortEE public BufferedReaderSE getReader() throws UnsupportedEncodingExceptionSE
ServletRequestEE 内の getReaderEE UnsupportedEncodingExceptionSEpublic void setRemoteAddr(StringSE remoteAddr)
public StringSE getRemoteAddr()
ServletRequestEE 内の getRemoteAddrEE public void setRemoteHost(StringSE remoteHost)
public StringSE getRemoteHost()
ServletRequestEE 内の getRemoteHostEE public void setAttribute(StringSE name, @Nullable ObjectSE value)
ServletRequestEE 内の setAttributeEE public void removeAttribute(StringSE name)
ServletRequestEE 内の removeAttributeEE public void clearAttributes()
public void addPreferredLocale(LocaleSE locale)
public void setPreferredLocales(ListSE<LocaleSE> locales)
addPreferredLocale(java.util.Locale)public LocaleSE getLocale()
明示的に構成されたロケールがない場合、このリクエストによってモックされたサーバーのデフォルトの優先 LocaleSE は Locale.ENGLISHSE です。
サーブレット仕様とは対照的に、このモック実装では、Accept-Language ヘッダーを介して指定されたロケールは考慮されません。
ServletRequestEE 内の getLocaleEE ServletRequest.getLocale()EE, addPreferredLocale(Locale), setPreferredLocales(List)public EnumerationSE<LocaleSE> getLocales()
明示的に構成されたロケールがない場合、このリクエストによってモックされたサーバーのデフォルトの優先 LocaleSE は Locale.ENGLISHSE です。
サーブレット仕様とは対照的に、このモック実装では、Accept-Language ヘッダーを介して指定されたロケールは考慮されません。
ServletRequestEE 内の getLocalesEE ServletRequest.getLocales()EE, addPreferredLocale(Locale), setPreferredLocales(List)public void setSecure(boolean secure)
secure フラグを設定します。public boolean isSecure()
ServletRequestEE 内の isSecureEE ServletRequest.isSecure()EEpublic RequestDispatcherEE getRequestDispatcher(StringSE path)
ServletRequestEE 内の getRequestDispatcherEE @DeprecatedSE public StringSE getRealPath(StringSE path)
ServletRequestEE 内の getRealPathEE public void setRemotePort(int remotePort)
public int getRemotePort()
ServletRequestEE 内の getRemotePortEE public void setLocalName(StringSE localName)
public StringSE getLocalName()
ServletRequestEE 内の getLocalNameEE public void setLocalAddr(StringSE localAddr)
public StringSE getLocalAddr()
ServletRequestEE 内の getLocalAddrEE public void setLocalPort(int localPort)
public int getLocalPort()
ServletRequestEE 内の getLocalPortEE public AsyncContextEE startAsync()
ServletRequestEE 内の startAsyncEE public AsyncContextEE startAsync(ServletRequestEE request, @Nullable ServletResponseEE response)
ServletRequestEE 内の startAsyncEE public void setAsyncStarted(boolean asyncStarted)
public boolean isAsyncStarted()
ServletRequestEE 内の isAsyncStartedEE public void setAsyncSupported(boolean asyncSupported)
public boolean isAsyncSupported()
ServletRequestEE 内の isAsyncSupportedEE public void setAsyncContext(@Nullable MockAsyncContext asyncContext)
@Nullable public AsyncContextEE getAsyncContext()
ServletRequestEE 内の getAsyncContextEE public void setDispatcherType(DispatcherTypeEE dispatcherType)
public DispatcherTypeEE getDispatcherType()
ServletRequestEE 内の getDispatcherTypeEE @Nullable public StringSE getAuthType()
HttpServletRequestEE 内の getAuthTypeEE @Nullable public CookieEE[] getCookies()
HttpServletRequestEE 内の getCookiesEE public void addHeader(StringSE name, ObjectSE value)
このメソッドは任意の Object をパラメーターとして取ることができますが、以下の型を使用することをお勧めします。
toString() を使用して変換される文字列または任意のオブジェクト。getHeader(java.lang.String) を参照してください。getDateHeader(java.lang.String) を参照してください。getIntHeader(java.lang.String) を参照してください。String[] または Collection<String> (複数の値の場合)。getHeaders(java.lang.String) を参照してください。public void removeHeader(StringSE name)
public long getDateHeader(StringSE name)
name を持つ日付ヘッダーの長いタイムスタンプを返します。内部値表現が文字列である場合、このメソッドは、サポートされている日付形式を使用して日付として解析しようとします。
HttpServletRequestEE 内の getDateHeaderEE name - ヘッダー名 @Nullable public StringSE getHeader(StringSE name)
HttpServletRequestEE 内の getHeaderEE public EnumerationSE<StringSE> getHeaders(StringSE name)
HttpServletRequestEE 内の getHeadersEE public EnumerationSE<StringSE> getHeaderNames()
HttpServletRequestEE 内の getHeaderNamesEE public int getIntHeader(StringSE name)
HttpServletRequestEE 内の getIntHeaderEE @Nullable public StringSE getMethod()
HttpServletRequestEE 内の getMethodEE @Nullable public StringSE getPathInfo()
HttpServletRequestEE 内の getPathInfoEE @Nullable public StringSE getPathTranslated()
HttpServletRequestEE 内の getPathTranslatedEE public void setContextPath(StringSE contextPath)
public StringSE getContextPath()
HttpServletRequestEE 内の getContextPathEE @Nullable public StringSE getQueryString()
HttpServletRequestEE 内の getQueryStringEE @Nullable public StringSE getRemoteUser()
HttpServletRequestEE 内の getRemoteUserEE public void addUserRole(StringSE role)
public boolean isUserInRole(StringSE role)
HttpServletRequestEE 内の isUserInRoleEE public void setUserPrincipal(@Nullable PrincipalSE userPrincipal)
@Nullable public PrincipalSE getUserPrincipal()
HttpServletRequestEE 内の getUserPrincipalEE @Nullable public StringSE getRequestedSessionId()
HttpServletRequestEE 内の getRequestedSessionIdEE @Nullable public StringSE getRequestURI()
HttpServletRequestEE 内の getRequestURIEE public StringBufferSE getRequestURL()
HttpServletRequestEE 内の getRequestURLEE public void setServletPath(StringSE servletPath)
public StringSE getServletPath()
HttpServletRequestEE 内の getServletPathEE public void setSession(HttpSessionEE session)
@Nullable public HttpSessionEE getSession(boolean create)
HttpServletRequestEE 内の getSessionEE @Nullable public HttpSessionEE getSession()
HttpServletRequestEE 内の getSessionEE public StringSE changeSessionId()
MockHttpSession.changeSessionId() を呼び出します。それ以外の場合は、単に現在のセッション ID を返します。HttpServletRequestEE 内の changeSessionIdEE public void setRequestedSessionIdValid(boolean requestedSessionIdValid)
public boolean isRequestedSessionIdValid()
HttpServletRequestEE 内の isRequestedSessionIdValidEE public void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)
public boolean isRequestedSessionIdFromCookie()
HttpServletRequestEE 内の isRequestedSessionIdFromCookieEE public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
public boolean isRequestedSessionIdFromURL()
HttpServletRequestEE 内の isRequestedSessionIdFromURLEE @DeprecatedSE public boolean isRequestedSessionIdFromUrl()
HttpServletRequestEE 内の isRequestedSessionIdFromUrlEE public boolean authenticate(HttpServletResponseEE response) throws IOExceptionSE, ServletExceptionEE
HttpServletRequestEE 内の authenticateEE IOExceptionSEServletExceptionEEpublic void login(StringSE username, StringSE password) throws ServletExceptionEE
HttpServletRequestEE 内の loginEE ServletExceptionEEpublic void logout()
throws ServletExceptionEEHttpServletRequestEE 内の logoutEE ServletExceptionEEpublic void addPart(PartEE part)
@Nullable public PartEE getPart(StringSE name) throws IOExceptionSE, ServletExceptionEE
HttpServletRequestEE 内の getPartEE IOExceptionSEServletExceptionEEpublic CollectionSE<PartEE> getParts() throws IOExceptionSE, ServletExceptionEE
HttpServletRequestEE 内の getPartsEE IOExceptionSEServletExceptionEEpublic <T extends HttpUpgradeHandlerEE> T upgrade(ClassSE<T> handlerClass) throws IOExceptionSE, ServletExceptionEE
HttpServletRequestEE 内の upgradeEE IOExceptionSEServletExceptionEE