From: Kai Moritz Date: Sun, 29 Sep 2024 12:47:52 +0000 (+0200) Subject: Tests wider so benannt, wie von Spring vorgegeben -- MOVE X-Git-Tag: consumer/spring-consumer--BRANCH-ENDE~4 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=c89b40522976a21d553d93c2f156ad8ee3fe5663;p=demos%2Fkafka%2Ftraining Tests wider so benannt, wie von Spring vorgegeben -- MOVE --- diff --git a/src/test/java/de/juplo/kafka/ApplicationIT.java b/src/test/java/de/juplo/kafka/ApplicationIT.java deleted file mode 100644 index 584773e..0000000 --- a/src/test/java/de/juplo/kafka/ApplicationIT.java +++ /dev/null @@ -1,40 +0,0 @@ -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; - -import static de.juplo.kafka.ApplicationIT.TOPIC; - - -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = { - "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}", - "simple.consumer.topics=" + TOPIC }) -@EmbeddedKafka(topics = TOPIC) -public class ApplicationIT -{ - public static final String TOPIC = "FOO"; - - @LocalServerPort - private int port; - - @Autowired - private TestRestTemplate restTemplate; - - - - @Test - public void testApplicationStartup() - { - restTemplate.getForObject( - "http://localhost:" + port + "/actuator/health", - String.class - ) - .contains("UP"); - } -} diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java new file mode 100644 index 0000000..584773e --- /dev/null +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -0,0 +1,40 @@ +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; + +import static de.juplo.kafka.ApplicationIT.TOPIC; + + +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { + "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}", + "simple.consumer.topics=" + TOPIC }) +@EmbeddedKafka(topics = TOPIC) +public class ApplicationIT +{ + public static final String TOPIC = "FOO"; + + @LocalServerPort + private int port; + + @Autowired + private TestRestTemplate restTemplate; + + + + @Test + public void testApplicationStartup() + { + restTemplate.getForObject( + "http://localhost:" + port + "/actuator/health", + String.class + ) + .contains("UP"); + } +}