PropertyUtil { public static Set<?> getPropertiesValues(String propertyName, String keyPrefix) { Properties localProps = loadProperties(propertyName); if (localProps == null) { return null; } Enumeration<String> keyEnum = getPropertyNames(localProps, keyPrefix); if (keyEnum == null) { return null; } return getPropertiesValues(localProps, keyEnum); }  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 testGetPropertiesValuesString01() throws Exception { String input = "test"; String key = "file"; Set<?> result = PropertyUtil.getPropertiesValues(input, key); assertTrue(result.contains("/tmp/test")); }
@Test public void testGetPropertiesValuesString02() throws Exception { String input = "test"; String key = "code"; Set<?> result = PropertyUtil.getPropertiesValues(input, key); assertTrue(result.contains("select values01,values01,values01 " + "from table_kamoTest where Key1 between ? and ?")); assertTrue(result.contains("\u660e\u6cbb")); assertTrue(result.contains("\u662d\u548c")); assertTrue(result.contains("\u6c5f\u6238")); assertTrue(result.contains("\u5e73\u6210")); assertTrue(result.contains("\u5927\u6b63")); }
@Test public void testGetPropertiesValuesString03() throws Exception { String input = "test"; String key = null; Set<?> result = PropertyUtil.getPropertiesValues(input, key); assertNull(result); }
@Test public void testGetPropertiesValuesString04() throws Exception { String input = null; String key = "file"; Set<?> result = PropertyUtil.getPropertiesValues(input, key); assertNull(result); }
@Test public void testGetPropertiesValuesString05() throws Exception { String input = "test_message_01"; String key = "file"; Set<?> result = PropertyUtil.getPropertiesValues(input, key); assertTrue(result.isEmpty()); }
@Test public void testGetPropertiesValuesString06() throws Exception { String input = ""; String key = "file"; Set<?> result = PropertyUtil.getPropertiesValues(input, key); assertNull(result); }
@Test public void testGetPropertiesValuesString07() throws Exception { String input = "test_message_01"; String key = ""; Set<?> result = PropertyUtil.getPropertiesValues(input, key); assertTrue(result.contains("{0}デフォルトメッセージ")); assertTrue(result.contains("例外メッセージ")); assertTrue(result.contains("")); }
@Test public void testGetPropertiesValuesString08() throws Exception { String input = "test"; String key = "property.test004"; Set<?> result = PropertyUtil.getPropertiesValues(input, key); assertTrue(result.contains("testB")); assertFalse(result.contains("testA")); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues01() throws Exception { String key1 = "SystemExceptionHandlerTest.key"; String value1 = "{0}message"; Properties input = new Properties(); input.setProperty(key1, value1); @SuppressWarnings("rawtypes") Enumeration em = new StringTokenizer("SystemExceptionHandlerTest.key"); Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertTrue(result.contains("{0}message")); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues02() throws Exception { String key1 = "property.test001.id.0"; String value1 = "test"; String key2 = "property.test002.id.0"; String value2 = "test0"; String key3 = "property.test002.id.1"; String value3 = "test1"; Properties input = new Properties(); input.setProperty(key1, value1); input.setProperty(key2, value2); input.setProperty(key3, value3); @SuppressWarnings("rawtypes") Enumeration em = new StringTokenizer("property.test001.id.0 property.test002.id.0 property.test002.id.1"); Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertTrue(result.contains("test0")); assertTrue(result.contains("test1")); assertTrue(result.contains("test")); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues03() throws Exception { String key1 = "property.test001.id.0"; String value1 = "test"; String key2 = "property.test002.id.0"; String value2 = "test0"; String key3 = "property.test003.id.0"; String value3 = ""; Properties input = new Properties(); input.setProperty(key1, value1); input.setProperty(key2, value2); input.setProperty(key3, value3); @SuppressWarnings("rawtypes") Enumeration em = new StringTokenizer("property.test001.id.0 property.test002.id.0 property.test003.id.0"); Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertTrue(result.contains("test0")); assertTrue(result.contains("test")); assertTrue(result.contains("")); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues04() throws Exception { Properties input = null; @SuppressWarnings("rawtypes") Enumeration em = new StringTokenizer("property.test001.id.0"); Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertNull(result); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues05() throws Exception { Properties input = new Properties(); String key1 = "property.test001.id.0"; String value1 = "test"; input.setProperty(key1, value1); @SuppressWarnings("rawtypes") Enumeration em = null; Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertNull(result); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues06() throws Exception { Properties input = new Properties(); @SuppressWarnings("rawtypes") Enumeration em = new StringTokenizer("property.test001.id.0"); Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertTrue(result.contains(null)); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues07() throws Exception { Properties input = new Properties(); String key1 = "property.test001.id.0"; String value1 = "test"; input.setProperty(key1, value1); @SuppressWarnings("rawtypes") Enumeration em = new StringTokenizer(""); Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertTrue(result.isEmpty()); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues08() throws Exception { Properties input = new Properties(); String key1 = "property.test004.id.0"; String value1 = "testA"; String key2 = "property.test004.id.0"; String value2 = "testB"; input.setProperty(key1, value1); input.setProperty(key2, value2); @SuppressWarnings("rawtypes") Enumeration em = new StringTokenizer("property.test004.id.0"); Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertTrue(result.contains("testB")); assertFalse(result.contains("testA")); }
@SuppressWarnings("unchecked") @Test public void testGetPropertiesValues09() throws Exception { Properties input = new Properties(); String key1 = "property.test001.id.0"; String value1 = "test"; input.setProperty(key1, value1); @SuppressWarnings("rawtypes") Enumeration em = new StringTokenizer("property.test004.id.0"); Set<?> result = PropertyUtil.getPropertiesValues(input, em); assertTrue(result.contains(null)); assertFalse(result.contains("test")); }