FileServer { void startFileServing(String fileName, Receiver target) { FileReference reference = new FileReference(fileName); File file = root.getFile(reference); if (file.exists()) { pushExecutor.execute(() -> serveFile(reference, target)); } } @SuppressWarnings("WeakerAccess") // Created by dependency injection @Inject  FileServer(ConfigserverConfig configserverConfig);  FileServer(File rootDir); private  FileServer(ConnectionPool connectionPool, File rootDir); void serveFile(String fileReference, boolean downloadFromOtherSourceIfNotFound, Request request, Receiver receiver); FileDownloader downloader(); void close();  }
@Test public void requireThatWeCanReplayFile() throws IOException, InterruptedException, ExecutionException { File dir = getFileServerRootDir(); IOUtils.writeFile(dir + "/12y/f1", "dummy-data", true); CompletableFuture<byte []> content = new CompletableFuture<>(); fileServer.startFileServing("12y", new FileReceiver(content)); assertEquals(new String(content.get()), "dummy-data"); }