diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-10-25 16:05:10 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-10-25 16:05:10 +0000 |
commit | e31971dcdb4ab8208fc543909e3238d7e00f3347 (patch) | |
tree | 4dfc2b1815a1a02cdf2ade5241301a41cd6a6645 /test/java | |
parent | e5b06f828b5d684968d3210af4df8eedf264d6c3 (diff) | |
download | xmlgraphics-fop-e31971dcdb4ab8208fc543909e3238d7e00f3347.tar.gz xmlgraphics-fop-e31971dcdb4ab8208fc543909e3238d7e00f3347.zip |
Style only.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@467698 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java')
-rw-r--r-- | test/java/org/apache/fop/render/pdf/BasePDFTestCase.java | 97 | ||||
-rw-r--r-- | test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java | 6 |
2 files changed, 57 insertions, 46 deletions
diff --git a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java index 11ee3e75f..54e2ba9d8 100644 --- a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java +++ b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java @@ -15,6 +15,8 @@ * limitations under the License. */ +/* $Id$ */ + package org.apache.fop.render.pdf; import java.io.File; @@ -34,51 +36,60 @@ import org.apache.fop.apps.MimeConstants; import junit.framework.TestCase; -/** Base class for automated tests that create PDF files - * $Id$ +/** + * Base class for automated tests that create PDF files */ - public class BasePDFTestCase extends TestCase { - protected final FopFactory fopFactory = FopFactory.newInstance(); - protected final TransformerFactory tFactory = TransformerFactory.newInstance(); - protected BasePDFTestCase(String name) { - super(name); - - final File uc = getUserConfigFile(); - - try { - fopFactory.setUserConfig(uc); - } catch (Exception e) { - throw new RuntimeException("fopFactory.setUserConfig (" + uc.getAbsolutePath() + ") failed: " + e.getMessage()); + /** the FopFactory */ + protected final FopFactory fopFactory = FopFactory.newInstance(); + + /** the JAXP TransformerFactory */ + protected final TransformerFactory tFactory = TransformerFactory.newInstance(); + + /** + * Main constructor + * @param name the name of the test case + */ + protected BasePDFTestCase(String name) { + super(name); + + final File uc = getUserConfigFile(); + + try { + fopFactory.setUserConfig(uc); + } catch (Exception e) { + throw new RuntimeException("fopFactory.setUserConfig (" + + uc.getAbsolutePath() + ") failed: " + e.getMessage()); + } + } + + /** + * Convert a test FO file to PDF + * @param foFile the FO file + * @param ua the preconfigured user agent + * @param dumpPdfFile if true, dumps the generated PDF file to a file name (foFile).pdf + * @return the generated PDF data + * @throws Exception if the conversion fails + */ + protected byte[] convertFO(File foFile, FOUserAgent ua, boolean dumpPdfFile) + 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); + } + return result; + } + + /** get FOP config File */ + protected File getUserConfigFile() { + return new File("test/test.xconf"); } - } - - /** - * Convert a test FO file to PDF - * @param foFile the FO file - * @param ua the preconfigured user agent - * @param dumpPdfFile if true, dumps the generated PDF file to a file name (foFile).pdf - * @return the generated PDF data - * @throws Exception if the conversion fails - */ - protected byte[] convertFO(File foFile, FOUserAgent ua, boolean dumpPdfFile) 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); - } - return result; - } - - /** get FOP config File */ - protected File getUserConfigFile() { - return new File("test/test.xconf"); - } } diff --git a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java index 1e5b70056..54ea5b571 100644 --- a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java @@ -44,9 +44,9 @@ public class PDFAConformanceTestCase extends BasePDFTestCase { * @return an initialized FOUserAgent * */ protected FOUserAgent getUserAgent() { - final FOUserAgent a = fopFactory.newFOUserAgent(); - a.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); - return a; + final FOUserAgent a = fopFactory.newFOUserAgent(); + a.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); + return a; } /** |