Polish "Create EndpointWebExtension only if necessary"
See gh-28475
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,7 +68,8 @@ class CachesEndpointAutoConfigurationTests {
|
||||
@Test
|
||||
void runWhenOnlyExposedOverJmxShouldHaveEndpointBeanWithoutWebExtension() {
|
||||
this.contextRunner.withBean(CacheManager.class, () -> mock(CacheManager.class))
|
||||
.withPropertyValues("spring.jmx.enabled=true", "management.endpoints.jmx.exposure.include=caches")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=info", "spring.jmx.enabled=true",
|
||||
"management.endpoints.jmx.exposure.include=caches")
|
||||
.run((context) -> assertThat(context).hasSingleBean(CachesEndpoint.class)
|
||||
.doesNotHaveBean(CachesEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
@@ -106,7 +106,8 @@ class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
|
||||
@Test
|
||||
void runWhenOnlyExposedOverJmxShouldHaveEndpointBeanWithoutWebExtension() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.jmx.enabled=true", "management.endpoints.jmx.exposure.include=configprops")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=info", "spring.jmx.enabled=true",
|
||||
"management.endpoints.jmx.exposure.include=configprops")
|
||||
.run((context) -> assertThat(context).hasSingleBean(ConfigurationPropertiesReportEndpoint.class)
|
||||
.doesNotHaveBean(ConfigurationPropertiesReportEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
@@ -94,6 +94,15 @@ class EnvironmentEndpointAutoConfigurationTests {
|
||||
.run(validateSystemProperties("******", "******"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenOnlyExposedOverJmxShouldHaveEndpointBeanWithoutWebExtension() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=info", "spring.jmx.enabled=true",
|
||||
"management.endpoints.jmx.exposure.include=env")
|
||||
.run((context) -> assertThat(context).hasSingleBean(EnvironmentEndpoint.class)
|
||||
.doesNotHaveBean(EnvironmentEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> validateSystemProperties(String dbPassword, String apiKey) {
|
||||
return (context) -> {
|
||||
assertThat(context).hasSingleBean(EnvironmentEndpoint.class);
|
||||
@@ -110,14 +119,6 @@ class EnvironmentEndpointAutoConfigurationTests {
|
||||
.get();
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenOnlyExposedOverJmxShouldHaveEndpointBeanWithoutWebExtension() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.jmx.enabled=true", "management.endpoints.jmx.exposure.include=env")
|
||||
.run((context) -> assertThat(context).hasSingleBean(EnvironmentEndpoint.class)
|
||||
.doesNotHaveBean(EnvironmentEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class SanitizingFunctionConfiguration {
|
||||
|
||||
|
||||
@@ -75,7 +75,8 @@ class QuartzEndpointAutoConfigurationTests {
|
||||
@Test
|
||||
void runWhenOnlyExposedOverJmxShouldHaveEndpointBeanWithoutWebExtension() {
|
||||
this.contextRunner.withBean(Scheduler.class, () -> mock(Scheduler.class))
|
||||
.withPropertyValues("spring.jmx.enabled=true", "management.endpoints.jmx.exposure.include=quartz")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=info", "spring.jmx.enabled=true",
|
||||
"management.endpoints.jmx.exposure.include=quartz")
|
||||
.run((context) -> assertThat(context).hasSingleBean(QuartzEndpoint.class)
|
||||
.doesNotHaveBean(QuartzEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user