FileDocCategorySizeDatePackage
ReplaceTest.javaAPI DocApache Ant 1.703206Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs

ReplaceTest

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

Fields Summary
Constructors Summary
public ReplaceTest(String name)

        super(name);
    
Methods Summary
public voidassertEqualContent(java.io.File expect, java.io.File result)

        if (!result.exists()) {
            fail("Expected file "+result+" doesn\'t exist");
        }

        InputStream inExpect = null;
        InputStream inResult = null;
        try {
            inExpect = new BufferedInputStream(new FileInputStream(expect));
            inResult = new BufferedInputStream(new FileInputStream(result));

            int expectedByte = inExpect.read();
            while (expectedByte != -1) {
                assertEquals(expectedByte, inResult.read());
                expectedByte = inExpect.read();
            }
            assertEquals("End of file", -1, inResult.read());
        } finally {
            if (inResult != null) {
                inResult.close();
            }
            if (inExpect != null) {
                inExpect.close();
            }
        }
    
public voidsetUp()

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

        executeTarget("cleanup");
    
public voidtest1()

        expectBuildException("test1", "required argument not specified");
    
public voidtest2()

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

        expectBuildException("test3", "required argument not specified");
    
public voidtest4()

        expectBuildException("test4", "empty token not allowed");
    
public voidtest5()

        executeTarget("test5");
    
public voidtest6()

        expectBuildException("test6", "required argument not specified");
    
public voidtest7()

        expectBuildException("test7", "empty token not allowed");
    
public voidtest8()

        executeTarget("test8");
    
public voidtest9()

        executeTarget("test9");
        String tmpdir = project.getProperty("tmp.dir");
        assertEqualContent(new File(tmpdir, "result.txt"),
                    new File(tmpdir, "output.txt"));