### Question:
StrUtil { public static String replaceVariable(final String param) { Map<String, String> mapping = new HashMap<String, String>(); Matcher matcher = VARIABLE_PATTERN.matcher(param); while (matcher.find()) { String variable = matcher.group(2); String value = System.getProperty(variable); if (StringUtils.isBlank(value)) { value = matcher.group(); } mapping.put(matcher.group(), value); } String retString = param; for (final String key : mapping.keySet()) { retString = retString.replace(key, mapping.get(key)); } return retString; } private  StrUtil(); static String stringify(long byteNumber); static String replaceVariable(final String param); static String compressMiddle(String s, int headLength, int tailLength);  }### Answer:
@Test public void testReplaceVariable() { assertEquals("foo\\$foo\\$", replaceVariable("foo\\$foo\\$")); }
@Test public void testReplaceVariable() throws Exception { Properties valuesMap = System.getProperties(); valuesMap.put("animal", "quick brown fox"); valuesMap.put("target", "lazy dog"); String templateString = "The $animal jumped over the ${target}."; String resolvedString =StrUtil.replaceVariable(templateString); System.out.println(resolvedString); assertEquals(resolvedString, "The quick brown fox jumped over the lazy dog."); }