From: Kai Moritz Date: Thu, 12 Jan 2023 22:06:10 +0000 (+0100) Subject: refactor: Renamed the test to `InMemoryWithFilesStorageIT` X-Git-Tag: wip~38 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=b9929f0c29b1c483ec4c4e335cb7e953c94ae398;p=demos%2Fkafka%2Fchat refactor: Renamed the test to `InMemoryWithFilesStorageIT` --- diff --git a/src/test/java/de/juplo/kafka/chat/backend/ChatBackendApplicationTests.java b/src/test/java/de/juplo/kafka/chat/backend/ChatBackendApplicationTests.java deleted file mode 100644 index 9dac22ec..00000000 --- a/src/test/java/de/juplo/kafka/chat/backend/ChatBackendApplicationTests.java +++ /dev/null @@ -1,54 +0,0 @@ -package de.juplo.kafka.chat.backend; - -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.server.LocalServerPort; -import org.springframework.http.MediaType; -import org.springframework.test.web.reactive.server.WebTestClient; -import org.testcontainers.shaded.org.awaitility.Awaitility; - -import java.time.Duration; - - -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = "chat.backend.storage-directory=target/test-classes/data/files") -class ChatBackendApplicationTests -{ - @LocalServerPort - private int port; - @Autowired - private WebTestClient webTestClient; - - @Test - void contextLoads() - { - Awaitility - .await() - .atMost(Duration.ofSeconds(15)) - .untilAsserted(() -> - { - webTestClient - .get() - .uri("http://localhost:{port}/actuator/health", port) - .exchange() - .expectStatus().isOk() - .expectBody().jsonPath("$.status").isEqualTo("UP"); - webTestClient - .get() - .uri("http://localhost:{port}/618e89ae-fdc0-4c65-8055-f49908295e8f", port) - .accept(MediaType.APPLICATION_JSON) - .exchange() - .expectStatus().isOk() - .expectBody().jsonPath("$.name").isEqualTo("Peter's Chat-Room"); - webTestClient - .get() - .uri("http://localhost:{port}/4ace69b7-a79f-481b-ad0d-d756d60b66ec/ute/1478", port) - .accept(MediaType.APPLICATION_JSON) - .exchange() - .expectStatus().isOk() - .expectBody().jsonPath("$.text").isEqualTo("Nachricht Nr. 1478"); - }); - } -} diff --git a/src/test/java/de/juplo/kafka/chat/backend/InMemoryWithFilesStorageIT.java b/src/test/java/de/juplo/kafka/chat/backend/InMemoryWithFilesStorageIT.java new file mode 100644 index 00000000..12abf7aa --- /dev/null +++ b/src/test/java/de/juplo/kafka/chat/backend/InMemoryWithFilesStorageIT.java @@ -0,0 +1,54 @@ +package de.juplo.kafka.chat.backend; + +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.server.LocalServerPort; +import org.springframework.http.MediaType; +import org.springframework.test.web.reactive.server.WebTestClient; +import org.testcontainers.shaded.org.awaitility.Awaitility; + +import java.time.Duration; + + +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = "chat.backend.storage-directory=target/test-classes/data/files") +class InMemoryWithFilesStorageIT +{ + @LocalServerPort + private int port; + @Autowired + private WebTestClient webTestClient; + + @Test + void contextLoads() + { + Awaitility + .await() + .atMost(Duration.ofSeconds(15)) + .untilAsserted(() -> + { + webTestClient + .get() + .uri("http://localhost:{port}/actuator/health", port) + .exchange() + .expectStatus().isOk() + .expectBody().jsonPath("$.status").isEqualTo("UP"); + webTestClient + .get() + .uri("http://localhost:{port}/618e89ae-fdc0-4c65-8055-f49908295e8f", port) + .accept(MediaType.APPLICATION_JSON) + .exchange() + .expectStatus().isOk() + .expectBody().jsonPath("$.name").isEqualTo("Peter's Chat-Room"); + webTestClient + .get() + .uri("http://localhost:{port}/618e89ae-fdc0-4c65-8055-f49908295e8f/ute/1478", port) + .accept(MediaType.APPLICATION_JSON) + .exchange() + .expectStatus().isOk() + .expectBody().jsonPath("$.text").isEqualTo("Nachricht Nr. 1478"); + }); + } +}