3c77a4440f68abfeb26a316d40d6cbdb1edddfac
[demos/kafka/training] / src / test / java / de / juplo / kafka / ApplicationTests.java
1 package de.juplo.kafka;
2
3 import org.junit.jupiter.api.Test;
4 import org.springframework.beans.factory.annotation.Autowired;
5 import org.springframework.boot.test.context.SpringBootTest;
6 import org.springframework.boot.test.web.client.TestRestTemplate;
7 import org.springframework.boot.test.web.server.LocalServerPort;
8 import org.springframework.kafka.test.context.EmbeddedKafka;
9
10
11 @SpringBootTest(
12     webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
13     properties = "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}")
14 @EmbeddedKafka(topics = "out")
15 public class ApplicationTests
16 {
17   @LocalServerPort
18   private int port;
19
20   @Autowired
21   private TestRestTemplate restTemplate;
22
23
24
25   @Test
26   public void testApplicationStartup()
27   {
28     restTemplate.getForObject(
29         "http://localhost:" + port + "/actuator/health",
30         String.class
31         )
32         .contains("UP");
33   }
34 }