diff options
Diffstat (limited to 'tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests')
6 files changed, 0 insertions, 738 deletions
diff --git a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/FileUtil.java b/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/FileUtil.java deleted file mode 100644 index e5ef8d06c..000000000 --- a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/FileUtil.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.eclipse.wst.xml.resolver.tools.tests.internal; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.InputStream; -import java.io.PrintWriter; - -public class FileUtil { - - public FileUtil() { - super(); - } - - public static void copyFile(String src, String dest) { - InputStream is = null; - FileOutputStream fos = null; - try { - is = new FileInputStream(src); - fos = new FileOutputStream(dest); - int c = 0; - byte[] array = new byte[1024]; - while ((c = is.read(array)) >= 0) { - fos.write(array, 0, c); - } - } catch (Exception e) { - } finally { - try { - fos.close(); - is.close(); - } catch (Exception e) { - } - } - } - - public static File createFileAndParentDirectories(String fileName) - throws Exception { - File file = new File(fileName); - File parent = file.getParentFile(); - if (!parent.exists()) { - parent.mkdirs(); - } - file.createNewFile(); - return file; - } - - public static void deleteDirectories(File dir) - throws Exception { - - File[] children = dir.listFiles(); - for(int i=0; i< children.length; i++){ - if(children[i].list() != null && children[i].list().length > 0){ - deleteDirectories(children[i]); - } - else{ - children[i].delete(); - } - } - dir.delete(); - - } - - public static boolean textualCompare(final File first, final File second, File diff) throws java.io.IOException { - BufferedReader r1 = new BufferedReader(new FileReader(first)); - BufferedReader r2 = new BufferedReader(new FileReader(second)); - PrintWriter printWriter = new PrintWriter(new FileOutputStream(diff)); - - boolean diffFound = false; - while (r1.ready()) { - String s1 = r1.readLine(); - String s2 = r2.readLine(); - if (s1 == null) { - if (s2 == null) - return diffFound; // files equal - else - diffFound = true; // files differ in length - } - if (!s1.equals(s2)) { - printWriter.println("<<<< " + s1); - printWriter.println("<<<< " + s2); - diffFound = true; // files differ - } - } - - printWriter.flush(); - - return diffFound; - - } - -} diff --git a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/ResolvingXMLParser.java b/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/ResolvingXMLParser.java deleted file mode 100644 index 389d00192..000000000 --- a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/ResolvingXMLParser.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.eclipse.wst.xml.resolver.tools.tests.internal; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.Vector; - -import org.apache.xml.resolver.CatalogManager; -import org.apache.xml.resolver.apps.XParseError; -import org.apache.xml.resolver.tools.ResolvingXMLReader; - -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; - -public class ResolvingXMLParser { - - public boolean validationError = false; - - protected static int maxErrs = 10; - - protected static boolean nsAware = true; - - protected static boolean validating = true; - - protected static boolean showErrors = true; - - protected static boolean showWarnings = true; - - protected static Vector catalogFiles = new Vector(); - - protected void parseAndValidate(String xmlFile, String[] catalogs) - throws MalformedURLException, FileNotFoundException, IOException { - - CatalogManager myManager = new CatalogManager(); - StringBuffer catalogFile = new StringBuffer(); - for(int i=0; i<catalogs.length; i++){ - catalogFile = catalogFile.append(catalogs[i] + ";"); - } - myManager.setCatalogFiles(catalogFile.toString()); - myManager.setIgnoreMissingProperties(true); - myManager.setVerbosity(2); - ResolvingXMLReader reader = new ResolvingXMLReader(myManager); - try { - reader.setFeature("http://xml.org/sax/features/namespaces", - nsAware); - reader.setFeature("http://xml.org/sax/features/validation", - validating); - reader.setFeature( - "http://apache.org/xml/features/validation/schema", true); - } catch (SAXNotRecognizedException e1) { - e1.printStackTrace(); - } catch (SAXNotSupportedException e1) { - e1.printStackTrace(); - } - - XParseError xpe = new XParseError(showErrors, showWarnings); - xpe.setMaxMessages(maxErrs); - reader.setErrorHandler(xpe); - - String parseType = validating ? "validating" : "well-formed"; - String nsType = nsAware ? "namespace-aware" : "namespace-ignorant"; - if (maxErrs > 0) { - System.out.println("Attempting " + parseType + ", " + nsType - + " parse"); - } - - try { - reader.parse(xmlFile); - } catch (Exception e) { - validationError = true; - e.printStackTrace(); - } - - if (maxErrs > 0) { - System.out.print("Parse "); - if (xpe.getFatalCount() > 0) { - validationError = true; - System.out.print("failed "); - } else { - System.out.print("succeeded "); - System.out.print("("); - } - System.out.print("with "); - - int errCount = xpe.getErrorCount(); - int warnCount = xpe.getWarningCount(); - - if (errCount > 0) { - validationError = true; - System.out.print(errCount + " error"); - System.out.print(errCount > 1 ? "s" : ""); - System.out.print(" and "); - } else { - System.out.print("no errors and "); - } - - if (warnCount > 0) { - validationError = true; - System.out.print(warnCount + " warning"); - System.out.print(warnCount > 1 ? "s" : ""); - System.out.print("."); - } else { - System.out.print("no warnings."); - } - - System.out.println(""); - } - } - - -} diff --git a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/TraXLiaison.java b/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/TraXLiaison.java deleted file mode 100644 index 46861c2fb..000000000 --- a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/TraXLiaison.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "The Jakarta Project", "Ant", and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -package org.eclipse.wst.xml.resolver.tools.tests.internal; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -import org.xml.sax.InputSource; -import org.xml.sax.EntityResolver; -import org.xml.sax.XMLReader; - -import javax.xml.parsers.SAXParserFactory; - -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.Templates; - -import javax.xml.transform.ErrorListener; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -import javax.xml.transform.Source; -import javax.xml.transform.URIResolver; - -import javax.xml.transform.sax.SAXSource; - -/** - * Concrete liaison for XSLT processor implementing TraX. (ie JAXP 1.1) - * - * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> - * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a> - * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> - * @since Ant 1.3 - */ -public class TraXLiaison implements XSLTLiaison, ErrorListener { - - /** The trax TransformerFactory */ - private TransformerFactory tfactory = null; - - /** stylesheet stream, close it asap */ - private FileInputStream xslStream = null; - - /** Stylesheet template */ - private Templates templates = null; - - /** transformer */ - private Transformer transformer = null; - - /** possible resolver for publicIds */ - private EntityResolver entityResolver; - - /** possible resolver for URIs */ - private URIResolver uriResolver; - - public TraXLiaison() throws Exception { - tfactory = TransformerFactory.newInstance(); - tfactory.setErrorListener(this); - } - - /** - * Set the output property for the current transformer. - * Note that the stylesheet must be set prior to calling - * this method. - * @param name the output property name. - * @param value the output property value. - */ - public void setOutputProperty(String name, String value) { - if (transformer == null) { - throw new IllegalStateException("stylesheet must be set prior to setting the output properties"); - } - transformer.setOutputProperty(name, value); - } - - //------------------- IMPORTANT - // 1) Don't use the StreamSource(File) ctor. It won't work with - // xalan prior to 2.2 because of systemid bugs. - - // 2) Use a stream so that you can close it yourself quickly - // and avoid keeping the handle until the object is garbaged. - // (always keep control), otherwise you won't be able to delete - // the file quickly on windows. - - // 3) Always set the systemid to the source for imports, includes... - // in xsl and xml... - - public void setStylesheet(File stylesheet) throws Exception { - xslStream = new FileInputStream(stylesheet); - StreamSource src = new StreamSource(xslStream); - src.setSystemId(getSystemId(stylesheet)); - templates = tfactory.newTemplates(src); - transformer = templates.newTransformer(); - transformer.setErrorListener(this); - } - - public void transform(File infile, File outfile) throws Exception { - FileInputStream fis = null; - FileOutputStream fos = null; - try { - fis = new FileInputStream(infile); - fos = new FileOutputStream(outfile); - // FIXME: need to use a SAXSource as the source for the transform - // so we can plug in our own entity resolver - Source src = null; - if (entityResolver != null) { - if (tfactory.getFeature(SAXSource.FEATURE)) { - SAXParserFactory spFactory = SAXParserFactory.newInstance(); - spFactory.setNamespaceAware(true); - XMLReader reader = spFactory.newSAXParser().getXMLReader(); - reader.setEntityResolver(entityResolver); - src = new SAXSource(reader, new InputSource(fis)); - } else { - throw new IllegalStateException( - "xcatalog specified, but " - + "parser doesn't support SAX"); - } - } else { - src = new StreamSource(fis); - } - src.setSystemId(getSystemId(infile)); - StreamResult res = new StreamResult(fos); - // not sure what could be the need of this... - res.setSystemId(getSystemId(outfile)); - - if (uriResolver != null) - transformer.setURIResolver(uriResolver); - - transformer.transform(src, res); - } finally { - // make sure to close all handles, otherwise the garbage - // collector will close them...whenever possible and - // Windows may complain about not being able to delete files. - try { - if (xslStream != null) { - xslStream.close(); - } - } catch (IOException ignored) { - } - try { - if (fis != null) { - fis.close(); - } - } catch (IOException ignored) { - } - try { - if (fos != null) { - fos.close(); - } - } catch (IOException ignored) { - } - } - } - - // make sure that the systemid is made of '/' and not '\' otherwise - // crimson will complain that it cannot resolve relative entities - // because it grabs the base uri via lastIndexOf('/') without - // making sure it is really a /'ed path - protected String getSystemId(File file) { - String path = file.getAbsolutePath(); - path = path.replace('\\', '/'); - - // on Windows, use 'file:///' - if (File.separatorChar == '\\') { - return FILE_PROTOCOL_PREFIX + "/" + path; - } - // Unix, use 'file://' - return FILE_PROTOCOL_PREFIX + path; - } - - public void addParam(String name, String value) { - transformer.setParameter(name, value); - } - - public void error(TransformerException e) { - logError(e, "Error"); - } - - public void fatalError(TransformerException e) { - logError(e, "Fatal Error"); - } - - public void warning(TransformerException e) { - logError(e, "Warning"); - } - - private void logError(TransformerException e, String type) { - - StringBuffer msg = new StringBuffer(); - if (e.getLocator() != null) { - if (e.getLocator().getSystemId() != null) { - String url = e.getLocator().getSystemId(); - if (url.startsWith("file:///")) { - url = url.substring(8); - } - msg.append(url); - } else { - msg.append("Unknown file"); - } - if (e.getLocator().getLineNumber() != -1) { - msg.append(":" + e.getLocator().getLineNumber()); - if (e.getLocator().getColumnNumber() != -1) { - msg.append(":" + e.getLocator().getColumnNumber()); - } - } - } - msg.append(": " + type + "! "); - msg.append(e.getMessage()); - if (e.getCause() != null) { - msg.append(" Cause: " + e.getCause()); - } - - System.out.println(msg.toString()); - } - - /** Set the class to resolve entities during the transformation - */ - public void setEntityResolver(EntityResolver aResolver) { - entityResolver = aResolver; - } - - /** Set the class to resolve URIs during the transformation - */ - public void setURIResolver(URIResolver aResolver) { - uriResolver = aResolver; - tfactory.setURIResolver(aResolver); - } - -} //-- TraXLiaison diff --git a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/ValidatorTest.java b/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/ValidatorTest.java deleted file mode 100644 index 45e7ac970..000000000 --- a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/ValidatorTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.eclipse.wst.xml.resolver.tools.tests.internal; - -import java.io.IOException; - -import junit.framework.TestCase; - -import org.eclipse.wst.xml.catalog.tests.internal.TestPlugin; - - -/** - * To run this test need to add resolver.jar to the classpath. - * Run as JUnit Plugin test: - * - put resolver.jar on the boot class path - * - add VM argument: - * - * -Xbootclasspath/p:<install location>\jre\lib\ext\resolver.jar - * - * - */ -public class ValidatorTest extends TestCase { - - - - protected void setUp() throws Exception { - super.setUp(); - - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public ValidatorTest(String name) { - super(name); - } - - - public void testValidatingParser() throws IOException { - String xmlFile = "/data/Personal/personal-schema.xml"; - xmlFile = TestPlugin.resolvePluginLocation(xmlFile); - - String catalogFile = "/data/catalog2.xml"; - catalogFile = TestPlugin.resolvePluginLocation(catalogFile); - - System.out.println("---------" + this.getName() + "---------"); - ResolvingXMLParser parser = new ResolvingXMLParser(); - parser.parseAndValidate(xmlFile, new String[]{catalogFile}); - assertFalse(parser.validationError); - } - -} diff --git a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/XSLTLiaison.java b/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/XSLTLiaison.java deleted file mode 100644 index 7bf36a890..000000000 --- a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/XSLTLiaison.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "The Jakarta Project", "Ant", and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -package org.eclipse.wst.xml.resolver.tools.tests.internal; - -import java.io.File; - -/** - * Proxy interface for XSLT processors. - * - * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> - * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> - * @see XSLTProcess - * @since Ant 1.1 - */ -public interface XSLTLiaison { - - /** - * the file protocol prefix for systemid. - * This file protocol must be appended to an absolute path. - * Typically: <tt>FILE_PROTOCOL_PREFIX + file.getAbsolutePath()</tt> - * Note that on Windows, an extra '/' must be appended to the - * protocol prefix so that there is always 3 consecutive slashes. - * @since Ant 1.4 - */ - String FILE_PROTOCOL_PREFIX = "file://"; - - /** - * set the stylesheet to use for the transformation. - * @param stylesheet the stylesheet to be used for transformation. - * @since Ant 1.4 - */ - void setStylesheet(File stylesheet) throws Exception; - - /** - * Add a parameter to be set during the XSL transformation. - * @param name the parameter name. - * @param expression the parameter value as an expression string. - * @throws Exception thrown if any problems happens. - * @since Ant 1.3 - */ - void addParam(String name, String expression) throws Exception; - - /** - * Perform the transformation of a file into another. - * @param infile the input file, probably an XML one. :-) - * @param outfile the output file resulting from the transformation - * @throws Exception thrown if any problems happens. - * @see #setStylesheet(File) - * @since Ant 1.4 - */ - void transform(File infile, File outfile) throws Exception; - -} //-- XSLTLiaison diff --git a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/XSLTWithCatalogResolverTest.java b/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/XSLTWithCatalogResolverTest.java deleted file mode 100644 index 4cfb3addc..000000000 --- a/tests/org.eclipse.wst.xml.catalog.tests/src/org/eclipse/wst/xml/resolver/tools/tests/internal/XSLTWithCatalogResolverTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.eclipse.wst.xml.resolver.tools.tests.internal; - -import java.io.File; - -import junit.framework.TestCase; - -import org.apache.xml.resolver.tools.CatalogResolver; -import org.eclipse.wst.xml.catalog.tests.internal.TestPlugin; - - -/** - * Test from http://issues.apache.org/bugzilla/show_bug.cgi?id=16336 - * - * To run this test need to add resolver.jar to the classpath. - * Run as JUnit Plugin test: - * - put resolver.jar on the boot class path - * - add VM argument: - * - * -Xbootclasspath/p:<install location>\jre\lib\ext\resolver.jar - * - * - */ -public class XSLTWithCatalogResolverTest extends TestCase { - - CatalogResolver catalogResolver = null; - TraXLiaison xsltLiason = null; - static String SEP = File.separator; - - public XSLTWithCatalogResolverTest(String name) { - super(name); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(XSLTWithCatalogResolverTest.class); - } - - protected void setUp() throws Exception { - super.setUp(); - catalogResolver = new CatalogResolver(); - xsltLiason = new TraXLiaison(); - xsltLiason.setEntityResolver(catalogResolver); - xsltLiason.setURIResolver(catalogResolver); - - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testXSLTwithCatalogResolver() throws Exception { - - String testDirName = "data/testXSLTwithCatalogResolver"; - testDirName = TestPlugin.resolvePluginLocation(testDirName); - - String catalogFileName = testDirName + SEP + "catalog.xml"; - String xslFileName = testDirName + SEP + "xmlcatalog.xsl"; - String xmlFileName = testDirName + SEP + "xmlcatalog2.xml"; - String resultFileName = xmlFileName + "-out"; - String idealResultFileName = xmlFileName + "-result"; - - //setup catalog - - File catalogFile = new File(catalogFileName); - - assertTrue("Catalog file " + catalogFileName + " should exist for the test", catalogFile.exists()); - - catalogResolver.getCatalog().parseCatalog(catalogFileName); - - File xslFile = new File(xslFileName); - - assertTrue("XSL file " + xslFileName + " should exist for the test", xslFile.exists()); - - File inFile = new File(xmlFileName); - - assertTrue("XML file " + xslFileName + " should exist for the test", xslFile.exists()); - - File outFile = FileUtil.createFileAndParentDirectories(resultFileName); - - xsltLiason.setStylesheet(xslFile); - xsltLiason.addParam("outprop", "testvalue"); - - xsltLiason.transform(inFile, outFile); - - boolean diffFound = - FileUtil.textualCompare( - outFile, - new File(idealResultFileName), - new File(resultFileName + "-diff")); - - assertTrue("Output file should match the expected results", !diffFound); - - - - } - - -} |