|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
41 | 41 | class MetricsAspectsAutoConfigurationTests {
|
42 | 42 |
|
43 | 43 | private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple())
|
| 44 | + .withPropertyValues("micrometer.observations.annotations.enabled=true") |
44 | 45 | .withConfiguration(AutoConfigurations.of(MetricsAspectsAutoConfiguration.class));
|
45 | 46 |
|
| 47 | + @Test |
| 48 | + void shouldNotConfigureAspectsByDefault() { |
| 49 | + new ApplicationContextRunner().with(MetricsRun.simple()) |
| 50 | + .withConfiguration(AutoConfigurations.of(MetricsAspectsAutoConfiguration.class)) |
| 51 | + .run((context) -> { |
| 52 | + assertThat(context).doesNotHaveBean(CountedAspect.class); |
| 53 | + assertThat(context).doesNotHaveBean(TimedAspect.class); |
| 54 | + }); |
| 55 | + } |
| 56 | + |
46 | 57 | @Test
|
47 | 58 | void shouldConfigureAspects() {
|
48 | 59 | this.contextRunner.run((context) -> {
|
@@ -78,11 +89,12 @@ void shouldNotConfigureAspectsIfAspectjIsMissing() {
|
78 | 89 |
|
79 | 90 | @Test
|
80 | 91 | void shouldNotConfigureAspectsIfMeterRegistryBeanIsMissing() {
|
81 |
| - new ApplicationContextRunner().run((context) -> { |
82 |
| - assertThat(context).doesNotHaveBean(MeterRegistry.class); |
83 |
| - assertThat(context).doesNotHaveBean(CountedAspect.class); |
84 |
| - assertThat(context).doesNotHaveBean(TimedAspect.class); |
85 |
| - }); |
| 92 | + new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(MetricsAspectsAutoConfiguration.class)) |
| 93 | + .run((context) -> { |
| 94 | + assertThat(context).doesNotHaveBean(MeterRegistry.class); |
| 95 | + assertThat(context).doesNotHaveBean(CountedAspect.class); |
| 96 | + assertThat(context).doesNotHaveBean(TimedAspect.class); |
| 97 | + }); |
86 | 98 | }
|
87 | 99 |
|
88 | 100 | @Test
|
|
0 commit comments