How to write unit test for CommonsMultipartFile with Mock

file type need to be org.springframework.web.multipart.MultipartFile. This is the super interface above CommonsMultiPartFile and MockMultipartFile. If you have done this, then you can create a mock of the multipart file itself with an mock object that is provided by spring, just like below:
MockMultipartFile mockMultipartFile = new MockMultipartFile(String name, String originalFilename, String contentType, byte[] content);

you can get more information from http://stackoverflow.com/questions/8799378/how-to-write-unit-test-for-commonsmultipartfile-with-mock-in-spring

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章