1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package ch.elca.el4j.tests.env.xml;
18
19 import static org.junit.Assert.assertEquals;
20
21 import java.util.HashMap;
22 import java.util.Iterator;
23 import java.util.Map;
24 import java.util.Properties;
25 import java.util.Map.Entry;
26
27 import org.junit.Test;
28
29 import ch.elca.el4j.env.xml.ResolverUtils;
30
31
32
33
34 public class ResolverUtilsTest {
35 @Test
36 public void testResolve() {
37 Properties values = new Properties();
38 values.setProperty("varA", "valueA");
39 values.setProperty("varB", "valueB");
40
41 Map<String, String> tests = new HashMap<String, String>();
42 tests.put("", "");
43 tests.put("varA", "varA");
44 tests.put("${varA}", "valueA");
45 tests.put("${varA}${varB}", "valueAvalueB");
46 tests.put("${varA} bla ${varB}", "valueA bla valueB");
47 tests.put("xx${varB}zz", "xxvalueBzz");
48
49 tests.put("${notFound}", "${notFound}");
50
51 tests.put("$$", "$$");
52 tests.put("$}{$", "$}{$");
53 tests.put("${", "${");
54 tests.put("${}", "${}");
55
56 Iterator<Entry<String, String>> i = tests.entrySet().iterator();
57
58 while (i.hasNext()) {
59 Entry<String, String> pair = i.next();
60 assertEquals(pair.getValue(), ResolverUtils.resolve(pair.getKey(), values));
61 }
62 }
63 }