use of cn.taketoday.http.server.reactive.MockServerHttpResponse in project today-infrastructure by TAKETODAY.
the class ServerSentEventHttpMessageWriterTests method writeMultiLineString.
@ParameterizedDataBufferAllocatingTest
void writeMultiLineString(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
Flux<String> source = Flux.just("foo\nbar", "foo\nbaz");
testWrite(source, outputMessage, String.class);
StepVerifier.create(outputMessage.getBody()).consumeNextWith(stringConsumer("data:foo\ndata:bar\n\n")).consumeNextWith(stringConsumer("data:foo\ndata:baz\n\n")).expectComplete().verify();
}
use of cn.taketoday.http.server.reactive.MockServerHttpResponse in project today-infrastructure by TAKETODAY.
the class ServerSentEventHttpMessageWriterTests method writeServerSentEvent.
@ParameterizedDataBufferAllocatingTest
void writeServerSentEvent(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
ServerSentEvent<?> event = ServerSentEvent.builder().data("bar").id("c42").event("foo").comment("bla\nbla bla\nbla bla bla").retry(Duration.ofMillis(123L)).build();
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
Mono<ServerSentEvent> source = Mono.just(event);
testWrite(source, outputMessage, ServerSentEvent.class);
StepVerifier.create(outputMessage.getBody()).consumeNextWith(stringConsumer("id:c42\nevent:foo\nretry:123\n:bla\n:bla bla\n:bla bla bla\ndata:bar\n\n")).expectComplete().verify();
}
use of cn.taketoday.http.server.reactive.MockServerHttpResponse in project today-framework by TAKETODAY.
the class ServerSentEventHttpMessageWriterTests method writePojoWithPrettyPrint.
@ParameterizedDataBufferAllocatingTest
// SPR-14899
void writePojoWithPrettyPrint(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().indentOutput(true).build();
this.messageWriter = new ServerSentEventHttpMessageWriter(new Jackson2JsonEncoder(mapper));
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
Flux<Pojo> source = Flux.just(new Pojo("foofoo", "barbar"), new Pojo("foofoofoo", "barbarbar"));
testWrite(source, outputMessage, Pojo.class);
StepVerifier.create(outputMessage.getBody()).consumeNextWith(stringConsumer("data:")).consumeNextWith(stringConsumer("{\n" + "data: \"foo\" : \"foofoo\",\n" + "data: \"bar\" : \"barbar\"\n" + "data:}")).consumeNextWith(stringConsumer("\n\n")).consumeNextWith(stringConsumer("data:")).consumeNextWith(stringConsumer("{\n" + "data: \"foo\" : \"foofoofoo\",\n" + "data: \"bar\" : \"barbarbar\"\n" + "data:}")).consumeNextWith(stringConsumer("\n\n")).expectComplete().verify();
}
use of cn.taketoday.http.server.reactive.MockServerHttpResponse in project today-framework by TAKETODAY.
the class ServerSentEventHttpMessageWriterTests method writeString.
@ParameterizedDataBufferAllocatingTest
void writeString(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
Flux<String> source = Flux.just("foo", "bar");
testWrite(source, outputMessage, String.class);
StepVerifier.create(outputMessage.getBody()).consumeNextWith(stringConsumer("data:foo\n\n")).consumeNextWith(stringConsumer("data:bar\n\n")).expectComplete().verify();
}
use of cn.taketoday.http.server.reactive.MockServerHttpResponse in project today-framework by TAKETODAY.
the class ServerSentEventHttpMessageWriterTests method writeMultiLineString.
@ParameterizedDataBufferAllocatingTest
void writeMultiLineString(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
Flux<String> source = Flux.just("foo\nbar", "foo\nbaz");
testWrite(source, outputMessage, String.class);
StepVerifier.create(outputMessage.getBody()).consumeNextWith(stringConsumer("data:foo\ndata:bar\n\n")).consumeNextWith(stringConsumer("data:foo\ndata:baz\n\n")).expectComplete().verify();
}
Aggregations