FileDocCategorySizeDatePackage
AntTest.javaAPI DocApache Ant 1.7017596Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs

AntTest

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

Fields Summary
Constructors Summary
public AntTest(String name)

        super(name);
    
Methods Summary
public voidsetUp()

        configureProject("src/etc/testcases/taskdefs/ant.xml");
    
public voidtearDown()

        executeTarget("cleanup");
    
public voidtest1()

        expectBuildException("test1", "recursive call");
    
public voidtest2()

        expectBuildException("test2", "required argument not specified");
    
public voidtest3()

        expectBuildException("test1", "recursive call");
    
public voidtest4()

        expectBuildException("test4", "target attribute must not be empty");
    
public voidtest4b()

        expectBuildException("test4b", "target doesn't exist");
    
public voidtest5()

        executeTarget("test5");
    
public voidtest6()

        executeTarget("test6");
    
protected voidtestBaseDirs(java.lang.String target, java.lang.String[] dirs)

        BasedirChecker bc = new BasedirChecker(dirs);
        project.addBuildListener(bc);
        executeTarget(target);
        AssertionFailedError ae = bc.getError();
        if (ae != null) {
            throw ae;
        }
        project.removeBuildListener(bc);
    
public voidtestBasedirTripleCall()

        File dir1 = getProjectDir();
        File dir2 = project.resolveFile("ant");
        testBaseDirs("tripleCall",
                     new String[] {dir1.getAbsolutePath(),
                                   dir2.getAbsolutePath(),
                                   dir1.getAbsolutePath()
                     });
    
public voidtestBlankTarget()

        expectBuildException("blank-target", "target name must not be empty");
    
public voidtestDoNotInheritBasedir()

        File dir1 = getProjectDir();
        File dir2 = project.resolveFile("ant");
        String basedir = getProjectDir().getAbsolutePath();
        testBaseDirs("doNotInheritBasedir",
                     new String[] {dir1.getAbsolutePath(),
                                   dir2.getAbsolutePath()
                     });
    
public voidtestExplicitBasedir1()

        File dir1 = getProjectDir();
        File dir2 = project.resolveFile("..");
        testBaseDirs("explicitBasedir1",
                     new String[] {dir1.getAbsolutePath(),
                                   dir2.getAbsolutePath()
                     });
    
public voidtestExplicitBasedir2()

        File dir1 = getProjectDir();
        File dir2 = project.resolveFile("..");
        testBaseDirs("explicitBasedir2",
                     new String[] {dir1.getAbsolutePath(),
                                   dir2.getAbsolutePath()
                     });
    
public voidtestInfiniteLoopViaDepends()

        expectBuildException("infinite-loop-via-depends", "recursive call");
    
public voidtestInheritBasedir()

        String basedir = getProjectDir().getAbsolutePath();
        testBaseDirs("inheritBasedir", new String[] {basedir, basedir});
    
public voidtestInheritPath()

        executeTarget("testInheritPath");
    
public voidtestInputHandlerInheritance()

        InputHandler ih = new PropertyFileInputHandler();
        getProject().setInputHandler(ih);
        InputHandlerChecker ic = new InputHandlerChecker(ih);
        getProject().addBuildListener(ic);
        executeTarget("tripleCall");
        AssertionFailedError ae = ic.getError();
        if (ae != null) {
            throw ae;
        }
        getProject().removeBuildListener(ic);
    
public voidtestLogfilePlacement()

        File[] logFiles = new File[] {
            getProject().resolveFile("test1.log"),
            getProject().resolveFile("test2.log"),
            getProject().resolveFile("ant/test3.log"),
            getProject().resolveFile("ant/test4.log")
        };
        for (int i=0; i<logFiles.length; i++) {
            assertTrue(logFiles[i].getName()+" doesn\'t exist",
                       !logFiles[i].exists());
        }

        executeTarget("testLogfilePlacement");

        for (int i=0; i<logFiles.length; i++) {
            assertTrue(logFiles[i].getName()+" exists",
                       logFiles[i].exists());
        }
    
public voidtestMultiSameProperty()

        expectLog("multi-same-property", "prop is two");
    
