Add a shim Endpoint if management context is child
When management endpoints are on a different port the HandlerMappings are restricted to a single EndpointHandlerMapping, so the error controller (which is a normal @Controller with @RequestMappings) does not get mapped. Fixed by addinga shim Endpoint on "/error" that delegates to the ErrorController (which interface picks up an extra method).
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.sample.ops;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -27,7 +29,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
@@ -44,8 +45,6 @@ import org.springframework.security.crypto.codec.Base64;
|
||||
import org.springframework.web.client.DefaultResponseErrorHandler;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Integration tests for separate management and main service ports.
|
||||
*
|
||||
@@ -93,9 +92,7 @@ public class ManagementAddressSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMetrics() throws Exception {
|
||||
// FIXME broken because error page is no longer exposed on management port
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = getRestTemplate().getForEntity(
|
||||
@@ -104,9 +101,7 @@ public class ManagementAddressSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testHealth() throws Exception {
|
||||
// FIXME broken because error page is no longer exposed on management port
|
||||
ResponseEntity<String> entity = getRestTemplate().getForEntity(
|
||||
"http://localhost:" + managementPort + "/health", String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
@@ -114,9 +109,7 @@ public class ManagementAddressSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testErrorPage() throws Exception {
|
||||
// FIXME broken because error page is no longer exposed on management port
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = getRestTemplate().getForEntity(
|
||||
"http://localhost:" + managementPort + "/error", Map.class);
|
||||
|
||||
Reference in New Issue
Block a user