@Test public void testFactory() throws Exception { if (System.getProperty("os.name").toLowerCase().contains("mac")) { return; } File dir = Files.createTempDir(); File f1 = dir.toPath().resolve("f1").toFile(); File f2 = dir.toPath().resolve("f2").toFile(); File f3 = dir.toPath().resolve("f3").toFile(); try { FileUpdateWatcher.getInstance().start(); TestHelper.writeFile(newBytes("a=1"), f1); TestHelper.writeFile(newBytes("a=2\nb=2"), f2); LocalConfigFactory factory = new LocalConfigFactory(dir.toPath()); IChangeableConfig c1 = factory.getConfig("f1"); IChangeableConfig merge = factory.getConfig("f1,f2,f3"); assertThat(c1.getInt("a"), is(1)); assertThat(merge.getInt("a"), is(1)); assertThat(merge.getInt("b"), is(2)); final AtomicInteger num = new AtomicInteger(0); merge.addListener(new IChangeListener() { @Override public void changed(IConfig config) { LOG.info("{} changed", config.getName()); num.incrementAndGet(); } }, false); byte[] bytes = newBytes("a=3"); TestHelper.writeFile(bytes, f1); assertArrayEquals(bytes, Files.toByteArray(f1)); TestHelper.busyWait(num); assertThat(merge.getInt("a"), is(3)); num.set(0); TestHelper.writeFile(newBytes("c=4"), f3); TestHelper.busyWait(num); assertThat(merge.getInt("c"), is(4)); } finally { TestHelper.deleteFile(f1); TestHelper.deleteFile(f2); TestHelper.deleteFile(f3); TestHelper.deleteFile(dir); } }
public static LocalConfigFactory getInstance() { return LazyHolder.instance; }
LocalConfigFactory extends AbstractConfigFactory { public static LocalConfigFactory getInstance() { return LazyHolder.instance; } }
LocalConfigFactory extends AbstractConfigFactory { public static LocalConfigFactory getInstance() { return LazyHolder.instance; } LocalConfigFactory(Path localConfigPath); }
LocalConfigFactory extends AbstractConfigFactory { public static LocalConfigFactory getInstance() { return LazyHolder.instance; } LocalConfigFactory(Path localConfigPath); static LocalConfigFactory getInstance(); Path getPath(); }
LocalConfigFactory extends AbstractConfigFactory { public static LocalConfigFactory getInstance() { return LazyHolder.instance; } LocalConfigFactory(Path localConfigPath); static LocalConfigFactory getInstance(); Path getPath();  }