FileServer { public FileDownloader downloader() { return downloader; } @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 requireThatDifferentNumberOfConfigServersWork() throws IOException { ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder() .configServerDBDir(temporaryFolder.newFolder("serverdb").getAbsolutePath()) .configDefinitionsDir(temporaryFolder.newFolder("configdefinitions").getAbsolutePath()); FileServer fileServer = createFileServer(builder); assertEquals(0, fileServer.downloader().fileReferenceDownloader().connectionPool().getSize()); List<ConfigserverConfig.Zookeeperserver.Builder> servers = new ArrayList<>(); ConfigserverConfig.Zookeeperserver.Builder serverBuilder = new ConfigserverConfig.Zookeeperserver.Builder(); serverBuilder.hostname(HostName.getLocalhost()); serverBuilder.port(123456); servers.add(serverBuilder); builder.zookeeperserver(servers); fileServer = createFileServer(builder); assertEquals(0, fileServer.downloader().fileReferenceDownloader().connectionPool().getSize()); ConfigserverConfig.Zookeeperserver.Builder serverBuilder2 = new ConfigserverConfig.Zookeeperserver.Builder(); serverBuilder2.hostname("bar"); serverBuilder2.port(123456); servers.add(serverBuilder2); builder.zookeeperserver(servers); fileServer = createFileServer(builder); assertEquals(1, fileServer.downloader().fileReferenceDownloader().connectionPool().getSize()); }