You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/10/25 18:05:10 UTC
svn commit: r467698 - in
/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf:
BasePDFTestCase.java PDFAConformanceTestCase.java PDFEncodingTestCase.java
Author: jeremias
Date: Wed Oct 25 09:05:10 2006
New Revision: 467698
URL: http://svn.apache.org/viewvc?view=rev&rev=467698
Log:
Style only.
Modified:
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java (contents, props changed)
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java (contents, props changed)
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java (props changed)
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java?view=diff&rev=467698&r1=467697&r2=467698
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java Wed Oct 25 09:05:10 2006
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+/* $Id$ */
+
package org.apache.fop.render.pdf;
import java.io.File;
@@ -34,51 +36,60 @@
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");
- }
}
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java?view=diff&rev=467698&r1=467697&r2=467698
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java Wed Oct 25 09:05:10 2006
@@ -44,9 +44,9 @@
* @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;
}
/**
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org