MockRestServiceServer: how to mock a POST call with a body?

后端 未结 3 1317
北荒
北荒 2021-02-12 22:05

I am trying to mock a POST method with MockRestServiceServer in the following way:

MockRestServiceServer server = bindTo(restTemplate).build();
serv         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-12 22:40

    You can use content().string to verify body:

    .andExpect(content().string(expectedContent))

    Or content().bytes:

    this.mockServer.expect(content().bytes("foo".getBytes()))

    this.mockServer.expect(content().string("foo"))

提交回复
热议问题