import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
+import org.springframework.http.codec.ServerSentEvent;
import org.springframework.web.reactive.function.client.WebClient;
import org.testcontainers.containers.*;
import org.testcontainers.containers.output.Slf4jLogConsumer;
.forEach(result -> log.info("{}", result));
receiveMessages(chatRoom).subscribe(message -> log.info("message: {}", message));
-
- Thread.sleep(1000000);
}
Mono<ChatRoomInfoTo> createChatRoom(String name)
});
}
- Flux<byte[]> receiveMessages(ChatRoomInfoTo chatRoom)
+ Flux<ServerSentEvent<String>> receiveMessages(ChatRoomInfoTo chatRoom)
{
return webClient
.get()
.uri(
"/{chatRoomId}/listen",
chatRoom.getId())
- .accept(MediaType.APPLICATION_OCTET_STREAM)
+ .accept(MediaType.TEXT_EVENT_STREAM)
.retrieve()
- .bodyToFlux(byte[].class);
+ .bodyToFlux(sseType);
}
@BeforeEach
{
String status;
}
+
+ ParameterizedTypeReference<ServerSentEvent<String>> sseType = new ParameterizedTypeReference<>() {};
}