Package org.springframework.test.web.servlet.request

# Class MockMultipartHttpServletRequestBuilder

java.lang.Object
org.springframework.test.web.servlet.request.AbstractMockHttpServletRequestBuilder<MockHttpServletRequestBuilder>
org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder

All Implemented Interfaces:
  `org.springframework.beans.Mergeable`, `ConfigurableSmartRequestBuilder<MockHttpServletRequestBuilder>`, `RequestBuilder`, `SmartRequestBuilder`

public class MockMultipartHttpServletRequestBuilder extends MockHttpServletRequestBuilder
Default builder for `MockMultipartHttpServletRequest`.

Since:
  3.2
Author:
  Rossen Stoyanchev, Arjen Poutsma, Stephane Nicoll

## Method Summary

Modifier and Type
Method
Description
`protected final MockHttpServletRequest`
`createServletRequest(ServletContext servletContext)`
Create a new `MockMultipartHttpServletRequest` based on the supplied `ServletContext` and the `MockMultipartFiles` added to this builder.
`MockMultipartHttpServletRequestBuilder`
`file(String name, byte[] content)`
Add a new `MockMultipartFile` with the given content.
`MockMultipartHttpServletRequestBuilder`
`file(MockMultipartFile file)`
Add the given `MockMultipartFile`.
`Object`
`merge(Object parent)`
Merges the properties of the "parent" RequestBuilder accepting values only if not already set in "this" instance.
`MockMultipartHttpServletRequestBuilder`
`part(Part... parts)`
Add `Part` components to the request.

### Methods inherited from class org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder

`accept, accept, characterEncoding, characterEncoding, content, content, contentType, contentType, contextPath, cookie, flashAttr, flashAttrs, formField, formFields, header, headers, locale, locale, param, params, pathInfo, principal, queryParam, queryParams, remoteAddress, requestAttr, secure, servletPath, session, sessionAttr, sessionAttrs, uri, uri, with`

### Methods inherited from class org.springframework.test.web.servlet.request.AbstractMockHttpServletRequestBuilder

`buildRequest, isMergeEnabled, postProcessRequest, self`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### file

public MockMultipartHttpServletRequestBuilder file(String name, byte[] content)
Add a new `MockMultipartFile` with the given content.

Parameters:
  `name` - the name of the file
  `content` - the content of the file

### file

public MockMultipartHttpServletRequestBuilder file(MockMultipartFile file)
Add the given `MockMultipartFile`.

Parameters:
  `file` - the multipart file

### part

public MockMultipartHttpServletRequestBuilder part(Part... parts)
Add `Part` components to the request.

Parameters:
  `parts` - one or more parts to add
Since:
  5.0

### merge

public Object merge(@Nullable Object parent)
Description copied from class: `AbstractMockHttpServletRequestBuilder`
Merges the properties of the "parent" RequestBuilder accepting values only if not already set in "this" instance.

Specified by:
  `merge` in interface `org.springframework.beans.Mergeable`
Overrides:
  `merge` in class `AbstractMockHttpServletRequestBuilder<MockHttpServletRequestBuilder>`
Parameters:
  `parent` - the parent `RequestBuilder` to inherit properties from
Returns:
  the result of the merge

### createServletRequest

protected final MockHttpServletRequest createServletRequest(ServletContext servletContext)
Create a new `MockMultipartHttpServletRequest` based on the supplied `ServletContext` and the `MockMultipartFiles` added to this builder.

Overrides:
  `createServletRequest` in class `AbstractMockHttpServletRequestBuilder<MockHttpServletRequestBuilder>`