From d8527a97086b5e78e6096558eb4641b03ff62170 Mon Sep 17 00:00:00 2001 From: Yunkun Huang Date: Wed, 24 Jan 2018 19:34:22 +0800 Subject: [PATCH] Add tests for WebEndpointAutoConfiguration Closes gh-11754 See gh-11684 --- .../WebEndpointAutoConfigurationTests.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java index 4488a8a6a1..c6365185ac 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java @@ -19,8 +19,12 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web; import org.junit.Test; 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.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.test.context.runner.WebApplicationContextRunner; @@ -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" + ); + }); + } + }