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, waitSEgetHttpServletMappingEE, getTrailerFieldsEE, isTrailerFieldsReadyEE, newPushBuilderEEpublic 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