@Test public void shouldWriteFile() { given(mockHttpServerResponse.sendFile(any(), anyLong(), anyLong(), any())).will(invocation -> { Handler<AsyncResult<Void>> handler = invocation.getArgument(3); handler.handle(Future.succeededFuture()); return mockHttpServerResponse; }); response.writeWith(Paths.get("/tmp/test"), 0, 0) .block(); verify(mockHttpServerResponse).sendFile(eq("/tmp/test"), eq(0L), eq(0L), any()); }
@Override public Mono<Void> writeWith(Path file, long position, long count) { Mono<Void> writeCompletion = Mono.create(sink -> { logger.debug("Sending file '{}' pos='{}' count='{}'", file, position, count); delegate.sendFile(file.toString(), position, count, result -> { if (result.succeeded()) { sink.success(); } else { sink.error(result.cause()); } }); }); return doCommit(() -> writeCompletion); }
VertxServerHttpResponse extends AbstractServerHttpResponse implements ZeroCopyHttpOutputMessage { @Override public Mono<Void> writeWith(Path file, long position, long count) { Mono<Void> writeCompletion = Mono.create(sink -> { logger.debug("Sending file '{}' pos='{}' count='{}'", file, position, count); delegate.sendFile(file.toString(), position, count, result -> { if (result.succeeded()) { sink.success(); } else { sink.error(result.cause()); } }); }); return doCommit(() -> writeCompletion); } }
VertxServerHttpResponse extends AbstractServerHttpResponse implements ZeroCopyHttpOutputMessage { @Override public Mono<Void> writeWith(Path file, long position, long count) { Mono<Void> writeCompletion = Mono.create(sink -> { logger.debug("Sending file '{}' pos='{}' count='{}'", file, position, count); delegate.sendFile(file.toString(), position, count, result -> { if (result.succeeded()) { sink.success(); } else { sink.error(result.cause()); } }); }); return doCommit(() -> writeCompletion); } VertxServerHttpResponse(RoutingContext context, BufferConverter bufferConverter); }
VertxServerHttpResponse extends AbstractServerHttpResponse implements ZeroCopyHttpOutputMessage { @Override public Mono<Void> writeWith(Path file, long position, long count) { Mono<Void> writeCompletion = Mono.create(sink -> { logger.debug("Sending file '{}' pos='{}' count='{}'", file, position, count); delegate.sendFile(file.toString(), position, count, result -> { if (result.succeeded()) { sink.success(); } else { sink.error(result.cause()); } }); }); return doCommit(() -> writeCompletion); } VertxServerHttpResponse(RoutingContext context, BufferConverter bufferConverter); @SuppressWarnings("unchecked") @Override T getNativeResponse(); @Override Mono<Void> writeWith(Path file, long position, long count); }
VertxServerHttpResponse extends AbstractServerHttpResponse implements ZeroCopyHttpOutputMessage { @Override public Mono<Void> writeWith(Path file, long position, long count) { Mono<Void> writeCompletion = Mono.create(sink -> { logger.debug("Sending file '{}' pos='{}' count='{}'", file, position, count); delegate.sendFile(file.toString(), position, count, result -> { if (result.succeeded()) { sink.success(); } else { sink.error(result.cause()); } }); }); return doCommit(() -> writeCompletion); } VertxServerHttpResponse(RoutingContext context, BufferConverter bufferConverter); @SuppressWarnings("unchecked") @Override T getNativeResponse(); @Override Mono<Void> writeWith(Path file, long position, long count);  }