Skip to content

Commit 6e9745b

Browse files
committed
Updates for boot 2 actuator path changes
1 parent a051c24 commit 6e9745b

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.junit.runner.RunWith;
1111
import org.springframework.beans.factory.annotation.Autowired;
1212
import org.springframework.boot.SpringBootConfiguration;
13+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
1314
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
1415
import org.springframework.boot.test.context.SpringBootTest;
1516
import org.springframework.cloud.client.serviceregistry.Registration;
@@ -36,6 +37,8 @@
3637
@RunWith(SpringRunner.class)
3738
@SpringBootTest(classes = ServiceRegistryEndpointTests.TestConfiguration.class, properties = "management.endpoints.web.expose=*")
3839
public class ServiceRegistryEndpointTests {
40+
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
41+
3942
private static final String UPDATED_STATUS = "updatedstatus";
4043
private static final String MYSTATUS = "mystatus";
4144

@@ -54,14 +57,14 @@ public void setUp() {
5457

5558
@Test
5659
public void testGet() throws Exception {
57-
this.mvc.perform(get("/application/service-registry")).andExpect(status().isOk())
60+
this.mvc.perform(get(BASE_PATH + "/service-registry")).andExpect(status().isOk())
5861
.andExpect(content().string(containsString(MYSTATUS)));
5962
}
6063

6164
@Test
6265
public void testPost() throws Exception {
6366
Map<String, String> status = Collections.singletonMap("status", UPDATED_STATUS);
64-
this.mvc.perform(post("/application/service-registry")
67+
this.mvc.perform(post(BASE_PATH + "/service-registry")
6568
.content(new ObjectMapper().writeValueAsString(status))
6669
.contentType(MediaType.APPLICATION_JSON))
6770
.andExpect(status().isOk());

spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.junit.runner.RunWith;
3030

3131
import org.springframework.beans.factory.annotation.Autowired;
32+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
3233
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
3334
import org.springframework.boot.context.properties.ConfigurationProperties;
3435
import org.springframework.boot.test.context.SpringBootTest;
@@ -51,6 +52,8 @@
5152
@SpringBootTest(classes = TestConfiguration.class, properties = "management.endpoints.web.expose=*")
5253
public class EnvironmentManagerIntegrationTests {
5354

55+
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
56+
5457
@Autowired
5558
private TestProperties properties;
5659

@@ -72,7 +75,7 @@ public void testRefresh() throws Exception {
7275
assertEquals("Hello scope!", properties.getMessage());
7376
String content = property("message", "Foo");
7477

75-
this.mvc.perform(post("/application/env")
78+
this.mvc.perform(post(BASE_PATH + "/env")
7679
.content(content)
7780
.contentType(MediaType.APPLICATION_JSON))
7881
.andExpect(status().isOk())
@@ -92,7 +95,7 @@ private String property(String name, String value) throws JsonProcessingExceptio
9295
@Test
9396
public void testRefreshFails() throws Exception {
9497
try {
95-
this.mvc.perform(post("/application/env")
98+
this.mvc.perform(post(BASE_PATH + "/env")
9699
.content(property("delay", "foo"))
97100
.contentType(MediaType.APPLICATION_JSON))
98101
.andExpect(status().isOk())

spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.junit.runner.RunWith;
2525
import org.springframework.beans.factory.annotation.Value;
2626
import org.springframework.boot.SpringApplication;
27+
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
2728
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2829
import org.springframework.boot.test.context.SpringBootTest;
2930
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -50,17 +51,19 @@
5051
@RunWith(SpringRunner.class)
5152
@SpringBootTest(classes = ClientApp.class, properties = "management.endpoints.web.expose=*", webEnvironment = RANDOM_PORT)
5253
public class RefreshEndpointIntegrationTests {
53-
54+
55+
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
56+
5457
@LocalServerPort
5558
private int port;
5659

5760
@Test
5861
public void webAccess() throws Exception {
5962
TestRestTemplate template = new TestRestTemplate();
6063
template.exchange(
61-
getUrlEncodedEntity("http://localhost:" + this.port + "/application/env", "message",
64+
getUrlEncodedEntity("http://localhost:" + this.port + BASE_PATH + "/env", "message",
6265
"Hello Dave!"), String.class);
63-
template.postForObject("http://localhost:" + this.port + "/application/refresh", null, String.class);
66+
template.postForObject("http://localhost:" + this.port + BASE_PATH + "/refresh", null, String.class);
6467
String message = template.getForObject("http://localhost:" + this.port + "/",
6568
String.class);
6669
assertEquals("Hello Dave!", message);

0 commit comments

Comments
 (0)