public String get (String name) { return get(name, ""); } public int getInt (String name) {
public boolean getBoolean (String name) { String v = get (name, "false").trim(); return v.equalsIgnoreCase("true") || v.equalsIgnoreCase("yes"); } public boolean getBoolean (String name, boolean def) {
public boolean getBoolean (String name, boolean def) { String v = get (name); return v.length() == 0 ? def : v.equalsIgnoreCase("true") || v.equalsIgnoreCase("yes"); } public void load(String filename)
@Test public void testGet() throws Throwable { String result = new SimpleConfiguration(new Properties()).get("testSimpleConfigurationName", null); assertNull("result", result); }
@Test public void testGet1() throws Throwable { String result = new SimpleConfiguration(new Properties()).get("testSimpleConfigurationName", "testSimpleConfigurationDef"); assertEquals("result", "testSimpleConfigurationDef", result); }
@Test public void testGet3() throws Throwable { String result = new SimpleConfiguration(new Properties()).get("testSimpleConfigurationName"); assertEquals("result", "", result); }
@Test public void testGet2() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("testString", ""); String result = simpleConfiguration.get("testString", "testSimpleConfigurationDef"); assertEquals("result", "", result); }
@Test public void testGet4() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("E", ""); String result = simpleConfiguration.get("E"); assertEquals("result", "", result); }
@Test public void testGetThrowsNullPointerException1() throws Throwable { try { new SimpleConfiguration((Properties) null).get("testSimpleConfigurationName"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testGetThrowsNullPointerException() throws Throwable { try { new SimpleConfiguration((Properties) null).get("testSimpleConfigurationName", "testSimpleConfigurationDef"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testSerializable() throws Throwable { SimpleConfiguration cfg = new SimpleConfiguration(); cfg.put ("A", "The Quick Brown Fox Jumps Over The Lazy Dog"); Configuration cfg1 = Serializer.serializeDeserialize(cfg); assertEquals("cfg.A should equal cfg1.A", cfg.get("A"), cfg1.get("A")); assertEquals ("cfg should equal cfg1", cfg, cfg1); } }