Polish "Make auto-config of RestTemplate metrics back off with no builder bean"
Closes gh-15842
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.core.annotation.Order;
|
||||
* @author Jon Schneider
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
* @author Raheela Aslam
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@Configuration
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
*
|
||||
* @author Jon Schneider
|
||||
* @author Phillip Webb
|
||||
* @author raheela.aslam
|
||||
* @author Raheela Aslam
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(RestTemplate.class)
|
||||
|
||||
@@ -42,7 +42,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Jon Schneider
|
||||
* @author raheela.aslam
|
||||
* @author Raheela Aslam
|
||||
*/
|
||||
public class RestTemplateMetricsConfigurationTests {
|
||||
|
||||
@@ -100,6 +100,16 @@ public class RestTemplateMetricsConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void backsOffWhenRestTemplateBuilderIsMissing() {
|
||||
new ApplicationContextRunner().with(MetricsRun.simple())
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(HttpClientMetricsAutoConfiguration.class))
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(DefaultRestTemplateExchangeTagsProvider.class)
|
||||
.doesNotHaveBean(MetricsRestTemplateCustomizer.class));
|
||||
}
|
||||
|
||||
private MeterRegistry getInitializedMeterRegistry(
|
||||
AssertableApplicationContext context) {
|
||||
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
||||
@@ -133,14 +143,4 @@ public class RestTemplateMetricsConfigurationTests {
|
||||
return restTemplate;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void backsOffWhenRestTemplateBuilderIsMissing() {
|
||||
new ApplicationContextRunner().with(MetricsRun.simple())
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(HttpClientMetricsAutoConfiguration.class))
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(DefaultRestTemplateExchangeTagsProvider.class)
|
||||
.doesNotHaveBean(MetricsRestTemplateCustomizer.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user