/** * Create a new builder for this object. * * @return A new builder for this object. */ public static ConfigMemoryStoreBuilder create() { return new ConfigMemoryStoreBuilder(); }
@Override /* ContextBuilder */ public ConfigMemoryStore build() { return new ConfigMemoryStore(getPropertyStore()); } }
private static ConfigStore initStore(String name, String...contents) { return ConfigMemoryStore.create().build().update(name, contents); } }
private static ConfigStore initStore(String name, String...contents) { return ConfigMemoryStore.create().build().update(name, contents); }
/** * Create a new builder for this object. * * @return A new builder for this object. */ public static ConfigMemoryStoreBuilder create() { return new ConfigMemoryStoreBuilder(); }
@Test public void testNoFile() throws Exception { ConfigMemoryStore fs = ConfigMemoryStore.create().build(); assertEquals("", fs.read("X")); }
@Override /* ContextBuilder */ public ConfigMemoryStore build() { return new ConfigMemoryStore(getPropertyStore()); } }
/** * Create a new builder for this object. * * @return A new builder for this object. */ public static ConfigMemoryStoreBuilder create() { return new ConfigMemoryStoreBuilder(); }
@Test public void testUpdate() throws Exception { ConfigMemoryStore fs = ConfigMemoryStore.create().build(); final CountDownLatch latch = new CountDownLatch(2); fs.register("X", new ConfigStoreListener() { @Override public void onChange(String contents) { if ("xxx".equals(contents)) latch.countDown(); } }); fs.register("Y", new ConfigStoreListener() { @Override public void onChange(String contents) { if ("yyy".equals(contents)) latch.countDown(); } }); fs.update("X", "xxx"); fs.update("Y", "yyy"); if (! latch.await(10, TimeUnit.SECONDS)) throw new Exception("CountDownLatch never reached zero."); }
@Override /* ContextBuilder */ public ConfigMemoryStore build() { return new ConfigMemoryStore(getPropertyStore()); } }
@Override /* Context */ public ConfigMemoryStoreBuilder builder() { return new ConfigMemoryStoreBuilder(getPropertyStore()); }
@Test public void testNonExistentConfig() throws Exception { ConfigStore s = ConfigMemoryStore.create().build(); ConfigMap cm = s.getMap("Foo.cfg"); assertEquals("", cm.toString()); }
@Override /* Context */ public ConfigMemoryStoreBuilder builder() { return new ConfigMemoryStoreBuilder(getPropertyStore()); }
@Test public void testSimpleCreate() throws Exception { ConfigMemoryStore fs = ConfigMemoryStore.create().build(); assertNull(fs.write("X", null, "foo")); assertEquals("foo", fs.read("X")); }
@Override /* Context */ public ConfigMemoryStoreBuilder builder() { return new ConfigMemoryStoreBuilder(getPropertyStore()); }
@Test public void importNotFound() throws Exception { ConfigMemoryStore ms = ConfigMemoryStore.create().build(); ms.write("B", "", "<A>\nx=1"); Config c = Config.create("B").store(ms).build(); assertEquals("1", c.getString("x")); }
@Test public void overlappingSectionsAndValues() throws Exception { ConfigMemoryStore ms = ConfigMemoryStore.create().build(); ms.write("A", "", "x=1\n[A]\na1=1"); ms.write("B", "", "<A>\n[A]\na1=2"); Config c = Config.create("B").store(ms).build(); assertEquals("2", c.getString("A/a1")); }
@Test public void nestedImportsLoop() throws Exception { // This shouldn't blow up. ConfigMemoryStore ms = ConfigMemoryStore.create().build(); ms.write("A1", "", "<A2>\nx=1"); ms.write("A2", "", "<A1>\ny=2"); ms.write("B", "", "<A2>"); try { Config.create("B").store(ms).build(); fail("Exception expected."); } catch (Exception e) { // OK } }
@Test public void overlappingSections() throws Exception { ConfigMemoryStore ms = ConfigMemoryStore.create().build(); ms.write("A", "", "x=1\n[A]\na1=1"); ms.write("B", "", "<A>\n[A]\na2=2"); Config c = Config.create("B").store(ms).build(); assertEquals("1", c.getString("A/a1")); assertEquals("2", c.getString("A/a2")); }
@Test public void overlappingSectionsImportAtEnd() throws Exception { ConfigMemoryStore ms = ConfigMemoryStore.create().build(); ms.write("A", "", "x=1\n[A]\na1=1"); ms.write("B", "", "[A]\na2=2\n<A>"); Config c = Config.create("B").store(ms).build(); assertEquals("1", c.getString("A/a1")); assertEquals("2", c.getString("A/a2")); }