From: Kai Moritz Date: Fri, 12 Aug 2022 21:27:45 +0000 (+0200) Subject: Der Integration-Test prüft auch, ob der HealthIndicator 'UP' zurückgibt X-Git-Tag: endless-stream-consumer-DEPRECATED^2^2^2~1^2 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=2768e0f97c441ade5ce8ff371aa590fdc3cfd6c6;p=demos%2Fkafka%2Ftraining Der Integration-Test prüft auch, ob der HealthIndicator 'UP' zurückgibt --- diff --git a/src/test/java/de/juplo/kafka/ApplicationIT.java b/src/test/java/de/juplo/kafka/ApplicationIT.java index 4c149cc..cded0ee 100644 --- a/src/test/java/de/juplo/kafka/ApplicationIT.java +++ b/src/test/java/de/juplo/kafka/ApplicationIT.java @@ -1,14 +1,18 @@ package de.juplo.kafka; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.kafka.test.context.EmbeddedKafka; import static de.juplo.kafka.ApplicationTests.TOPIC; @SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "consumer.bootstrap-server=${spring.embedded.kafka.brokers}", "consumer.topic=" + TOPIC, @@ -19,7 +23,21 @@ public class ApplicationIT { public static final String TOPIC = "FOO"; + @LocalServerPort + private int port; + + @Autowired + private TestRestTemplate restTemplate; + + @Test - public void testApplicationStartup() {} + public void testApplicationStartup() + { + restTemplate.getForObject( + "http://localhost:" + port + "/actuator/health", + String.class + ) + .contains("UP"); + } }