String responseBody = "<TestResponse><Message>Hello World!</Message></TestResponse>";
endpointConfiguration.setRequestMethod(HttpMethod.GET);
endpointConfiguration.setRequestUrl(requestUrl);
Message requestMessage = new HttpMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");
EndpointUriResolver endpointUriResolver = EasyMock.createMock(EndpointUriResolver.class);
endpointConfiguration.setEndpointUriResolver(endpointUriResolver);
endpointConfiguration.setRestTemplate(restTemplate);
reset(restTemplate, endpointUriResolver);
restTemplate.setErrorHandler(anyObject(ResponseErrorHandler.class));
expectLastCall().once();
expect(endpointUriResolver.resolveEndpointUri(requestMessage, "http://localhost:8088/test")).andReturn("http://localhost:8081/new").once();
expect(restTemplate.exchange(eq("http://localhost:8081/new"), eq(HttpMethod.GET), anyObject(HttpEntity.class), eq(String.class)))
.andReturn(new ResponseEntity<String>(responseBody, HttpStatus.OK)).once();
replay(restTemplate, endpointUriResolver);
httpClient.send(requestMessage, context);
HttpMessage responseMessage = (HttpMessage) httpClient.receive(context, endpointConfiguration.getTimeout());
Assert.assertEquals(responseMessage.getPayload(), responseBody);
Assert.assertEquals(responseMessage.getStatusCode(), HttpStatus.OK);
Assert.assertEquals(responseMessage.getReasonPhrase(), "OK");
verify(restTemplate, endpointUriResolver);
}