rucko24 / EspFlow

Simple UI for esp32+ and esp8266 utilities
Apache License 2.0
3 stars 1 forks source link

leer line by line con DataBufferUtils #21

Closed rucko24 closed 2 months ago

rucko24 commented 3 months ago
@Test
@DisplayName("Leyendo line a linea un inputStream decodificado para poder leer bien, sin mapping extraños")
void testRead() {
    final var countDownLatch = new CountDownLatch(1);
    DataBufferUtils.readInputStream(() ->  this.commandService.execute(getIpAddressInfo())
            .getInputStream(),  DefaultDataBufferFactory.sharedInstance, FileCopyUtils.BUFFER_SIZE)
            .transformDeferred(this::stringDecoder)
            .delayElements(Duration.ofSeconds(1))
            .log()
            .doOnTerminate(countDownLatch::countDown)
            .subscribe();
    try {
        countDownLatch.await();
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
private Flux<String> stringDecoder(Flux<DataBuffer> dataBuffer) {
    return StringDecoder.allMimeTypes().decode(dataBuffer,null,  null,  null);
}