@Test public void testResolveString() { FromSystemProperties resolver = new FromSystemProperties(); assertNotEquals("%sysprop{java.version}", resolver.resolve("%sysprop{java.version}")); assertNotEquals("%sysprop{java.version}%sysprop{java.version}", resolver.resolve("%sysprop{java.version}%sysprop{java.version}")); assertEquals("hello", resolver.resolve("hello")); assertEquals("not.a.system.property", resolver.resolve("%sysprop{not.a.system.property}")); assertNull(resolver.resolve(null)); }
@Override public String resolve(String s) { if (s == null) { return null; } String result = s; log.trace("Resolving {} from system properties", s); Matcher m = resolverPattern.matcher(s); Map<String, String> properties = asMap(System.getProperties()); while (m.matches()) { String key = m.group(1); log.trace("Resolve on {} ", key); String syspropValue = resolve(key, properties); String toReplace = "%sysprop{" + key + "}"; result = result.replace(toReplace, syspropValue); m = resolverPattern.matcher(result); } return result; }
FromSystemProperties extends ResolverImp { @Override public String resolve(String s) { if (s == null) { return null; } String result = s; log.trace("Resolving {} from system properties", s); Matcher m = resolverPattern.matcher(s); Map<String, String> properties = asMap(System.getProperties()); while (m.matches()) { String key = m.group(1); log.trace("Resolve on {} ", key); String syspropValue = resolve(key, properties); String toReplace = "%sysprop{" + key + "}"; result = result.replace(toReplace, syspropValue); m = resolverPattern.matcher(result); } return result; } }
FromSystemProperties extends ResolverImp { @Override public String resolve(String s) { if (s == null) { return null; } String result = s; log.trace("Resolving {} from system properties", s); Matcher m = resolverPattern.matcher(s); Map<String, String> properties = asMap(System.getProperties()); while (m.matches()) { String key = m.group(1); log.trace("Resolve on {} ", key); String syspropValue = resolve(key, properties); String toReplace = "%sysprop{" + key + "}"; result = result.replace(toReplace, syspropValue); m = resolverPattern.matcher(result); } return result; } FromSystemProperties(); }
FromSystemProperties extends ResolverImp { @Override public String resolve(String s) { if (s == null) { return null; } String result = s; log.trace("Resolving {} from system properties", s); Matcher m = resolverPattern.matcher(s); Map<String, String> properties = asMap(System.getProperties()); while (m.matches()) { String key = m.group(1); log.trace("Resolve on {} ", key); String syspropValue = resolve(key, properties); String toReplace = "%sysprop{" + key + "}"; result = result.replace(toReplace, syspropValue); m = resolverPattern.matcher(result); } return result; } FromSystemProperties(); @Override String resolve(String s); @Override boolean canHandle(String value); }
FromSystemProperties extends ResolverImp { @Override public String resolve(String s) { if (s == null) { return null; } String result = s; log.trace("Resolving {} from system properties", s); Matcher m = resolverPattern.matcher(s); Map<String, String> properties = asMap(System.getProperties()); while (m.matches()) { String key = m.group(1); log.trace("Resolve on {} ", key); String syspropValue = resolve(key, properties); String toReplace = "%sysprop{" + key + "}"; result = result.replace(toReplace, syspropValue); m = resolverPattern.matcher(result); } return result; } FromSystemProperties(); @Override String resolve(String s); @Override boolean canHandle(String value);  }