Skip to content

Commit 926052c

Browse files
committed
Reduce dependencies of spring-boot-actuator
1 parent 7321259 commit 926052c

File tree

65 files changed

+16356
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+16356
-81
lines changed

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ include "spring-boot-project:spring-boot-actuator"
4545
include "spring-boot-project:spring-boot-actuator-autoconfigure"
4646
include "spring-boot-project:spring-boot-actuator-autoconfigure-all"
4747
include "spring-boot-project:spring-boot-actuator-docs"
48+
include "spring-boot-project:spring-boot-actuator-integration-tests"
4849
include "spring-boot-project:spring-boot-amqp"
4950
include "spring-boot-project:spring-boot-artemis"
5051
include "spring-boot-project:spring-boot-autoconfigure"

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import io.micrometer.core.instrument.binder.tomcat.TomcatMetrics;
2121
import org.apache.catalina.Manager;
2222

23-
import org.springframework.boot.actuate.metrics.web.tomcat.TomcatMetricsBinder;
2423
import org.springframework.boot.autoconfigure.AutoConfiguration;
2524
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2625
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@@ -29,6 +28,7 @@
2928
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
3029
import org.springframework.boot.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration;
3130
import org.springframework.boot.tomcat.TomcatWebServer;
31+
import org.springframework.boot.tomcat.actuate.metrics.TomcatMetricsBinder;
3232
import org.springframework.context.annotation.Bean;
3333

