01: /*
02: * Created on 28/08/2005 22:23:41
03: */
04: package net.jforum.util.preferences;
05:
06: import java.util.HashMap;
07: import java.util.Map;
08:
09: import junit.framework.TestCase;
10:
11: /**
12: * @author Rafael Steil
13: * @version $Id: VariableExpanderTest.java,v 1.1 2005/08/29 02:13:23 rafaelsteil Exp $
14: */
15: public class VariableExpanderTest extends TestCase {
16: private static class MyStore implements VariableStore {
17: private Map data = new HashMap();
18:
19: public MyStore() {
20: this .fill();
21: }
22:
23: private void fill() {
24: this .data.put("config.dir", "/config");
25: this .data.put("database.driver.name", "mysql");
26: }
27:
28: public String getVariableValue(String variableName) {
29: return (String) this .data.get(variableName);
30: }
31: }
32:
33: private VariableExpander extapnder;
34:
35: private String test = "${config.dir}/database/${database.driver.name}/${database.driver.name}.properties";
36:
37: /**
38: * @see junit.framework.TestCase#setUp()
39: */
40: protected void setUp() throws Exception {
41: this .extapnder = new VariableExpander(new MyStore(), "${", "}");
42: }
43:
44: public void testExpand() {
45: String result = this .extapnder.expandVariables(this .test);
46: assertEquals("/config/database/mysql/mysql.properties", result);
47: }
48: }
|