View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2009 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
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   * @svnLink $Revision: 4010 $;$Date: 2009-12-01 10:59:54 +0100 (Di, 01. Dez 2009) $;$Author: jonasha $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/env/src/test/java/ch/elca/el4j/tests/env/xml/ResolverUtilsTest.java $
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  }