Add actuator to webflux sample

Closes gh-10258
This commit is contained in:
Stephane Nicoll 2017-09-13 12:11:20 +02:00
parent 73f4a2e130
commit b5d8e072f1
2 changed files with 21 additions and 2 deletions

View File

@ -25,6 +25,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -42,6 +46,14 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>generate build info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -40,17 +40,24 @@ public class SampleWebFluxApplicationTests {
private WebTestClient webClient;
@Test
public void testWelcome() throws Exception {
public void testWelcome() {
this.webClient.get().uri("/").accept(MediaType.TEXT_PLAIN).exchange()
.expectBody(String.class).isEqualTo("Hello World");
}
@Test
public void testEcho() throws Exception {
public void testEcho() {
this.webClient.post().uri("/echo").contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.TEXT_PLAIN)
.body(Mono.just("Hello WebFlux!"), String.class).exchange()
.expectBody(String.class).isEqualTo("Hello WebFlux!");
}
@Test
public void testActuatorStatus() {
this.webClient.get().uri("/application/status").accept(MediaType.APPLICATION_JSON)
.exchange().expectStatus().isOk().expectBody()
.json("{\"status\":\"UP\"}");
}
}