1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.property;
17
18 import java.util.Properties;
19
20 import org.junit.Test;
21 import org.springframework.util.PropertyPlaceholderHelper;
22
23 public class EscapingPropertyPlaceholderHelperTest {
24
25 @Test
26 public void test() {
27 PropertyPlaceholderHelper helper = Constants.DEFAULT_PROPERTY_PLACEHOLDER_HELPER;
28 Properties properties = new Properties();
29 properties.setProperty("a", "1");
30 properties.setProperty("b", "2");
31 properties.setProperty("d", "5");
32 properties.setProperty("1.2", "foo");
33 String original = "\\${${a}.${b}} ${${a}.${b}} ${c:${d:4}} \\${foo";
34 String resolved = helper.replacePlaceholders(original, properties);
35 System.out.println(resolved);
36 }
37
38 @Test
39 public void test1() {
40 PropertyPlaceholderHelper helper = Constants.DEFAULT_PROPERTY_PLACEHOLDER_HELPER;
41 Properties properties = new Properties();
42 properties.setProperty("kuali.encoding", "UTF-8");
43 String original = "kuali.encoding=${kuali.encoding} \\${user.home}";
44 String resolved = helper.replacePlaceholders(original, properties);
45 System.out.println(resolved);
46 }
47 }