MapConfiguration extends AbstractConfiguration { @Override public void setProperty(String key, String value) { configMap.put(key, value); } MapConfiguration();  MapConfiguration(Map<String, String> configMap);  MapConfiguration(Configuration config); @Override Configuration subset(String prefix); @Override Configuration strippedSubset(String prefix); static MapConfiguration merge(Configuration ... configs); @Override boolean isEmpty(); @Override boolean containsKey(String key); @Override void setProperty(String key, String value); @Override void clear(); @Override void clearProperty(String key); @Override Iterable<String> getKeys(); @Override String getProperty(String key); @Override String getProperty(String key, String defaultValue); @Override String toString();  }
@Test public void testSetProperty() { config.setProperty("x", "y"); assertTrue(config.containsKey("x")); assertEquals("y", config.getProperty("x")); }
@Test public void testGetBoolean() { config.setProperty("x", "true"); config.setProperty("bar", "false"); config.setProperty("bar1", "1"); config.setProperty("bar2", "yes"); config.setProperty("no", "n"); assertTrue(config.getBoolean("x")); assertTrue(config.getBoolean("bar1")); assertTrue(config.getBoolean("bar2")); assertFalse(config.getBoolean("bar")); assertFalse(config.getBoolean("no")); }
@Test public void testGetInteger() { config.setProperty("x", "1"); assertEquals(1, config.getInt("x")); }
@Test public void testGetIntWithDefault() { config.setProperty("threshold", "10"); assertEquals(5, config.getInt("nothere", 5)); assertEquals(10, config.getInt("threshold", 5)); }
@Test public void testGetLong() { config.setProperty("x", "1"); assertEquals(1L, config.getLong("x")); }
@Test public void testGetString() { config.setProperty("x", "y"); assertEquals("y", config.getString("x")); }
@Test public void testGetStringTrimsByDefault() { config.setProperty("x", "\t y \t"); assertEquals("y", config.getString("x")); }
@Test public void testGetStringTrims() { config.setProperty("x", "\t y \t"); assertEquals("y", config.getString("x", null, TrimMode.TRIM)); }
@Test public void testGetStringWithNoTrim() { config.setProperty("x", "\t y \t"); assertEquals("\t y \t", config.getString("x", null, TrimMode.NO_TRIM)); }
@Test public void testGetList() { config.setProperty("x", "a, b, c"); assertEquals(Arrays.asList("a", "b", "c"), config.getList("x")); }
@Test public void testGetSet() { config.setProperty("x", " a , b , c "); Set<String> expected = new HashSet<>(Arrays.asList("a", "b", "c")); assertEquals(expected, config.getSet("x")); }
@Test public void testTrimSpaces() { config.setProperty("good", "good"); config.setProperty("bad", " bad "); assertEquals("good", config.getString("good")); assertEquals("bad", config.getString("bad")); }