### Question:
PropertyUtil { public static String getProperty(String str) { String value = ""; String defaultValue = ""; if( !StringUtils.isNullOrEmpty(str) && str.startsWith("${") && str.endsWith("}") ) { String variable = str.trim().substring(2, str.length()-1); if( variable.contains(":") ) { defaultValue = variable.substring(variable.indexOf(":")+1); variable = variable.substring(0, variable.indexOf(":") ); } value = System.getProperty(variable); if(StringUtils.isNullOrEmpty(value)) { value = defaultValue; } return value; } else { return str; } }  static String getProperty(String str);  }### Answer:
@Test public void testProperty() { Assert.assertEquals("1", PropertyUtil.getProperty("${test:1}")); Assert.assertEquals("", PropertyUtil.getProperty("${test}")); System.setProperty("test", "2"); Assert.assertEquals("2", PropertyUtil.getProperty("${test}")); Assert.assertEquals("2", PropertyUtil.getProperty("${test:1}")); }