我有一个api文件下载(txt,.doc,*。csv)使用java.i中的spring框架想要使用空手道进行验收测试。我可以这样做。
这是我的代码
@RequestMapping(path = "/download", method = RequestMethod.GET)
public ResponseEntity<Resource> download(String param) throws
IOException {
InputStreamResource resource = new InputStreamResource(new FileInputStream(file));
return ResponseEntity.ok()
.headers(headers)
.contentLength(file.length())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(resource);
}
请参阅此示例upload.feature
中的第16行
这是一个正常的get