public class

MockMultipartActionRequest

extends MockActionRequest
implements MultipartActionRequest
java.lang.Object
   ↳ org.springframework.mock.web.portlet.MockPortletRequest
     ↳ org.springframework.mock.web.portlet.MockClientDataRequest
       ↳ org.springframework.mock.web.portlet.MockActionRequest
         ↳ org.springframework.mock.web.portlet.MockMultipartActionRequest

Class Overview

Mock implementation of the MultipartActionRequest interface.

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

Summary

Public Constructors
MockMultipartActionRequest()
Public Methods
void addFile(MultipartFile file)
Add a file to this request.
MultipartFile getFile(String name)
Return the contents plus description of an uploaded file in this request, or null if it does not exist.
Map<StringMultipartFile> getFileMap()
Return a Map of the multipart files contained in this request.
Iterator<String> getFileNames()
Return an Iterator of String objects containing the parameter names of the multipart files contained in this request.
List<MultipartFile> getFiles(String name)
Return the contents plus description of uploaded files in this request, or an empty list if it does not exist.
MultiValueMap<StringMultipartFile> getMultiFileMap()
Return a MultiValueMap of the multipart files contained in this request.
[Expand]
Inherited Methods
From class org.springframework.mock.web.portlet.MockActionRequest
From class org.springframework.mock.web.portlet.MockClientDataRequest
From class org.springframework.mock.web.portlet.MockPortletRequest
From class java.lang.Object
From interface org.springframework.web.multipart.MultipartRequest

Public Constructors

public MockMultipartActionRequest ()

Public Methods

public void addFile (MultipartFile file)

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

Parameters
file multipart file to be added

public MultipartFile getFile (String name)

Return the contents plus description of an uploaded file in this request, or null if it does not exist.

Parameters
name a String specifying the parameter name of the multipart file
Returns

public Map<StringMultipartFile> getFileMap ()

Return a Map of the multipart files contained in this request.

Returns
  • a map containing the parameter names as keys, and the MultipartFile objects as values

public Iterator<String> getFileNames ()

Return an Iterator of String objects containing the parameter names of the multipart files contained in this request. These are the field names of the form (like with normal parameters), not the original file names.

Returns
  • the names of the files

public List<MultipartFile> getFiles (String name)

Return the contents plus description of uploaded files in this request, or an empty list if it does not exist.

Parameters
name a String specifying the parameter name of the multipart file
Returns

public MultiValueMap<StringMultipartFile> getMultiFileMap ()

Return a MultiValueMap of the multipart files contained in this request.

Returns
  • a map containing the parameter names as keys, and a list of MultipartFile objects as values