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

StyleTest

public class StyleTest extends org.apache.tools.ant.BuildFileTest
TestCases for {@link XSLTProcess} task. XXX merge with {@link XsltTest}?
version
2003-08-05

Fields Summary
private static final org.apache.tools.ant.util.FileUtils
FILE_UTILS
Constructors Summary
public StyleTest(String s)


       
        super(s);
    
Methods Summary
private voidassertFileContains(java.lang.String filename, java.lang.String contains)

        String content = getFileString(filename);
        assertTrue(
              "expecting file " + filename
            + " to contain " + contains
            + " but got " + content,
            content.indexOf(contains) > -1);
    
private voidexpectFileContains(java.lang.String target, java.lang.String filename, java.lang.String contains)

        executeTarget(target);
        assertFileContains(filename, contains);
    
private java.lang.StringgetFileString(java.lang.String filename)

        Reader r = null;
        try {
            r = new FileReader(getProject().resolveFile(filename));
            return  FileUtils.readFully(r);
        }
        finally {
            FileUtils.close(r);
        }
    
protected voidsetUp()

        configureProject("src/etc/testcases/taskdefs/style/build.xml");
        //executeTarget("setup");
        //commented out for performance while target is empty
    
protected voidtearDown()

        executeTarget("teardown");
    
public voidtestCustomMapper()

        assertTrue(!FILE_UTILS.resolveFile(
                getProject().getBaseDir(), "out/out.xml").exists());
        expectFileContains("testCustomMapper",
                           "out/out.xml",
                           "set='myvalue'");
    
public voidtestDefaultMapper()

        testDefaultMapper("testDefaultMapper");
    
public voidtestDefaultMapper(java.lang.String target)

        assertTrue(!(FileUtils.getFileUtils().resolveFile(
                getProject().getBaseDir(),"out/data.html")).exists());
        expectFileContains(target,
                           "out/data.html",
                           "set='myvalue'");
    
public voidtestDirectoryHierarchyWithDirMatching()

        executeTarget("testDirectoryHierarchyWithDirMatching");
        assertTrue(FILE_UTILS.resolveFile(
                getProject().getBaseDir(), "out/dest/level1/data.html")
                   .exists());
    
public voidtestDirsWithSpaces()

        executeTarget("testDirsWithSpaces");
        assertTrue(FILE_UTILS.resolveFile(
                getProject().getBaseDir(), "out/d est/data.html")
                   .exists());
    
public voidtestExplicitFileset()

        testDefaultMapper("testExplicitFileset");
    
public voidtestFilenameAndFiledirAsParam()

        executeTarget("testFilenameAndFiledirAsParam");
        assertFileContains("out/out/one.txt",      "filename='one.xml'");
        assertFileContains("out/out/one.txt",      "filedir ='.'");
        assertFileContains("out/out/dir/four.txt", "filename='four.xml'");
        assertFileContains("out/out/dir/four.txt", "filedir ='dir'");
    
public voidtestFilenameAsParam()

        executeTarget("testFilenameAsParam");
        assertFileContains("out/out/one.txt",      "filename='one.xml'");
        assertFileContains("out/out/two.txt",      "filename='two.xml'");
        assertFileContains("out/out/three.txt",    "filename='three.xml'");
        assertFileContains("out/out/dir/four.txt", "filename='four.xml'");
        assertFileContains("out/out/dir/four.txt", "filedir ='-not-set-'");
    
public voidtestFilenameAsParamNoSetting()

        executeTarget("testFilenameAsParamNoSetting");
        assertFileContains("out/out/one.txt",      "filename='-not-set-'");
        assertFileContains("out/out/two.txt",      "filename='-not-set-'");
        assertFileContains("out/out/three.txt",    "filename='-not-set-'");
        assertFileContains("out/out/dir/four.txt", "filename='-not-set-'");
    
public voidtestNewerStylesheet()

        expectFileContains("testNewerStylesheet",
                           "out/out.xml",
                           "new-value");
    
public voidtestStyleIsSet()

        expectSpecificBuildException("testStyleIsSet",
                "no stylesheet specified", "specify the " +
                "stylesheet either as a filename in style " +
                "attribute or as a nested resource");
    
public voidtestTransferParameterEmpty()

        expectFileContains("testTransferParameterEmpty",
                           "out/out.xml",
                           "empty=''");
    
public voidtestTransferParameterSet()

        expectFileContains("testTransferParameterSet",  // target
                           "out/out.xml",               // file
                           "set='myvalue'");            // exptected string
    
public voidtestTransferParameterUnset()

        expectFileContains("testTransferParameterUnset",
                           "out/out.xml",
                           "undefined='${value}'");
    
public voidtestTransferParameterUnsetWithIf()

        expectFileContains("testTransferParameterUnsetWithIf",
                           "out/out.xml",
                           "undefined='undefined default value'");
    
public voidtestTypedMapper()

        assertTrue(!FILE_UTILS.resolveFile(
                getProject().getBaseDir(), "out/out.xml").exists());
        expectFileContains("testTypedMapper",
                           "out/out.xml",
                           "set='myvalue'");
    
public voidtestWithFileResource()

        expectFileContains("testWithFileResource", "out/out.xml", "set='value'");
    
public voidtestWithStyleAttrAndResource()

        expectSpecificBuildException("testWithStyleAttrAndResource",
                "Must throws a BuildException", "specify the " +
                "stylesheet either as a filename in style " +
                "attribute or as a nested resource but not " +
                "as both");
    
public voidtestWithUrlResource()

        expectFileContains("testWithUrlResource", "out/out.xml", "set='value'");