1 17 18 19 package org.apache.tools.ant; 20 21 24 public class PropertyExpansionTest extends BuildFileTest { 25 26 27 public PropertyExpansionTest(String name) { 28 super(name); 29 } 30 31 35 public void setUp() { 36 configureProject("src/etc/testcases/core/immutable.xml"); 37 } 38 39 42 public void testPropertyExpansion() { 43 assertExpandsTo("",""); 44 assertExpandsTo("$","$"); 45 assertExpandsTo("$$-","$-"); 46 assertExpandsTo("$$","$"); 47 project.setProperty("expanded","EXPANDED"); 48 assertExpandsTo("a${expanded}b","aEXPANDEDb"); 49 assertExpandsTo("${expanded}${expanded}","EXPANDEDEXPANDED"); 50 assertExpandsTo("$$$","$$"); 51 assertExpandsTo("$$$$-","$$-"); 52 assertExpandsTo("",""); 53 assertExpandsTo("Class$$subclass","Class$subclass"); 54 } 55 56 59 public void testDollarPassthru() { 60 assertExpandsTo("$-","$-"); 61 assertExpandsTo("Class$subclass","Class$subclass"); 62 assertExpandsTo("$$$-","$$-"); 63 assertExpandsTo("$$$$$","$$$"); 64 assertExpandsTo("${unassigned.property}","${unassigned.property}"); 65 assertExpandsTo("a$b","a$b"); 66 assertExpandsTo("$}}","$}}"); 67 } 68 69 70 73 public void oldtestQuirkyLegacyBehavior() { 74 assertExpandsTo("Class$subclass","Classsubclass"); 75 assertExpandsTo("$$$-","$-"); 76 assertExpandsTo("a$b","ab"); 77 assertExpandsTo("$}}","}}"); 78 } 79 80 83 private void assertExpandsTo(String source,String expected) { 84 String actual=project.replaceProperties(source); 85 assertEquals(source,expected,actual); 86 } 87 88 } 90 | Popular Tags |