- ChatRoomInfoTo chatRoom = createChatRoom("bar").block();
- TestClient testClient = new TestClient(
- containers.haproxy.getMappedPort(8400),
- chatRoom,
- "nerd");
- testClient.run();
-
- receiveMessages(chatRoom)
- .take(100)
+ ChatRoomInfoTo[] chatRooms = Flux
+ .range(0, NUM_CHATROOMS)
+ .flatMap(i -> createChatRoom("#" + i))
+ .toStream()
+ .toArray(size -> new ChatRoomInfoTo[size]);
+
+ TestClient[] testClients = Flux
+ .fromStream(IntStream.range(0, NUM_CLIENTS).mapToObj(i -> Integer.toString(i)))
+ .map(i -> new TestClient(
+ containers.haproxy.getMappedPort(8400),
+ chatRooms,
+ i))
+ .doOnNext(testClient -> executorService.execute(testClient))
+ .toStream()
+ .toArray(size -> new TestClient[size]);
+
+ Thread.sleep(2000);
+
+ Flux
+ .fromArray(chatRooms)
+ .flatMap(chatRoom ->receiveMessages(chatRoom).take(100))