StringPropertyReplacer { public static String replaceProperties(final String string) { return replaceProperties(string, null); }  static String replaceProperties(final String string); static String replaceProperties(final String string, final Properties props); static String replaceProperties(final String string, final Properties props, Function<String, String> filter); static final String NEWLINE; }
@Test public void testReplaceProperties() throws Exception { Properties properties = new Properties(); String value = StringPropertyReplacer.replaceProperties("${foo:bar}", properties); assertThat(value).isEqualTo("bar"); properties.put("foo", "baz"); value = StringPropertyReplacer.replaceProperties("${foo:bar}", properties); assertThat(value).isEqualTo("baz"); properties.put("foo:bar", "ABC"); value = StringPropertyReplacer.replaceProperties("${foo:bar}", properties); assertThat(value).isEqualTo("ABC"); }
@Test public void testPortOffset() throws Exception { Properties properties = new Properties(); String value = StringPropertyReplacer.replaceProperties("${jboss.http.port:8080}", properties); assertThat(value).isEqualTo("8080"); properties.put("jboss.http.port", "9090"); value = StringPropertyReplacer.replaceProperties("${jboss.http.port:8080}", properties); assertThat(value).isEqualTo("9090"); properties.put("jboss.socket.binding.port-offset", "10"); value = StringPropertyReplacer.replaceProperties("${jboss.http.port:8080}", properties); assertThat(value).isEqualTo("9100"); properties.remove("jboss.http.port"); value = StringPropertyReplacer.replaceProperties("${jboss.http.port:8080}", properties); assertThat(value).isEqualTo("8090"); value = StringPropertyReplacer.replaceProperties("${jboss.http.port,foo:8080}", properties); assertThat(value).isEqualTo("8090"); value = StringPropertyReplacer.replaceProperties("${bar,jboss.http.port,foo:8080}", properties); assertThat(value).isEqualTo("8090"); properties.put("jboss.socket.binding.port-offset", "hello world"); value = StringPropertyReplacer.replaceProperties("${bar,jboss.http.port,foo:8080}", properties); assertThat(value).isEqualTo("8080"); properties.put("jboss.socket.binding.port-offset", "10"); value = StringPropertyReplacer.replaceProperties("${jboss.http.port:hello}", properties); assertThat(value).isEqualTo("hello"); properties.put("jboss.http.port", "world"); value = StringPropertyReplacer.replaceProperties("${jboss.http.port:8080}", properties); assertThat(value).isEqualTo("world"); }