FileDocCategorySizeDatePackage
MakeUrlTest.javaAPI DocApache Ant 1.704364Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs

MakeUrlTest

public class MakeUrlTest extends org.apache.tools.ant.BuildFileTest

Fields Summary
Constructors Summary
public MakeUrlTest(String s)

        super(s);
    
Methods Summary
protected voidassertPropertyContains(java.lang.String property, java.lang.String contains)
assert that a property contains a string

param
property name of property to look for
param
contains what to search for in the string

        String result = getProperty(property);

        assertTrue("expected " + contains + " in " + result,
                result != null && result.indexOf(contains) >= 0);
    
private voidassertPropertyEndsWith(java.lang.String property, java.lang.String ending)
assert that a property ends with

param
property
param
ending

        String result = getProperty(property);
        String substring = result.substring(result.length() - ending.length());
        assertEquals(ending, substring);
    
protected java.lang.StringgetProperty(java.lang.String property)
get a property from the project

param
property
return

        return project.getProperty(property);
    
public voidsetUp()

        configureProject("src/etc/testcases/taskdefs/makeurl.xml");
    
public voidtestEmpty()

        expectBuildExceptionContaining("testEmpty", "missing property", "property");
    
public voidtestFileset()

        executeTarget("testFileset");
        assertPropertyContains("testFileset", ".xml ");
        String result = getProperty("testFileset");
        assertPropertyEndsWith("testFileset", ".xml");
    
public voidtestFilesetSeparator()

        executeTarget("testFilesetSeparator");
        assertPropertyContains("testFilesetSeparator", ".xml\",\"");
        assertPropertyEndsWith("testFilesetSeparator", ".xml");
    
public voidtestIllegalChars()

        executeTarget("testIllegalChars");
        assertPropertyContains("testIllegalChars", "file:");
        assertPropertyContains("testIllegalChars", "fo%20o%25");
    
public voidtestIllegalCombinations()

        executeTarget("testIllegalCombinations");
        assertPropertyContains("testIllegalCombinations", "/foo");
        assertPropertyContains("testIllegalCombinations", ".xml");
    
public voidtestNoFile()

        expectBuildExceptionContaining("testNoFile", "missing file", "file");
    
public voidtestNoProperty()

        expectBuildExceptionContaining("testNoProperty", "missing property", "property");
    
public voidtestPath()

        executeTarget("testPath");
        assertPropertyContains("testPath", "makeurl.xml");
    
public voidtestRoundTrip()
test that we can round trip by opening a url that exists

throws
IOException

        executeTarget("testRoundTrip");
        assertPropertyContains("testRoundTrip", "file:");
        String property = getProperty("testRoundTrip");
        URL url = new URL(property);
        InputStream instream = url.openStream();
        instream.close();
    
public voidtestValidation()

        expectBuildExceptionContaining("testValidation", MakeUrl.ERROR_MISSING_FILE, "file");
    
public voidtestWorks()

        executeTarget("testWorks");
        assertPropertyContains("testWorks", "file:");
        assertPropertyContains("testWorks", "/foo");