[bs-107] Finish off varz->metrics

[Fixes #49496887] [bs-107] Remove trailing "z" from management endpoint URLs
This commit is contained in:
Dave Syer
2013-05-23 19:26:25 +01:00
parent b7c0e3279e
commit e649ef44cc
11 changed files with 65 additions and 28 deletions

View File

@@ -43,7 +43,7 @@ public class HealthConfiguration {
private HealthIndicator<? extends Object> healthIndicator = new VanillaHealthIndicator();
@Bean
public HealthEndpoint<? extends Object> healthzEndpoint() {
public HealthEndpoint<? extends Object> healthEndpoint() {
return new HealthEndpoint<Object>(this.healthIndicator);
}

View File

@@ -19,9 +19,9 @@ package org.springframework.bootstrap.actuate.autoconfigure;
import javax.servlet.Servlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.bootstrap.actuate.endpoint.metrics.MetricsEndpoint;
import org.springframework.bootstrap.actuate.endpoint.metrics.PublicMetrics;
import org.springframework.bootstrap.actuate.endpoint.metrics.VanillaPublicMetrics;
import org.springframework.bootstrap.actuate.endpoint.metrics.MetricsEndpoint;
import org.springframework.bootstrap.actuate.metrics.MetricRepository;
import org.springframework.bootstrap.context.annotation.ConditionalOnClass;
import org.springframework.bootstrap.context.annotation.ConditionalOnMissingBean;
@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;
/**
* {@link EnableAutoConfiguration Auto-configuration} for /varz endpoint.
* {@link EnableAutoConfiguration Auto-configuration} for /metrics endpoint.
*
* @author Dave Syer
*/

View File

@@ -57,8 +57,8 @@ public class SecurityConfiguration {
private static class BoostrapWebSecurityConfigurerAdapter extends
WebSecurityConfigurerAdapter {
@Value("${endpoints.healthz.path:/healthz}")
private String healthzPath = "/healthz";
@Value("${endpoints.health.path:/health}")
private String healthPath = "/health";
@Value("${endpoints.info.path:/info}")
private String infoPath = "/info";
@@ -80,7 +80,7 @@ public class SecurityConfiguration {
@Override
public void configure(WebSecurityConfiguration builder) throws Exception {
builder.ignoring().antMatchers(this.healthzPath, this.infoPath);
builder.ignoring().antMatchers(this.healthPath, this.infoPath);
}
@Override

View File

@@ -36,9 +36,9 @@ public class HealthEndpoint<T> {
this.indicator = indicator;
}
@RequestMapping("${endpoints.healthz.path:/healthz}")
@RequestMapping("${endpoints.health.path:/health}")
@ResponseBody
public T healthz() {
public T health() {
return this.indicator.health();
}

View File

@@ -39,9 +39,9 @@ public class MetricsEndpoint {
this.metrics = metrics;
}
@RequestMapping("${endpoints.varz.path:/varz}")
@RequestMapping("${endpoints.metrics.path:/metrics}")
@ResponseBody
public Map<String, Object> varz() {
public Map<String, Object> metrics() {
Map<String, Object> result = new LinkedHashMap<String, Object>();
for (Metric metric : this.metrics.metrics()) {
result.put(metric.getName(), metric.getValue());

View File

@@ -18,10 +18,16 @@ package org.springframework.bootstrap.actuate.autoconfigure;
import org.junit.Test;
import org.springframework.bootstrap.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockServletContext;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.TestingAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
@@ -41,4 +47,35 @@ public class SecurityConfigurationTests {
assertNotNull(this.context.getBean(AuthenticationManager.class));
}
@Test
public void testOverrideAuthenticationManager() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class, SecurityConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertEquals(this.context.getBean(TestConfiguration.class).authenticationManager,
this.context.getBean(AuthenticationManager.class));
}
@Configuration
protected static class TestConfiguration {
private AuthenticationManager authenticationManager;
@Bean
public AuthenticationManager myAuthenticationManager() {
this.authenticationManager = new AuthenticationManager() {
@Override
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
return new TestingAuthenticationToken("foo", "bar");
}
};
return this.authenticationManager;
}
}
}