Created
December 21, 2017 19:55
-
-
Save Jotschi/76ba42e7dc66a4a280b1323599152364 to your computer and use it in GitHub Desktop.
Vert.x 3.5.0 RxJava2 PumpTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.Assert.assertEquals; | |
import java.io.File; | |
import java.io.IOException; | |
import org.apache.commons.io.FileUtils; | |
import org.junit.Test; | |
import io.reactivex.Observable; | |
import io.vertx.core.file.OpenOptions; | |
import io.vertx.reactivex.core.Vertx; | |
import io.vertx.reactivex.core.buffer.Buffer; | |
import io.vertx.reactivex.core.file.AsyncFile; | |
import io.vertx.reactivex.core.streams.Pump; | |
public class PumpTest { | |
@Test | |
public void testPump() throws IOException { | |
Vertx vertx = Vertx.vertx(); | |
File file = new File("target/test"); | |
file.delete(); | |
Observable<Buffer> rs = Observable.just(Buffer.buffer("test123")); | |
vertx.fileSystem().rxOpen(file.getAbsolutePath(), new OpenOptions()).map(f -> { | |
Pump pump = Pump.pump(rs, f); | |
pump.start(); | |
return f; | |
}).map(AsyncFile::flush).toCompletable().blockingAwait(); | |
assertEquals("test123", FileUtils.readFileToString(file)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment