Remove BodyInserters.fromServerSentEvent variants
Removed superfluous `fromServerSentEvent` variants from `BodyInserters`, as their functionality can also be obtained by passing a stream of strings or POJOs (to be encoded as JSON) to `fromPublisher(Publisher, Class)}`, and specifying a `text/event-stream` Content-Type. Issue: SPR-15826
This commit is contained in:
@@ -247,17 +247,6 @@ public class BodyInsertersTests {
|
||||
StepVerifier.create(result).expectNextCount(0).expectComplete().verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ofServerSentEventClass() throws Exception {
|
||||
Flux<String> body = Flux.just("foo");
|
||||
BodyInserter<Flux<String>, ServerHttpResponse> inserter =
|
||||
BodyInserters.fromServerSentEvents(body, String.class);
|
||||
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
Mono<Void> result = inserter.insert(response, this.context);
|
||||
StepVerifier.create(result).expectNextCount(0).expectComplete().verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ofFormData() throws Exception {
|
||||
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
|
||||
|
||||
@@ -25,6 +25,7 @@ import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.ServerSentEvent;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
@@ -120,13 +121,17 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn
|
||||
|
||||
public Mono<ServerResponse> string(ServerRequest request) {
|
||||
Flux<String> flux = Flux.interval(Duration.ofMillis(100)).map(l -> "foo " + l).take(2);
|
||||
return ServerResponse.ok().body(fromServerSentEvents(flux, String.class));
|
||||
return ServerResponse.ok()
|
||||
.contentType(MediaType.TEXT_EVENT_STREAM)
|
||||
.body(flux, String.class);
|
||||
}
|
||||
|
||||
public Mono<ServerResponse> person(ServerRequest request) {
|
||||
Flux<Person> flux = Flux.interval(Duration.ofMillis(100))
|
||||
.map(l -> new Person("foo " + l)).take(2);
|
||||
return ServerResponse.ok().body(fromServerSentEvents(flux, Person.class));
|
||||
return ServerResponse.ok()
|
||||
.contentType(MediaType.TEXT_EVENT_STREAM)
|
||||
.body(flux, Person.class);
|
||||
}
|
||||
|
||||
public Mono<ServerResponse> sse(ServerRequest request) {
|
||||
|
||||
Reference in New Issue
Block a user