From 2768e0f97c441ade5ce8ff371aa590fdc3cfd6c6 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 12 Aug 2022 23:27:45 +0200 Subject: [PATCH] =?utf8?q?Der=20Integration-Test=20pr=C3=BCft=20auch,=20ob?= =?utf8?q?=20der=20HealthIndicator=20'UP'=20zur=C3=BCckgibt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/de/juplo/kafka/ApplicationIT.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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"); + } } -- 2.20.1