Provide links for actuators at / when using a separate management port
See gh-17418pull/17431/head
parent
edea223841
commit
c108629311
@ -0,0 +1,37 @@
|
|||||||
|
package smoketest.actuator;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||||
|
properties = { "management.endpoints.web.base-path=/","management.server.port=0"})
|
||||||
|
public class ManagementDifferentPortSampleActuatorApplicationTests {
|
||||||
|
|
||||||
|
@LocalServerPort
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@LocalManagementPort
|
||||||
|
private int managementPort;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDifferentServerPort(){
|
||||||
|
if(this.managementPort != this.port) {
|
||||||
|
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
|
||||||
|
.getForEntity("http://localhost:" + this.managementPort + "/", String.class);
|
||||||
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
|
assertThat(entity.getBody()).contains("\"_links\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPassword(){
|
||||||
|
return "password";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package smoketest.jersey;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"management.server.port=0","management.endpoints.web.base-path=/"})
|
||||||
|
public class JerseyDifferentPortSampleActuatorApplicationTests {
|
||||||
|
|
||||||
|
@LocalManagementPort
|
||||||
|
private int managementPort;
|
||||||
|
|
||||||
|
@LocalServerPort
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDifferentServerPort(){
|
||||||
|
if(this.managementPort != this.port) {
|
||||||
|
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
|
||||||
|
.getForEntity("http://localhost:" + this.managementPort + "/", String.class);
|
||||||
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
|
assertThat(entity.getBody()).contains("\"_links\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPassword(){
|
||||||
|
return "password";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package smoketest.webflux;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"management.server.port=0","management.endpoints.web.base-path=/"})
|
||||||
|
public class WebFluxDifferentPortSampleActuatorApplicationTests {
|
||||||
|
|
||||||
|
@LocalManagementPort
|
||||||
|
private int managementPort;
|
||||||
|
|
||||||
|
@LocalServerPort
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDifferentServerPort(){
|
||||||
|
if(this.managementPort != this.port) {
|
||||||
|
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
|
||||||
|
.getForEntity("http://localhost:" + this.managementPort + "/", String.class);
|
||||||
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
|
assertThat(entity.getBody()).contains("\"_links\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPassword(){
|
||||||
|
return "password";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue