title: 'no multipart boundary was found' when testing max upload size using CommonsMultipartResolver
body: <p>In real application  i'm using <code>org.springframework.web.multipart.commons.CommonsMultipartResolver</code> where i define <em>maxUploadSize</em> parameter. So I whant to test catching <code>MaxUploadSizeExceededException</code> using spring mvc test.</p>
  
  <p>For this i'm adding <code>org.springframework.web.multipart.support.MultipartFilter</code> in Java:</p>
  
  <pre><code>@Autowired
  private WebApplicationContext wac;
  
  @Autowired
  private MultipartFilter multipartFilter;
  
  private MockMvc mockMvc;
  
  @Before
  public void init() {
      mockMvc = MockMvcBuilders.webAppContextSetup(wac)
          .addFilter(multipartFilter).build();
  }
  </code></pre>
  
  <p>In test conext (xml based configuration):</p>
  
  <pre><code>&lt;bean id="multipartFilter" class="org.springframework.web.multipart.support.MultipartFilter"&gt;
      &lt;property name="multipartResolverBeanName" value="MyMultipartResolverBeanName" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>MyMultipartResolverBeanName bean is defined in real life context that is added to test context with maven-surefire-plugin.</p>
  
  <p>My test is like in tutorial:</p>
  
  <pre><code>@Test(expected = MaxUploadSizeExceededException.class)
  public void testCertSizeInvalid() throws Exception {
      mockMvc.perform(fileUpload(SUBMIT_URL)
          .file(new MockMultipartFile("fileName", new byte[MAX_UPLOAD_SIZE + 10]))
      );
  }
  </code></pre>
  
  <p>When runing i getting <strong>Caused by: org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found</strong> from <code>org.apache.commons.fileupload.FileUploadBase</code> </p>
  
  <p>As i understand, in real life browser sets unique boundary in Content-Type header and separates parts in body with this boundary but spring mock test doen't sets boundary wile sending mock multipart request.</p>
  
  <p>So i found <code>org.springframework.http.converter.FormHttpMessageConverter</code>, create <code>org.springframework.test.web.servlet.request.RequestPostProcessor</code> where convert body and Content-Type header to correct (with boundary) and add post processor to request builder - <strong>test is passed!</strong>.</p>
  
  <p><strong>Maybe anybody knows better or more simple way to add boundary to Content-Type header and body of mock request?!</strong></p>
  
  <p><strong>PS</strong> <br> 
  If there is no better way - i can attach my RequestPostProcessor here <br>
  Used versions:
  <ul></p>
  
  
  <li>spring-test-3.2.0</li>
  <li>commons-fileupload-1.2.2</li>
  </ul>