Skip to content

Commit

Permalink
Align with new fail-fast behaviour in Micrometer 1.1.4
Browse files Browse the repository at this point in the history
Closes gh-16425
  • Loading branch information
wilkinsona committed Apr 3, 2019
1 parent 3c05858 commit ca01199
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public void backsOffWithoutAClock() {

@Test
public void autoConfiguresItsConfigAndMeterRegistry() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner
.withPropertyValues("management.metrics.export.appoptics.api-token=abcde")
.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(AppOpticsMeterRegistry.class)
.hasSingleBean(AppOpticsConfig.class));
Expand All @@ -73,16 +75,19 @@ public void allowsCustomConfigToBeUsed() {

@Test
public void allowsCustomRegistryToBeUsed() {
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner
.withPropertyValues("management.metrics.export.appoptics.api-token=abcde")
.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(AppOpticsMeterRegistry.class)
.hasBean("customRegistry").hasSingleBean(AppOpticsConfig.class));
}

@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> {
this.contextRunner
.withPropertyValues("management.metrics.export.appoptics.api-token=abcde")
.withUserConfiguration(BaseConfiguration.class).run((context) -> {
AppOpticsMeterRegistry registry = context
.getBean(AppOpticsMeterRegistry.class);
assertThat(registry.isClosed()).isFalse();
Expand All @@ -107,7 +112,12 @@ static class CustomConfigConfiguration {

@Bean
public AppOpticsConfig customConfig() {
return (key) -> null;
return (key) -> {
if ("appoptics.apiToken".equals(key)) {
return "abcde";
}
return null;
};
}

}
Expand Down

0 comments on commit ca01199

Please sign in to comment.