aboutsummaryrefslogtreecommitdiffstats
path: root/test/java/org/apache
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-02-18 09:41:03 +0000
committerJeremias Maerki <jeremias@apache.org>2008-02-18 09:41:03 +0000
commit263b70846b06d2a119d5d253633e5678a9f908bb (patch)
tree61e818e9d7c8edd89cf227670d821e52ad2145e4 /test/java/org/apache
parenta5c33430c6e04172ab219455fdecf86eb9f63aae (diff)
downloadxmlgraphics-fop-263b70846b06d2a119d5d253633e5678a9f908bb.tar.gz
xmlgraphics-fop-263b70846b06d2a119d5d253633e5678a9f908bb.zip
Extract original exception in BasePDFTestCase.java. They are normally embedded in a TransformerException and sometimes additionally in a SAXException (depending on the JAXP implementation).
Restore validation for Base14 font check when PDF/A is active. Got lost when I refactored to generic structures in the PDF library. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@628668 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java/org/apache')
-rw-r--r--test/java/org/apache/fop/render/pdf/BasePDFTestCase.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
index 3b4e03118..7c66a0ceb 100644
--- a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
+++ b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
@@ -23,12 +23,16 @@ import java.io.File;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
+import org.xml.sax.SAXException;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
+
import org.apache.fop.AbstractFOPTestCase;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
@@ -78,21 +82,37 @@ public class BasePDFTestCase extends AbstractFOPTestCase {
* @throws Exception if the conversion fails
*/
protected byte[] convertFO(File foFile, FOUserAgent ua, boolean dumpPdfFile)
- throws Exception {
+ throws Exception {
ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, ua, baout);
Transformer transformer = tFactory.newTransformer();
Source src = new StreamSource(foFile);
SAXResult res = new SAXResult(fop.getDefaultHandler());
- transformer.transform(src, res);
- final byte[] result = baout.toByteArray();
- if (dumpPdfFile) {
- final File outFile = new File(foFile.getParentFile(), foFile.getName() + ".pdf");
- FileUtils.writeByteArrayToFile(outFile, result);
+ try {
+ transformer.transform(src, res);
+ final byte[] result = baout.toByteArray();
+ if (dumpPdfFile) {
+ final File outFile = new File(foFile.getParentFile(), foFile.getName() + ".pdf");
+ FileUtils.writeByteArrayToFile(outFile, result);
+ }
+ return result;
+ } catch (TransformerException e) {
+ throw extractOriginalException(e);
}
- return result;
}
+ private static Exception extractOriginalException(Exception e) {
+ if (e.getCause() != null) {
+ return extractOriginalException((Exception)e.getCause());
+ } else if (e instanceof SAXException) {
+ SAXException se = (SAXException)e;
+ if (se.getException() != null) {
+ return extractOriginalException(se.getException());
+ }
+ }
+ return e;
+ }
+
/**
* get FOP config File
* @return user config file to be used for testing