From: Kai Moritz Date: Wed, 28 Feb 2024 09:09:56 +0000 (+0100) Subject: test: HandoverIT-POC - clients are stopped after some time X-Git-Tag: rebase--2024-03-03--11-38~23 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=f62fc04de07b8088b90defebdb8fdf1319b9e66a;p=demos%2Fkafka%2Fchat test: HandoverIT-POC - clients are stopped after some time --- 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) {