From a0436fb24868f4b0c02bcae1c11114d2a1423100 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 28 Jul 2008 13:14:04 +0000 Subject: [PATCH] Set error listener on both IF and AT tests. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@680341 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractIntermediateTestCase.java | 24 +++++++++++++++++++ .../intermediate/AreaTreeParserTestCase.java | 1 + .../fop/intermediate/IFParserTestCase.java | 18 +------------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java b/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java index c8f1810de..19b1a4a9d 100644 --- a/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java +++ b/test/java/org/apache/fop/intermediate/AbstractIntermediateTestCase.java @@ -25,12 +25,14 @@ import java.io.FileOutputStream; import java.io.OutputStream; import java.net.MalformedURLException; +import javax.xml.transform.ErrorListener; import javax.xml.transform.OutputKeys; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Templates; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.stream.StreamResult; @@ -227,4 +229,26 @@ public abstract class AbstractIntermediateTestCase extends XMLTestCase { protected abstract void parseAndRender(Source src, OutputStream out) throws Exception; + /** + * Sets an error listener which doesn't swallow errors like Xalan's default one. + * @param transformer the transformer to set the error listener on + */ + protected void setErrorListener(Transformer transformer) { + transformer.setErrorListener(new ErrorListener() { + + public void error(TransformerException exception) throws TransformerException { + throw exception; + } + + public void fatalError(TransformerException exception) throws TransformerException { + throw exception; + } + + public void warning(TransformerException exception) throws TransformerException { + //ignore + } + + }); + } + } diff --git a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java index 724bd80cf..fb394b099 100644 --- a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java @@ -69,6 +69,7 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTestCase { } else { transformer = tFactory.newTransformer(); } + setErrorListener(transformer); //Set up XMLRenderer to render to a DOM TransformerHandler handler = tFactory.newTransformerHandler(); diff --git a/test/java/org/apache/fop/intermediate/IFParserTestCase.java b/test/java/org/apache/fop/intermediate/IFParserTestCase.java index af0040e67..4e5500298 100644 --- a/test/java/org/apache/fop/intermediate/IFParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/IFParserTestCase.java @@ -22,12 +22,10 @@ package org.apache.fop.intermediate; import java.io.File; import java.io.OutputStream; -import javax.xml.transform.ErrorListener; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Templates; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamResult; @@ -70,21 +68,7 @@ public class IFParserTestCase extends AbstractIntermediateTestCase { transformer = tFactory.newTransformer(); } - transformer.setErrorListener(new ErrorListener() { - - public void error(TransformerException exception) throws TransformerException { - throw exception; - } - - public void fatalError(TransformerException exception) throws TransformerException { - throw exception; - } - - public void warning(TransformerException exception) throws TransformerException { - //ignore - } - - }); + setErrorListener(transformer); //Set up XMLRenderer to render to a DOM DOMResult domResult = new DOMResult(); -- 2.39.5