|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -34,57 +34,52 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
* Tests for {@link WebEndpointAutoConfiguration}.
|
|
|
|
* Tests for {@link WebEndpointAutoConfiguration}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
|
|
|
|
* @author Yunkun Huang
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class WebEndpointAutoConfigurationTests {
|
|
|
|
public class WebEndpointAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
|
|
|
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class,
|
|
|
|
|
|
|
|
WebEndpointAutoConfiguration.class));
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void webApplicationConfiguresEndpointMediaTypes() {
|
|
|
|
public void webApplicationConfiguresEndpointMediaTypes() {
|
|
|
|
new WebApplicationContextRunner().withConfiguration(AutoConfigurations
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
.of(EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class))
|
|
|
|
EndpointMediaTypes endpointMediaTypes = context
|
|
|
|
.run((context) -> {
|
|
|
|
.getBean(EndpointMediaTypes.class);
|
|
|
|
EndpointMediaTypes endpointMediaTypes = context
|
|
|
|
assertThat(endpointMediaTypes.getConsumed())
|
|
|
|
.getBean(EndpointMediaTypes.class);
|
|
|
|
.containsExactly(ActuatorMediaType.V2_JSON, "application/json");
|
|
|
|
assertThat(endpointMediaTypes.getConsumed()).containsExactly(
|
|
|
|
});
|
|
|
|
ActuatorMediaType.V2_JSON, "application/json");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void webApplicationConfiguresPathMapper() {
|
|
|
|
public void webApplicationConfiguresPathMapper() {
|
|
|
|
new WebApplicationContextRunner()
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("management.endpoints.web.path-mapping.health=healthcheck")
|
|
|
|
.withPropertyValues(
|
|
|
|
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class,
|
|
|
|
"management.endpoints.web.path-mapping.health=healthcheck")
|
|
|
|
WebEndpointAutoConfiguration.class))
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
assertThat(context).hasSingleBean(PathMapper.class);
|
|
|
|
assertThat(context).hasSingleBean(PathMapper.class);
|
|
|
|
String pathMapping = context.getBean(PathMapper.class).getRootPath("health");
|
|
|
|
String pathMapping = context.getBean(PathMapper.class)
|
|
|
|
|
|
|
|
.getRootPath("health");
|
|
|
|
assertThat(pathMapping).isEqualTo("healthcheck");
|
|
|
|
assertThat(pathMapping).isEqualTo("healthcheck");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void webApplicationConfiguresEndpointDiscoverer() {
|
|
|
|
public void webApplicationConfiguresEndpointDiscoverer() {
|
|
|
|
new WebApplicationContextRunner()
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class,
|
|
|
|
assertThat(context).hasSingleBean(ControllerEndpointDiscoverer.class);
|
|
|
|
WebEndpointAutoConfiguration.class))
|
|
|
|
assertThat(context).hasSingleBean(WebEndpointDiscoverer.class);
|
|
|
|
.run((context) -> {
|
|
|
|
});
|
|
|
|
assertThat(context).hasSingleBean(ControllerEndpointDiscoverer.class);
|
|
|
|
|
|
|
|
assertThat(context).hasSingleBean(WebEndpointDiscoverer.class);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void webApplicationConfiguresExposeExcludePropertyEndpointFilter() {
|
|
|
|
public void webApplicationConfiguresExposeExcludePropertyEndpointFilter() {
|
|
|
|
new WebApplicationContextRunner()
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class,
|
|
|
|
assertThat(context).getBeans(ExposeExcludePropertyEndpointFilter.class)
|
|
|
|
WebEndpointAutoConfiguration.class))
|
|
|
|
.containsKeys("webIncludeExcludePropertyEndpointFilter",
|
|
|
|
.run((context) -> {
|
|
|
|
"controllerIncludeExcludePropertyEndpointFilter");
|
|
|
|
assertThat(context).getBeans(ExposeExcludePropertyEndpointFilter.class).containsKeys(
|
|
|
|
});
|
|
|
|
"webIncludeExcludePropertyEndpointFilter",
|
|
|
|
|
|
|
|
"controllerIncludeExcludePropertyEndpointFilter"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|