Einfacher geht es nicht mehr
[demos/kafka/training] / src / test / java / de / juplo / kafka / ApplicationTests.java
diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java
new file mode 100644 (file)
index 0000000..3c77a44
--- /dev/null
@@ -0,0 +1,34 @@
+package de.juplo.kafka;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+
+@SpringBootTest(
+    webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
+    properties = "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}")
+@EmbeddedKafka(topics = "out")
+public class ApplicationTests
+{
+  @LocalServerPort
+  private int port;
+
+  @Autowired
+  private TestRestTemplate restTemplate;
+
+
+
+  @Test
+  public void testApplicationStartup()
+  {
+    restTemplate.getForObject(
+        "http://localhost:" + port + "/actuator/health",
+        String.class
+        )
+        .contains("UP");
+  }
+}