Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
c3984188
Commit
c3984188
authored
Apr 09, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25952 from izeye
* pr/25952: Fix MongoMetricsAutoConfigurationTests Closes gh-25952
parents
719d10b6
98b0b6c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
MongoMetricsAutoConfigurationTests.java
...ure/metrics/mongo/MongoMetricsAutoConfigurationTests.java
+21
-14
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/mongo/MongoMetricsAutoConfigurationTests.java
View file @
c3984188
...
@@ -46,6 +46,7 @@ import static org.mockito.Mockito.mock;
...
@@ -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 {
...
@@ -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 {
...
@@ -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
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment