|
|
@ -46,6 +46,7 @@ import static org.mockito.Mockito.mock;
|
|
|
|
* Tests for {@link MongoMetricsAutoConfiguration}.
|
|
|
|
* Tests for {@link MongoMetricsAutoConfiguration}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Chris Bono
|
|
|
|
* @author Chris Bono
|
|
|
|
|
|
|
|
* @author Johnny Lim
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class MongoMetricsAutoConfigurationTests {
|
|
|
|
class MongoMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
@ -80,13 +81,13 @@ class MongoMetricsAutoConfigurationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void whenThereIsNoMeterRegistryThenNoMetricsCommandListenerIsAdded() {
|
|
|
|
void whenThereIsNoMeterRegistryThenNoMetricsCommandListenerIsAdded() {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
.run((context) -> assertThatMetricsCommandListenerNotAdded());
|
|
|
|
.run(assertThatMetricsCommandListenerNotAdded());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void whenThereIsNoMeterRegistryThenNoMetricsConnectionPoolListenerIsAdded() {
|
|
|
|
void whenThereIsNoMeterRegistryThenNoMetricsConnectionPoolListenerIsAdded() {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
.run((context) -> assertThatMetricsConnectionPoolListenerNotAdded());
|
|
|
|
.run(assertThatMetricsConnectionPoolListenerNotAdded());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -112,44 +113,50 @@ class MongoMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void whenThereIsNoMongoClientSettingsOnClasspathThenNoMetricsCommandListenerIsAdded() {
|
|
|
|
void whenThereIsNoMongoClientSettingsOnClasspathThenNoMetricsCommandListenerIsAdded() {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
this.contextRunner.with(MetricsRun.simple())
|
|
|
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
.withClassLoader(new FilteredClassLoader(MongoClientSettings.class))
|
|
|
|
.withClassLoader(new FilteredClassLoader(MongoClientSettings.class))
|
|
|
|
.run((context) -> assertThatMetricsCommandListenerNotAdded());
|
|
|
|
.run(assertThatMetricsCommandListenerNotAdded());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void whenThereIsNoMongoClientSettingsOnClasspathThenNoMetricsConnectionPoolListenerIsAdded() {
|
|
|
|
void whenThereIsNoMongoClientSettingsOnClasspathThenNoMetricsConnectionPoolListenerIsAdded() {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
this.contextRunner.with(MetricsRun.simple())
|
|
|
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
.withClassLoader(new FilteredClassLoader(MongoClientSettings.class))
|
|
|
|
.withClassLoader(new FilteredClassLoader(MongoClientSettings.class))
|
|
|
|
.run((context) -> assertThatMetricsConnectionPoolListenerNotAdded());
|
|
|
|
.run(assertThatMetricsConnectionPoolListenerNotAdded());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void whenThereIsNoMongoMetricsCommandListenerOnClasspathThenNoMetricsCommandListenerIsAdded() {
|
|
|
|
void whenThereIsNoMongoMetricsCommandListenerOnClasspathThenNoMetricsCommandListenerIsAdded() {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
this.contextRunner.with(MetricsRun.simple())
|
|
|
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
.withClassLoader(new FilteredClassLoader(MongoMetricsCommandListener.class))
|
|
|
|
.withClassLoader(new FilteredClassLoader(MongoMetricsCommandListener.class))
|
|
|
|
.run((context) -> assertThatMetricsCommandListenerNotAdded());
|
|
|
|
.run(assertThatMetricsCommandListenerNotAdded());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void whenThereIsNoMongoMetricsConnectionPoolListenerOnClasspathThenNoMetricsConnectionPoolListenerIsAdded() {
|
|
|
|
void whenThereIsNoMongoMetricsConnectionPoolListenerOnClasspathThenNoMetricsConnectionPoolListenerIsAdded() {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
this.contextRunner.with(MetricsRun.simple())
|
|
|
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
.withClassLoader(new FilteredClassLoader(MongoMetricsConnectionPoolListener.class))
|
|
|
|
.withClassLoader(new FilteredClassLoader(MongoMetricsConnectionPoolListener.class))
|
|
|
|
.run((context) -> assertThatMetricsConnectionPoolListenerNotAdded());
|
|
|
|
.run(assertThatMetricsConnectionPoolListenerNotAdded());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void whenMetricsCommandListenerEnabledPropertyFalseThenNoMetricsCommandListenerIsAdded() {
|
|
|
|
void whenMetricsCommandListenerEnabledPropertyFalseThenNoMetricsCommandListenerIsAdded() {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
this.contextRunner.with(MetricsRun.simple())
|
|
|
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
.withPropertyValues("management.metrics.mongo.command.enabled:false")
|
|
|
|
.withPropertyValues("management.metrics.mongo.command.enabled:false")
|
|
|
|
.run((context) -> assertThatMetricsCommandListenerNotAdded());
|
|
|
|
.run(assertThatMetricsCommandListenerNotAdded());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void whenMetricsConnectionPoolListenerEnabledPropertyFalseThenNoMetricsConnectionPoolListenerIsAdded() {
|
|
|
|
void whenMetricsConnectionPoolListenerEnabledPropertyFalseThenNoMetricsConnectionPoolListenerIsAdded() {
|
|
|
|
this.contextRunner.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
this.contextRunner.with(MetricsRun.simple())
|
|
|
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
|
|
|
|
.withPropertyValues("management.metrics.mongo.connectionpool.enabled:false")
|
|
|
|
.withPropertyValues("management.metrics.mongo.connectionpool.enabled:false")
|
|
|
|
.run((context) -> assertThatMetricsConnectionPoolListenerNotAdded());
|
|
|
|
.run(assertThatMetricsConnectionPoolListenerNotAdded());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ContextConsumer<AssertableApplicationContext> assertThatMetricsCommandListenerNotAdded() {
|
|
|
|
private ContextConsumer<AssertableApplicationContext> assertThatMetricsCommandListenerNotAdded() {
|
|
|
|