FileDocCategorySizeDatePackage
DirSetTest.javaAPI DocApache Ant 1.702840Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.types

DirSetTest

public class DirSetTest extends AbstractFileSetTest
JUnit 3 testcases for org.apache.tools.ant.types.DirSet.

Fields Summary
Constructors Summary
public DirSetTest(String name)

        super(name);
    
Methods Summary
protected AbstractFileSetgetInstance()

        return new DirSet();
    
public voidtestFileSetIsNoDirSet()

        DirSet ds = (DirSet) getInstance();
        ds.setProject(getProject());
        FileSet fs = new FileSet();
        fs.setProject(getProject());
        getProject().addReference("dummy", fs);
        ds.setRefid(new Reference(getProject(), "dummy"));
        try {
            ds.getDir(getProject());
            fail("DirSet created from FileSet reference");
        } catch (BuildException e) {
            assertEquals("dummy doesn\'t denote a DirSet", e.getMessage());
        }

        ds = (DirSet) getInstance();
        ds.setProject(getProject());
        getProject().addReference("dummy2", ds);
        fs.setRefid(new Reference(getProject(), "dummy2"));
        try {
            fs.getDir(getProject());
            fail("FileSet created from DirSet reference");
        } catch (BuildException e) {
            assertEquals("dummy2 doesn\'t denote a FileSet", e.getMessage());
        }
    
public voidtestToString()

        File tmp = File.createTempFile("DirSetTest", "");
        tmp.delete();
        File a = new File(tmp, "a");
        a.mkdirs();
        File b = new File(tmp, "b");
        File bc = new File(b, "c");
        bc.mkdirs();
        new FileOutputStream(new File(a, "x")).close();
        new FileOutputStream(new File(b, "x")).close();
        new FileOutputStream(new File(bc, "x")).close();
        DirSet ds = new DirSet();
        ds.setProject(getProject());
        ds.setDir(tmp);
        ds.setIncludes("b/");
        assertEquals("b;b" + File.separator + "c", ds.toString());