}
@Test
public void testSaveWithXML() throws Exception {
User user = new User();
user.setId(1L);
user.setName("zhang");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
marshaller.marshal(user, new StreamResult(bos));
String userXml = bos.toString();
String uri = baseUri;
String createdLocation = baseUri + "/" + 1;
mockServer
.expect(requestTo(uri)) //验证请求URI
.andExpect(xpath("/user/name/text()").string(user.getName())) //验证请求的JSON数据
.andRespond(withCreatedEntity(URI.create(createdLocation)).body(userXml).contentType(MediaType.APPLICATION_XML)); //添加响应信息
restTemplate.setMessageConverters(Arrays.<HttpMessageConverter<?>>asList(new Jaxb2RootElementHttpMessageConverter()));
ResponseEntity<User> responseEntity = restTemplate.postForEntity(uri, user, User.class);