将MockHttpServletResponse转换为ResponseEntity的最佳方法

时间:2018-05-22 11:43:23

标签: spring spring-mvc spring-test spring-test-mvc

只是想知道将MockHttpServletResponse转换为ResponseEntity的简单/最佳方法是什么

背景是我目前使用TestRestTemplate进行测试并计划将它们迁移到使用MockMvc

情况是MockMvc.perform(...)。getResponse()返回一个MockHttpServletResponse和TestRestTemplate.exchange(...)返回一个ResponseEntity

我想知道是否有任何开箱即用的方式进行此转换,如果不是,最好的方法是什么?目前我唯一的解决方法是忽略ResponseEntity并直接使用带有json mapper转换的实例来自字符串

0 个答案:

没有答案
相关问题