Skip to content

Commit ca54221

Browse files
committed
Split WebEndpointTest infrastructure configuration
1 parent adf1e32 commit ca54221

File tree

24 files changed

+492
-185
lines changed

24 files changed

+492
-185
lines changed

settings.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ 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"
4848
include "spring-boot-project:spring-boot-actuator-integration-tests"
49-
include "spring-boot-project:spring-boot-actuator-test-support"
5049
include "spring-boot-project:spring-boot-amqp"
5150
include "spring-boot-project:spring-boot-artemis"
5251
include "spring-boot-project:spring-boot-autoconfigure"

spring-boot-project/spring-boot-actuator-integration-tests/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ description = "Spring Boot Actuator Integration Tests"
77

88
dependencies {
99
testImplementation(project(":spring-boot-project:spring-boot-actuator"))
10-
testImplementation(project(":spring-boot-project:spring-boot-actuator-test-support"))
1110
testImplementation(project(":spring-boot-project:spring-boot-autoconfigure"))
1211
testImplementation(project(":spring-boot-project:spring-boot-http-converter"))
1312
testImplementation(project(":spring-boot-project:spring-boot-jackson"))
@@ -20,6 +19,9 @@ dependencies {
2019
testImplementation(project(":spring-boot-project:spring-boot-web-server"))
2120
testImplementation(project(":spring-boot-project:spring-boot-webflux"))
2221
testImplementation(project(":spring-boot-project:spring-boot-webmvc"))
22+
testImplementation(testFixtures(project(":spring-boot-project:spring-boot-jersey")))
23+
testImplementation(testFixtures(project(":spring-boot-project:spring-boot-webflux")))
24+
testImplementation(testFixtures(project(":spring-boot-project:spring-boot-webmvc")))
2325
testImplementation("io.micrometer:micrometer-registry-prometheus")
2426
testImplementation("io.prometheus:prometheus-metrics-exposition-formats")
2527
testImplementation("net.minidev:json-smart")

spring-boot-project/spring-boot-actuator-test-support/build.gradle

Lines changed: 0 additions & 37 deletions
This file was deleted.

spring-boot-project/spring-boot-actuator/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id "java-library"
3+
id "java-test-fixtures"
34
id "org.springframework.boot.configuration-properties"
45
id "org.springframework.boot.optional-dependencies"
56
id "org.springframework.boot.deployed"
@@ -45,6 +46,10 @@ dependencies {
4546
optional("org.springframework.security:spring-security-core")
4647
optional("org.springframework.security:spring-security-web")
4748

49+
testFixturesApi("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
50+
testFixturesImplementation("org.junit.jupiter:junit-jupiter-api")
51+
testFixturesImplementation("org.springframework:spring-test")
52+
4853
testImplementation(project(":spring-boot-project:spring-boot-autoconfigure"))
4954
testImplementation(project(":spring-boot-project:spring-boot-jackson"))
5055
testImplementation(project(":spring-boot-project:spring-boot-jsonb"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.test;
18+
19+
import java.util.List;
20+
21+
import org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest.Infrastructure;
22+
23+
/**
24+
* Strategy interface to provide the web endpoint configuration for a target
25+
* {@linkplain Infrastructure infrastructure}.
26+
*
27+
* @author Stephane Nicoll
28+
* @since 4.0.0
29+
*/
30+
public interface WebEndpointInfrastructureProvider {
31+
32+
/**
33+
* Specify if the given {@link Infrastructure} is supported.
34+
* @param infrastructure the infrastructure to target
35+
* @return {@code true} if this instance can provide the configuration
36+
*/
37+
boolean supports(Infrastructure infrastructure);
38+
39+
/**
40+
* Return the configuration to use for the given {@code infrastructure}.
41+
* @param infrastructure the infrastructure to target
42+
* @return the configuration for that infrastructure
43+
*/
44+
List<Class<?>> getInfrastructureConfiguration(Infrastructure infrastructure);
45+
46+
}

spring-boot-project/spring-boot-actuator-test-support/src/main/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointTest.java renamed to spring-boot-project/spring-boot-actuator/src/testFixtures/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,27 @@ enum Infrastructure {
5353
/**
5454
* Actuator running on the Jersey-based infrastructure.
5555
*/
56-
JERSEY("Jersey", WebEndpointTestInvocationContextProvider::createJerseyContext),
56+
JERSEY("Jersey"),
5757

5858
/**
5959
* Actuator running on the WebMVC-based infrastructure.
6060
*/
61-
MVC("WebMvc", WebEndpointTestInvocationContextProvider::createWebMvcContext),
61+
MVC("WebMvc"),
6262

6363
/**
6464
* Actuator running on the WebFlux-based infrastructure.
6565
*/
66-
WEBFLUX("WebFlux", WebEndpointTestInvocationContextProvider::createWebFluxContext);
66+
WEBFLUX("WebFlux");
6767

6868
private final String name;
6969

70-
private final Function<List<Class<?>>, ConfigurableApplicationContext> contextFactory;
71-
72-
Infrastructure(String name, Function<List<Class<?>>, ConfigurableApplicationContext> contextFactory) {
70+
Infrastructure(String name) {
7371
this.name = name;
74-
this.contextFactory = contextFactory;
7572
}
7673

77-
WebEndpointsInvocationContext createInvocationContext() {
78-
return new WebEndpointsInvocationContext(this.name, this.contextFactory);
74+
WebEndpointsInvocationContext createInvocationContext(
75+
Function<List<Class<?>>, ConfigurableApplicationContext> contextFactory) {
76+
return new WebEndpointsInvocationContext(this.name, contextFactory);
7977
}
8078

8179
}

0 commit comments

Comments
 (0)