From: Kai Moritz Date: Sun, 29 Sep 2024 13:29:07 +0000 (+0200) Subject: Letze Angleichungen an Neu-Aufgleisung per REBASE X-Git-Tag: consumer/spring-consumer--BRANCH-ENDE~1 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=2478145b033df6091a67b1e5d4d1a2185363f561;p=demos%2Fkafka%2Ftraining Letze Angleichungen an Neu-Aufgleisung per REBASE --- diff --git a/pom.xml b/pom.xml index 156c65e..63651ca 100644 --- a/pom.xml +++ b/pom.xml @@ -26,10 +26,6 @@ org.springframework.boot spring-boot-starter-web - - org.springframework.boot - spring-boot-starter-validation - org.springframework.boot spring-boot-starter-actuator @@ -39,6 +35,10 @@ spring-boot-configuration-processor true + + org.springframework.boot + spring-boot-starter-validation + org.springframework.kafka spring-kafka @@ -72,6 +72,10 @@ + + pl.project13.maven + git-commit-id-plugin + io.fabric8 docker-maven-plugin diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml deleted file mode 100644 index b8e6780..0000000 --- a/src/main/resources/logback.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - %highlight(%-5level) %m%n - - - - - - - - - - - diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java index 4df6f16..53c15c9 100644 --- a/src/test/java/de/juplo/kafka/ApplicationTests.java +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -2,39 +2,46 @@ package de.juplo.kafka; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 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 org.springframework.test.web.servlet.MockMvc; +import java.time.Duration; + +import static de.juplo.kafka.ApplicationTests.PARTITIONS; import static de.juplo.kafka.ApplicationTests.TOPIC; +import static org.awaitility.Awaitility.await; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}", + "spring.kafka.consumer.auto-offset-reset=earliest", "juplo.consumer.topics=" + TOPIC }) -@EmbeddedKafka(topics = TOPIC) +@AutoConfigureMockMvc +@EmbeddedKafka(topics = TOPIC, partitions = PARTITIONS) public class ApplicationTests { - public static final String TOPIC = "FOO"; - - @LocalServerPort - private int port; + static final String TOPIC = "FOO"; + static final int PARTITIONS = 10; @Autowired - private TestRestTemplate restTemplate; + MockMvc mockMvc; @Test public void testApplicationStartup() { - restTemplate.getForObject( - "http://localhost:" + port + "/actuator/health", - String.class - ) - .contains("UP"); + await("Application is healthy") + .atMost(Duration.ofSeconds(5)) + .untilAsserted(() -> mockMvc + .perform(get("/actuator/health")) + .andExpect(status().isOk()) + .andExpect(jsonPath("status").value("UP"))); } }