use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class MockServerRestTemplateCustomizerTests method customizeShouldBindServer.
@Test
public void customizeShouldBindServer() throws Exception {
RestTemplate template = new RestTemplateBuilder(this.customizer).build();
this.customizer.getServer().expect(requestTo("/test")).andRespond(withSuccess());
template.getForEntity("/test", String.class);
this.customizer.getServer().verify();
}
use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class MockServerRestTemplateCustomizerTests method createShouldUseExpectationManagerClass.
@Test
public void createShouldUseExpectationManagerClass() throws Exception {
MockServerRestTemplateCustomizer customizer = new MockServerRestTemplateCustomizer(UnorderedRequestExpectationManager.class);
customizer.customize(new RestTemplate());
assertThat(customizer.getServer()).extracting("expectationManager").hasAtLeastOneElementOfType(UnorderedRequestExpectationManager.class);
}
use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class MockServerRestTemplateCustomizerTests method getServerWhenMultipleServersAreBoundShouldThrowException.
@Test
public void getServerWhenMultipleServersAreBoundShouldThrowException() throws Exception {
this.customizer.customize(new RestTemplate());
this.customizer.customize(new RestTemplate());
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Unable to return a single MockRestServiceServer since " + "MockServerRestTemplateCustomizer has been bound to more than one RestTemplate");
this.customizer.getServer();
}
use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method messageConvertersShouldApply.
@Test
public void messageConvertersShouldApply() throws Exception {
RestTemplate template = this.builder.messageConverters(this.messageConverter).build();
assertThat(template.getMessageConverters()).containsOnly(this.messageConverter);
}
use of org.springframework.web.client.RestTemplate in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method basicAuthorizationShouldApply.
@Test
public void basicAuthorizationShouldApply() throws Exception {
RestTemplate template = this.builder.basicAuthorization("spring", "boot").build();
ClientHttpRequestInterceptor interceptor = template.getInterceptors().get(0);
assertThat(interceptor).isInstanceOf(BasicAuthorizationInterceptor.class);
assertThat(interceptor).extracting("username").containsExactly("spring");
assertThat(interceptor).extracting("password").containsExactly("boot");
}
Aggregations