public voidtestMultiplePropertyFileChildren()

        PropertyChecker pcBar = new PropertyChecker("bar",
                                                    new String[] {null, "Bar"});
        PropertyChecker pcFoo = new PropertyChecker("foo",
                                                    new String[] {null, "Foo"});
        project.addBuildListener(pcBar);
        project.addBuildListener(pcFoo);
        executeTarget("multiple-property-file-children");
        AssertionFailedError aeBar = pcBar.getError();
        if (aeBar != null) {
            throw aeBar;
        }
        AssertionFailedError aeFoo = pcFoo.getError();
        if (aeFoo != null) {
            throw aeFoo;
        }
        project.removeBuildListener(pcBar);
        project.removeBuildListener(pcFoo);
    
public voidtestMultipleTargets()

        expectLog("multiple-targets", "tadadctbdbtc");
    
public voidtestMultipleTargets2()

        expectLog("multiple-targets-2", "dadctb");
    
public voidtestOverrideWinsInheritAll()

        expectLogContaining("test-property-override-inheritall-start",
                            "The value of test is 4");
    
public voidtestOverrideWinsNoInheritAll()

        expectLogContaining("test-property-override-no-inheritall-start",
                            "The value of test is 4");
    
public voidtestPropertySet()

        executeTarget("test-propertyset");
        assertTrue(getLog().indexOf("test1 is ${test1}") > -1);
        assertTrue(getLog().indexOf("test2 is ${test2}") > -1);
        assertTrue(getLog().indexOf("test1.x is 1") > -1);
    
public voidtestRefId()

        Path testPath = new Path(project);
        testPath.createPath().setPath(System.getProperty("java.class.path"));
        PropertyChecker pc =
            new PropertyChecker("testprop",
                                new String[] {null,
                                              testPath.toString()});
        project.addBuildListener(pc);
        executeTarget("testRefid");
        AssertionFailedError ae = pc.getError();
        if (ae != null) {
            throw ae;
        }
        project.removeBuildListener(pc);
    
protected voidtestReference(java.lang.String target, java.lang.String[] keys, boolean[] expect, java.lang.Object value)

        ReferenceChecker rc = new ReferenceChecker(keys, expect, value);
        project.addBuildListener(rc);
        executeTarget(target);
        AssertionFailedError ae = rc.getError();
        if (ae != null) {
            throw ae;
        }
        project.removeBuildListener(rc);
    
public voidtestReferenceInheritance()

        Path p = Path.systemClasspath;
        p.setProject(project);
        project.addReference("path", p);
        project.addReference("no-override", p);
        testReference("testInherit", new String[] {"path", "path"},
                      new boolean[] {true, true}, p);
        testReference("testInherit",
                      new String[] {"no-override", "no-override"},
                      new boolean[] {true, false}, p);
        testReference("testInherit",
                      new String[] {"no-override", "no-override"},
                      new boolean[] {false, false}, null);
    
public voidtestReferenceNoInheritance()

        Path p = Path.systemClasspath;
        p.setProject(project);
        project.addReference("path", p);
        project.addReference("no-override", p);
        testReference("testNoInherit", new String[] {"path", "path"},
                      new boolean[] {true, false}, p);
        testReference("testNoInherit", new String[] {"path", "path"},
                      new boolean[] {false, true}, null);
        testReference("testInherit",
                      new String[] {"no-override", "no-override"},
                      new boolean[] {true, false}, p);
        testReference("testInherit",
                      new String[] {"no-override", "no-override"},
                      new boolean[] {false, false}, null);
    
public voidtestReferenceRename()

        Path p = Path.systemClasspath;
        p.setProject(project);
        project.addReference("path", p);
        testReference("testRename", new String[] {"path", "path"},
                      new boolean[] {true, false}, p);
        testReference("testRename", new String[] {"path", "path"},
                      new boolean[] {false, true}, null);
        testReference("testRename", new String[] {"newpath", "newpath"},
                      new boolean[] {false, true}, p);
    
public voidtestTopLevelTarget()

        expectLog("topleveltarget", "Hello world");
    
public voidtestUserPropertyWinsInheritAll()

        getProject().setUserProperty("test", "7");
        expectLogContaining("test-property-override-inheritall-start",
                            "The value of test is 7");
    
public voidtestUserPropertyWinsNoInheritAll()

        getProject().setUserProperty("test", "7");
        expectLogContaining("test-property-override-no-inheritall-start",
                            "The value of test is 7");