3434
/**

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
2121
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
2222
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
23-
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider;
24-
import org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletsMappingDescriptionProvider;
2523
import org.springframework.boot.actuate.web.mappings.servlet.FiltersMappingDescriptionProvider;
2624
import org.springframework.boot.actuate.web.mappings.servlet.ServletsMappingDescriptionProvider;
2725
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -30,6 +28,8 @@
3028
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3129
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
3230
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
31+
import org.springframework.boot.webflux.actuate.mappings.DispatcherHandlersMappingDescriptionProvider;
32+
import org.springframework.boot.webmvc.actuate.mappings.DispatcherServletsMappingDescriptionProvider;
3333
import org.springframework.context.ApplicationContext;
3434
import org.springframework.context.annotation.Bean;
3535
import org.springframework.context.annotation.Configuration;

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
import org.junit.jupiter.api.Test;
2727

2828
import org.springframework.boot.SpringApplication;
29-
import org.springframework.boot.actuate.metrics.web.tomcat.TomcatMetricsBinder;
3029
import org.springframework.boot.autoconfigure.AutoConfigurations;
3130
import org.springframework.boot.context.event.ApplicationStartedEvent;
3231
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
3332
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
3433
import org.springframework.boot.tomcat.TomcatWebServer;
34+
import org.springframework.boot.tomcat.actuate.metrics.TomcatMetricsBinder;
3535
import org.springframework.boot.tomcat.autoconfigure.reactive.TomcatReactiveWebServerAutoConfiguration;
3636
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
3737
import org.springframework.boot.tomcat.reactive.TomcatReactiveWebServerFactory;

spring-boot-project/spring-boot-actuator-docs/src/test/java/org/springframework/boot/actuate/docs/web/mappings/MappingsEndpointReactiveDocumentationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
import org.springframework.boot.actuate.docs.AbstractEndpointDocumentationTests;
2929
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
3030
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
31-
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider;
3231
import org.springframework.boot.reactor.netty.NettyReactiveWebServerFactory;
3332
import org.springframework.boot.test.context.SpringBootTest;
3433
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3534
import org.springframework.boot.web.server.test.LocalServerPort;
35+
import org.springframework.boot.webflux.actuate.mappings.DispatcherHandlersMappingDescriptionProvider;
3636
import org.springframework.context.ConfigurableApplicationContext;
3737
import org.springframework.context.annotation.Bean;
3838
import org.springframework.context.annotation.Configuration;

spring-boot-project/spring-boot-actuator-docs/src/test/java/org/springframework/boot/actuate/docs/web/mappings/MappingsEndpointServletDocumentationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
import org.springframework.boot.actuate.docs.AbstractEndpointDocumentationTests;
2929
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
3030
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
31-
import org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletsMappingDescriptionProvider;
3231
import org.springframework.boot.actuate.web.mappings.servlet.FiltersMappingDescriptionProvider;
3332
import org.springframework.boot.actuate.web.mappings.servlet.ServletsMappingDescriptionProvider;
3433
import org.springframework.boot.test.context.SpringBootTest;
3534
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3635
import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory;
3736
import org.springframework.boot.web.server.test.LocalServerPort;
37+
import org.springframework.boot.webmvc.actuate.mappings.DispatcherServletsMappingDescriptionProvider;
3838
import org.springframework.context.ConfigurableApplicationContext;
3939
import org.springframework.context.annotation.Bean;
4040
import org.springframework.context.annotation.Configuration;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id "java-library"
3+
id "java-test-fixtures"
4+
}
5+
6+
description = "Spring Boot Actuator Integration Tests"
7+
8+
9+
dependencies {
10+
testFixturesImplementation(project(":spring-boot-project:spring-boot-actuator"))
11+
testFixturesImplementation(project(":spring-boot-project:spring-boot-autoconfigure"))
12+
testFixturesImplementation(project(":spring-boot-project:spring-boot-http-converter"))
13+
testFixturesImplementation(project(":spring-boot-project:spring-boot-jackson"))
14+
testFixturesImplementation(project(":spring-boot-project:spring-boot-jersey"))
15+
testFixturesImplementation(project(":spring-boot-project:spring-boot-reactor-netty"))
16+
testFixturesImplementation(project(":spring-boot-project:spring-boot-test"))
17+
testFixturesImplementation(project(":spring-boot-project:spring-boot-tomcat"))
18+
testFixturesImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
19+
testFixturesImplementation(project(":spring-boot-project:spring-boot-webflux"))
20+
testFixturesImplementation(project(":spring-boot-project:spring-boot-webmvc"))
21+
testFixturesImplementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
22+
testImplementation(project(":spring-boot-project:spring-boot-actuator"))
23+
testImplementation(project(":spring-boot-project:spring-boot-autoconfigure"))
24+
testImplementation(project(":spring-boot-project:spring-boot-http-converter"))
25+
testImplementation(project(":spring-boot-project:spring-boot-jackson"))
26+
testImplementation(project(":spring-boot-project:spring-boot-jersey"))
27+
testImplementation(project(":spring-boot-project:spring-boot-reactor-netty"))
28+
testImplementation(project(":spring-boot-project:spring-boot-test"))
29+
testImplementation(project(":spring-boot-project:spring-boot-tomcat"))
30+
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
31+
testImplementation(project(":spring-boot-project:spring-boot-web-server"))
32+
testImplementation(project(":spring-boot-project:spring-boot-webflux"))
33+
testImplementation(project(":spring-boot-project:spring-boot-webmvc"))
34+
testImplementation("io.micrometer:micrometer-registry-prometheus")
35+
testImplementation("io.prometheus:prometheus-metrics-exposition-formats")
36+
testImplementation("net.minidev:json-smart")
37+
testImplementation("org.springframework.security:spring-security-web")
38+
testRuntimeOnly("ch.qos.logback:logback-classic")
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"groups": [],
3+
"properties": []
4+
}

spring-boot-project/spring-boot-actuator-integration-tests/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright 2012-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.endpoint.web.annotation;
18+
19+
import java.util.Arrays;
20+
import java.util.Collections;
21+
import java.util.List;
22+
23+
import org.springframework.beans.factory.ObjectProvider;
24+
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
25+
import org.springframework.boot.actuate.endpoint.invoke.convert.ConversionServiceParameterValueMapper;
26+
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
27+
import org.springframework.boot.actuate.endpoint.web.PathMapper;
28+
import org.springframework.boot.tomcat.TomcatEmbeddedWebappClassLoader;
29+
import org.springframework.context.ApplicationContext;
30+
import org.springframework.context.annotation.Bean;
31+
import org.springframework.context.annotation.Configuration;
32+
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
33+
import org.springframework.core.convert.support.DefaultConversionService;
34+
35+
import static org.mockito.Mockito.mock;
36+
37+
/**
38+
* Base configuration shared by tests.
39+
*
40+
* @author Andy Wilkinson
41+
*/
42+
@Configuration(proxyBeanMethods = false)
43+
class BaseConfiguration {
44+
45+
@Bean
46+
AbstractWebEndpointIntegrationTests.EndpointDelegate endpointDelegate() {
47+
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
48+
if (classLoader instanceof TomcatEmbeddedWebappClassLoader) {
49+
Thread.currentThread().setContextClassLoader(classLoader.getParent());
50+
}
51+
try {
52+
return mock(AbstractWebEndpointIntegrationTests.EndpointDelegate.class);
53+
}
54+
finally {
55+
Thread.currentThread().setContextClassLoader(classLoader);
56+
}
57+
}
58+
59+
@Bean
60+
EndpointMediaTypes endpointMediaTypes() {
61+
List<String> mediaTypes = Arrays.asList("application/vnd.test+json", "application/json");
62+
return new EndpointMediaTypes(mediaTypes, mediaTypes);
63+
}
64+
65+
@Bean
66+
WebEndpointDiscoverer webEndpointDiscoverer(EndpointMediaTypes endpointMediaTypes,
67+
ApplicationContext applicationContext, ObjectProvider<PathMapper> pathMappers) {
68+
ParameterValueMapper parameterMapper = new ConversionServiceParameterValueMapper(
69+
DefaultConversionService.getSharedInstance());
70+
return new WebEndpointDiscoverer(applicationContext, parameterMapper, endpointMediaTypes,
71+
pathMappers.orderedStream().toList(), Collections.emptyList(), Collections.emptyList(),
72+
Collections.emptyList(), Collections.emptyList());
73+
}
74+
75+
@Bean
76+
static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
77+
return new PropertySourcesPlaceholderConfigurer();
78+
}
79+
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright 2012-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.health;
18+
19+
import java.util.function.Predicate;
20+
21+
import org.springframework.boot.actuate.endpoint.SecurityContext;
22+
23+
/**
24+
* Test implementation of {@link HealthEndpointGroups}.
25+
*
26+
* @author Phillip Webb
27+
*/
28+
class TestHealthEndpointGroup implements HealthEndpointGroup {
29+
30+
private final StatusAggregator statusAggregator = new SimpleStatusAggregator();
31+
32+
private final HttpCodeStatusMapper httpCodeStatusMapper = new SimpleHttpCodeStatusMapper();
33+
34+
private final Predicate<String> memberPredicate;
35+
36+
private Boolean showComponents;
37+
38+
private boolean showDetails = true;
39+
40+
private AdditionalHealthEndpointPath additionalPath;
41+
42+
TestHealthEndpointGroup() {
43+
this((name) -> true);
44+
}
45+
46+
TestHealthEndpointGroup(Predicate<String> memberPredicate) {
47+
this.memberPredicate = memberPredicate;
48+
}
49+
50+
@Override
51+
public boolean isMember(String name) {
52+
return this.memberPredicate.test(name);
53+
}
54+
55+
@Override
56+
public boolean showComponents(SecurityContext securityContext) {
57+
return (this.showComponents != null) ? this.showComponents : this.showDetails;
58+
}
59+
60+
void setShowComponents(Boolean showComponents) {
61+
this.showComponents = showComponents;
62+
}
63+
64+
@Override
65+
public boolean showDetails(SecurityContext securityContext) {
66+
return this.showDetails;
67+
}
68+
69+
void setShowDetails(boolean includeDetails) {
70+
this.showDetails = includeDetails;
71+
}
72+
73+
@Override
74+
public StatusAggregator getStatusAggregator() {
75+
return this.statusAggregator;
76+
}
77+
78+
@Override
79+
public HttpCodeStatusMapper getHttpCodeStatusMapper() {
80+
return this.httpCodeStatusMapper;
81+
}
82+
83+
@Override
84+
public AdditionalHealthEndpointPath getAdditionalPath() {
85+
return this.additionalPath;
86+
}
87+
88+
void setAdditionalPath(AdditionalHealthEndpointPath additionalPath) {
89+
this.additionalPath = additionalPath;
90+
}
91+
92+
}

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/web/mappings/MappingsEndpointTests.java renamed to spring-boot-project/spring-boot-actuator-integration-tests/src/test/java/org/springframework/boot/actuate/web/mappings/MappingsEndpointIntegrationTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030

