2
我正在尝试为使用RestTemplate的一个REST Webservice客户端编写Junit。面向REST模板客户端的Junit
下面是方法调用REST模板:
final ResponseEntity<LogDateVO[]> result = restTemplate.postForEntity(url, LogDateInputVO, LogDateVO[].class);
在我的测试类我试图像下面的一些事情:
mockServer.expect(requestTo("http://abc.def.pvt:80/testOperations/api/traffic/logs/")).andExpect(method(HttpMethod.POST))
.andRespond(MockRestResponseCreators.withSuccess("{ \"id\" : \"42\", \"name\" : \"Holiday Inn\"}", MediaType.APPLICATION_JSON));
我无法得到结果返回,而不是能够继续采用这种方法,我需要一些帮助来获得这个。
我的意图是当我的restTemplate
被调用时,它应该检查以上期望并返回一些数据的成功。