Path to test resources
java.nio.file.Path;=
Path resourceDirectory = Paths.get("src", "test", "resources");
String filePath = resourceDirectory.toFile().getAbsolutePath();
File f = new File(absolutePath);
File[] list = f.listFiles();
InputStream targetStream = new FileInputStream(list[0]);
MockMultipartFile file = new MockMultipartFile("file", "sampletest.xml", MediaType.TEXT_PLAIN_VALUE,
targetStream);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
mockMvc.perform(multipart("/uploadFile").file(file).param("filePath", absolutePath)).andExpect(status().isOk());
No comments:
Post a Comment