From f62fc04de07b8088b90defebdb8fdf1319b9e66a Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 28 Feb 2024 10:09:56 +0100 Subject: [PATCH] test: HandoverIT-POC - clients are stopped after some time --- .../java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java | 4 ++++ src/test/java/de/juplo/kafka/chat/backend/TestClient.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java b/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java index a9148f0d..743b9bb4 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java @@ -13,6 +13,7 @@ import org.testcontainers.junit.jupiter.Testcontainers; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import java.util.Arrays; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.stream.IntStream; @@ -57,6 +58,9 @@ public abstract class AbstractHandoverIT .toArray(size -> new TestClient[size]); Thread.sleep(10000); + Arrays + .stream(testClients) + .forEach(testClient -> testClient.running = false); Flux .fromArray(chatRooms) diff --git a/src/test/java/de/juplo/kafka/chat/backend/TestClient.java b/src/test/java/de/juplo/kafka/chat/backend/TestClient.java index 964a06ba..524c297c 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/TestClient.java +++ b/src/test/java/de/juplo/kafka/chat/backend/TestClient.java @@ -19,7 +19,7 @@ public class TestClient implements Runnable @Override public void run() { - for (int i = 0; i < 100; i++) + for (int i = 0; running; i++) { String message = "Message #" + i; for (ChatRoomInfoTo chatRoom : chatRooms) @@ -76,6 +76,8 @@ public class TestClient implements Runnable private final ChatRoomInfoTo[] chatRooms; private final User user; + volatile boolean running = true; + TestClient(Integer port, ChatRoomInfoTo[] chatRooms, String username) { -- 2.20.1