diff options
Diffstat (limited to 'test/java')
7 files changed, 80 insertions, 9 deletions
diff --git a/test/java/org/apache/fop/DebugHelper.java b/test/java/org/apache/fop/DebugHelper.java index 9ee7de072..1fb7074ee 100644 --- a/test/java/org/apache/fop/DebugHelper.java +++ b/test/java/org/apache/fop/DebugHelper.java @@ -30,7 +30,7 @@ public final class DebugHelper { private DebugHelper() { } - private static boolean elObserversRegistered = false; + private static boolean elObserversRegistered; /** * Registers the default element list observers used for debugging. diff --git a/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java b/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java index b4e2cee2e..39b6fd50f 100644 --- a/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java +++ b/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java @@ -30,9 +30,9 @@ import static org.junit.Assert.assertTrue; public class OTFFileTestCase { protected OTFFile sourceSansProBold; - protected FontFileReader sourceSansReader = null; + protected FontFileReader sourceSansReader; protected OTFFile alexBrush; - protected FontFileReader alexBrushReader = null; + protected FontFileReader alexBrushReader; /** * Initializes fonts used for the testing of reading OTF CFF diff --git a/test/java/org/apache/fop/fotreetest/ResultCollector.java b/test/java/org/apache/fop/fotreetest/ResultCollector.java index d5b362704..948b856bf 100644 --- a/test/java/org/apache/fop/fotreetest/ResultCollector.java +++ b/test/java/org/apache/fop/fotreetest/ResultCollector.java @@ -28,7 +28,7 @@ import java.util.List; */ public class ResultCollector { - private static ResultCollector instance = null; + private static ResultCollector instance; private List<String> results = new ArrayList<String>(); diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java index 963b66dff..2649838f4 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java @@ -59,7 +59,7 @@ public final class LayoutEngineTestUtils { private static class FilenameHandler extends DefaultHandler { private StringBuffer buffer = new StringBuffer(128); - private boolean readingFilename = false; + private boolean readingFilename; private List<String> filenames; public FilenameHandler(List<String> filenames) { diff --git a/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java b/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java index 880613a78..5d423442c 100644 --- a/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java @@ -25,6 +25,7 @@ import java.awt.Font; import java.awt.Graphics2D; import org.junit.Test; +import static org.junit.Assert.assertEquals; import org.apache.commons.io.output.ByteArrayOutputStream; @@ -32,8 +33,6 @@ import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.svg.PDFDocumentGraphics2D; -import junit.framework.Assert; - /** * Tests for {@link PDFDocumentGraphics2D}. */ @@ -86,7 +85,7 @@ public class PDFDocumentGraphics2DTestCase { g2d.finish(); String pdfString = baout.toString("ISO-8859-1"); - Assert.assertEquals("%%EOF not found", + assertEquals("%%EOF not found", pdfString.substring(pdfString.length() - 6), "%%EOF\n"); } diff --git a/test/java/org/apache/fop/render/pdf/extensions/PDFDocumentInformationElementTestCase.java b/test/java/org/apache/fop/render/pdf/extensions/PDFDocumentInformationElementTestCase.java new file mode 100644 index 000000000..939b5fb11 --- /dev/null +++ b/test/java/org/apache/fop/render/pdf/extensions/PDFDocumentInformationElementTestCase.java @@ -0,0 +1,72 @@ +/* + * 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.render.pdf.extensions; + +import java.io.FileInputStream; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +import org.apache.xmlgraphics.util.QName; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.events.EventChecker; +import org.apache.fop.fo.FODocumentParser; +import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; +import org.apache.fop.fo.FOEventHandler; +import org.apache.fop.fo.FOValidationEventProducer; +import org.apache.fop.fo.LoadingException; +import org.apache.fop.fotreetest.DummyFOEventHandler; + +public class PDFDocumentInformationElementTestCase { + + private FODocumentParser parser = FODocumentParser.newInstance(new FOEventHandlerFactory() { + + public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) { + return new DummyFOEventHandler(foUserAgent); + } + }); + + @Test(expected = LoadingException.class) + public void illegalChild() throws Exception { + Map<String, Object> expectedParams = new HashMap<String, Object>(); + expectedParams.put("offendingNode", new QName(PDFElementMapping.NAMESPACE, "dictionary")); + runTest("invalid-child.fo", FOValidationEventProducer.class.getName() + ".invalidChild", expectedParams); + } + + @Test + public void standardKeyword() throws Exception { + Map<String, Object> expectedParams = new HashMap<String, Object>(); + expectedParams.put("keyword", "Creator"); + runTest("reserved-keyword.fo", PDFExtensionEventProducer.class.getName() + ".reservedKeyword", expectedParams); + } + + private void runTest(String testCase, String expectedEventKey, Map<String, Object> expectedEventParams) + throws Exception { + EventChecker eventChecker = new EventChecker(expectedEventKey, expectedEventParams); + parser.setEventListener(eventChecker); + try { + parser.parse(new FileInputStream("test/pdf/extensions/document-information/" + testCase)); + } finally { + eventChecker.end(); + } + } +} diff --git a/test/java/org/apache/fop/threading/FOPTestbed.java b/test/java/org/apache/fop/threading/FOPTestbed.java index f015479c7..7b08b7cd1 100644 --- a/test/java/org/apache/fop/threading/FOPTestbed.java +++ b/test/java/org/apache/fop/threading/FOPTestbed.java @@ -59,7 +59,7 @@ public class FOPTestbed extends AbstractLogEnabled private Processor foprocessor; private boolean writeToDevNull; - private int counter = 0; + private int counter; private List results = Collections.synchronizedList(new java.util.LinkedList()); |