import de.juplo.kafka.chat.backend.api.ChatRoomInfoTo;
import de.juplo.kafka.chat.backend.api.MessageTo;
import lombok.extern.slf4j.Slf4j;
+import org.awaitility.Awaitility;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
+import java.time.Duration;
import java.util.List;
import java.util.concurrent.CompletableFuture;
log.info("Joined TestWriter {}", testWriters[i].user);
}
- // Yield the work, so that the last messages can be received
- Thread.sleep(500);
+ Awaitility
+ .await()
+ .atMost(Duration.ofSeconds(5))
+ .untilAsserted(() -> assertAllSentMessagesReceived(testWriters, testListener));
+ }
+ private void assertAllSentMessagesReceived(
+ TestWriter[] testWriters,
+ TestListener testListener)
+ {
for (int i = 0; i < NUM_CLIENTS; i++)
{
TestWriter testWriter = testWriters[i];