Skip to content

Commit a325b13

Browse files
committed
Polish "Auto-configure a ResourceConfig for Jersey endpoints if needed"
Closes gh-11948
1 parent bb2864a commit a325b13

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfigurationTests.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,29 @@
3131
import static org.assertj.core.api.Assertions.assertThat;
3232

3333
/**
34+
* Tests for {@link JerseyWebEndpointManagementContextConfiguration}.
35+
*
3436
* @author Michael Simons
3537
*/
3638
public class JerseyWebEndpointManagementContextConfigurationTests {
3739

3840
private final WebApplicationContextRunner runner = new WebApplicationContextRunner()
39-
.withConfiguration(AutoConfigurations.of(WebEndpointAutoConfiguration.class, JerseyWebEndpointManagementContextConfiguration.class));
41+
.withConfiguration(AutoConfigurations.of(WebEndpointAutoConfiguration.class,
42+
JerseyWebEndpointManagementContextConfiguration.class));
4043

4144
@Test
42-
public void contextShouldContainSingleResourceConfig() {
43-
this.runner
44-
.withUserConfiguration(WebEndpointsSupplierConfig.class)
45-
.run(context -> assertThat(context).hasSingleBean(ResourceConfig.class));
45+
public void resourceConfigIsAutoConfiguredWhenNeeded() {
46+
this.runner.withUserConfiguration(WebEndpointsSupplierConfig.class).run(
47+
(context) -> assertThat(context).hasSingleBean(ResourceConfig.class));
4648
}
4749

4850
@Test
49-
public void contextWhenResourceConfigExistsShouldContainSingleResourceConfig() {
50-
this.runner
51-
.withUserConfiguration(
52-
WebEndpointsSupplierConfig.class,
53-
ConfigWithResourceConfig.class)
54-
.run(context -> {
55-
assertThat(context).hasSingleBean(ResourceConfig.class);
56-
assertThat(context).hasBean("customResourceConfig");
57-
});
51+
public void existingResourceConfigIsUsedWhenAvailable() {
52+
this.runner.withUserConfiguration(WebEndpointsSupplierConfig.class,
53+
ConfigWithResourceConfig.class).run((context) -> {
54+
assertThat(context).hasSingleBean(ResourceConfig.class);
55+
assertThat(context).hasBean("customResourceConfig");
56+
});
5857
}
5958

6059
@Configuration
@@ -64,6 +63,7 @@ static class WebEndpointsSupplierConfig {
6463
public WebEndpointsSupplier webEndpointsSupplier() {
6564
return () -> Collections.emptyList();
6665
}
66+
6767
}
6868

6969
@Configuration
@@ -73,5 +73,7 @@ static class ConfigWithResourceConfig {
7373
public ResourceConfig customResourceConfig() {
7474
return new ResourceConfig();
7575
}
76+
7677
}
78+
7779
}

0 commit comments

Comments
 (0)