mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Revisit metrics and tracing test properties
This commit renames 'spring.test.metrics.auto-configure' and 'spring.test.tracing.auto-configure' for consistency with the non-test properties. It also adds a configuration metadata entry for 'spring.test.observability.auto-configure' that's superseded by these two properties. Closes gh-47776
This commit is contained in:
+7
@@ -6,6 +6,13 @@
|
||||
"description": "Whether auto-configuration of JSON testers is enabled.",
|
||||
"defaultValue": "true"
|
||||
},
|
||||
{
|
||||
"name": "spring.test.observability.auto-configure",
|
||||
"deprecation": {
|
||||
"reason": "Superseded by 'spring.test.metrics.export' and 'spring.test.tracing.export'.",
|
||||
"level": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spring.test.print-condition-evaluation-report",
|
||||
"type": "java.lang.Boolean",
|
||||
|
||||
+1
-2
@@ -41,8 +41,7 @@ import org.springframework.test.context.TestContextAnnotationUtils;
|
||||
*/
|
||||
class MetricsContextCustomizerFactory implements ContextCustomizerFactory {
|
||||
|
||||
// TODO spring.test.metrics.export?
|
||||
static final String AUTO_CONFIGURE_PROPERTY = "spring.test.metrics.auto-configure";
|
||||
static final String AUTO_CONFIGURE_PROPERTY = "spring.test.metrics.export";
|
||||
|
||||
@Override
|
||||
public ContextCustomizer createContextCustomizer(Class<?> testClass,
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"properties": [
|
||||
{
|
||||
"name": "spring.test.metrics.auto-configure",
|
||||
"name": "spring.test.metrics.export",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether metrics should be auto-configured in tests.",
|
||||
"description": "Whether metrics export should be auto-configured in tests.",
|
||||
"defaultValue": false
|
||||
}
|
||||
]
|
||||
|
||||
+5
-5
@@ -94,18 +94,18 @@ class MetricsContextCustomizerFactoryTests {
|
||||
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
|
||||
ConfigurableApplicationContext context = new GenericApplicationContext();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.test.metrics.auto-configure", "true");
|
||||
environment.setProperty("spring.test.metrics.export", "true");
|
||||
context.setEnvironment(environment);
|
||||
applyCustomizerToContext(customizer, context);
|
||||
assertThatMetricsAreEnabled(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
void metricsCanBeDisabledViaProperty() {
|
||||
void metricsExportCanBeDisabledViaProperty() {
|
||||
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
|
||||
ConfigurableApplicationContext context = new GenericApplicationContext();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.test.metrics.auto-configure", "false");
|
||||
environment.setProperty("spring.test.metrics.export", "false");
|
||||
context.setEnvironment(environment);
|
||||
applyCustomizerToContext(customizer, context);
|
||||
assertThatMetricsAreDisabled(context);
|
||||
@@ -116,7 +116,7 @@ class MetricsContextCustomizerFactoryTests {
|
||||
ContextCustomizer customizer = createContextCustomizer(MetricsExportEnabled.class);
|
||||
ConfigurableApplicationContext context = new GenericApplicationContext();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.test.metrics.auto-configure", "false");
|
||||
environment.setProperty("spring.test.metrics.export", "false");
|
||||
context.setEnvironment(environment);
|
||||
applyCustomizerToContext(customizer, context);
|
||||
assertThatMetricsAreEnabled(context);
|
||||
@@ -127,7 +127,7 @@ class MetricsContextCustomizerFactoryTests {
|
||||
ContextCustomizer customizer = createContextCustomizer(MetricsExportDisabled.class);
|
||||
ConfigurableApplicationContext context = new GenericApplicationContext();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.test.metrics.auto-configure", "true");
|
||||
environment.setProperty("spring.test.metrics.export", "true");
|
||||
context.setEnvironment(environment);
|
||||
applyCustomizerToContext(customizer, context);
|
||||
assertThatMetricsAreDisabled(context);
|
||||
|
||||
+1
-2
@@ -41,8 +41,7 @@ import org.springframework.test.context.TestContextAnnotationUtils;
|
||||
*/
|
||||
class TracingContextCustomizerFactory implements ContextCustomizerFactory {
|
||||
|
||||
// TODO spring.test.tracing.export?
|
||||
static final String AUTO_CONFIGURE_PROPERTY = "spring.test.tracing.auto-configure";
|
||||
static final String AUTO_CONFIGURE_PROPERTY = "spring.test.tracing.export";
|
||||
|
||||
@Override
|
||||
public ContextCustomizer createContextCustomizer(Class<?> testClass,
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"properties": [
|
||||
{
|
||||
"name": "spring.test.tracing.auto-configure",
|
||||
"name": "spring.test.tracing.export",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether tracing should be auto-configured in tests.",
|
||||
"description": "Whether tracing export should be auto-configured in tests.",
|
||||
"defaultValue": false
|
||||
}
|
||||
]
|
||||
|
||||
+4
-4
@@ -93,7 +93,7 @@ class TracingContextCustomizerFactoryTests {
|
||||
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
|
||||
ConfigurableApplicationContext context = new GenericApplicationContext();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.test.tracing.auto-configure", "true");
|
||||
environment.setProperty("spring.test.tracing.export", "true");
|
||||
context.setEnvironment(environment);
|
||||
applyCustomizerToContext(customizer, context);
|
||||
assertThatTracingExportIsEnabled(context);
|
||||
@@ -104,7 +104,7 @@ class TracingContextCustomizerFactoryTests {
|
||||
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
|
||||
ConfigurableApplicationContext context = new GenericApplicationContext();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.test.tracing.auto-configure", "false");
|
||||
environment.setProperty("spring.test.tracing.export", "false");
|
||||
context.setEnvironment(environment);
|
||||
applyCustomizerToContext(customizer, context);
|
||||
assertThatTracingExportIsDisabled(context);
|
||||
@@ -115,7 +115,7 @@ class TracingContextCustomizerFactoryTests {
|
||||
ContextCustomizer customizer = createContextCustomizer(TracingExportEnabled.class);
|
||||
ConfigurableApplicationContext context = new GenericApplicationContext();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.test.tracing.auto-configure", "false");
|
||||
environment.setProperty("spring.test.tracing.export", "false");
|
||||
context.setEnvironment(environment);
|
||||
applyCustomizerToContext(customizer, context);
|
||||
assertThatTracingExportIsEnabled(context);
|
||||
@@ -126,7 +126,7 @@ class TracingContextCustomizerFactoryTests {
|
||||
ContextCustomizer customizer = createContextCustomizer(TracingExportDisabled.class);
|
||||
ConfigurableApplicationContext context = new GenericApplicationContext();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.test.tracing.auto-configure", "true");
|
||||
environment.setProperty("spring.test.tracing.export", "true");
|
||||
context.setEnvironment(environment);
|
||||
applyCustomizerToContext(customizer, context);
|
||||
assertThatTracingExportIsDisabled(context);
|
||||
|
||||
Reference in New Issue
Block a user