|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.support.BeanDefinitionOverrideException;
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
|
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
|
|
|
|
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
|
|
|
@ -42,6 +43,7 @@ import org.springframework.mock.http.client.MockClientHttpResponse;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
|
import static org.mockito.ArgumentMatchers.any;
|
|
|
|
|
import static org.mockito.BDDMockito.given;
|
|
|
|
|
import static org.mockito.BDDMockito.then;
|
|
|
|
@ -65,6 +67,15 @@ class RestTemplateAutoConfigurationTests {
|
|
|
|
|
.isTrue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void assertExceptionWhenCustomRestTemplateConfigurerIsDefined() {
|
|
|
|
|
this.contextRunner
|
|
|
|
|
.withUserConfiguration(RestTemplateCustomConfigurerConfig.class)
|
|
|
|
|
.run((context) -> assertThrows( BeanDefinitionOverrideException.class, () ->{
|
|
|
|
|
context.getBeanFactory().getBeanDefinition("restTemplateBuilderConfigurer");
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void restTemplateBuilderShouldBeLazilyDefined() {
|
|
|
|
|
this.contextRunner
|
|
|
|
@ -263,6 +274,16 @@ class RestTemplateAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
static class RestTemplateCustomConfigurerConfig {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
RestTemplateBuilderConfigurer restTemplateBuilderConfigurer() {
|
|
|
|
|
return new RestTemplateBuilderConfigurer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static class CustomHttpMessageConverter extends StringHttpMessageConverter {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|