FileDocCategorySizeDatePackage
AbstractXSLTLiaisonTest.javaAPI DocApache Ant 1.703749Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.optional

AbstractXSLTLiaisonTest

public abstract class AbstractXSLTLiaisonTest extends TestCase
Abtract testcase for XSLTLiaison. Override createLiaison for each XSLTLiaison. Stephane Bailliez

Fields Summary
private static final org.apache.tools.ant.util.FileUtils
FILE_UTILS
protected org.apache.tools.ant.taskdefs.XSLTLiaison
liaison
Constructors Summary
protected AbstractXSLTLiaisonTest(String name)


       
        super(name);
    
Methods Summary
protected abstract org.apache.tools.ant.taskdefs.XSLTLiaisoncreateLiaison()

protected java.io.FilegetFile(java.lang.String name)
load the file from the caller classloader that loaded this class

        URL url = getClass().getResource(name);
        if (url == null){
          throw new FileNotFoundException("Unable to load '" + name + "' from classpath");
        }
        return new File(FILE_UTILS.fromURI(url.toExternalForm()));
    
public org.w3c.dom.DocumentparseXML(java.io.File file)

        DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dbuilder = dbfactory.newDocumentBuilder();
        return dbuilder.parse(file);
    
protected voidsetUp()

        liaison = createLiaison();
    
public voidtestEncoding()

        File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl");
        liaison.setStylesheet(xsl);
        File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml");
        File out = new File("xsltliaison-encoding.tmp");
        out.deleteOnExit(); // just to be sure
        try {
            liaison.transform(in, out);
            Document doc = parseXML(out);
            assertEquals("root",doc.getDocumentElement().getNodeName());
            assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName());
            assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue());
        } finally {
            out.delete();
        }
    
public voidtestTransform()
keep it simple stupid

        File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl");
        liaison.setStylesheet(xsl);
        liaison.addParam("param", "value");
        File in = getFile("/taskdefs/optional/xsltliaison-in.xml");
        File out = new File("xsltliaison.tmp");
        out.deleteOnExit(); // just to be sure
        try {
            liaison.transform(in, out);
        } finally {
            out.delete();
        }