Sas*_*ota 5 java junit spring spring-boot spring-rest
我正在尝试MockRestServiceServer通过以下方式模拟POST方法:
MockRestServiceServer server = bindTo(restTemplate).build();
server.expect(requestTo("/my-api"))
.andExpect(method(POST))
.andRespond(withSuccess(expectedResponce, APPLICATION_JSON));
Run Code Online (Sandbox Code Playgroud)
问题:如何在此设置中验证请求正文?
我浏览了文档和一些示例,但仍然不知道如何完成。
use*_*900 12
您可以使用content().string来验证正文:
.andExpect(content().string(expectedContent))
this.mockServer.expect(content().bytes("foo".getBytes()))
this.mockServer.expect(content().string("foo"))
| 归档时间: |
|
| 查看次数: |
690 次 |
| 最近记录: |