1 18 19 package org.apache.roller.util; 20 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 import junit.framework.TestCase; 25 26 31 public class PropertyExpanderTest extends TestCase 32 { 33 private static final Map props = new HashMap (); 34 35 static 36 { 37 props.put("defined.property.one", "value one"); 38 props.put("defined.property.two", "value two"); 39 props.put("defined.property.with.dollar.sign.in.value", "$2"); 40 } 41 42 public void testExpansion() throws Exception 43 { 44 String expanded = 45 PropertyExpander.expandProperties("String with ${defined.property.one} and ${defined.property.two} and ${defined.property.with.dollar.sign.in.value} and ${undefined.property} and some stuff.", props); 46 47 assertEquals("Expanded string doesn't match expected", 48 "String with value one and value two and $2 and ${undefined.property} and some stuff.", 49 expanded); 50 } 51 52 public void testSystemProperty() throws Exception 53 { 54 String expanded = 55 PropertyExpander.expandSystemProperties("${java.home}"); 56 assertEquals("Expanded string doesn't match expected", 57 System.getProperty("java.home"), 58 expanded); 59 } 60 61 } 62 | Popular Tags |