use of org.springframework.core.io.buffer.DefaultDataBufferFactory in project spring-framework by spring-projects.
the class DefaultServerRequestTests method bodyToFlux.
@Test
public void bodyToFlux() throws Exception {
DefaultDataBufferFactory factory = new DefaultDataBufferFactory();
DefaultDataBuffer dataBuffer = factory.wrap(ByteBuffer.wrap("foo".getBytes(StandardCharsets.UTF_8)));
Flux<DataBuffer> body = Flux.just(dataBuffer);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_PLAIN);
when(mockRequest.getHeaders()).thenReturn(httpHeaders);
when(mockRequest.getBody()).thenReturn(body);
Set<HttpMessageReader<?>> messageReaders = Collections.singleton(new DecoderHttpMessageReader<String>(new StringDecoder()));
when(mockHandlerStrategies.messageReaders()).thenReturn(messageReaders::stream);
Flux<String> resultFlux = defaultRequest.bodyToFlux(String.class);
Mono<List<String>> result = resultFlux.collectList();
assertEquals(Collections.singletonList("foo"), result.block());
}
use of org.springframework.core.io.buffer.DefaultDataBufferFactory in project spring-framework by spring-projects.
the class ResourceRegionEncoderTests method setUp.
@Before
public void setUp() {
this.encoder = new ResourceRegionEncoder();
this.bufferFactory = new DefaultDataBufferFactory();
}
Aggregations