/** * Replaces this {@link ByteStream} with a new {@link ByteStream}. * * Consumes this stream by safely disposing each {@link Buffer} object * and then emits {@link Buffer} objects from the provided * {@code byteStream}. * * @param byteStream a replacement byte stream. * @return a {@link ByteStream} object. */ public ByteStream replaceWith(ByteStream byteStream) { return this.drop().concat(byteStream); }
@Test public void concatenatesStreams() { ByteStream stream = new ByteStream(Flux.just(buf1, buf2)) .concat(new ByteStream(Flux.just(buf3))); StepVerifier.create(stream) .expectNext(buf1) .expectNext(buf2) .expectNext(buf3) .verifyComplete(); }