Skip to content

Commit edf3cb1

Browse files
committed
Position endpoint documentation tests alongside endpoint's auto-config
Closes gh-44639
1 parent 5ec0997 commit edf3cb1

File tree

29 files changed

+85
-109
lines changed

29 files changed

+85
-109
lines changed

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ dependencies {
192192
tasks.named("test") {
193193
jvmArgs += "--add-opens=java.base/java.net=ALL-UNNAMED"
194194
filter {
195-
excludeTestsMatching("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*")
195+
excludeTestsMatching("*DocumentationTests")
196196
}
197197
}
198198

@@ -201,7 +201,7 @@ def documentationTest = tasks.register("documentationTest", Test) {
201201
classpath = testing.suites.test.sources.runtimeClasspath
202202
jvmArgs += "--add-opens=java.base/java.net=ALL-UNNAMED"
203203
filter {
204-
includeTestsMatching("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*")
204+
includeTestsMatching("*DocumentationTests")
205205
}
206206
outputs.dir(layout.buildDirectory.dir("generated-snippets"))
207207
develocity {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.audit;
1818

1919
import java.time.OffsetDateTime;
2020
import java.time.format.DateTimeFormatter;
@@ -26,10 +26,10 @@
2626
import org.springframework.boot.actuate.audit.AuditEvent;
2727
import org.springframework.boot.actuate.audit.AuditEventRepository;
2828
import org.springframework.boot.actuate.audit.AuditEventsEndpoint;
29+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
2930
import org.springframework.boot.test.mock.mockito.MockBean;
3031
import org.springframework.context.annotation.Bean;
3132
import org.springframework.context.annotation.Configuration;
32-
import org.springframework.context.annotation.Import;
3333

3434
import static org.mockito.ArgumentMatchers.any;
3535
import static org.mockito.BDDMockito.given;
@@ -90,7 +90,6 @@ void filteredAuditEvents() throws Exception {
9090
}
9191

9292
@Configuration(proxyBeanMethods = false)
93-
@Import(BaseDocumentationConfiguration.class)
9493
static class TestConfiguration {
9594

9695
@Bean
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.beans;
1818

1919
import java.util.Collection;
2020
import java.util.List;
@@ -23,11 +23,11 @@
2323

2424
import org.junit.jupiter.api.Test;
2525

26+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
2627
import org.springframework.boot.actuate.beans.BeansEndpoint;
2728
import org.springframework.context.ConfigurableApplicationContext;
2829
import org.springframework.context.annotation.Bean;
2930
import org.springframework.context.annotation.Configuration;
30-
import org.springframework.context.annotation.Import;
3131
import org.springframework.restdocs.payload.FieldDescriptor;
3232
import org.springframework.restdocs.payload.JsonFieldType;
3333
import org.springframework.restdocs.payload.ResponseFieldsSnippet;
@@ -74,7 +74,6 @@ private boolean isIndependentBean(Entry<String, Map<String, Object>> bean) {
7474
}
7575

7676
@Configuration(proxyBeanMethods = false)
77-
@Import(BaseDocumentationConfiguration.class)
7877
static class TestConfiguration {
7978

8079
@Bean
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.cache;
1818

1919
import java.util.Collections;
2020
import java.util.HashMap;
@@ -23,13 +23,13 @@
2323

2424
import org.junit.jupiter.api.Test;
2525

26+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
2627
import org.springframework.boot.actuate.cache.CachesEndpoint;
2728
import org.springframework.boot.actuate.cache.CachesEndpointWebExtension;
2829
import org.springframework.cache.CacheManager;
2930
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
3031
import org.springframework.context.annotation.Bean;
3132
import org.springframework.context.annotation.Configuration;
32-
import org.springframework.context.annotation.Import;
3333
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
3434
import org.springframework.restdocs.payload.FieldDescriptor;
3535
import org.springframework.restdocs.request.ParameterDescriptor;
@@ -93,7 +93,6 @@ void evictNamedCache() throws Exception {
9393
}
9494

9595
@Configuration(proxyBeanMethods = false)
96-
@Import(BaseDocumentationConfiguration.class)
9796
static class TestConfiguration {
9897

9998
@Bean
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,19 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.condition;
1818

1919
import java.util.List;
2020

2121
import org.junit.jupiter.api.Test;
2222

23-
import org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint;
23+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
2424
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
2525
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
2626
import org.springframework.context.ConfigurableApplicationContext;
2727
import org.springframework.context.annotation.Bean;
2828
import org.springframework.context.annotation.Configuration;
29-
import org.springframework.context.annotation.Import;
3029
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
3130
import org.springframework.restdocs.payload.FieldDescriptor;
3231
import org.springframework.restdocs.payload.JsonFieldType;
@@ -76,7 +75,6 @@ void conditions() throws Exception {
7675
}
7776

7877
@Configuration(proxyBeanMethods = false)
79-
@Import(BaseDocumentationConfiguration.class)
8078
static class TestConfiguration {
8179

8280
@Bean
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,15 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.context;
1818

1919
import org.junit.jupiter.api.Test;
2020

21+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
2122
import org.springframework.boot.actuate.context.ShutdownEndpoint;
2223
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
2324
import org.springframework.context.annotation.Bean;
2425
import org.springframework.context.annotation.Configuration;
25-
import org.springframework.context.annotation.Import;
2626
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
2727

2828
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
@@ -46,7 +46,6 @@ void shutdown() throws Exception {
4646
}
4747

4848
@Configuration(proxyBeanMethods = false)
49-
@Import(BaseDocumentationConfiguration.class)
5049
static class TestConfiguration {
5150

5251
@Bean
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,17 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.context.properties;
1818

1919
import java.util.Collections;
2020

2121
import org.junit.jupiter.api.Test;
2222

23+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
2324
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint;
2425
import org.springframework.boot.actuate.endpoint.Show;
2526
import org.springframework.context.annotation.Bean;
2627
import org.springframework.context.annotation.Configuration;
27-
import org.springframework.context.annotation.Import;
2828
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
2929

3030
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
@@ -80,7 +80,6 @@ void configPropsFilterByPrefix() throws Exception {
8080
}
8181

8282
@Configuration(proxyBeanMethods = false)
83-
@Import(BaseDocumentationConfiguration.class)
8483
static class TestConfiguration {
8584

8685
@Bean

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
3232
import org.springframework.boot.actuate.autoconfigure.endpoint.jackson.JacksonEndpointAutoConfiguration;
3333
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
34+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.AbstractEndpointDocumentationTests.BaseDocumentationConfiguration;
3435
import org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive.WebFluxEndpointManagementContextConfiguration;
3536
import org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.WebMvcEndpointManagementContextConfiguration;
3637
import org.springframework.boot.actuate.endpoint.jackson.EndpointObjectMapper;
@@ -44,6 +45,7 @@
4445
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
4546
import org.springframework.context.annotation.Bean;
4647
import org.springframework.context.annotation.Configuration;
48+
import org.springframework.context.annotation.Import;
4749
import org.springframework.restdocs.operation.preprocess.ContentModifyingOperationPreprocessor;
4850
import org.springframework.restdocs.operation.preprocess.OperationPreprocessor;
4951
import org.springframework.restdocs.payload.FieldDescriptor;
@@ -60,6 +62,7 @@
6062
* @author Andy Wilkinson
6163
*/
6264
@TestPropertySource(properties = { "management.endpoints.web.exposure.include=*" })
65+
@Import(BaseDocumentationConfiguration.class)
6366
public abstract class AbstractEndpointDocumentationTests {
6467

6568
protected static String describeEnumValues(Class<? extends Enum<?>> enumType) {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.env;
1818

1919
import java.io.IOException;
2020
import java.util.Collections;
@@ -28,11 +28,11 @@
2828
import com.fasterxml.jackson.databind.SerializationFeature;
2929
import org.junit.jupiter.api.Test;
3030

31+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
3132
import org.springframework.boot.actuate.endpoint.Show;
3233
import org.springframework.boot.actuate.env.EnvironmentEndpoint;
3334
import org.springframework.context.annotation.Bean;
3435
import org.springframework.context.annotation.Configuration;
35-
import org.springframework.context.annotation.Import;
3636
import org.springframework.core.env.AbstractEnvironment;
3737
import org.springframework.core.env.ConfigurableEnvironment;
3838
import org.springframework.core.env.EnumerablePropertySource;
@@ -145,7 +145,6 @@ private boolean retainKey(String key) {
145145
}
146146

147147
@Configuration(proxyBeanMethods = false)
148-
@Import(BaseDocumentationConfiguration.class)
149148
static class TestConfiguration {
150149

151150
@Bean
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.flyway;
1818

1919
import java.util.List;
2020

@@ -23,14 +23,14 @@
2323
import org.flywaydb.core.api.MigrationState;
2424
import org.junit.jupiter.api.Test;
2525

26+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
2627
import org.springframework.boot.actuate.flyway.FlywayEndpoint;
2728
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
2829
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
2930
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
3031
import org.springframework.context.ApplicationContext;
3132
import org.springframework.context.annotation.Bean;
3233
import org.springframework.context.annotation.Configuration;
33-
import org.springframework.context.annotation.Import;
3434
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
3535
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
3636
import org.springframework.restdocs.payload.FieldDescriptor;
@@ -85,7 +85,6 @@ private List<FieldDescriptor> migrationFieldDescriptors() {
8585
}
8686

8787
@Configuration(proxyBeanMethods = false)
88-
@Import(BaseDocumentationConfiguration.class)
8988
@ImportAutoConfiguration(FlywayAutoConfiguration.class)
9089
static class TestConfiguration {
9190

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
17+
package org.springframework.boot.actuate.autoconfigure.health;
1818

1919
import java.io.File;
2020
import java.util.Collections;
@@ -26,6 +26,7 @@
2626

2727
import org.junit.jupiter.api.Test;
2828

29+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.MockMvcEndpointDocumentationTests;
2930
import org.springframework.boot.actuate.endpoint.SecurityContext;
3031
import org.springframework.boot.actuate.health.AdditionalHealthEndpointPath;
3132
import org.springframework.boot.actuate.health.CompositeHealthContributor;
@@ -47,7 +48,6 @@
4748
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
4849
import org.springframework.context.annotation.Bean;
4950
import org.springframework.context.annotation.Configuration;
50-
import org.springframework.context.annotation.Import;
5151
import org.springframework.http.MediaType;
5252
import org.springframework.restdocs.payload.FieldDescriptor;
5353
import org.springframework.util.unit.DataSize;
@@ -105,7 +105,6 @@ void healthComponentInstance() throws Exception {
105105
}
106106

107107
@Configuration(proxyBeanMethods = false)
108-
@Import(BaseDocumentationConfiguration.class)
109108
@ImportAutoConfiguration(DataSourceAutoConfiguration.class)
110109
static class TestConfiguration {
111110

0 commit comments

Comments
 (0)