FileDocCategorySizeDatePackage
PropertyExpansionTest.javaAPI DocApache Ant 1.702838Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant

PropertyExpansionTest

public class PropertyExpansionTest extends BuildFileTest
class to look at how we expand properties

Fields Summary
Constructors Summary
public PropertyExpansionTest(String name)

        super(name);
    
Methods Summary
private voidassertExpandsTo(java.lang.String source, java.lang.String expected)
little helper method to validate stuff

        String actual=project.replaceProperties(source);
        assertEquals(source,expected,actual);
    
public voidoldtestQuirkyLegacyBehavior()
old things we dont want; not a test no more

        assertExpandsTo("Class$subclass","Classsubclass");
        assertExpandsTo("$$$-","$-");
        assertExpandsTo("a$b","ab");
        assertExpandsTo("$}}","}}");
    
public voidsetUp()
we bind to an existing test file because we are too lazy to write our own, and we don't really care what it is

        configureProject("src/etc/testcases/core/immutable.xml");
    
public voidtestDollarPassthru()
new things we want

        assertExpandsTo("$-","$-");
        assertExpandsTo("Class$subclass","Class$subclass");
        assertExpandsTo("$$$-","$$-");
        assertExpandsTo("$$$$$","$$$");
        assertExpandsTo("${unassigned.property}","${unassigned.property}");
        assertExpandsTo("a$b","a$b");
        assertExpandsTo("$}}","$}}");
    
public voidtestPropertyExpansion()
run through the test cases of expansion

        assertExpandsTo("","");
        assertExpandsTo("$","$");
        assertExpandsTo("$$-","$-");
        assertExpandsTo("$$","$");
        project.setProperty("expanded","EXPANDED");
        assertExpandsTo("a${expanded}b","aEXPANDEDb");
        assertExpandsTo("${expanded}${expanded}","EXPANDEDEXPANDED");
        assertExpandsTo("$$$","$$");
        assertExpandsTo("$$$$-","$$-");
        assertExpandsTo("","");
        assertExpandsTo("Class$$subclass","Class$subclass");