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
被調用時,它應該檢查以上期望並返回一些數據的成功。