@Test public void testWritable() throws IOException { assertTrue(true); Settings settings = SettingsBuilder.createDefault().build(); assertNotNull(settings.getString("foo")); assertEquals("bar", settings.getString("foo")); assertNotNull(settings.getString("os.name")); assertEquals(System.getProperty("os.name"), settings.getString("os.name")); WritableSettings w = new WritableSettings("whoo", settings); w.setString("wow", "its writable"); assertNotNull(w.getString("wow")); assertEquals("its writable", w.getString("wow")); assertEquals("x", w.getString("wubbity", "x")); assertEquals(23, w.getInt("age", -1)); assertEquals(23L, w.getLong("age", -1L)); assertNull(settings.getString("wow")); assertEquals(System.getProperty("os.name"), w.getString("os.name")); w.setString("os.name", "BeOS"); assertEquals("BeOS", w.getString("os.name")); w.clear("os.name"); assertNull(w.getString("os.name")); w.setString("os.name", "OS/2"); assertEquals("OS/2", w.getString("os.name")); }
@Test public void test() throws IOException { Settings config = new SettingsBuilder() .addDefaultsFromClasspath() .addGeneratedDefaultsFromClasspath() .build(); assertNotNull(config); assertTrue(config.getBoolean("auto")); assertEquals("bar", config.getString("foo")); assertFalse(config.getBoolean("hey", false)); assertNull(config.getString("Nothing!")); assertEquals("whoopty", config.getString("whee")); }
@Test public void testLayered() throws IOException { com.mastfrog.settings.Settings config = new SettingsBuilder() .addDefaultsFromClasspath() .addGeneratedDefaultsFromClasspath() .build(); Settings config2 = new SettingsBuilder() .add(config) .add("com/mastfrog/configuration/others.properties") .add("com/mastfrog/configuration/more.properties") .build(); assertEquals("oobiedoobie", config2.getString("whee")); }