Skip to content

Commit 7d04ca1

Browse files
author
Dave Syer
committed
Add tests to assert behaviour of actuator endpoints with context path
See gh-4401
1 parent ae13082 commit 7d04ca1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,36 @@ public void onDifferentPort() throws Exception {
158158
assertAllClosed();
159159
}
160160

161+
@Test
162+
public void onDifferentPortAndContext() throws Exception {
163+
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
164+
DifferentPortConfig.class, BaseConfiguration.class,
165+
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
166+
EnvironmentTestUtils.addEnvironment(this.applicationContext,
167+
"management.context-path=/admin");
168+
this.applicationContext.refresh();
169+
assertContent("/controller", ports.get().server, "controlleroutput");
170+
assertContent("/admin/endpoint", ports.get().management, "endpointoutput");
171+
assertContent("/admin/error", ports.get().management, startsWith("{"));
172+
this.applicationContext.close();
173+
assertAllClosed();
174+
}
175+
176+
@Test
177+
public void onDifferentPortAndMainContext() throws Exception {
178+
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
179+
DifferentPortConfig.class, BaseConfiguration.class,
180+
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
181+
EnvironmentTestUtils.addEnvironment(this.applicationContext,
182+
"management.context-path=/admin", "server.context-path=/spring");
183+
this.applicationContext.refresh();
184+
assertContent("/spring/controller", ports.get().server, "controlleroutput");
185+
assertContent("/admin/endpoint", ports.get().management, "endpointoutput");
186+
assertContent("/admin/error", ports.get().management, startsWith("{"));
187+
this.applicationContext.close();
188+
assertAllClosed();
189+
}
190+
161191
@Test
162192
public void onDifferentPortWithoutErrorMvcAutoConfiguration() throws Exception {
163193
this.applicationContext.register(RootConfig.class, EndpointConfig.class,

0 commit comments

Comments
 (0)