]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2353: Test PDF-A preflight warnings
authorSimon Steiner <ssteiner@apache.org>
Tue, 26 Aug 2014 09:05:14 +0000 (09:05 +0000)
committerSimon Steiner <ssteiner@apache.org>
Tue, 26 Aug 2014 09:05:14 +0000 (09:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1620537 13f79535-47bb-0310-9956-ffa450edef68

test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java

index a86b5b2b264e0742d7ccb82c3d1c7cf6bd5c9efb..6cd6208706223f152a5b2a9ce2e1a3bdb85fe31d 100644 (file)
 
 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();