Search in sources :

Example 6 with MockRestServiceServer

use of org.springframework.test.web.client.MockRestServiceServer in project spring-boot by spring-projects.

the class RootUriRequestExpectationManagerTests method boundRestTemplateWhenUrlIncludesDomainShouldNotPrefixRootUri.

@Test
public void boundRestTemplateWhenUrlIncludesDomainShouldNotPrefixRootUri() {
    RestTemplate restTemplate = new RestTemplateBuilder().rootUri("http://example.com").build();
    MockRestServiceServer server = RootUriRequestExpectationManager.bindTo(restTemplate);
    server.expect(requestTo("/hello")).andRespond(withSuccess());
    this.thrown.expect(AssertionError.class);
    this.thrown.expectMessage("expected:<http://example.com/hello> but was:<http://spring.io/hello>");
    restTemplate.getForEntity("http://spring.io/hello", String.class);
}
Also used : RestTemplateBuilder(org.springframework.boot.web.client.RestTemplateBuilder) RestTemplate(org.springframework.web.client.RestTemplate) MockRestServiceServer(org.springframework.test.web.client.MockRestServiceServer) Test(org.junit.Test)

Aggregations

MockRestServiceServer (org.springframework.test.web.client.MockRestServiceServer)6 Test (org.junit.Test)5 RestTemplate (org.springframework.web.client.RestTemplate)5 RestTemplateBuilder (org.springframework.boot.web.client.RestTemplateBuilder)4 RequestExpectationManager (org.springframework.test.web.client.RequestExpectationManager)1 SimpleRequestExpectationManager (org.springframework.test.web.client.SimpleRequestExpectationManager)1