spring-framework / org.springframework.mock.web / MockMultipartHttpServletRequest

MockMultipartHttpServletRequest

open class MockMultipartHttpServletRequest : MockHttpServletRequest, MultipartHttpServletRequest

Mock implementation of the org.springframework.web.multipart.MultipartHttpServletRequest interface.

As of Spring 5.0, this set of mocks is designed on a Servlet 4.0 baseline.

Useful for testing application controllers that access multipart uploads. MockMultipartFile can be used to populate these mock requests with files.

Author
Juergen Hoeller

Author
Eric Crampton

Author
Arjen Poutsma

Since
2.0

See Also
MockMultipartFile

Constructors

<init>

MockMultipartHttpServletRequest()

Create a new MockMultipartHttpServletRequest with a default MockServletContext.

MockMultipartHttpServletRequest(servletContext: ServletContext)

Create a new MockMultipartHttpServletRequest with the supplied ServletContext.

Functions

addFile

open fun addFile(file: MultipartFile): Unit

Add a file to this request. The parameter name from the multipart form is taken from the MultipartFile#getName().

getFile

open fun getFile(name: String): MultipartFile

getFileMap

open fun getFileMap(): MutableMap<String, MultipartFile>

getFileNames

open fun getFileNames(): MutableIterator<String>

getFiles

open fun getFiles(name: String): MutableList<MultipartFile>

getMultiFileMap

open fun getMultiFileMap(): MultiValueMap<String, MultipartFile>

getMultipartContentType

open fun getMultipartContentType(paramOrFileName: String): String

getMultipartHeaders

open fun getMultipartHeaders(paramOrFileName: String): HttpHeaders

getRequestHeaders

open fun getRequestHeaders(): HttpHeaders

getRequestMethod

open fun getRequestMethod(): HttpMethod