PropertyUtil { public static Enumeration<String> getPropertyNames() { return Collections.enumeration(props.keySet()); }  static synchronized void addPropertyFile(String name); static String getProperty(String key); static String getProperty(String key, String defaultValue); static Enumeration<String> getPropertyNames(); static Enumeration<String> getPropertyNames(String keyPrefix); static Set<?> getPropertiesValues(String propertyName,
            String keyPrefix); static Enumeration<String> getPropertyNames(Properties localProps,
            String keyPrefix); static Set<String> getPropertiesValues(Properties localProps,
            Enumeration<String> propertyNames); static Properties loadProperties(String propertyName); static final String DEFAULT_PROPERTY_FILE; }
@Test public void testGetPropertyNames01() throws Exception { Enumeration<String> en = PropertyUtil.getPropertyNames(); Vector<String> v = new Vector<String>(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); v.add(key); } assertTrue(v.contains("system.name")); assertTrue(v.contains("property.test001.id.0")); assertTrue(v.contains("property.test002.id.0")); assertTrue(v.contains("property.test002.id.1")); assertTrue(v.contains("property.test002.id.2")); assertTrue(v.contains("property.test003.id.0")); assertTrue(v.contains("property.test004.id.0")); assertTrue(v.contains("property.test004.id.0")); assertTrue(v.contains("@property.test0")); assertTrue(v.contains("fileutiltest.dir.base")); assertTrue(v.contains("property.test100.id.0")); assertTrue(v.contains("property.test005")); assertTrue(v.contains("property.test006.id.0")); assertTrue(v.contains("property.test007.id.0")); assertTrue(v.contains("property.test008.id.0")); assertTrue(v.contains("property.test009.id.0")); assertTrue(v.contains("codelist.gengo1.define.1")); assertTrue(v.contains("codelist.gengo1.define.2")); assertTrue(v.contains("codelist.gengo1.define.3")); assertTrue(v.contains("codelist.gengo2.define.1")); assertTrue(v.contains("codelist.gengo2.define.2")); assertTrue(v.contains("codelist.sql1.sql.0")); }
@Test public void testGetPropertyNamesString01() throws Exception { String input1 = "property.test001.id"; Enumeration<String> enume = PropertyUtil.getPropertyNames(input1); assertEquals("property.test001.id.0", enume.nextElement()); assertFalse(enume.hasMoreElements()); }
@Test public void testGetPropertyNamesString02() throws Exception { String input1 = "property.test999.id"; Enumeration<String> enume = PropertyUtil.getPropertyNames(input1); assertFalse(enume.hasMoreElements()); }
@Test public void testGetPropertyNamesString03() throws Exception { String input1 = "property.test002.id"; Enumeration<String> enume = PropertyUtil.getPropertyNames(input1); assertEquals("property.test002.id.0", enume.nextElement()); assertEquals("property.test002.id.1", enume.nextElement()); assertEquals("property.test002.id.2", enume.nextElement()); assertFalse(enume.hasMoreElements()); }
@Test public void testGetPropertyNamesString04() throws Exception { String input1 = null; try { PropertyUtil.getPropertyNames(input1); fail(); } catch (NullPointerException e) { return; } }
@SuppressWarnings("unchecked") @Test public void testGetPropertyNamesString05() throws Exception { String input1 = ""; Enumeration<String> actualEnum = PropertyUtil.getPropertyNames(input1); Field field = PropertyUtil.class.getDeclaredField("props"); field.setAccessible(true); Map<String, String> expectedProps = (Map<String, String>) field.get( PropertyUtil.class); Enumeration<String> expectedEnum = Collections.enumeration(expectedProps .keySet()); while (expectedEnum.hasMoreElements()) { String actualStr = (String) actualEnum.nextElement(); String expectedStr = (String) expectedEnum.nextElement(); assertEquals(expectedStr, actualStr); } }
@Test public void testGetPropertyNamesString06() throws Exception { String input1 = "property.test004.id"; Enumeration<String> enume = PropertyUtil.getPropertyNames(input1); assertEquals("property.test004.id.0", enume.nextElement()); assertFalse(enume.hasMoreElements()); }
@Test public void testGetPropertyNamesPropertiesString01() throws Exception { String key1 = "SystemExceptionHandlerTest.key"; String value1 = "{0}message"; Properties input = new Properties(); input.setProperty(key1, value1); String keyprefix = "System"; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); Set<String> set = new HashSet<String>(); set.add("SystemExceptionHandlerTest.key"); assertTrue(set.contains(result.nextElement())); assertFalse(result.hasMoreElements()); }
@Test public void testGetPropertyNamesPropertiesString02() throws Exception { String key1 = "SystemExceptionHandlerTest.key"; String value1 = "{0}message"; String key2 = "property.test004.id.0"; String value2 = "testA"; Properties input = new Properties(); input.setProperty(key1, value1); input.setProperty(key2, value2); String keyprefix = "System"; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); Set<String> set = new HashSet<String>(); set.add("SystemExceptionHandlerTest.key"); assertTrue(set.contains(result.nextElement())); assertFalse(result.hasMoreElements()); }
@Test public void testGetPropertyNamesPropertiesString03() throws Exception { String key1 = "SystemExceptionHandlerTest.key"; String value1 = "{0}message"; String key2 = "property.test002.id.2"; String value2 = "test2"; String key3 = "property.test004.id.0"; String value3 = "testB"; Properties input = new Properties(); input.setProperty(key1, value1); input.setProperty(key2, value2); input.setProperty(key3, value3); String keyprefix = "property"; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); Set<String> set = new HashSet<String>(); set.add("property.test002.id.2"); set.add("property.test004.id.0"); assertTrue(set.contains(result.nextElement())); assertTrue(set.contains(result.nextElement())); assertFalse(result.hasMoreElements()); }
@Test public void testGetPropertyNamesPropertiesString04() throws Exception { String key1 = "SystemExceptionHandlerTest.key"; String value1 = "{0}message"; String key2 = "property.test002.id.2"; String value2 = "test2"; String key3 = "property.test004.id.0"; String value3 = "testB"; Properties input = new Properties(); input.setProperty(key1, value1); input.setProperty(key2, value2); input.setProperty(key3, value3); String keyprefix = "a"; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); assertFalse(result.hasMoreElements()); }
@Test public void testGetPropertyNamesPropertiesString05() throws Exception { Properties input = null; String keyprefix = "properties"; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); assertNull(result); }
@Test public void testGetPropertyNamesPropertiesString06() throws Exception { Properties input = new Properties(); String key1 = "SystemExceptionHandlerTest.key"; String value1 = "{0}message"; input.setProperty(key1, value1); String keyprefix = null; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); assertNull(result); }
@Test public void testGetPropertyNamesPropertiesString07() throws Exception { Properties input = new Properties(); String keyprefix = "properties"; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); assertFalse(result.hasMoreElements()); }
@Test public void testGetPropertyNamesPropertiesString08() throws Exception { Properties input = new Properties(); String key1 = "property.test002.id.2"; String value1 = "test2"; String key2 = "property.test004.id.0"; String value2 = "testB"; String key3 = "property.test001.id.0"; String value3 = "test"; input.setProperty(key1, value1); input.setProperty(key2, value2); input.setProperty(key3, value3); String keyprefix = ""; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); Set<String> set = new HashSet<String>(); set.add("property.test002.id.2"); set.add("property.test004.id.0"); set.add("property.test001.id.0"); assertTrue(set.contains(result.nextElement())); assertTrue(set.contains(result.nextElement())); assertTrue(set.contains(result.nextElement())); assertFalse(result.hasMoreElements()); }
@Test public void testGetPropertyNamesPropertiesString09() throws Exception { String key1 = "SystemExceptionHandlerTest.key"; String value1 = "{0}message"; String key2 = "property.test002.id.2"; String value2 = "test2"; String key3 = "property.test004.id.0"; String value3 = "testA"; String key4 = "property.test004.id.0"; String value4 = "testB"; Properties input = new Properties(); input.setProperty(key1, value1); input.setProperty(key2, value2); input.setProperty(key3, value3); input.setProperty(key4, value4); String keyprefix = "pro"; Enumeration<String> result = PropertyUtil.getPropertyNames(input, keyprefix); Set<String> set = new HashSet<String>(); set.add("property.test002.id.2"); set.add("property.test004.id.0"); assertTrue(set.contains(result.nextElement())); assertTrue(set.contains(result.nextElement())); assertFalse(result.hasMoreElements()); }