Guard Endpoint bean declarations with ConditionalOnExposedEndpoint
This commit adds the newly introduced `@ConditionalOnExposedEndpoint` conditional annotation to all auto-configured `Endpoint` in Actuator. With that change, `EndPoint` instances and related infrastructure will only be created when they are meant to be exposed and used. This will save CPU and memory resources when Actuator is present. Closes gh-16093
This commit is contained in:
parent
4ffbe6c9e8
commit
6586bae889
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.audit;
|
|||
import org.springframework.boot.actuate.audit.AuditEventRepository;
|
||||
import org.springframework.boot.actuate.audit.AuditEventsEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.logging.LoggersEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -38,6 +39,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Configuration
|
||||
@AutoConfigureAfter(AuditAutoConfiguration.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = AuditEventsEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = AuditEventsEndpoint.class)
|
||||
public class AuditEventsEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.beans;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.beans.BeansEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -32,6 +33,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = BeansEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = BeansEndpoint.class)
|
||||
public class BeansEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.cache;
|
|||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.cache.CachesEndpoint;
|
||||
import org.springframework.boot.actuate.cache.CachesEndpointWebExtension;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
@ -41,6 +42,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Configuration
|
||||
@ConditionalOnClass(CacheManager.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = CachesEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = CachesEndpoint.class)
|
||||
@AutoConfigureAfter(CacheAutoConfiguration.class)
|
||||
public class CachesEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.springframework.beans.BeansException;
|
|||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
||||
|
@ -75,6 +76,7 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
@ConditionalOnExposedEndpoint
|
||||
@ConditionalOnBean({ HealthEndpoint.class, ReactiveHealthEndpointWebExtension.class })
|
||||
public CloudFoundryReactiveHealthEndpointWebExtension cloudFoundryReactiveHealthEndpointWebExtension(
|
||||
ReactiveHealthEndpointWebExtension reactiveHealthEndpointWebExtension) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
|
||||
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementContextAutoConfiguration;
|
||||
import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
|
||||
|
@ -79,6 +80,7 @@ public class CloudFoundryActuatorAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
@ConditionalOnExposedEndpoint
|
||||
@ConditionalOnBean({ HealthEndpoint.class, HealthEndpointWebExtension.class })
|
||||
public CloudFoundryHealthEndpointWebExtension cloudFoundryHealthEndpointWebExtension(
|
||||
HealthEndpointWebExtension healthEndpointWebExtension) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.condition;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
|
@ -33,6 +34,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = ConditionsReportEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = ConditionsReportEndpoint.class)
|
||||
public class ConditionsReportEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.context;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.context.ShutdownEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -31,6 +32,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = ShutdownEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = ShutdownEndpoint.class)
|
||||
public class ShutdownEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.context.properties;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -34,6 +35,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = ConfigurationPropertiesReportEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = ConfigurationPropertiesReportEndpoint.class)
|
||||
@EnableConfigurationProperties(ConfigurationPropertiesReportEndpointProperties.class)
|
||||
public class ConfigurationPropertiesReportEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.springframework.boot.actuate.endpoint.jmx.annotation.JmxEndpointDisco
|
|||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
|
||||
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
@ -58,6 +59,7 @@ import org.springframework.util.ObjectUtils;
|
|||
@Configuration
|
||||
@AutoConfigureAfter(JmxAutoConfiguration.class)
|
||||
@EnableConfigurationProperties(JmxEndpointProperties.class)
|
||||
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true")
|
||||
public class JmxEndpointAutoConfiguration {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.env;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.env.EnvironmentEndpoint;
|
||||
import org.springframework.boot.actuate.env.EnvironmentEndpointWebExtension;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -36,6 +37,7 @@ import org.springframework.core.env.Environment;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = EnvironmentEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = EnvironmentEndpoint.class)
|
||||
@EnableConfigurationProperties(EnvironmentEndpointProperties.class)
|
||||
public class EnvironmentEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.flyway;
|
|||
import org.flywaydb.core.Flyway;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.flyway.FlywayEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -39,6 +40,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Configuration
|
||||
@ConditionalOnClass(Flyway.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = FlywayEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = FlywayEndpoint.class)
|
||||
@AutoConfigureAfter(FlywayAutoConfiguration.class)
|
||||
public class FlywayEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.health;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.health.CompositeHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.HealthAggregator;
|
||||
import org.springframework.boot.actuate.health.HealthEndpoint;
|
||||
|
@ -34,6 +35,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Configuration
|
||||
@ConditionalOnSingleCandidate(HealthIndicatorRegistry.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = HealthEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = HealthEndpoint.class)
|
||||
class HealthEndpointConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.health;
|
|||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.health.CompositeReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.HealthAggregator;
|
||||
import org.springframework.boot.actuate.health.HealthEndpoint;
|
||||
|
@ -43,6 +44,8 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(HealthIndicatorProperties.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = HealthEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = HealthEndpoint.class)
|
||||
class HealthEndpointWebExtensionConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -68,7 +71,6 @@ class HealthEndpointWebExtensionConfiguration {
|
|||
@Configuration
|
||||
@ConditionalOnWebApplication(type = Type.REACTIVE)
|
||||
@ConditionalOnSingleCandidate(ReactiveHealthIndicatorRegistry.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = HealthEndpoint.class)
|
||||
static class ReactiveWebHealthConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -89,7 +91,6 @@ class HealthEndpointWebExtensionConfiguration {
|
|||
|
||||
@Configuration
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = HealthEndpoint.class)
|
||||
static class ServletWebHealthConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.info.InfoContributor;
|
||||
import org.springframework.boot.actuate.info.InfoEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
@ -36,6 +37,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = InfoEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = InfoEndpoint.class)
|
||||
@AutoConfigureAfter(InfoContributorAutoConfiguration.class)
|
||||
public class InfoEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.integration;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.integration.IntegrationGraphEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -41,6 +42,7 @@ import org.springframework.integration.graph.IntegrationGraphServer;
|
|||
@ConditionalOnClass(IntegrationGraphServer.class)
|
||||
@ConditionalOnBean(IntegrationConfigurationBeanFactoryPostProcessor.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = IntegrationGraphEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = IntegrationGraphEndpoint.class)
|
||||
@AutoConfigureAfter(IntegrationAutoConfiguration.class)
|
||||
public class IntegrationGraphEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.jolokia;
|
|||
import org.jolokia.http.AgentServlet;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
|
@ -37,6 +38,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
@ConditionalOnClass(AgentServlet.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = JolokiaEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = JolokiaEndpoint.class)
|
||||
@EnableConfigurationProperties(JolokiaProperties.class)
|
||||
public class JolokiaEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import liquibase.integration.spring.SpringLiquibase;
|
|||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.liquibase.LiquibaseEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -42,6 +43,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Configuration
|
||||
@ConditionalOnClass(SpringLiquibase.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = LiquibaseEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = LiquibaseEndpoint.class)
|
||||
@AutoConfigureAfter(LiquibaseAutoConfiguration.class)
|
||||
public class LiquibaseEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.logging;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.logging.LoggersEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
||||
|
@ -39,6 +40,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = LoggersEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = LoggersEndpoint.class)
|
||||
public class LoggersEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.management;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.management.HeapDumpWebEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -31,6 +32,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = HeapDumpWebEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = HeapDumpWebEndpoint.class)
|
||||
public class HeapDumpWebEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.management;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.management.ThreadDumpEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -31,6 +32,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = ThreadDumpEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = ThreadDumpEndpoint.class)
|
||||
public class ThreadDumpEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.micrometer.core.annotation.Timed;
|
|||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.metrics.MetricsEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -38,6 +39,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Configuration
|
||||
@ConditionalOnClass(Timed.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = MetricsEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = MetricsEndpoint.class)
|
||||
@AutoConfigureAfter({ MetricsAutoConfiguration.class,
|
||||
CompositeMeterRegistryAutoConfiguration.class })
|
||||
public class MetricsEndpointAutoConfiguration {
|
||||
|
|
|
@ -26,6 +26,7 @@ import io.prometheus.client.CollectorRegistry;
|
|||
import io.prometheus.client.exporter.PushGateway;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
|
||||
|
@ -83,6 +84,7 @@ public class PrometheusMetricsExportAutoConfiguration {
|
|||
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = PrometheusScrapeEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = PrometheusScrapeEndpoint.class)
|
||||
public static class PrometheusScrapeEndpointConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
@ -35,6 +36,7 @@ import org.springframework.scheduling.config.ScheduledTaskHolder;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = ScheduledTasksEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = ScheduledTasksEndpoint.class)
|
||||
public class ScheduledTasksEndpointAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.session;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.session.SessionsEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -38,6 +39,7 @@ import org.springframework.session.Session;
|
|||
@Configuration
|
||||
@ConditionalOnClass(FindByIndexNameSessionRepository.class)
|
||||
@ConditionalOnEnabledEndpoint(endpoint = SessionsEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = SessionsEndpoint.class)
|
||||
@AutoConfigureAfter(SessionAutoConfiguration.class)
|
||||
public class SessionsEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.actuate.autoconfigure.trace.http;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.trace.http.HttpTraceEndpoint;
|
||||
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
@ -34,6 +35,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
*/
|
||||
@Configuration
|
||||
@ConditionalOnEnabledEndpoint(endpoint = HttpTraceEndpoint.class)
|
||||
@ConditionalOnExposedEndpoint(endpoint = HttpTraceEndpoint.class)
|
||||
@AutoConfigureAfter(HttpTraceAutoConfiguration.class)
|
||||
public class HttpTraceEndpointAutoConfiguration {
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
|
||||
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
||||
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
|
||||
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider;
|
||||
|
@ -48,6 +49,7 @@ public class MappingsEndpointAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
@ConditionalOnExposedEndpoint
|
||||
public MappingsEndpoint mappingsEndpoint(ApplicationContext applicationContext,
|
||||
ObjectProvider<MappingDescriptionProvider> descriptionProviders) {
|
||||
return new MappingsEndpoint(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -39,14 +39,24 @@ public class AuditEventsEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=auditevents")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(AuditEventsEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(AuditEventsEndpoint.class));
|
||||
.doesNotHaveBean(AuditEventsEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpoint() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.auditevents.enabled:false")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=*")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(AuditEventsEndpoint.class));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -38,12 +38,20 @@ public class BeansEndpointAutoConfigurationTests {
|
|||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=beans")
|
||||
.run((context) -> assertThat(context).hasSingleBean(BeansEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).doesNotHaveBean(BeansEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.beans.enabled:false")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=*")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(BeansEndpoint.class));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -42,19 +42,30 @@ public class CachesEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.withUserConfiguration(CacheConfiguration.class).run(
|
||||
(context) -> assertThat(context).hasSingleBean(CachesEndpoint.class));
|
||||
this.contextRunner.withUserConfiguration(CacheConfiguration.class)
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=caches")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(CachesEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWithoutCacheManagerShouldHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(CachesEndpoint.class));
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=caches")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(CachesEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withUserConfiguration(CacheConfiguration.class).run(
|
||||
(context) -> assertThat(context).doesNotHaveBean(CachesEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.caches.enabled:false")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=*")
|
||||
.withUserConfiguration(CacheConfiguration.class)
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(CachesEndpoint.class));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -36,8 +36,17 @@ public class ConditionsReportEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=conditions")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(ConditionsReportEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(ConditionsReportEndpoint.class));
|
||||
.doesNotHaveBean(ConditionsReportEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -38,10 +38,18 @@ public class ShutdownEndpointAutoConfigurationTests {
|
|||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.shutdown.enabled:true")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=shutdown")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(ShutdownEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.shutdown.enabled:true")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(ShutdownEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -47,6 +47,8 @@ public class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
|
|||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.withUserConfiguration(Config.class)
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=configprops")
|
||||
.run(validateTestProperties("******", "654321"));
|
||||
}
|
||||
|
||||
|
@ -62,9 +64,17 @@ public class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
|
|||
public void keysToSanitizeCanBeConfiguredViaTheEnvironment() {
|
||||
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues(
|
||||
"management.endpoint.configprops.keys-to-sanitize: .*pass.*, property")
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=configprops")
|
||||
.run(validateTestProperties("******", "******"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(ConfigurationPropertiesReportEndpoint.class));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> validateTestProperties(
|
||||
String dbPassword, String myTestProperty) {
|
||||
return (context) -> {
|
||||
|
|
|
@ -44,7 +44,9 @@ public class EnvironmentEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.withSystemProperties("dbPassword=123456", "apiKey=123456")
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=env")
|
||||
.withSystemProperties("dbPassword=123456", "apiKey=123456")
|
||||
.run(validateSystemProperties("******", "******"));
|
||||
}
|
||||
|
||||
|
@ -55,9 +57,17 @@ public class EnvironmentEndpointAutoConfigurationTests {
|
|||
.doesNotHaveBean(EnvironmentEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(EnvironmentEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keysToSanitizeCanBeConfiguredViaTheEnvironment() {
|
||||
this.contextRunner.withSystemProperties("dbPassword=123456", "apiKey=123456")
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=env")
|
||||
.withSystemProperties("dbPassword=123456", "apiKey=123456")
|
||||
.withPropertyValues("management.endpoint.env.keys-to-sanitize=.*pass.*")
|
||||
.run(validateSystemProperties("******", "123456"));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -42,8 +42,10 @@ public class FlywayEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(FlywayEndpoint.class));
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=flyway")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(FlywayEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,6 +55,12 @@ public class FlywayEndpointAutoConfigurationTests {
|
|||
.doesNotHaveBean(FlywayEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).doesNotHaveBean(FlywayEndpoint.class));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class FlywayConfiguration {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -42,8 +42,11 @@ public class IntegrationGraphEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(IntegrationGraphEndpoint.class));
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=integrationgraph")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(IntegrationGraphEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,6 +59,14 @@ public class IntegrationGraphEndpointAutoConfigurationTests {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(IntegrationGraphEndpoint.class);
|
||||
assertThat(context).doesNotHaveBean(IntegrationGraphServer.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenSpringIntegrationIsNotEnabledShouldNotHaveEndpointBean() {
|
||||
ApplicationContextRunner noSpringIntegrationRunner = new ApplicationContextRunner()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -58,18 +58,30 @@ public class JolokiaEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void jolokiaServletShouldBeEnabledByDefault() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=jolokia")
|
||||
.run((context) -> {
|
||||
ExposableServletEndpoint endpoint = getEndpoint(context);
|
||||
assertThat(endpoint.getRootPath()).isEqualTo("jolokia");
|
||||
Object servlet = ReflectionTestUtils
|
||||
.getField(endpoint.getEndpointServlet(), "servlet");
|
||||
assertThat(servlet).isInstanceOf(AgentServlet.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jolokiaServletWhenEndpointNotExposedShouldNotBeDiscovered() {
|
||||
this.contextRunner.run((context) -> {
|
||||
ExposableServletEndpoint endpoint = getEndpoint(context);
|
||||
assertThat(endpoint.getRootPath()).isEqualTo("jolokia");
|
||||
Object servlet = ReflectionTestUtils.getField(endpoint.getEndpointServlet(),
|
||||
"servlet");
|
||||
assertThat(servlet).isInstanceOf(AgentServlet.class);
|
||||
Collection<ExposableServletEndpoint> endpoints = context
|
||||
.getBean(ServletEndpointsSupplier.class).getEndpoints();
|
||||
assertThat(endpoints).isEmpty();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jolokiaServletWhenDisabledShouldNotBeDiscovered() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.jolokia.enabled=false")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=jolokia")
|
||||
.run((context) -> {
|
||||
Collection<ExposableServletEndpoint> endpoints = context
|
||||
.getBean(ServletEndpointsSupplier.class).getEndpoints();
|
||||
|
@ -81,6 +93,7 @@ public class JolokiaEndpointAutoConfigurationTests {
|
|||
public void jolokiaServletWhenHasCustomConfigShouldApplyInitParams() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.jolokia.config.debug=true")
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=jolokia")
|
||||
.run((context) -> {
|
||||
ExposableServletEndpoint endpoint = getEndpoint(context);
|
||||
assertThat(endpoint.getEndpointServlet()).extracting("initParameters")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -43,8 +43,11 @@ public class LiquibaseEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.withUserConfiguration(LiquibaseConfiguration.class).run(
|
||||
(context) -> assertThat(context).hasSingleBean(LiquibaseEndpoint.class));
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=liquibase")
|
||||
.withUserConfiguration(LiquibaseConfiguration.class)
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(LiquibaseEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -55,10 +58,17 @@ public class LiquibaseEndpointAutoConfigurationTests {
|
|||
.doesNotHaveBean(LiquibaseEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(LiquibaseEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disablesCloseOfDataSourceWhenEndpointIsEnabled() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(DataSourceClosingLiquibaseConfiguration.class)
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=liquibase")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(LiquibaseEndpoint.class);
|
||||
assertThat(context.getBean(DataSourceClosingSpringLiquibase.class))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -42,8 +42,10 @@ public class LoggersEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(LoggersEndpoint.class));
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=loggers")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(LoggersEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,6 +55,12 @@ public class LoggersEndpointAutoConfigurationTests {
|
|||
.doesNotHaveBean(LoggersEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).doesNotHaveBean(LoggersEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWithNoneLoggingSystemShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -37,13 +37,23 @@ public class ThreadDumpEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(ThreadDumpEndpoint.class));
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=threaddump")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(ThreadDumpEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(ThreadDumpEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=*")
|
||||
.withPropertyValues("management.endpoint.threaddump.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(ThreadDumpEndpoint.class));
|
||||
|
|
|
@ -104,15 +104,29 @@ public class PrometheusMetricsExportAutoConfigurationTests {
|
|||
.withConfiguration(
|
||||
AutoConfigurations.of(ManagementContextAutoConfiguration.class))
|
||||
.withUserConfiguration(BaseConfiguration.class)
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=prometheus")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(PrometheusScrapeEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scrapeEndpointNotAddedToManagementContextWhenNotExposed() {
|
||||
this.contextRunner
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(ManagementContextAutoConfiguration.class))
|
||||
.withUserConfiguration(BaseConfiguration.class)
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(PrometheusScrapeEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scrapeEndpointCanBeDisabled() {
|
||||
this.contextRunner
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(ManagementContextAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=prometheus")
|
||||
.withPropertyValues("management.endpoint.prometheus.enabled=false")
|
||||
.withUserConfiguration(BaseConfiguration.class)
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -40,8 +40,17 @@ public class ScheduledTasksEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void endpointIsAutoConfigured() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"management.endpoints.web.exposure.include=scheduledtasks")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(ScheduledTasksEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void endpointNotAutoConfiguredWhenNotExposed() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(ScheduledTasksEndpoint.class));
|
||||
.doesNotHaveBean(ScheduledTasksEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -42,8 +42,16 @@ public class SessionsEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=sessions")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(SessionsEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(SessionsEndpoint.class));
|
||||
(context) -> assertThat(context).doesNotHaveBean(SessionsEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
|
@ -39,8 +39,16 @@ public class HttpTraceEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(HttpTraceEndpoint.class));
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.web.exposure.include=httptrace")
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(HttpTraceEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(HttpTraceEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue