0

My controller is like below

@RequestMapping(method = RequestMethod.POST)
protected String processSubmit(HttpServletRequest request,
        @Valid @ModelAttribute("binaryUploadForm") BinaryUploadForm form, BindingResult result, ModelMap model) throws Exception {

then I loop through files

    final int numberOfFiles = form.getFiles().size();
    for (int i = 0; i < numberOfFiles; i++) {
        final MultipartFile multipartFile = form.getFiles().get(i);

I want to write a test case for this using MockMvc of spring.

mockMvc.perform(fileUpload("/binary-management/add-binary.html").file(file)

is not helpful as multipartfile is not coming as part of parameter but as a field in form.

Can you please help.

Replies to comments:

in JSP I have a field like below

<input id="files0" type="file" name="files[0]" style="font-size:1.2em;height:22px;position:static;" size="48"/>

and form implementation is as below

public List<MultipartFile> getFiles() {
    return files;
}


public void setFiles(List<MultipartFile> files) {
    this.files = files;
}

html form is submitted using javascript which is quite complex and using EXT JS

Sammy Pawar
  • 1,201
  • 3
  • 19
  • 38

0 Answers0