dimanche 29 mars 2020

Can i send real file using MockMultipartFile?

I have simple controller.

@PostMapping()
public Integer uploadFile(MultipartFile file) throws IOException {
    return service.readFileFromExcel(file);
}

And i want to write integration test for it. I've read about MockMultipartFile and i've seen some examples, but they are too simple like

MockMultipartFile file = new MockMultipartFile("file", "hello.txt", MediaType.TEXT_PLAIN_VALUE, "Hello, World!".getBytes());

But do I have some way to send real file instead "Hello, World!".getBytes() from resourses directory?

Aucun commentaire:

Enregistrer un commentaire