ProvidenceConfigSupplier extends UpdatingConfigSupplier<Message, Field> { @Override public String getName() { return "ProvidenceConfig{" + configFile.getName() + "}"; } ProvidenceConfigSupplier(@Nonnull File configFile,
                                    @Nullable ConfigSupplier<Message, Field> parentSupplier,
                                    @Nullable FileWatcher fileWatcher,
                                    @Nonnull ProvidenceConfigParser configParser,
                                    @Nonnull Clock clock); @Override String toString(); @Override String getName();  }
@Test public void testReferencedFilesOnUpdatesFromCanonicalFiles() throws IOException { SimpleTypeRegistry registry = new SimpleTypeRegistry(); registry.registerRecursively(Service.kDescriptor); watcher = new FileWatcher(); parser = new ProvidenceConfigParser(registry, true); File service = new File(tmp.getRoot(), "service.config").getAbsoluteFile(); File include = new File(tmp.getRoot(), "include.config").getAbsoluteFile(); File v1 = tmp.newFolder("..dist", "v1").getAbsoluteFile(); File service1 = new File(v1, "service.config").getAbsoluteFile(); File include1 = new File(v1, "include.config").getAbsoluteFile(); File v2 = tmp.newFolder("..dist", "v2").getAbsoluteFile(); File service2 = new File(v2, "service.config").getAbsoluteFile(); File include2 = new File(v2, "include.config").getAbsoluteFile(); writeContentTo("config.ServicePort {\n" + " port = 8080\n" + "}\n", include1); writeContentTo("include \"include.config\" as inc\n" + "config.Service {\n" + " name = \"test\"\n" + " http = inc\n" + "}\n", service1); writeContentTo("config.ServicePort {\n" + " port = 80\n" + "}\n", include2); writeContentTo("include \"include.config\" as inc\n" + "config.Service {\n" + " name = \"other\"\n" + " http = inc\n" + "}\n", service2); Files.createSymbolicLink(service.toPath(), service1.toPath()); Files.createSymbolicLink(include.toPath(), include1.toPath()); ProvidenceConfigSupplier<Service,Service._Field> config = new ProvidenceConfigSupplier<>(service, null, watcher, parser, clock); Service serviceConfig = config.get(); AtomicReference<Service> serviceRef = new AtomicReference<>(serviceConfig); assertThat(serviceConfig.getName(), is("test")); assertThat(serviceConfig.getHttp().getPort(), is((short) 8080)); AtomicBoolean updated = new AtomicBoolean(); ConfigListener<Service,Service._Field> listener = cf -> { serviceRef.set(cf); updated.set(true); }; config.addListener(listener); File tmpFile = new File(tmp.getRoot(), "..tmp"); Files.createSymbolicLink(tmpFile.toPath(), service2.toPath()); Files.move(tmpFile.toPath(), service.toPath(), StandardCopyOption.REPLACE_EXISTING); waitAtMost(Duration.ONE_SECOND).untilTrue(updated); serviceConfig = serviceRef.get(); assertThat(serviceConfig.getName(), is("other")); assertThat(serviceConfig.getHttp().getPort(), is((short) 80)); }