use of org.springframework.test.web.client.MockRestServiceServer in project spring-boot by spring-projects.
the class MockServerRestTemplateCustomizer method customize.
@Override
public void customize(RestTemplate restTemplate) {
RequestExpectationManager expectationManager = createExpectationManager();
if (this.detectRootUri) {
expectationManager = RootUriRequestExpectationManager.forRestTemplate(restTemplate, expectationManager);
}
MockRestServiceServer server = MockRestServiceServer.bindTo(restTemplate).build(expectationManager);
this.expectationManagers.put(restTemplate, expectationManager);
this.servers.put(restTemplate, server);
}
use of org.springframework.test.web.client.MockRestServiceServer in project spring-boot by spring-projects.
the class RootUriRequestExpectationManagerTests method bindToWithExpectationManagerShouldReturnMockRestServiceServer.
@Test
public void bindToWithExpectationManagerShouldReturnMockRestServiceServer() throws Exception {
RestTemplate restTemplate = new RestTemplateBuilder().build();
MockRestServiceServer bound = RootUriRequestExpectationManager.bindTo(restTemplate, this.delegate);
assertThat(bound).isNotNull();
}
use of org.springframework.test.web.client.MockRestServiceServer in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method rootUriShouldApply.
@Test
public void rootUriShouldApply() throws Exception {
RestTemplate restTemplate = this.builder.rootUri("http://example.com").build();
MockRestServiceServer server = MockRestServiceServer.bindTo(restTemplate).build();
server.expect(requestTo("http://example.com/hello")).andRespond(withSuccess());
restTemplate.getForEntity("/hello", String.class);
server.verify();
}
use of org.springframework.test.web.client.MockRestServiceServer in project spring-boot by spring-projects.
the class RootUriRequestExpectationManagerTests method bindToShouldReturnMockRestServiceServer.
@Test
public void bindToShouldReturnMockRestServiceServer() throws Exception {
RestTemplate restTemplate = new RestTemplateBuilder().build();
MockRestServiceServer bound = RootUriRequestExpectationManager.bindTo(restTemplate);
assertThat(bound).isNotNull();
}
use of org.springframework.test.web.client.MockRestServiceServer in project spring-boot by spring-projects.
the class RootUriRequestExpectationManagerTests method boundRestTemplateShouldPrefixRootUri.
@Test
public void boundRestTemplateShouldPrefixRootUri() {
RestTemplate restTemplate = new RestTemplateBuilder().rootUri("http://example.com").build();
MockRestServiceServer server = RootUriRequestExpectationManager.bindTo(restTemplate);
server.expect(requestTo("/hello")).andRespond(withSuccess());
restTemplate.getForEntity("/hello", String.class);
}
Aggregations