public class MockMultipartHttpServletRequest extends MockHttpServletRequest implements MultipartHttpServletRequest
MultipartHttpServletRequest
インターフェースのモック実装。Spring 5.0 以降、このモックのセットは Servlet 4.0 ベースラインに基づいて設計されています。
マルチパートアップロードにアクセスするアプリケーションコントローラーのテストに役立ちます。MockMultipartFile
を使用して、これらのモックリクエストにファイルを取り込むことができます。
MockMultipartFile
DEFAULT_PROTOCOL, DEFAULT_REMOTE_ADDR, DEFAULT_REMOTE_HOST, DEFAULT_SCHEME, DEFAULT_SERVER_ADDR, DEFAULT_SERVER_NAME, DEFAULT_SERVER_PORT
BASIC_AUTHEE, CLIENT_CERT_AUTHEE, DIGEST_AUTHEE, FORM_AUTHEE
コンストラクターと説明 |
---|
MockMultipartHttpServletRequest() デフォルトの MockServletContext で新しい MockMultipartHttpServletRequest を作成します。 |
MockMultipartHttpServletRequest(ServletContextEE servletContext) 提供された ServletContext EE で新しい MockMultipartHttpServletRequest を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
void | addFile(MultipartFile file) このリクエストにファイルを追加します。 |
MultipartFile | getFile(StringSE name) このリクエストでアップロードされたファイルの内容と説明を返すか、存在しない場合は null を返します。 |
MapSE<StringSE, MultipartFile> | getFileMap() このリクエストに含まれるマルチパートファイルの Map SE を返します。 |
IteratorSE<StringSE> | getFileNames() このリクエストに含まれるマルチパートファイルのパラメーター名を含む String オブジェクトの Iterator SE を返します。 |
ListSE<MultipartFile> | getFiles(StringSE name) このリクエストでアップロードされたファイルの内容と説明を返すか、存在しない場合は空のリストを返します。 |
MultiValueMap<StringSE, MultipartFile> | getMultiFileMap() このリクエストに含まれるマルチパートファイルの MultiValueMap を返します。 |
StringSE | getMultipartContentType(StringSE paramOrFileName) 指定されたリクエストパーツのコンテンツ型を決定します。 |
HttpHeaders | getMultipartHeaders(StringSE paramOrFileName) マルチパートリクエストの指定された部分のヘッダーを返します。 |
HttpHeaders | getRequestHeaders() このリクエストのヘッダーを便利な HttpHeaders インスタンスとして返します。 |
HttpMethod | getRequestMethod() このリクエストのメソッドを便利な HttpMethod インスタンスとして返します。 |
addHeader, addParameter, addParameter, addParameters, addPart, addPreferredLocale, addUserRole, authenticate, changeSessionId, checkActive, clearAttributes, close, getAsyncContext, getAttribute, getAttributeNames, getAuthType, getCharacterEncoding, getContentAsByteArray, getContentAsString, getContentLength, getContentLengthLong, getContentType, getContextPath, getCookies, getDateHeader, getDispatcherType, getHeader, getHeaderNames, getHeaders, getInputStream, getIntHeader, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getMethod, getParameter, getParameterMap, getParameterNames, getParameterValues, getPart, getParts, getPathInfo, getPathTranslated, getProtocol, getQueryString, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRemoteUser, getRequestDispatcher, getRequestedSessionId, getRequestURI, getRequestURL, getScheme, getServerName, getServerPort, getServletContext, getServletPath, getSession, getSession, getUserPrincipal, invalidate, isActive, isAsyncStarted, isAsyncSupported, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isSecure, isUserInRole, login, logout, removeAllParameters, removeAttribute, removeHeader, removeParameter, setAsyncContext, setAsyncStarted, setAsyncSupported, setAttribute, setAuthType, setCharacterEncoding, setContent, setContentType, setContextPath, setCookies, setDispatcherType, setLocalAddr, setLocalName, setLocalPort, setMethod, setParameter, setParameter, setParameters, setPathInfo, setPreferredLocales, setProtocol, setQueryString, setRemoteAddr, setRemoteHost, setRemotePort, setRemoteUser, setRequestedSessionId, setRequestedSessionIdFromCookie, setRequestedSessionIdFromURL, setRequestedSessionIdValid, setRequestURI, setScheme, setSecure, setServerName, setServerPort, setServletPath, setSession, setUserPrincipal, startAsync, startAsync, upgrade
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
authenticateEE, changeSessionIdEE, getAuthTypeEE, getContextPathEE, getCookiesEE, getDateHeaderEE, getHeaderEE, getHeaderNamesEE, getHeadersEE, getHttpServletMappingEE, getIntHeaderEE, getMethodEE, getPartEE, getPartsEE, getPathInfoEE, getPathTranslatedEE, getQueryStringEE, getRemoteUserEE, getRequestedSessionIdEE, getRequestURIEE, getRequestURLEE, getServletPathEE, getSessionEE, getSessionEE, getTrailerFieldsEE, getUserPrincipalEE, isRequestedSessionIdFromCookieEE, isRequestedSessionIdFromUrlEE, isRequestedSessionIdFromURLEE, isRequestedSessionIdValidEE, isTrailerFieldsReadyEE, isUserInRoleEE, loginEE, logoutEE, newPushBuilderEE, upgradeEE
getAsyncContextEE, getAttributeEE, getAttributeNamesEE, getCharacterEncodingEE, getContentLengthEE, getContentLengthLongEE, getContentTypeEE, getDispatcherTypeEE, getInputStreamEE, getLocalAddrEE, getLocaleEE, getLocalesEE, getLocalNameEE, getLocalPortEE, getParameterEE, getParameterMapEE, getParameterNamesEE, getParameterValuesEE, getProtocolEE, getReaderEE, getRealPathEE, getRemoteAddrEE, getRemoteHostEE, getRemotePortEE, getRequestDispatcherEE, getSchemeEE, getServerNameEE, getServerPortEE, getServletContextEE, isAsyncStartedEE, isAsyncSupportedEE, isSecureEE, removeAttributeEE, setAttributeEE, setCharacterEncodingEE, startAsyncEE, startAsyncEE
public MockMultipartHttpServletRequest()
MockServletContext
で新しい MockMultipartHttpServletRequest
を作成します。public MockMultipartHttpServletRequest(@Nullable ServletContextEE servletContext)
ServletContext
EE で新しい MockMultipartHttpServletRequest
を作成します。servletContext
- リクエストが実行される ServletContext (デフォルトの MockServletContext
を使用する null
の場合があります)public void addFile(MultipartFile file)
MultipartFile.getName()
から取得されます。file
- 追加するマルチパートファイル public IteratorSE<StringSE> getFileNames()
MultipartRequest
Iterator
SE を返します。これらはフォームのフィールド名であり(通常のパラメーターと同様)、元のファイル名ではありません。MultipartRequest
の getFileNames
public MultipartFile getFile(StringSE name)
MultipartRequest
null
を返します。MultipartRequest
の getFile
name
- マルチパートファイルのパラメーター名を指定する文字列 MultipartFile
オブジェクトの形式でアップロードされたコンテンツ public ListSE<MultipartFile> getFiles(StringSE name)
MultipartRequest
MultipartRequest
の getFiles
name
- マルチパートファイルのパラメーター名を指定する文字列 MultipartFile
リストの形式でアップロードされたコンテンツ public MapSE<StringSE,MultipartFile> getFileMap()
MultipartRequest
Map
SE を返します。MultipartRequest
の getFileMap
MultipartFile
オブジェクトを値として含むマップ public MultiValueMap<StringSE,MultipartFile> getMultiFileMap()
MultipartRequest
MultiValueMap
を返します。MultipartRequest
の getMultiFileMap
MultipartFile
オブジェクトのリスト public StringSE getMultipartContentType(StringSE paramOrFileName)
MultipartRequest
MultipartRequest
の getMultipartContentType
paramOrFileName
- パーツの名前 null
public HttpMethod getRequestMethod()
MultipartHttpServletRequest
MultipartHttpServletRequest
の getRequestMethod
public HttpHeaders getRequestHeaders()
MultipartHttpServletRequest
MultipartHttpServletRequest
の getRequestHeaders
public HttpHeaders getMultipartHeaders(StringSE paramOrFileName)
MultipartHttpServletRequest
基盤となる実装がパーツヘッダーへのアクセスをサポートしている場合、すべてのヘッダーが返されます。それ以外の場合、たとえばファイルのアップロードの場合、返されるヘッダーは、可能な場合は "Content-Type" を公開する場合があります。
MultipartHttpServletRequest
の getMultipartHeaders