use of io.vertx.core.file.AsyncFile in project vertx-web by vert-x3.
the class InterceptorTest method testMutateCodecInterceptor.
@Test
public void testMutateCodecInterceptor() throws Exception {
server.requestHandler(req -> req.response().end("foo!"));
startServer();
File f = Files.createTempFile("vertx", ".dat").toFile();
assertTrue(f.delete());
AsyncFile foo = vertx.fileSystem().openBlocking(f.getAbsolutePath(), new OpenOptions().setSync(true).setTruncateExisting(true));
client.addInterceptor(this::handleMutateCodec);
HttpRequest<Void> builder = client.get("/somepath").as(BodyCodec.pipe(foo));
builder.send(onSuccess(resp -> {
foo.write(Buffer.buffer("bar!"));
foo.close(onSuccess(v -> {
assertEquals("bar!", vertx.fileSystem().readFileBlocking(f.getAbsolutePath()).toString());
testComplete();
}));
}));
await();
if (f.exists()) {
f.delete();
}
}
Aggregations