1 package org.apache.tools.ant.taskdefs.optional; 2 3 import org.apache.tools.ant.taskdefs.XSLTLiaison; 4 import org.apache.tools.ant.taskdefs.XSLTLogger; 5 import org.apache.tools.ant.BuildException; 6 7 import java.io.File ; 8 9 import junit.framework.AssertionFailedError; 10 11 27 28 31 public class TraXLiaisonTest extends AbstractXSLTLiaisonTest 32 implements XSLTLogger { 33 34 public TraXLiaisonTest(String name){ 35 super(name); 36 } 37 38 public void tearDown() { 39 File f = new File ("xalan2-redirect-out.tmp"); 40 if (f.exists()) { 41 f.delete(); 42 } 43 } 44 45 public XSLTLiaison createLiaison() throws Exception { 46 TraXLiaison l = new TraXLiaison(); 47 l.setLogger(this); 48 return l; 49 } 50 51 public void testXalan2Redirect() throws Exception { 52 File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl"); 53 liaison.setStylesheet(xsl); 54 File out = new File ("xalan2-redirect-out-dummy.tmp"); 55 File in = getFile("/taskdefs/optional/xsltliaison-in.xsl"); 56 try { 57 liaison.addParam("xalan-version", "2"); 58 liaison.transform(in, out); 59 } finally { 60 out.delete(); 61 } 62 } 63 64 public void testMultipleTransform() throws Exception { 65 File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl"); 66 liaison.setStylesheet(xsl); 67 liaison.addParam("param", "value"); 68 File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); 69 for (int i = 0; i < 50; i++){ 71 File out = new File ("xsltliaison" + i + ".tmp"); 72 try { 73 liaison.transform(in, out); 74 } catch (Exception e){ 75 throw new BuildException("failed in transform " + i, e); 76 } finally { 77 out.delete(); 78 } 79 } 80 } 81 82 public void testSystemId(){ 83 File file = null; 84 if ( File.separatorChar == '\\' ){ 85 file = new File ("d:\\jdk"); 86 } else { 87 file = new File ("/user/local/bin"); 88 } 89 String systemid = ((TraXLiaison)liaison).getSystemId(file); 90 assertTrue("SystemIDs should start by file:///", systemid.startsWith("file:///")); 91 assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////")); 92 } 93 94 public void log(String message) { 95 throw new AssertionFailedError("Liaison sent message: "+message); 96 } 97 98 } 99 | Popular Tags |