aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMehdi Houshmand <mehdi@apache.org>2011-11-21 16:35:41 +0000
committerMehdi Houshmand <mehdi@apache.org>2011-11-21 16:35:41 +0000
commitd955d844f87378114e860a7a2ab637a03dc35d7e (patch)
tree222283e96f66f7ba8f0759f908a2ead07eac0055 /test
parent96f6f23137a6709d0752ce70f5861852c2211bfb (diff)
downloadxmlgraphics-fop-d955d844f87378114e860a7a2ab637a03dc35d7e.tar.gz
xmlgraphics-fop-d955d844f87378114e860a7a2ab637a03dc35d7e.zip
Changed the error handling for AFP fonts such that errors are passed to the AFPEventProducer.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1204579 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/config/afp-codepage-missing.xconf16
-rw-r--r--test/config/afp-font-missing.xconf13
-rw-r--r--test/config/afp-invalid-characterset.xconf16
-rw-r--r--test/config/afp-invalid-config.xconf16
-rw-r--r--test/config/afp-invalid-file-name.xconf16
-rw-r--r--test/config/afp-raster-font-missing.xconf15
-rw-r--r--test/config/afp-triplet-missing.xconf15
-rw-r--r--test/java/org/apache/fop/afp/AFPEventProcessingTestCase.java79
-rw-r--r--test/java/org/apache/fop/afp/simple.fo14
-rw-r--r--test/java/org/apache/fop/events/EventProcessingTestCase.java15
-rw-r--r--test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java13
11 files changed, 217 insertions, 11 deletions
diff --git a/test/config/afp-codepage-missing.xconf b/test/config/afp-codepage-missing.xconf
new file mode 100644
index 000000000..c44b1256e
--- /dev/null
+++ b/test/config/afp-codepage-missing.xconf
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop version="1.0">
+ <base>.</base>
+ <renderers>
+ <renderer mime="application/x-afp">
+ <fonts>
+ <font>
+ <afp-font name="TEST" type="raster" codepage="codepage" encoding="Cp500">
+ <afp-raster-font size="36" characterset="C0N200Z0"/>
+ </afp-font>
+ <font-triplet name="TEST" style="normal" weight="normal"/>
+ </font>
+ </fonts>
+ </renderer>
+ </renderers>
+</fop>
diff --git a/test/config/afp-font-missing.xconf b/test/config/afp-font-missing.xconf
new file mode 100644
index 000000000..8eeb3557d
--- /dev/null
+++ b/test/config/afp-font-missing.xconf
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop version="1.0">
+ <base>.</base>
+ <renderers>
+ <renderer mime="application/x-afp">
+ <fonts>
+ <font>
+ <font-triplet name="TEST" style="normal" weight="normal"/>
+ </font>
+ </fonts>
+ </renderer>
+ </renderers>
+</fop>
diff --git a/test/config/afp-invalid-characterset.xconf b/test/config/afp-invalid-characterset.xconf
new file mode 100644
index 000000000..48147e726
--- /dev/null
+++ b/test/config/afp-invalid-characterset.xconf
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop version="1.0">
+ <base>.</base>
+ <renderers>
+ <renderer mime="application/x-afp">
+ <fonts>
+ <font>
+ <afp-font name="TEST" type="raster" codepage="T1V10500" encoding="Cp500" ebcdic-dbcs="true">
+ <afp-raster-font size="36" characterset="THIS NAME IS TOO LONG"/>
+ </afp-font>
+ <font-triplet name="TEST" style="normal" weight="normal"/>
+ </font>
+ </fonts>
+ </renderer>
+ </renderers>
+</fop>
diff --git a/test/config/afp-invalid-config.xconf b/test/config/afp-invalid-config.xconf
new file mode 100644
index 000000000..30eecbe6d
--- /dev/null
+++ b/test/config/afp-invalid-config.xconf
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop version="1.0">
+ <base>.</base>
+ <renderers>
+ <renderer mime="application/x-afp">
+ <fonts>
+ <font>
+ <afp-font name="TEST" type="raster" codepage="T1V10500" encoding="Cp500">
+ <afp-raster-font size="36" characterset="C0N200Z0"/>
+ </afp-font>
+ <font-triplet name="TEST" style="normal" weight="normal"/>
+ </font>
+ </fonts>
+ </renderer>
+ </renderers>
+</fop>
diff --git a/test/config/afp-invalid-file-name.xconf b/test/config/afp-invalid-file-name.xconf
new file mode 100644
index 000000000..8cbafcac9
--- /dev/null
+++ b/test/config/afp-invalid-file-name.xconf
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop version="1.0">
+ <base>.</base>
+ <renderers>
+ <renderer mime="application/x-afp">
+ <fonts>
+ <font>
+ <afp-font name="TEST" type="raster" codepage="bad:\\lkja" encoding="Cp500" ebcdic-dbcs="true">
+ <afp-raster-font size="36" characterset="C0N200Z0"/>
+ </afp-font>
+ <font-triplet name="TEST" style="normal" weight="normal"/>
+ </font>
+ </fonts>
+ </renderer>
+ </renderers>
+</fop>
diff --git a/test/config/afp-raster-font-missing.xconf b/test/config/afp-raster-font-missing.xconf
new file mode 100644
index 000000000..cf6578d6a
--- /dev/null
+++ b/test/config/afp-raster-font-missing.xconf
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop version="1.0">
+ <base>.</base>
+ <renderers>
+ <renderer mime="application/x-afp">
+ <fonts>
+ <font>
+ <afp-font name="TEST" type="raster" codepage="T1V10500" encoding="Cp500">
+ </afp-font>
+ <font-triplet name="TEST" style="normal" weight="normal"/>
+ </font>
+ </fonts>
+ </renderer>
+ </renderers>
+</fop>
diff --git a/test/config/afp-triplet-missing.xconf b/test/config/afp-triplet-missing.xconf
new file mode 100644
index 000000000..59ddd9689
--- /dev/null
+++ b/test/config/afp-triplet-missing.xconf
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop version="1.0">
+ <base>.</base>
+ <renderers>
+ <renderer mime="application/x-afp">
+ <fonts>
+ <font>
+ <afp-font name="Times Roman" type="raster" codepage="T1V10500" encoding="Cp500">
+ <afp-raster-font size="36" characterset="C0N200Z0" base14-font="TimesRoman"/>
+ </afp-font>
+ </font>
+ </fonts>
+ </renderer>
+ </renderers>
+</fop>
diff --git a/test/java/org/apache/fop/afp/AFPEventProcessingTestCase.java b/test/java/org/apache/fop/afp/AFPEventProcessingTestCase.java
new file mode 100644
index 000000000..cd0faa39b
--- /dev/null
+++ b/test/java/org/apache/fop/afp/AFPEventProcessingTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.afp;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.transform.TransformerException;
+
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import org.apache.xmlgraphics.util.MimeConstants;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.events.EventProcessingTestCase;
+
+/**
+ * A test class for testing AFP events.
+ */
+public class AFPEventProcessingTestCase {
+
+ private EventProcessingTestCase eventsTests = new EventProcessingTestCase();
+ private static final String CONFIG_BASE_DIR = EventProcessingTestCase.CONFIG_BASE_DIR;
+
+ private void testInvalidConfigEvent(String xconf, String eventId)
+ throws FOPException, TransformerException, IOException, SAXException {
+ InputStream inStream = getClass().getResourceAsStream("simple.fo");
+ eventsTests.doTest(inStream, CONFIG_BASE_DIR + xconf,
+ AFPEventProducer.class.getName() + eventId, MimeConstants.MIME_AFP);
+ }
+
+ @Test
+ public void testMissingFontConfigurationElement() throws FOPException, TransformerException,
+ IOException, SAXException {
+ testInvalidConfigEvent("afp-font-missing.xconf", ".fontConfigMissing");
+ }
+
+ @Test
+ public void testInvalidCharactersetName() throws FOPException, TransformerException,
+ IOException, SAXException {
+ testInvalidConfigEvent("afp-invalid-characterset.xconf", ".characterSetNameInvalid");
+ }
+
+ @Test
+ public void testinvalidConfig() throws FOPException, TransformerException, IOException,
+ SAXException {
+ testInvalidConfigEvent("afp-invalid-config.xconf", ".invalidConfiguration");
+ }
+
+ @Test
+ public void testRasterFontElementMissing() throws FOPException, TransformerException,
+ IOException, SAXException {
+ testInvalidConfigEvent("afp-raster-font-missing.xconf", ".fontConfigMissing");
+ }
+
+ @Test
+ public void testTripletElementMissing() throws FOPException, TransformerException,
+ IOException, SAXException {
+ testInvalidConfigEvent("afp-triplet-missing.xconf", ".fontConfigMissing");
+ }
+}
diff --git a/test/java/org/apache/fop/afp/simple.fo b/test/java/org/apache/fop/afp/simple.fo
new file mode 100644
index 000000000..760ff4b63
--- /dev/null
+++ b/test/java/org/apache/fop/afp/simple.fo
@@ -0,0 +1,14 @@
+<?xml version="1.0" standalone="no"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="420pt" page-width="320pt" margin="10pt">
+ <fo:region-body background-color="#F0F0F0"/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="page">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>This is a simple document.</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>
diff --git a/test/java/org/apache/fop/events/EventProcessingTestCase.java b/test/java/org/apache/fop/events/EventProcessingTestCase.java
index eda016002..8219fa71e 100644
--- a/test/java/org/apache/fop/events/EventProcessingTestCase.java
+++ b/test/java/org/apache/fop/events/EventProcessingTestCase.java
@@ -60,7 +60,10 @@ public class EventProcessingTestCase {
private static final String BASE_DIR = "test/events/";
- public void doTest(InputStream inStream, String fopConf, String expectedEventID)
+ /** The base directory of configuration files */
+ public static final String CONFIG_BASE_DIR = "test/config/";
+
+ public void doTest(InputStream inStream, String fopConf, String expectedEventID, String mimeType)
throws FOPException, TransformerException, IOException, SAXException {
EventChecker eventChecker = new EventChecker(expectedEventID);
if (fopConf != null) {
@@ -68,7 +71,7 @@ public class EventProcessingTestCase {
}
FOUserAgent userAgent = fopFactory.newFOUserAgent();
userAgent.getEventBroadcaster().addEventListener(eventChecker);
- Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, new NullOutputStream());
+ Fop fop = fopFactory.newFop(mimeType, userAgent, new NullOutputStream());
Transformer transformer = tFactory.newTransformer();
Source src = new StreamSource(inStream);
Result res = new SAXResult(fop.getDefaultHandler());
@@ -78,12 +81,8 @@ public class EventProcessingTestCase {
public void doTest(String filename, String expectedEventID) throws
FOPException, TransformerException, IOException, SAXException {
- doTest(filename, null, expectedEventID);
- }
-
- public void doTest(String filename, String fopConf, String expectedEventID) throws
- FOPException, TransformerException, IOException, SAXException {
- doTest(new FileInputStream(BASE_DIR + filename), fopConf, expectedEventID);
+ doTest(new FileInputStream(BASE_DIR + filename), null, expectedEventID,
+ MimeConstants.MIME_PDF);
}
@Test
diff --git a/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java b/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java
index b35f38877..898f83197 100644
--- a/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java
+++ b/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java
@@ -27,6 +27,8 @@ import javax.xml.transform.TransformerException;
import org.junit.Test;
import org.xml.sax.SAXException;
+import org.apache.xmlgraphics.util.MimeConstants;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.events.EventProcessingTestCase;
@@ -37,17 +39,22 @@ public class FontEventProcessingTestCase {
private EventProcessingTestCase eventsTests = new EventProcessingTestCase();
+ private static final String CONFIG_BASE_DIR = EventProcessingTestCase.CONFIG_BASE_DIR;
+
@Test
public void testFont() throws FOPException, TransformerException, IOException, SAXException {
InputStream inStream = getClass().getResourceAsStream("substituted-font.fo");
- eventsTests.doTest(inStream, null, FontEventProducer.class.getName() + ".fontSubstituted");
+ eventsTests.doTest(inStream, null, FontEventProducer.class.getName() + ".fontSubstituted",
+ MimeConstants.MIME_PDF);
}
@Test
public void testFontWithBadDirectory() throws FOPException, TransformerException, IOException,
SAXException {
InputStream inStream = getClass().getResourceAsStream("substituted-font.fo");
- eventsTests.doTest(inStream, "test/config/test_fonts_directory_bad.xconf",
- FontEventProducer.class.getName() + ".fontDirectoryNotFound");
+ eventsTests.doTest(inStream, CONFIG_BASE_DIR + "test_fonts_directory_bad.xconf",
+ FontEventProducer.class.getName() + ".fontDirectoryNotFound",
+ MimeConstants.MIME_PDF);
}
+
}