Commit d8527a97 authored by Yunkun Huang's avatar Yunkun Huang Committed by Phillip Webb

Add tests for WebEndpointAutoConfiguration

Closes gh-11754
See gh-11684
parent 093ca0a6
...@@ -19,8 +19,12 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web; ...@@ -19,8 +19,12 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.ExposeExcludePropertyEndpointFilter;
import org.springframework.boot.actuate.endpoint.http.ActuatorMediaType; import org.springframework.boot.actuate.endpoint.http.ActuatorMediaType;
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes; import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
import org.springframework.boot.actuate.endpoint.web.PathMapper;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer;
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
...@@ -45,4 +49,42 @@ public class WebEndpointAutoConfigurationTests { ...@@ -45,4 +49,42 @@ public class WebEndpointAutoConfigurationTests {
}); });
} }
@Test
public void webApplicationConfiguresPathMapper() {
new WebApplicationContextRunner()
.withPropertyValues("management.endpoints.web.path-mapping.health=healthcheck")
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class,
WebEndpointAutoConfiguration.class))
.run((context) -> {
assertThat(context).hasSingleBean(PathMapper.class);
String pathMapping = context.getBean(PathMapper.class).getRootPath("health");
assertThat(pathMapping).isEqualTo("healthcheck");
});
}
@Test
public void webApplicationConfiguresEndpointDiscoverer() {
new WebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class,
WebEndpointAutoConfiguration.class))
.run((context) -> {
assertThat(context).hasSingleBean(ControllerEndpointDiscoverer.class);
assertThat(context).hasSingleBean(WebEndpointDiscoverer.class);
});
}
@Test
public void webApplicationConfiguresExposeExcludePropertyEndpointFilter() {
new WebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class,
WebEndpointAutoConfiguration.class))
.run((context) -> {
assertThat(context).getBeans(ExposeExcludePropertyEndpointFilter.class).containsKeys(
"webIncludeExcludePropertyEndpointFilter",
"controllerIncludeExcludePropertyEndpointFilter"
);
});
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment