用于rest api的控制器,对于该测试我使用spring开发了一个测试用例
但是当我试图调用它时会出现500错误
请任何人告诉我如何测试?
如何从测试用例中调用该休息api url
休息api代码
@RequestMapping(value = "/new-work-plan", method = RequestMethod.POST)
public @ResponseBody String newWorkPlan(
@RequestBody WorkPlanEntity workplan, BindingResult result,
@RequestParam("signature") MultipartFile file {
System.out.println(workplan.getName());
System.out.println(workplan.getLocation());
System.out.println(file.isEmpty() + " " + file.getOriginalFilename() + " " + file.getSize());
return "";
}
test rest api
WorkPlanEntity wpe = new WorkPlanEntity();
wpe.setName("chaithu");
wpe.setLocation("Hyd");
MultiValueMap<String, Object> image = new LinkedMultiValueMap<String, Object>();
image.add("file1", new FileSystemResource("C:\\Users\\Public\\Pictures\\Sample Pictures\\Lighthouse.jpg"));
ResponseEntity<String> response3 = rest.postForEntity(URI + "new-work-plan/", wpe, String.class, parts);
System.out.println(response3);