3131
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ApplicationMappingsDescriptor;
3232
import org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappingsDescriptor;
33-
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlerMappingDescription;
34-
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider;
35-
import org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletMappingDescription;
36-
import org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletsMappingDescriptionProvider;
3733
import org.springframework.boot.actuate.web.mappings.servlet.FilterRegistrationMappingDescription;
3834
import org.springframework.boot.actuate.web.mappings.servlet.FiltersMappingDescriptionProvider;
3935
import org.springframework.boot.actuate.web.mappings.servlet.ServletRegistrationMappingDescription;
@@ -42,6 +38,10 @@
4238
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
4339
import org.springframework.boot.web.context.servlet.AnnotationConfigServletWebApplicationContext;
4440
import org.springframework.boot.web.servlet.ServletRegistrationBean;
41+
import org.springframework.boot.webflux.actuate.mappings.DispatcherHandlerMappingDescription;
42+
import org.springframework.boot.webflux.actuate.mappings.DispatcherHandlersMappingDescriptionProvider;
43+
import org.springframework.boot.webmvc.actuate.mappings.DispatcherServletMappingDescription;
44+
import org.springframework.boot.webmvc.actuate.mappings.DispatcherServletsMappingDescriptionProvider;
4545
import org.springframework.context.ApplicationContext;
4646
import org.springframework.context.annotation.Bean;
4747
import org.springframework.context.annotation.Configuration;
@@ -69,13 +69,13 @@
6969
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
7070

7171
/**
72-
* Tests for {@link MappingsEndpoint}.
72+
* Integration tests for {@link MappingsEndpoint}.
7373
*
7474
* @author Andy Wilkinson
7575
* @author Stephane Nicoll
7676
* @author Xiong Tang
7777
*/
78-
class MappingsEndpointTests {
78+
class MappingsEndpointIntegrationTests {
7979

8080
@Test
8181
void servletWebMappings() {

0 commit comments

Comments
 (0)