mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:13:21 +08:00
Use consistent MvcEndpoint class names
Rename HAL and docs MVC endpoints so that classnames consistently end with MvcEndpoint. Also rename integration tests so that they are grouped together in the IDE.
This commit is contained in:
parent
da6b041199
commit
b1b3fc6639
@ -31,9 +31,9 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ActuatorDocsEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ActuatorHalBrowserEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ActuatorHalJsonEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.DocsMvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HalJsonMvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HypermediaDisabled;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ManagementServletContext;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
||||
@ -103,29 +103,29 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
|
||||
|
||||
@ConditionalOnProperty(prefix = "endpoints.actuator", name = "enabled", matchIfMissing = true)
|
||||
@Bean
|
||||
public ActuatorHalJsonEndpoint actuatorMvcEndpoint(
|
||||
public HalJsonMvcEndpoint halJsonMvcEndpoint(
|
||||
ManagementServletContext managementServletContext,
|
||||
ResourceProperties resources, ResourceLoader resourceLoader) {
|
||||
if (ActuatorHalBrowserEndpoint.getHalBrowserLocation(resourceLoader) != null) {
|
||||
return new ActuatorHalBrowserEndpoint(managementServletContext);
|
||||
if (HalBrowserMvcEndpoint.getHalBrowserLocation(resourceLoader) != null) {
|
||||
return new HalBrowserMvcEndpoint(managementServletContext);
|
||||
}
|
||||
return new ActuatorHalJsonEndpoint(managementServletContext);
|
||||
return new HalJsonMvcEndpoint(managementServletContext);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "endpoints.docs", name = "enabled", matchIfMissing = true)
|
||||
@ConditionalOnResource(resources = "classpath:/META-INF/resources/spring-boot-actuator/docs/index.html")
|
||||
public ActuatorDocsEndpoint actuatorDocsEndpoint(
|
||||
public DocsMvcEndpoint docsMvcEndpoint(
|
||||
ManagementServletContext managementServletContext) {
|
||||
return new ActuatorDocsEndpoint(managementServletContext);
|
||||
return new DocsMvcEndpoint(managementServletContext);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(ActuatorDocsEndpoint.class)
|
||||
@ConditionalOnBean(DocsMvcEndpoint.class)
|
||||
@ConditionalOnMissingBean(CurieProvider.class)
|
||||
@ConditionalOnProperty(prefix = "endpoints.docs.curies", name = "enabled", matchIfMissing = false)
|
||||
public DefaultCurieProvider curieProvider(ServerProperties server,
|
||||
ManagementServerProperties management, ActuatorDocsEndpoint endpoint) {
|
||||
ManagementServerProperties management, DocsMvcEndpoint endpoint) {
|
||||
String path = management.getContextPath() + endpoint.getPath()
|
||||
+ "/#spring_boot_actuator__{rel}";
|
||||
if (server.getPort() == management.getPort() && management.getPort() != null
|
||||
@ -146,7 +146,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
|
||||
private MvcEndpoints endpoints;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ActuatorHalJsonEndpoint actuatorEndpoint;
|
||||
private HalJsonMvcEndpoint halJsonMvcEndpoint;
|
||||
|
||||
@Autowired
|
||||
private ManagementServerProperties management;
|
||||
@ -191,13 +191,13 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
|
||||
private void beforeBodyWrite(String path, ResourceSupport body) {
|
||||
if (isActuatorEndpointPath(path)) {
|
||||
this.linksEnhancer.addEndpointLinks(body,
|
||||
this.actuatorEndpoint.getPath());
|
||||
this.halJsonMvcEndpoint.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isActuatorEndpointPath(String path) {
|
||||
return this.actuatorEndpoint != null && (this.management.getContextPath()
|
||||
+ this.actuatorEndpoint.getPath()).equals(path);
|
||||
return this.halJsonMvcEndpoint != null && (this.management.getContextPath()
|
||||
+ this.halJsonMvcEndpoint.getPath()).equals(path);
|
||||
}
|
||||
|
||||
}
|
||||
@ -222,7 +222,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
|
||||
public boolean supports(MethodParameter returnType,
|
||||
Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
Class<?> controllerType = returnType.getDeclaringClass();
|
||||
return !ActuatorHalJsonEndpoint.class.isAssignableFrom(controllerType);
|
||||
return !HalJsonMvcEndpoint.class.isAssignableFrom(controllerType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("endpoints.docs")
|
||||
public class ActuatorDocsEndpoint extends WebMvcConfigurerAdapter implements MvcEndpoint {
|
||||
public class DocsMvcEndpoint extends WebMvcConfigurerAdapter implements MvcEndpoint {
|
||||
|
||||
private static final String DOCS_LOCATION = "classpath:/META-INF/resources/spring-boot-actuator/docs/";
|
||||
|
||||
@ -46,7 +46,7 @@ public class ActuatorDocsEndpoint extends WebMvcConfigurerAdapter implements Mvc
|
||||
return this.curies;
|
||||
}
|
||||
|
||||
public ActuatorDocsEndpoint(ManagementServletContext managementServletContext) {
|
||||
public DocsMvcEndpoint(ManagementServletContext managementServletContext) {
|
||||
this.managementServletContext = managementServletContext;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import org.springframework.web.servlet.resource.TransformedResource;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public class ActuatorHalBrowserEndpoint extends ActuatorHalJsonEndpoint
|
||||
public class HalBrowserMvcEndpoint extends HalJsonMvcEndpoint
|
||||
implements ResourceLoaderAware {
|
||||
|
||||
private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||
@ -54,7 +54,7 @@ public class ActuatorHalBrowserEndpoint extends ActuatorHalJsonEndpoint
|
||||
|
||||
private HalBrowserLocation location;
|
||||
|
||||
public ActuatorHalBrowserEndpoint(ManagementServletContext managementServletContext) {
|
||||
public HalBrowserMvcEndpoint(ManagementServletContext managementServletContext) {
|
||||
super(managementServletContext);
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ public class ActuatorHalBrowserEndpoint extends ActuatorHalJsonEndpoint
|
||||
ResourceTransformerChain transformerChain) throws IOException {
|
||||
resource = transformerChain.transform(request, resource);
|
||||
if (resource.getFilename().equalsIgnoreCase(
|
||||
ActuatorHalBrowserEndpoint.this.location.getHtmlFile())) {
|
||||
HalBrowserMvcEndpoint.this.location.getHtmlFile())) {
|
||||
return replaceInitialLink(resource);
|
||||
}
|
||||
return resource;
|
@ -37,7 +37,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("endpoints.actuator")
|
||||
public class ActuatorHalJsonEndpoint extends WebMvcConfigurerAdapter
|
||||
public class HalJsonMvcEndpoint extends WebMvcConfigurerAdapter
|
||||
implements MvcEndpoint {
|
||||
|
||||
/**
|
||||
@ -59,7 +59,7 @@ public class ActuatorHalJsonEndpoint extends WebMvcConfigurerAdapter
|
||||
|
||||
private final ManagementServletContext managementServletContext;
|
||||
|
||||
public ActuatorHalJsonEndpoint(ManagementServletContext managementServletContext) {
|
||||
public HalJsonMvcEndpoint(ManagementServletContext managementServletContext) {
|
||||
this.managementServletContext = managementServletContext;
|
||||
this.path = getDefaultPath(managementServletContext);
|
||||
}
|
@ -14,15 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure;
|
||||
package org.springframework.boot.actuate.endpoint.mvc;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.BrowserPathHypermediaIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ActuatorHalBrowserEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpointBrowserPathIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -41,7 +41,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ActuatorHalBrowserEndpoint}'s support for producing
|
||||
* Integration tests for {@link HalBrowserMvcEndpoint}'s support for producing
|
||||
* text/html
|
||||
*
|
||||
* @author Dave Syer
|
||||
@ -52,7 +52,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
@WebAppConfiguration
|
||||
@TestPropertySource(properties = "endpoints.actuator.path=/actuator")
|
||||
@DirtiesContext
|
||||
public class BrowserPathHypermediaIntegrationTests {
|
||||
public class HalBrowserMvcEndpointBrowserPathIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
@ -14,17 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure;
|
||||
package org.springframework.boot.actuate.endpoint.mvc;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.ManagementContextPathHypermediaIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ActuatorHalBrowserEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints;
|
||||
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpointManagementContextPathIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -45,7 +43,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ActuatorHalBrowserEndpoint} when a custom management
|
||||
* Integration tests for {@link HalBrowserMvcEndpoint} when a custom management
|
||||
* context path has been configured.
|
||||
*
|
||||
* @author Dave Syer
|
||||
@ -56,7 +54,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
@WebAppConfiguration
|
||||
@TestPropertySource(properties = "management.contextPath:/admin")
|
||||
@DirtiesContext
|
||||
public class ManagementContextPathHypermediaIntegrationTests {
|
||||
public class HalBrowserMvcEndpointManagementContextPathIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure;
|
||||
package org.springframework.boot.actuate.endpoint.mvc;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -22,8 +22,8 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.actuate.autoconfigure.ServerContextPathHypermediaIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ActuatorHalBrowserEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpointServerContextPathIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
@ -45,7 +45,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ActuatorHalBrowserEndpoint} when a custom server context
|
||||
* Integration tests for {@link HalBrowserMvcEndpoint} when a custom server context
|
||||
* path has been configured.
|
||||
*
|
||||
* @author Dave Syer
|
||||
@ -56,7 +56,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
@WebAppConfiguration
|
||||
@IntegrationTest({ "server.port=0", "server.contextPath=/spring" })
|
||||
@DirtiesContext
|
||||
public class ServerContextPathHypermediaIntegrationTests {
|
||||
public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
private int port;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure;
|
||||
package org.springframework.boot.actuate.endpoint.mvc;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -22,8 +22,8 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.actuate.autoconfigure.ServerPortHypermediaIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ActuatorHalBrowserEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpointServerPortIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
@ -45,7 +45,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ActuatorHalBrowserEndpoint} when a custom server port has
|
||||
* Integration tests for {@link HalBrowserMvcEndpoint} when a custom server port has
|
||||
* been configured.
|
||||
*
|
||||
* @author Dave Syer
|
||||
@ -56,7 +56,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
@WebAppConfiguration
|
||||
@IntegrationTest({ "server.port=0", "management.port=0" })
|
||||
@DirtiesContext
|
||||
public class ServerPortHypermediaIntegrationTests {
|
||||
public class HalBrowserMvcEndpointServerPortIntegrationTests {
|
||||
|
||||
@Value("${local.management.port}")
|
||||
private int port;
|
@ -14,17 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure;
|
||||
package org.springframework.boot.actuate.endpoint.mvc;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.VanillaHypermediaIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ActuatorHalBrowserEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints;
|
||||
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpointVanillaIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -43,7 +41,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ActuatorHalBrowserEndpoint}
|
||||
* Integration tests for {@link HalBrowserMvcEndpoint}
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
@ -52,7 +50,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
@SpringApplicationConfiguration(SpringBootHypermediaApplication.class)
|
||||
@WebAppConfiguration
|
||||
@DirtiesContext
|
||||
public class VanillaHypermediaIntegrationTests {
|
||||
public class HalBrowserMvcEndpointVanillaIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
Loading…
Reference in New Issue
Block a user