From f00026470476b32991733c7529fbbacb33210843 Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Tue, 26 Aug 2014 09:05:14 +0000 Subject: [PATCH] FOP-2353: Test PDF-A preflight warnings git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1620537 13f79535-47bb-0310-9956-ffa450edef68 --- .../fo/FO2StructureTreeConverterTestCase.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java b/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java index a86b5b2b2..6cd620870 100644 --- a/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java +++ b/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java @@ -19,8 +19,11 @@ package org.apache.fop.accessibility.fo; +import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -32,6 +35,7 @@ import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; +import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.custommonkey.xmlunit.Diff; @@ -40,17 +44,21 @@ import org.w3c.dom.Document; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.apache.fop.accessibility.StructureTree2SAXEventAdapter; import org.apache.fop.accessibility.StructureTreeEventHandler; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.FopFactory; import org.apache.fop.fo.FODocumentParser; import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.LoadingException; import org.apache.fop.fotreetest.DummyFOEventHandler; +import org.apache.fop.render.intermediate.IFContext; +import org.apache.fop.render.pdf.PDFDocumentHandler; public class FO2StructureTreeConverterTestCase { @@ -105,6 +113,20 @@ public class FO2StructureTreeConverterTestCase { return FO2StructureTreeConverterTestCase.class.getResourceAsStream(name); } + @Test + public void testPDFA() throws Exception { + FOUserAgent userAgent = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); + userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); + userAgent.setAccessibility(true); + PDFDocumentHandler d = new PDFDocumentHandler(new IFContext(userAgent)); + OutputStream writer = new ByteArrayOutputStream(); + StreamResult result = new StreamResult(writer); + d.setResult(result); + d.getStructureTreeEventHandler(); + d.startDocument(); + assertNull(d.getStructureTreeEventHandler().startNode("table-body", null, null)); + } + private void testConverter(String foResourceName) throws Exception { foLoader = new FOLoader(foResourceName); DOMResult expectedStructureTree = loadExpectedStructureTree(); -- 2.39.5