diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2014-03-17 09:31:13 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2014-03-17 09:31:13 +0000 |
commit | daad32822e9da5a05bb8dbe17878c8e677d0af29 (patch) | |
tree | 30412d8f693ba407f68b64b06076e79b18505373 /test/java/org/apache/fop | |
parent | aa09fc131c1cc8278486293cef5b3fc72f6ebac2 (diff) | |
parent | 4c131bd42f52e394b4c6220a3af179cb4539bf40 (diff) | |
download | xmlgraphics-fop-daad32822e9da5a05bb8dbe17878c8e677d0af29.tar.gz xmlgraphics-fop-daad32822e9da5a05bb8dbe17878c8e677d0af29.zip |
Brought the branch in sync with rev. 1577477 of trunk
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_WhitespaceManagement@1578276 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java/org/apache/fop')
219 files changed, 2260 insertions, 816 deletions
diff --git a/test/java/org/apache/fop/AbstractBasicTranscoderTest.java b/test/java/org/apache/fop/AbstractBasicTranscoderTest.java index 2087c8df2..7a40b353a 100644 --- a/test/java/org/apache/fop/AbstractBasicTranscoderTest.java +++ b/test/java/org/apache/fop/AbstractBasicTranscoderTest.java @@ -24,13 +24,15 @@ import java.io.InputStream; import org.junit.Test; +import static org.junit.Assert.assertTrue; + +import org.apache.commons.io.output.ByteArrayOutputStream; + import org.apache.batik.transcoder.Transcoder; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; -import org.apache.commons.io.output.ByteArrayOutputStream; import static org.apache.fop.FOPTestUtils.getBaseDir; -import static org.junit.Assert.assertTrue; /** * Basic runtime test for FOP's transcoders. It is used to verify that diff --git a/test/java/org/apache/fop/BasicDriverTestCase.java b/test/java/org/apache/fop/BasicDriverTestCase.java index f149b451e..e89a1c558 100644 --- a/test/java/org/apache/fop/BasicDriverTestCase.java +++ b/test/java/org/apache/fop/BasicDriverTestCase.java @@ -28,11 +28,13 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; -import org.apache.fop.apps.FOPException; import org.junit.Test; +import static org.junit.Assert.assertTrue; + import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; @@ -40,7 +42,6 @@ import org.apache.fop.apps.MimeConstants; import org.apache.fop.cli.InputHandler; import static org.apache.fop.FOPTestUtils.getBaseDir; -import static org.junit.Assert.assertTrue; /** * Basic runtime test for the old Fop class. It is used to verify that @@ -136,7 +137,7 @@ public class BasicDriverTestCase { InputHandler handler = new InputHandler(xmlFile, xsltFile, null); try { handler.renderTo(foUserAgent, MimeConstants.MIME_PDF, baout); - } catch (FOPException e) {} + } catch (FOPException e) { /* NOP */ } } } diff --git a/test/java/org/apache/fop/BasicDriverTestSuite.java b/test/java/org/apache/fop/BasicDriverTestSuite.java index 8330a5f7f..68619926a 100644 --- a/test/java/org/apache/fop/BasicDriverTestSuite.java +++ b/test/java/org/apache/fop/BasicDriverTestSuite.java @@ -27,6 +27,6 @@ import org.junit.runners.Suite.SuiteClasses; * Test suite for basic functionality of FOP's Driver API. */ @RunWith(Suite.class) -@SuiteClasses({ BasicDriverTestCase.class }) +@SuiteClasses(BasicDriverTestCase.class) public class BasicDriverTestSuite { } diff --git a/test/java/org/apache/fop/BasicPSTranscoderTestCase.java b/test/java/org/apache/fop/BasicPSTranscoderTestCase.java index f2f233a5a..2d6fc0d81 100644 --- a/test/java/org/apache/fop/BasicPSTranscoderTestCase.java +++ b/test/java/org/apache/fop/BasicPSTranscoderTestCase.java @@ -20,6 +20,7 @@ package org.apache.fop; import org.apache.batik.transcoder.Transcoder; + import org.apache.fop.render.ps.PSTranscoder; /** diff --git a/test/java/org/apache/fop/DebugHelper.java b/test/java/org/apache/fop/DebugHelper.java index 6705d2f56..9ee7de072 100644 --- a/test/java/org/apache/fop/DebugHelper.java +++ b/test/java/org/apache/fop/DebugHelper.java @@ -25,7 +25,10 @@ import org.apache.fop.logging.LoggingElementListObserver; /** * Handles some standard tasks for debugging. */ -public class DebugHelper { +public final class DebugHelper { + + private DebugHelper() { + } private static boolean elObserversRegistered = false; diff --git a/test/java/org/apache/fop/DigestFilterTestCase.java b/test/java/org/apache/fop/DigestFilterTestCase.java index 5606c2b66..679b65aee 100644 --- a/test/java/org/apache/fop/DigestFilterTestCase.java +++ b/test/java/org/apache/fop/DigestFilterTestCase.java @@ -19,8 +19,6 @@ package org.apache.fop; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.security.NoSuchAlgorithmException; @@ -28,13 +26,16 @@ import java.security.NoSuchAlgorithmException; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; -import org.apache.fop.util.DigestFilter; import org.junit.Before; import org.junit.Test; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; +import static org.junit.Assert.assertTrue; + +import org.apache.fop.util.DigestFilter; + /** * Test case for digesting SAX filter. * diff --git a/test/java/org/apache/fop/KnuthAlgorithmTestCase.java b/test/java/org/apache/fop/KnuthAlgorithmTestCase.java index b5132fee9..aa92191de 100644 --- a/test/java/org/apache/fop/KnuthAlgorithmTestCase.java +++ b/test/java/org/apache/fop/KnuthAlgorithmTestCase.java @@ -23,6 +23,7 @@ import java.util.List; import org.junit.Before; import org.junit.Test; + import static org.junit.Assert.assertEquals; import org.apache.fop.layoutmgr.BlockKnuthSequence; diff --git a/test/java/org/apache/fop/URIResolutionTestCase.java b/test/java/org/apache/fop/URIResolutionTestCase.java index e1015306e..e01271f2b 100644 --- a/test/java/org/apache/fop/URIResolutionTestCase.java +++ b/test/java/org/apache/fop/URIResolutionTestCase.java @@ -41,6 +41,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.w3c.dom.Document; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.xpath.XPathAPI; @@ -59,8 +62,6 @@ import org.apache.fop.apps.io.ResourceResolverFactory; import org.apache.fop.render.xml.XMLRenderer; import static org.apache.fop.FOPTestUtils.getBaseDir; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; /** * Tests URI resolution facilities. diff --git a/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java b/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java index fc5f1825c..e9134a90b 100644 --- a/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java +++ b/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java @@ -19,11 +19,11 @@ package org.apache.fop.afp; -import static org.junit.Assert.assertEquals; - import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * Test case for {@link AFPObjectAreaInfo}. */ diff --git a/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java b/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java index 47c93064c..e9806f944 100644 --- a/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java +++ b/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java @@ -19,11 +19,11 @@ package org.apache.fop.afp; -import static org.junit.Assert.assertEquals; - import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * Test case for {@link AFPPaintingState}. */ diff --git a/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java b/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java index 21540221f..9d805a7da 100644 --- a/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java +++ b/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java @@ -26,13 +26,13 @@ import java.io.IOException; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.xmlgraphics.util.MimeConstants; import org.apache.fop.apps.io.ResourceResolverFactory; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - /** * Test case for {@link AFPResourceManager}. */ diff --git a/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java b/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java index a7cf57ebe..178e5c6ad 100644 --- a/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java +++ b/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java @@ -19,8 +19,6 @@ package org.apache.fop.afp; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -29,11 +27,11 @@ import java.util.Arrays; import org.junit.Test; +import static org.junit.Assert.assertTrue; + import org.apache.commons.io.IOUtils; -import org.apache.fop.afp.util.AFPResourceUtil; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.apache.fop.afp.util.AFPResourceUtil; /** * Tests the {@link AFPResourceUtil} class. @@ -133,7 +131,7 @@ public class AFPResourceUtilTestCase { * names fails. * @throws Exception - */ - @Test(expected=Exception.class) + @Test(expected = Exception.class) public void testResourceNameMismatch() throws Exception { testResource(RESOURCE_NAME_MISMATCH, PSEG_B); } @@ -156,6 +154,6 @@ public class AFPResourceUtilTestCase { } private interface ResourceCopier { - public void copy(InputStream in, OutputStream out) throws IOException; + void copy(InputStream in, OutputStream out) throws IOException; } } diff --git a/test/java/org/apache/fop/afp/fonts/IntegerKeyStoreTestCase.java b/test/java/org/apache/fop/afp/fonts/IntegerKeyStoreTestCase.java new file mode 100644 index 000000000..96c0618a7 --- /dev/null +++ b/test/java/org/apache/fop/afp/fonts/IntegerKeyStoreTestCase.java @@ -0,0 +1,48 @@ +/* + * 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.fonts; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +public class IntegerKeyStoreTestCase { + + @Test + public void getAndPut() { + IntegerKeyStore<Integer> sut = new IntegerKeyStore<Integer>(); + assertNull(sut.get(0)); + sut.put(0, 0); + assertEquals(Integer.valueOf(0), sut.get(0)); + sut.put(0, 1); + assertEquals(Integer.valueOf(1), sut.get(0)); + sut.put(0, null); + assertNull(sut.get(0)); + try { + sut.put(-1, 0); + fail("Negative index"); + } catch (IndexOutOfBoundsException e) { + // As expected + } + } + +} diff --git a/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java b/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java index b77ef6e12..17c47743c 100644 --- a/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java +++ b/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java @@ -16,16 +16,17 @@ */ package org.apache.fop.afp.goca; -import static org.junit.Assert.assertEquals; - import java.io.ByteArrayOutputStream; import java.io.IOException; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + import org.apache.fop.afp.fonts.CharacterSet; import org.apache.fop.afp.fonts.CharacterSetBuilder; import org.apache.fop.fonts.Typeface; -import org.junit.Before; -import org.junit.Test; public class GraphicsCharacterStringTestCase { private GraphicsCharacterString gcsCp500; diff --git a/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java index 65c0224c2..a4c80cc65 100644 --- a/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java +++ b/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java @@ -19,10 +19,6 @@ package org.apache.fop.afp.modca; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -30,9 +26,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.fop.afp.Streamable; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.apache.fop.afp.Streamable; + /** * Tests the {@link AbstractAFPObject} class. */ diff --git a/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java index 5c863b6e4..0593ae637 100644 --- a/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java +++ b/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java @@ -19,12 +19,12 @@ package org.apache.fop.afp.modca; -import static org.junit.Assert.assertTrue; - import java.util.Arrays; import org.junit.Test; +import static org.junit.Assert.assertTrue; + /** * Tests the {@linkplain AbstractAFPObject} class. */ diff --git a/test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java index faef0a4f6..d0a543087 100644 --- a/test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java +++ b/test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java @@ -21,7 +21,8 @@ package org.apache.fop.afp.modca; import java.io.IOException; -public abstract class AbstractStructuredObjectTest<S extends AbstractStructuredObject> extends AbstractAFPObjectTest<S> { +public abstract class AbstractStructuredObjectTest<S extends AbstractStructuredObject> + extends AbstractAFPObjectTest<S> { /** * Test writeStart() - test that the contract is maintained with diff --git a/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java index 10c154550..fe25996bb 100644 --- a/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java +++ b/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java @@ -19,10 +19,6 @@ package org.apache.fop.afp.modca; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -33,6 +29,10 @@ import java.util.List; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.fop.afp.modca.triplets.AbstractTriplet; import org.apache.fop.afp.modca.triplets.AttributeQualifierTriplet; import org.apache.fop.afp.modca.triplets.CommentTriplet; diff --git a/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java b/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java index 0449f2599..7e096f98b 100644 --- a/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java +++ b/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java @@ -19,16 +19,17 @@ package org.apache.fop.afp.modca; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Arrays; -import org.apache.fop.afp.util.BinaryUtils; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertTrue; + +import org.apache.fop.afp.util.BinaryUtils; + /** * Test {@link IncludeObject} */ diff --git a/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java b/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java index c80ef086c..176344618 100644 --- a/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java +++ b/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java @@ -19,11 +19,6 @@ package org.apache.fop.afp.parser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.EOFException; @@ -32,6 +27,11 @@ import java.util.Arrays; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * MODCAParser and MODCAParser.UnparsedStructuredField Unit tests */ diff --git a/test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java b/test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java index 338c5e6f4..8d6c79d05 100644 --- a/test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java +++ b/test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java @@ -24,15 +24,16 @@ import java.io.OutputStream; import org.junit.Test; -import org.apache.fop.afp.fonts.CharactersetEncoder.EncodedChars; -import org.apache.fop.afp.ptoca.TransparentDataControlSequence.TransparentData; - -import static org.apache.fop.afp.ptoca.PtocaConstants.TRANSPARENT_DATA_MAX_SIZE; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.apache.fop.afp.fonts.CharactersetEncoder.EncodedChars; +import org.apache.fop.afp.ptoca.TransparentDataControlSequence.TransparentData; + +import static org.apache.fop.afp.ptoca.PtocaConstants.TRANSPARENT_DATA_MAX_SIZE; + public class TransparentDataControlSequenceTestCase { private EncodedChars encodedChars; diff --git a/test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java b/test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java index 9739db2f3..e4c9ceb44 100644 --- a/test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java +++ b/test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java @@ -19,6 +19,9 @@ package org.apache.fop.apps; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; @@ -28,9 +31,6 @@ import org.apache.fop.fonts.FontManager; import org.apache.fop.render.RendererConfig; import org.apache.fop.render.RendererConfig.RendererConfigParser; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public abstract class AbstractRendererConfigParserTester<B extends RendererConfBuilder, C extends RendererConfig> { diff --git a/test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java b/test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java index 58c14f5df..2487c0a63 100644 --- a/test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java +++ b/test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java @@ -24,16 +24,17 @@ import java.io.IOException; import org.xml.sax.SAXException; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; import org.apache.fop.render.PrintRendererConfigurator; import org.apache.fop.render.intermediate.IFDocumentHandler; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public abstract class AbstractRendererConfiguratorTest<T extends PrintRendererConfigurator, B extends RendererConfBuilder> { +public abstract class AbstractRendererConfiguratorTest<T extends PrintRendererConfigurator, + B extends RendererConfBuilder> { protected final String mimeType; protected FOUserAgent userAgent; diff --git a/test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java b/test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java index e94403e71..83bfd2076 100644 --- a/test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java +++ b/test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java @@ -21,7 +21,6 @@ import java.net.URI; import org.junit.Test; - import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; diff --git a/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java b/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java index e504c4bc4..86b4e7c04 100644 --- a/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java +++ b/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java @@ -27,6 +27,12 @@ import java.util.List; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import org.apache.fop.apps.io.ResourceResolverFactory; import org.apache.fop.area.AreaTreeHandler; import org.apache.fop.area.Block; @@ -45,12 +51,6 @@ import org.apache.fop.layoutmgr.PageSequenceLayoutManager; import org.apache.fop.layoutmgr.StaticContentLayoutManager; import org.apache.fop.layoutmgr.inline.ContentLayoutManager; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - /** * Test case for {@link FopFactoryBuilder}. */ diff --git a/test/java/org/apache/fop/apps/FopFactoryTestCase.java b/test/java/org/apache/fop/apps/FopFactoryTestCase.java index 8ac21c994..439ffa44e 100644 --- a/test/java/org/apache/fop/apps/FopFactoryTestCase.java +++ b/test/java/org/apache/fop/apps/FopFactoryTestCase.java @@ -24,16 +24,15 @@ import java.io.IOException; import org.junit.Test; import org.xml.sax.SAXException; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.config.BaseConstructiveUserConfigTest; -import org.apache.fop.render.RendererConfig.RendererConfigParser; -import org.apache.fop.render.pdf.PDFRendererConfig; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import org.apache.fop.config.BaseConstructiveUserConfigTest; +import org.apache.fop.render.RendererConfig.RendererConfigParser; +import org.apache.fop.render.pdf.PDFRendererConfig; + public class FopFactoryTestCase extends BaseConstructiveUserConfigTest { public FopFactoryTestCase() throws SAXException, IOException { diff --git a/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java b/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java index 13ca3df6b..3da4e1daf 100644 --- a/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java +++ b/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java @@ -22,10 +22,8 @@ package org.apache.fop.apps; import org.w3c.dom.Element; import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; -import org.apache.fop.pdf.PDFEncryptionParams; import org.apache.fop.render.RendererConfigOption; import org.apache.fop.render.pdf.PDFEncryptionOption; -import org.apache.fop.render.pdf.PDFRendererOption; import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_LENGTH; import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_PARAMS; diff --git a/test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java b/test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java index 2131407c1..e04283718 100644 --- a/test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java +++ b/test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java @@ -34,6 +34,8 @@ import javax.xml.transform.stream.StreamSource; import org.xml.sax.SAXException; +import static org.junit.Assert.assertTrue; + import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; @@ -48,7 +50,6 @@ import org.apache.fop.apps.FopFactoryBuilder; import org.apache.fop.apps.MimeConstants; import static org.apache.fop.FOPTestUtils.getBaseDir; -import static org.junit.Assert.assertTrue; public abstract class BaseURIResolutionTest { diff --git a/test/java/org/apache/fop/apps/io/FontURIResolver.java b/test/java/org/apache/fop/apps/io/FontURIResolver.java index 40d6c7402..781aca368 100644 --- a/test/java/org/apache/fop/apps/io/FontURIResolver.java +++ b/test/java/org/apache/fop/apps/io/FontURIResolver.java @@ -33,14 +33,13 @@ import javax.xml.transform.TransformerException; import org.junit.Test; import org.xml.sax.SAXException; -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.apps.PDFRendererConfBuilder; - import static org.junit.Assert.assertTrue; import org.apache.xmlgraphics.io.Resource; +import org.apache.fop.apps.FopConfBuilder; +import org.apache.fop.apps.PDFRendererConfBuilder; + public class FontURIResolver extends BaseURIResolutionTest { public enum Event { diff --git a/test/java/org/apache/fop/area/ViewportTest.java b/test/java/org/apache/fop/area/ViewportTest.java index cb2282071..46412c83d 100644 --- a/test/java/org/apache/fop/area/ViewportTest.java +++ b/test/java/org/apache/fop/area/ViewportTest.java @@ -19,13 +19,13 @@ package org.apache.fop.area; +import java.awt.Rectangle; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import java.awt.Rectangle; - /** * Tests implementations of the {@linkplain Viewport} interface. */ diff --git a/test/java/org/apache/fop/area/ViewportTestSuite.java b/test/java/org/apache/fop/area/ViewportTestSuite.java index 065e07bf9..891f1d081 100644 --- a/test/java/org/apache/fop/area/ViewportTestSuite.java +++ b/test/java/org/apache/fop/area/ViewportTestSuite.java @@ -19,11 +19,12 @@ package org.apache.fop.area; -import org.apache.fop.area.inline.InlineViewportTestCase; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +import org.apache.fop.area.inline.InlineViewportTestCase; + /** * A suite of all the tests relating to the {@linkplain Viewport} interface. */ diff --git a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java index edcf99d14..cba5759cf 100644 --- a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java +++ b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java @@ -19,9 +19,10 @@ package org.apache.fop.area.inline; -import org.apache.fop.area.ViewportTest; import org.junit.Test; +import org.apache.fop.area.ViewportTest; + /** * Tests the {@linkplain InlineViewport} class. */ diff --git a/test/java/org/apache/fop/check/ChecksFactory.java b/test/java/org/apache/fop/check/ChecksFactory.java index a493c09f2..d77ce422d 100644 --- a/test/java/org/apache/fop/check/ChecksFactory.java +++ b/test/java/org/apache/fop/check/ChecksFactory.java @@ -37,7 +37,7 @@ public abstract class ChecksFactory<C extends Check> { /** * A factory to create a particular kind of check. */ - protected static interface CheckFactory<C> { + protected interface CheckFactory<C> { /** * Creates a {@link Check} instance from the given XML element. diff --git a/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java b/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java index 9a80fd964..1be3daa84 100644 --- a/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java +++ b/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java @@ -19,15 +19,16 @@ package org.apache.fop.cli; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; -import org.apache.fop.apps.FOPException; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.apache.fop.apps.FOPException; + public class CommandLineOptionsTestCase { private final CommandLineOptions clo = new CommandLineOptions(); diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java b/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java index f20e113c1..8ed1af217 100644 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java +++ b/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java @@ -19,26 +19,23 @@ package org.apache.fop.complexscripts.bidi; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.apache.fop.complexscripts.bidi.UnicodeBidiAlgorithm; - import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * <p>Test case for Unicode Bidi Algorithm.</p> - * @author Glenn Adams */ public class BidiAlgorithmTestCase { /** * logging instance */ - private static final Log log = LogFactory.getLog(BidiAlgorithmTestCase.class); // CSOK: ConstantNameCheck + private static final Log log = LogFactory.getLog(BidiAlgorithmTestCase.class); /** * Concatenated array of <test-set,test-sequence> tuples @@ -122,7 +119,7 @@ public class BidiAlgorithmTestCase { } if (includeSequence(testSet, testSequence)) { includedSequences++; - if (! excludeSequence(testSet, testSequence)) { + if (!excludeSequence(testSet, testSequence)) { if (testBidiAlgorithm(testSet, testSequence, la, ra, ta, bs)) { passedSequences++; } @@ -151,7 +148,7 @@ public class BidiAlgorithmTestCase { } private boolean includeSequence(int testSet, int testSequence) { - if (! includeTestSet(testSet)) { + if (!includeTestSet(testSet)) { return false; } else { for (int i = 0, n = INCLUSIONS.length / 2; i < n; i++) { @@ -196,7 +193,8 @@ public class BidiAlgorithmTestCase { return false; } - private boolean testBidiAlgorithm(int testSet, int testSequence, int[] la, int[] ra, int[] ta, int bs) throws Exception { + private boolean testBidiAlgorithm(int testSet, int testSequence, int[] la, int[] ra, int[] ta, int bs) + throws Exception { boolean passed = true; int n = la.length; if (ra.length != n) { @@ -211,14 +209,14 @@ public class BidiAlgorithmTestCase { // LTR if ((bs & 2) != 0) { int[] levels = UnicodeBidiAlgorithm.resolveLevels(null, ta, 0, new int [ n ], true); - if (! verifyResults(la, levels, ta, 0, testSet, testSequence)) { + if (!verifyResults(la, levels, ta, 0, testSet, testSequence)) { passed = false; } } // RTL if ((bs & 4) != 0) { int[] levels = UnicodeBidiAlgorithm.resolveLevels(null, ta, 1, new int [ n ], true); - if (! verifyResults(la, levels, ta, 1, testSet, testSequence)) { + if (!verifyResults(la, levels, ta, 1, testSet, testSequence)) { passed = false; } } diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java b/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java index 10a84b856..f393e5b70 100644 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java +++ b/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java @@ -19,14 +19,13 @@ package org.apache.fop.complexscripts.bidi; -import org.apache.fop.complexscripts.bidi.BidiClass; -import org.apache.fop.util.CharUtilities; - import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import org.apache.fop.util.CharUtilities; + public class BidiClassTestCase { @Test @@ -46,8 +45,8 @@ public class BidiClassTestCase { private void testBidiClass(int[] da) throws Exception { int bc = da[0]; for (int i = 1, n = da.length; i < n; i += 2) { - int s = da[i+0]; - int e = da[i+1]; + int s = da[i + 0]; + int e = da[i + 1]; for (int c = s; c < e; c++) { int cbc = BidiClass.getBidiClass(c); assertEquals("bad bidi class for CH(" + CharUtilities.format(c) + ")", bc, cbc); diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java index 6be0c1fa9..49a5c9455 100644 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java +++ b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java @@ -65,7 +65,7 @@ public final class BidiTestData { data = null; } finally { if (is != null) { - try { is.close(); } catch (Exception e) {} + try { is.close(); } catch (Exception e) { /* NOP */ } } } return data; diff --git a/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java index af929d3a1..f1512903c 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java +++ b/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java @@ -21,21 +21,14 @@ package org.apache.fop.complexscripts.fonts; import java.io.File; -import org.apache.fop.complexscripts.fonts.GlyphSubtable; -import org.apache.fop.complexscripts.fonts.GlyphDefinitionSubtable; -import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable; -import org.apache.fop.complexscripts.fonts.GlyphTable.LookupSpec; -import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable; -import org.apache.fop.complexscripts.fonts.ttx.TTXFile; -import org.apache.fop.complexscripts.util.GlyphContextTester; -import org.apache.fop.complexscripts.util.GlyphSequence; - import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.apache.fop.complexscripts.fonts.ttx.TTXFile; + public class GDEFTestCase { private static String ttxFilesRoot = "test/resources/complexscripts"; diff --git a/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java index 270b56797..cf63b4eff 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java +++ b/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java @@ -20,18 +20,6 @@ package org.apache.fop.complexscripts.fonts; import java.io.File; -import java.util.List; -import java.util.Map; - -import org.apache.fop.complexscripts.fonts.GlyphSubtable; -import org.apache.fop.complexscripts.fonts.GlyphPositioningSubtable; -import org.apache.fop.complexscripts.fonts.GlyphPositioningTable; -import org.apache.fop.complexscripts.fonts.GlyphTable.LookupSpec; -import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable; -import org.apache.fop.complexscripts.fonts.ttx.TTXFile; -import org.apache.fop.complexscripts.util.GlyphContextTester; -import org.apache.fop.complexscripts.util.GlyphSequence; -import org.apache.fop.complexscripts.util.ScriptContextTester; import org.junit.Test; @@ -40,6 +28,14 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable; +import org.apache.fop.complexscripts.fonts.ttx.TTXFile; +import org.apache.fop.complexscripts.util.GlyphContextTester; +import org.apache.fop.complexscripts.util.GlyphSequence; +import org.apache.fop.complexscripts.util.ScriptContextTester; + +// CSOFF: LineLength + public class GPOSTestCase implements ScriptContextTester, GlyphContextTester { private static String ttxFilesRoot = "test/resources/complexscripts"; diff --git a/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java index b235fa58c..3f23d9ab3 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java +++ b/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java @@ -21,18 +21,6 @@ package org.apache.fop.complexscripts.fonts; import java.io.File; import java.nio.IntBuffer; -import java.util.List; -import java.util.Map; - -import org.apache.fop.complexscripts.fonts.GlyphSubtable; -import org.apache.fop.complexscripts.fonts.GlyphSubstitutionSubtable; -import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable; -import org.apache.fop.complexscripts.fonts.GlyphTable.LookupSpec; -import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable; -import org.apache.fop.complexscripts.fonts.ttx.TTXFile; -import org.apache.fop.complexscripts.util.GlyphContextTester; -import org.apache.fop.complexscripts.util.GlyphSequence; -import org.apache.fop.complexscripts.util.ScriptContextTester; import org.junit.Test; @@ -41,6 +29,14 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable; +import org.apache.fop.complexscripts.fonts.ttx.TTXFile; +import org.apache.fop.complexscripts.util.GlyphContextTester; +import org.apache.fop.complexscripts.util.GlyphSequence; +import org.apache.fop.complexscripts.util.ScriptContextTester; + +// CSOFF: LineLength + public class GSUBTestCase implements ScriptContextTester, GlyphContextTester { private static String ttxFilesRoot = "test/resources/complexscripts"; diff --git a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java b/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java index c106e65c8..178203ff6 100644 --- a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java +++ b/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java @@ -21,11 +21,9 @@ package org.apache.fop.complexscripts.fonts.ttx; import java.io.File; import java.io.IOException; - import java.nio.IntBuffer; - -import java.util.Arrays; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashMap; @@ -41,21 +39,23 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.xml.sax.Attributes; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.complexscripts.fonts.GlyphClassTable; import org.apache.fop.complexscripts.fonts.GlyphCoverageTable; -import org.apache.fop.complexscripts.fonts.GlyphDefinitionSubtable; import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable; import org.apache.fop.complexscripts.fonts.GlyphMappingTable; -import org.apache.fop.complexscripts.fonts.GlyphPositioningSubtable; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.Anchor; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.MarkAnchor; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.PairValues; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.Value; -import org.apache.fop.complexscripts.fonts.GlyphSubstitutionSubtable; import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable; import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable.Ligature; import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable.LigatureSet; @@ -66,11 +66,6 @@ import org.apache.fop.complexscripts.util.GlyphSequence; import org.apache.fop.complexscripts.util.UTF32; import org.apache.fop.util.CharUtilities; -import org.xml.sax.Attributes; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - // CSOFF: LineLengthCheck @@ -87,8 +82,6 @@ import org.xml.sax.helpers.DefaultHandler; * files directly in the FOP distribution. In such cases, <code>TTX</code> files are used * to distribute a subset of the complex script advanced table information contained in * certain font files to facilitate testing. - * - * @author Glenn Adams */ public class TTXFile { @@ -100,22 +93,22 @@ public class TTXFile { private static final String DEFAULT_LANGUAGE_TAG = "dflt"; /** ttxfile cache */ - private static Map<String,TTXFile> cache = new HashMap<String,TTXFile>(); + private static Map<String, TTXFile> cache = new HashMap<String, TTXFile>(); // transient parsing state private Locator locator; // current document locator private Stack<String[]> elements; // stack of ttx elements being parsed - private Map<String,Integer> glyphIds; // map of glyph names to glyph identifiers + private Map<String, Integer> glyphIds; // map of glyph names to glyph identifiers private List<int[]> cmapEntries; // list of <charCode,glyphCode> pairs private Vector<int[]> hmtxEntries; // vector of <width,lsb> pairs - private Map<String,Integer> glyphClasses; // map of glyph names to glyph classes - private Map<String,Map<String,List<String>>> scripts; // map of script tag to Map<language-tag,List<features-id>>> - private Map<String,List<String>> languages; // map of language tag to List<feature-id> - private Map<String,Object[]> features; // map of feature id to Object[2] : { feature-tag, List<lookup-id> } + private Map<String, Integer> glyphClasses; // map of glyph names to glyph classes + private Map<String, Map<String, List<String>>> scripts; // map of script tag to Map<language-tag,List<features-id>>> + private Map<String, List<String>> languages; // map of language tag to List<feature-id> + private Map<String, Object[]> features; // map of feature id to Object[2] : { feature-tag, List<lookup-id> } private List<String> languageFeatures; // list of language system feature ids, where first is (possibly null) required feature id private List<String> featureLookups; // list of lookup ids for feature being constructed private List<Integer> coverageEntries; // list of entries for coverage table being constructed - private Map<String,GlyphCoverageTable> coverages; // map of coverage table keys to coverage tables + private Map<String, GlyphCoverageTable> coverages; // map of coverage table keys to coverage tables private List subtableEntries; // list of lookup subtable entries private List<GlyphSubtable> subtables; // list of constructed subtables private List<Integer> alternates; // list of alternates in alternate set being constructed @@ -162,8 +155,8 @@ public class TTXFile { // resultant state private int upem; // units per em - private Map<Integer,Integer> cmap; // constructed character map - private Map<Integer,Integer> gmap; // constructed glyph map + private Map<Integer, Integer> cmap; // constructed character map + private Map<Integer, Integer> gmap; // constructed glyph map private int[][] hmtx; // constructed horizontal metrics - array of design { width, lsb } pairs, indexed by glyph code private int[] widths; // pdf normalized widths (millipoints) private GlyphDefinitionTable gdef; // constructed glyph definition table @@ -172,17 +165,17 @@ public class TTXFile { public TTXFile() { elements = new Stack<String[]>(); - glyphIds = new HashMap<String,Integer>(); + glyphIds = new HashMap<String, Integer>(); cmapEntries = new ArrayList<int[]>(); hmtxEntries = new Vector<int[]>(); - glyphClasses = new HashMap<String,Integer>(); - scripts = new HashMap<String,Map<String,List<String>>>(); - languages = new HashMap<String,List<String>>(); - features = new HashMap<String,Object[]>(); + glyphClasses = new HashMap<String, Integer>(); + scripts = new HashMap<String, Map<String, List<String>>>(); + languages = new HashMap<String, List<String>>(); + features = new HashMap<String, Object[]>(); languageFeatures = new ArrayList<String>(); featureLookups = new ArrayList<String>(); coverageEntries = new ArrayList<Integer>(); - coverages = new HashMap<String,GlyphCoverageTable>(); + coverages = new HashMap<String, GlyphCoverageTable>(); subtableEntries = new ArrayList(); subtables = new ArrayList<GlyphSubtable>(); alternates = new ArrayList<Integer>(); @@ -342,7 +335,7 @@ public class TTXFile { long rest1 = tw % upem; long storrest = 1000 * rest1; long ledd2 = (storrest != 0) ? (rest1 / storrest) : 0; - pw = - ((-1000 * tw) / upem - (int) ledd2); + pw = -((-1000 * tw) / upem - (int) ledd2); } else { pw = (tw / upem) * 1000 + ((tw % upem) * 1000) / upem; } @@ -370,7 +363,7 @@ public class TTXFile { public static synchronized void clearCache() { cache.clear(); } - private class Handler extends DefaultHandler { + private final class Handler extends DefaultHandler { private Handler() { } @Override @@ -493,7 +486,7 @@ public class TTXFile { } } else if (en[1].equals("BaseArray")) { String[] pn = new String[] { null, "MarkBasePos" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("BaseCoverage")) { @@ -587,7 +580,7 @@ public class TTXFile { if (glyphClass == null) { missingRequiredAttribute(en, "class"); } - if (! glyphIds.containsKey(glyph)) { + if (!glyphIds.containsKey(glyph)) { unsupportedGlyph(en, glyph); } else if (isParent(pn1)) { if (glyphClasses.containsKey(glyph)) { @@ -675,7 +668,7 @@ public class TTXFile { } } else if (en[1].equals("DefaultLangSys")) { String[] pn = new String[] { null, "Script" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } else { assertLanguageFeaturesClear(); @@ -718,7 +711,7 @@ public class TTXFile { } } else if (en[1].equals("Feature")) { String[] pn = new String[] { null, "FeatureRecord" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } else { assertFeatureLookupsClear(); @@ -752,7 +745,7 @@ public class TTXFile { String[] pn1 = new String[] { null, "GSUB" }; String[] pn2 = new String[] { null, "GPOS" }; String[][] pnx = new String[][] { pn1, pn2 }; - if (! isParent(pnx)) { + if (!isParent(pnx)) { notPermittedInElementContext(en, getParent(), pnx); } } else if (en[1].equals("FeatureRecord")) { @@ -885,7 +878,7 @@ public class TTXFile { } } else if (en[1].equals("GlyphOrder")) { String[] pn = new String[] { null, "ttFont" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("InputCoverage")) { @@ -923,7 +916,7 @@ public class TTXFile { } } else if (en[1].equals("LangSys")) { String[] pn = new String[] { null, "LangSysRecord" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } else { assertLanguageFeaturesClear(); @@ -953,7 +946,7 @@ public class TTXFile { } } else if (en[1].equals("LigCaretList")) { String[] pn = new String[] { null, "GDEF" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("Ligature")) { @@ -991,7 +984,7 @@ public class TTXFile { } } else if (en[1].equals("LigatureArray")) { String[] pn = new String[] { null, "MarkLigPos" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("LigatureAttach")) { @@ -1139,7 +1132,7 @@ public class TTXFile { String[] pn1 = new String[] { null, "GSUB" }; String[] pn2 = new String[] { null, "GPOS" }; String[][] pnx = new String[][] { pn1, pn2 }; - if (! isParent(pnx)) { + if (!isParent(pnx)) { notPermittedInElementContext(en, getParent(), pnx); } } else if (en[1].equals("LookupListIndex")) { @@ -1179,7 +1172,7 @@ public class TTXFile { } } else if (en[1].equals("Mark1Array")) { String[] pn = new String[] { null, "MarkMarkPos" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("Mark1Coverage")) { @@ -1220,7 +1213,7 @@ public class TTXFile { } } else if (en[1].equals("Mark2Array")) { String[] pn = new String[] { null, "MarkMarkPos" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("Mark2Coverage")) { @@ -1273,7 +1266,7 @@ public class TTXFile { String[] pn1 = new String[] { null, "MarkBasePos" }; String[] pn2 = new String[] { null, "MarkLigPos" }; String[][] pnx = new String[][] { pn1, pn2 }; - if (! isParent(pnx)) { + if (!isParent(pnx)) { notPermittedInElementContext(en, getParent(), pnx); } } else if (en[1].equals("MarkAttachClassDef")) { @@ -1549,14 +1542,14 @@ public class TTXFile { } } else if (en[1].equals("Script")) { String[] pn = new String[] { null, "ScriptRecord" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("ScriptList")) { String[] pn1 = new String[] { null, "GSUB" }; String[] pn2 = new String[] { null, "GPOS" }; String[][] pnx = new String[][] { pn1, pn2 }; - if (! isParent(pnx)) { + if (!isParent(pnx)) { notPermittedInElementContext(en, getParent(), pnx); } } else if (en[1].equals("ScriptRecord")) { @@ -1890,7 +1883,7 @@ public class TTXFile { } } else if (en[1].equals("cmap")) { String[] pn = new String[] { null, "ttFont" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("cmap_format_0")) { @@ -1997,12 +1990,12 @@ public class TTXFile { } } else if (en[1].equals("head")) { String[] pn = new String[] { null, "ttFont" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } } else if (en[1].equals("hmtx")) { String[] pn = new String[] { null, "ttFont" }; - if (! isParent(pn)) { + if (!isParent(pn)) { notPermittedInElementContext(en, getParent(), pn); } else if (glyphIdMax > 0) { hmtxEntries.setSize(glyphIdMax + 1); @@ -2216,7 +2209,7 @@ public class TTXFile { throw new SAXException("element stack is empty, elements are not balanced"); } String[] en = makeExpandedName(uri, localName, qName); - if (! sameExpandedName(enParent, en)) { + if (!sameExpandedName(enParent, en)) { throw new SAXException("element stack is unbalanced, expanded name mismatch"); } if (en[0] != null) { @@ -2244,7 +2237,7 @@ public class TTXFile { } else if (en[1].equals("AlternateSet")) { subtableEntries.add(extractAlternates()); } else if (en[1].equals("AlternateSubst")) { - if (! sortEntries(coverageEntries, subtableEntries)) { + if (!sortEntries(coverageEntries, subtableEntries)) { mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); } addGSUBSubtable(GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_ALTERNATE, extractCoverage()); @@ -2262,9 +2255,9 @@ public class TTXFile { } else if (en[1].equals("ChainContextPos") || en[1].equals("ChainContextSubst")) { GlyphCoverageTable coverage = null; if (stFormat == 3) { - GlyphCoverageTable igca[] = getCoveragesWithPrefix("in"); - GlyphCoverageTable bgca[] = getCoveragesWithPrefix("bk"); - GlyphCoverageTable lgca[] = getCoveragesWithPrefix("la"); + GlyphCoverageTable[] igca = getCoveragesWithPrefix("in"); + GlyphCoverageTable[] bgca = getCoveragesWithPrefix("bk"); + GlyphCoverageTable[] lgca = getCoveragesWithPrefix("la"); if ((igca.length == 0) || hasMissingCoverage(igca)) { missingCoverage(en, "input", igca.length); } else if (hasMissingCoverage(bgca)) { @@ -2363,7 +2356,7 @@ public class TTXFile { } else if (en[1].equals("LigatureSet")) { subtableEntries.add(extractLigatures()); } else if (en[1].equals("LigatureSubst")) { - if (! sortEntries(coverageEntries, subtableEntries)) { + if (!sortEntries(coverageEntries, subtableEntries)) { mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); } GlyphCoverageTable coverage = extractCoverage(); @@ -2475,7 +2468,8 @@ public class TTXFile { } GlyphCoverageTable coverage = coverages.get("main"); addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_PAIR, coverage); - vf1 = vf2 = -1; psIndex = -1; + vf1 = vf2 = -1; + psIndex = -1; } else if (en[1].equals("PairSet")) { if (psIndex != pairSets.size()) { invalidIndex(en, psIndex, pairSets.size()); @@ -2528,7 +2522,7 @@ public class TTXFile { addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_SINGLE, coverage); vf1 = -1; } else if (en[1].equals("SingleSubst")) { - if (! sortEntries(coverageEntries, subtableEntries)) { + if (!sortEntries(coverageEntries, subtableEntries)) { mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); } GlyphCoverageTable coverage = extractCoverage(); @@ -2556,7 +2550,7 @@ public class TTXFile { public void characters(char[] chars, int start, int length) { } private String[] getParent() { - if (! elements.empty()) { + if (!elements.empty()) { return elements.peek(); } else { return new String[] { null, null }; @@ -2572,13 +2566,11 @@ public class TTXFile { return false; } else if (enx instanceof String[]) { String[] en = (String[]) enx; - if (! elements.empty()) { + if (!elements.empty()) { String[] pn = elements.peek(); return (pn != null) && sameExpandedName(en, pn); - } else if ((en[0] == null) && (en[1] == null)) { - return true; } else { - return false; + return ((en[0] == null) && (en[1] == null)); } } else { return false; @@ -2595,14 +2587,12 @@ public class TTXFile { return true; } else if (ln.equals("MarkAnchor")) { return true; - } else if (ln.equals("Mark2Anchor")) { - return true; } else { - return false; + return ln.equals("Mark2Anchor"); } } - private Map<Integer,Integer> getCMAP() { - Map<Integer,Integer> cmap = new TreeMap(); + private Map<Integer, Integer> getCMAP() { + Map<Integer, Integer> cmap = new TreeMap(); for (int[] cme : cmapEntries) { Integer c = Integer.valueOf(cme[0]); Integer g = Integer.valueOf(cme[1]); @@ -2610,8 +2600,8 @@ public class TTXFile { } return cmap; } - private Map<Integer,Integer> getGMAP() { - Map<Integer,Integer> gmap = new TreeMap(); + private Map<Integer, Integer> getGMAP() { + Map<Integer, Integer> gmap = new TreeMap(); for (int[] cme : cmapEntries) { Integer c = Integer.valueOf(cme[0]); Integer g = Integer.valueOf(cme[1]); @@ -2631,7 +2621,7 @@ public class TTXFile { } return hmtx; } - private GlyphClassTable extractClassDefMapping(Map<String,Integer> glyphClasses, int format, boolean clearSourceMap) { + private GlyphClassTable extractClassDefMapping(Map<String, Integer> glyphClasses, int format, boolean clearSourceMap) { GlyphClassTable ct; if (format == 1) { ct = extractClassDefMapping1(extractClassMappings(glyphClasses, clearSourceMap)); @@ -2685,11 +2675,11 @@ public class TTXFile { } return GlyphClassTable.createClassTable(entries); } - private int[][] extractClassMappings(Map<String,Integer> glyphClasses, boolean clearSourceMap) { + private int[][] extractClassMappings(Map<String, Integer> glyphClasses, boolean clearSourceMap) { int nc = glyphClasses.size(); int i = 0; int[][] cma = new int [ nc ] [ 2 ]; - for (Map.Entry<String,Integer> e : glyphClasses.entrySet()) { + for (Map.Entry<String, Integer> e : glyphClasses.entrySet()) { Integer gid = glyphIds.get(e.getKey()); assert gid != null; int[] m = cma [ i ]; @@ -2856,8 +2846,8 @@ public class TTXFile { private void clearLanguageFeatures() { languageFeatures.clear(); } - private Map<String,List<String>> extractLanguages() { - Map<String,List<String>> lm = new HashMap(languages); + private Map<String, List<String>> extractLanguages() { + Map<String, List<String>> lm = new HashMap(languages); clearLanguages(); return lm; } @@ -2923,10 +2913,10 @@ public class TTXFile { ltFlags = 0; clearSubtablesInLookup(); } - private Map<GlyphTable.LookupSpec,List<String>> extractLookups() { - Map<GlyphTable.LookupSpec,List<String>> lookups = new LinkedHashMap<GlyphTable.LookupSpec,List<String>>(); + private Map<GlyphTable.LookupSpec, List<String>> extractLookups() { + Map<GlyphTable.LookupSpec, List<String>> lookups = new LinkedHashMap<GlyphTable.LookupSpec, List<String>>(); for (String st : scripts.keySet()) { - Map<String,List<String>> lm = scripts.get(st); + Map<String, List<String>> lm = scripts.get(st); if (lm != null) { for (String lt : lm.keySet()) { List<String> fids = lm.get(lt); @@ -3062,7 +3052,7 @@ public class TTXFile { missingParameter(en, "xAdvance"); } String yAdvance = attrs.getValue("YAdvance"); - int ya = 0;; + int ya = 0; if (yAdvance != null) { ya = Integer.parseInt(yAdvance); } else if ((format & GlyphPositioningTable.Value.Y_ADVANCE) != 0) { @@ -3207,7 +3197,7 @@ public class TTXFile { if (cm != null) { for (Anchor[] aa : cm) { if (aa != null) { - int nc = aa.length;; + int nc = aa.length; if (nc > ncMax) { ncMax = nc; } @@ -3223,7 +3213,7 @@ public class TTXFile { if (lam != null) { for (Anchor[][] cm : lam) { if (cm != null) { - int nx = cm.length;; + int nx = cm.length; if (nx > nxMax) { nxMax = nx; } @@ -3424,7 +3414,7 @@ public class TTXFile { return false; } if ((u1 != null) && (u2 != null)) { - if (! u1.equals(u2)) { + if (!u1.equals(u2)) { return false; } } @@ -3434,7 +3424,7 @@ public class TTXFile { return false; } if ((l1 != null) && (l2 != null)) { - if (! l1.equals(l2)) { + if (!l1.equals(l2)) { return false; } } diff --git a/test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java b/test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java index cf5d846b4..c48be5220 100644 --- a/test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java +++ b/test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java @@ -29,8 +29,6 @@ import org.apache.fop.complexscripts.scripts.arabic.ArabicTestCase; * Test suite for script specific functionality related to complex scripts. */ @RunWith(Suite.class) -@SuiteClasses({ - ArabicTestCase.class -}) +@SuiteClasses(ArabicTestCase.class) public class ScriptsTestSuite { } diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java index d34e88a03..8542faae9 100644 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java +++ b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java @@ -21,30 +21,26 @@ package org.apache.fop.complexscripts.scripts.arabic; import java.io.File; import java.io.FileInputStream; -import java.io.FilenameFilter; import java.io.FileNotFoundException; -import java.io.FileOutputStream; +import java.io.FilenameFilter; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.LineNumberReader; import java.io.ObjectInputStream; import java.nio.IntBuffer; -import java.nio.charset.Charset; -import java.util.ArrayList; import java.util.List; -import org.apache.fop.complexscripts.fonts.GlyphPositioningTable; -import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable; -import org.apache.fop.complexscripts.fonts.ttx.TTXFile; -import org.apache.fop.complexscripts.util.GlyphSequence; - -import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.apache.fop.complexscripts.fonts.GlyphPositioningTable; +import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable; +import org.apache.fop.complexscripts.fonts.ttx.TTXFile; +import org.apache.fop.complexscripts.util.GlyphSequence; + +// CSOFF: LineLength + /** * Tests for functionality related to the arabic script. */ @@ -52,9 +48,9 @@ public class ArabicTestCase implements ArabicTestConstants { @Test public void testArabicWordForms() { - for (String sfn : srcFiles) { + for (String sfn : SRC_FILES) { try { - processWordForms(new File(datFilesDir)); + processWordForms(new File(DAT_FILES_DIR)); } catch (Exception e) { fail(e.getMessage()); } @@ -72,7 +68,7 @@ public class ArabicTestCase implements ArabicTestConstants { private String[] listWordFormFiles(File dfd) { return dfd.list(new FilenameFilter() { public boolean accept(File f, String name) { - return hasPrefixFrom(name, srcFiles) && hasExtension(name, WF_FILE_DAT_EXT); + return hasPrefixFrom(name, SRC_FILES) && hasExtension(name, WF_FILE_DAT_EXT); } private boolean hasPrefixFrom(String name, String[] prefixes) { for (String p : prefixes) { @@ -108,7 +104,7 @@ public class ArabicTestCase implements ArabicTestConstants { throw new RuntimeException(e.getMessage(), e); } finally { if (fis != null) { - try { fis.close(); } catch (Exception e) {} + try { fis.close(); } catch (Exception e) { /* NOP */ } } } } @@ -129,7 +125,7 @@ public class ArabicTestCase implements ArabicTestConstants { script = (String) d[0]; language = (String) d[1]; tfn = (String) d[3]; - tf = TTXFile.getFromCache(ttxFontsDir + File.separator + tfn); + tf = TTXFile.getFromCache(TTX_FONTS_DIR + File.separator + tfn); assertTrue(tf != null); gsub = tf.getGSUB(); assertTrue(gsub != null); diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestConstants.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestConstants.java index 0669ff137..cc9167553 100644 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestConstants.java +++ b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestConstants.java @@ -24,22 +24,22 @@ package org.apache.fop.complexscripts.scripts.arabic; */ public interface ArabicTestConstants { - final String WF_FILE_SCRIPT = "arab"; - final String WF_FILE_LANGUAGE = "dflt"; + String WF_FILE_SCRIPT = "arab"; + String WF_FILE_LANGUAGE = "dflt"; - String srcFilesDir = "test/resources/complexscripts/arab/data"; - String datFilesDir = "test/resources/complexscripts/arab/data"; + String SRC_FILES_DIR = "test/resources/complexscripts/arab/data"; + String DAT_FILES_DIR = "test/resources/complexscripts/arab/data"; - String[] srcFiles = { + String[] SRC_FILES = { "arab-001", // unpointed word forms }; - final String WF_FILE_SRC_EXT = "txt"; - final String WF_FILE_DAT_EXT = "ser"; + String WF_FILE_SRC_EXT = "txt"; + String WF_FILE_DAT_EXT = "ser"; - String ttxFontsDir = "test/resources/complexscripts/arab/ttx"; + String TTX_FONTS_DIR = "test/resources/complexscripts/arab/ttx"; - String[] ttxFonts = { + String[] TTX_FONTS = { "arab-001.ttx", // simplified arabic "arab-002.ttx", // traditional arabic "arab-003.ttx", // lateef diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java index a4f876dd8..9ca16a164 100644 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java +++ b/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java @@ -40,7 +40,10 @@ import org.apache.fop.complexscripts.util.GlyphSequence; /** * Tests for functionality related to the arabic script. */ -public class GenerateArabicTestData implements ArabicTestConstants { +public final class GenerateArabicTestData implements ArabicTestConstants { + + private GenerateArabicTestData() { + } public static void main(String[] args) { boolean compile = false; @@ -69,9 +72,9 @@ public class GenerateArabicTestData implements ArabicTestConstants { } private static void compile() { - for (String sfn : srcFiles) { + for (String sfn : SRC_FILES) { try { - String spn = srcFilesDir + File.separator + sfn + "." + WF_FILE_SRC_EXT; + String spn = SRC_FILES_DIR + File.separator + sfn + "." + WF_FILE_SRC_EXT; compile(WF_FILE_SCRIPT, WF_FILE_LANGUAGE, spn); } catch (Exception e) { System.err.println(e.getMessage()); @@ -81,8 +84,8 @@ public class GenerateArabicTestData implements ArabicTestConstants { private static void compile(String script, String language, String spn) { int fno = 0; - for (String tfn : ttxFonts) { - TTXFile tf = TTXFile.getFromCache(ttxFontsDir + File.separator + tfn); + for (String tfn : TTX_FONTS) { + TTXFile tf = TTXFile.getFromCache(TTX_FONTS_DIR + File.separator + tfn); assert tf != null; List data = compile(script, language, spn, tfn, tf); output(makeDataPathName(spn, fno++), data); @@ -106,7 +109,7 @@ public class GenerateArabicTestData implements ArabicTestConstants { GlyphSequence igs = tf.mapCharsToGlyphs(wf); GlyphSequence ogs = gsub.substitute(igs, script, language); int[][] paa = new int [ ogs.getGlyphCount() ] [ 4 ]; - if (! gpos.position(ogs, script, language, 1000, widths, paa)) { + if (!gpos.position(ogs, script, language, 1000, widths, paa)) { paa = null; } data.add(new Object[] { wf, getGlyphs(igs), getGlyphs(ogs), paa }); @@ -121,7 +124,7 @@ public class GenerateArabicTestData implements ArabicTestConstants { throw new RuntimeException(e.getMessage(), e); } finally { if (fis != null) { - try { fis.close(); } catch (Exception e) {} + try { fis.close(); } catch (Exception e) { /* NOP */ } } } } else { @@ -142,7 +145,7 @@ public class GenerateArabicTestData implements ArabicTestConstants { private static String makeDataPathName(String spn, int fno) { File f = new File(spn); - return datFilesDir + File.separator + stripExtension(f.getName()) + "-f" + fno + "." + WF_FILE_DAT_EXT; + return DAT_FILES_DIR + File.separator + stripExtension(f.getName()) + "-f" + fno + "." + WF_FILE_DAT_EXT; } private static String stripExtension(String s) { @@ -171,7 +174,7 @@ public class GenerateArabicTestData implements ArabicTestConstants { throw new RuntimeException(e.getMessage(), e); } finally { if (fos != null) { - try { fos.close(); } catch (Exception e) {} + try { fos.close(); } catch (Exception e) { /* NOP */ } } } } diff --git a/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java b/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java index ea885b6c5..4e1db5fb3 100644 --- a/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java +++ b/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java @@ -30,12 +30,10 @@ import static org.junit.Assert.assertEquals; /** * Test number converter functionality. - * - * @author Glenn Adams */ public class NumberConverterTestCase { - static private String[][] formatDecimal = + private static String[][] formatDecimal = { { "1" }, { "0", "0" }, @@ -45,7 +43,7 @@ public class NumberConverterTestCase { { "1000000000", "1000000000" }, }; - static private String[][] formatDecimalPadded = + private static String[][] formatDecimalPadded = { { "001" }, { "0", "000" }, @@ -58,7 +56,7 @@ public class NumberConverterTestCase { { "1000", "1000" }, }; - static private String[][] formatDecimalGrouped = + private static String[][] formatDecimalGrouped = { { "1", ",", "1" }, { "0", "0" }, @@ -68,7 +66,7 @@ public class NumberConverterTestCase { { "1000000000", "1,0,0,0,0,0,0,0,0,0" }, }; - static private String[][] formatDecimalGroupedPadded = + private static String[][] formatDecimalGroupedPadded = { { "001", ",", "2" }, { "0", "0,00" }, @@ -81,7 +79,7 @@ public class NumberConverterTestCase { { "1000", "10,00" }, }; - static private String[][] formatDecimalArabic = + private static String[][] formatDecimalArabic = { { "\u0661" }, { "0", "\u0660" }, @@ -100,7 +98,7 @@ public class NumberConverterTestCase { { "1000000000", "\u0661\u0660\u0660\u0660\u0660\u0660\u0660\u0660\u0660\u0660" }, }; - static private String[][] formatDecimalArabicPadded = + private static String[][] formatDecimalArabicPadded = { { "\u0660\u0660\u0661" }, { "0", "\u0660\u0660\u0660" }, @@ -113,7 +111,7 @@ public class NumberConverterTestCase { { "1000", "\u0661\u0660\u0660\u0660" }, }; - static private String[][] formatDecimalArabicGrouped = + private static String[][] formatDecimalArabicGrouped = { { "\u0661", "\u066c", "1" }, { "0", "\u0660" }, @@ -123,7 +121,7 @@ public class NumberConverterTestCase { { "1000000000", "\u0661\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660" }, }; - static private String[][] formatDecimalArabicGroupedPadded = + private static String[][] formatDecimalArabicGroupedPadded = { { "\u0660\u0660\u0661", "\u066c", "2" }, { "0", "\u0660\u066c\u0660\u0660" }, @@ -136,7 +134,7 @@ public class NumberConverterTestCase { { "1000", "\u0661\u0660\u066c\u0660\u0660" }, }; - static private String[][] formatDecimalThai = + private static String[][] formatDecimalThai = { { "\u0E51" }, { "0", "\u0E50" }, @@ -155,7 +153,7 @@ public class NumberConverterTestCase { { "1000000000", "\u0E51\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50" }, }; - static private String[][] formatDecimalThaiPadded = + private static String[][] formatDecimalThaiPadded = { { "\u0E50\u0E50\u0E51" }, { "0", "\u0E50\u0E50\u0E50" }, @@ -168,7 +166,7 @@ public class NumberConverterTestCase { { "1000", "\u0E51\u0E50\u0E50\u0E50" }, }; - static private String[][] formatRomanLower = + private static String[][] formatRomanLower = { { "i" }, { "0", "0" }, @@ -206,7 +204,7 @@ public class NumberConverterTestCase { { "5000", "5000" }, }; - static private String[][] formatRomanUpper = + private static String[][] formatRomanUpper = { { "I" }, @@ -245,7 +243,7 @@ public class NumberConverterTestCase { { "5000", "5000" }, }; - static private String[][] formatRomanLargeLower = + private static String[][] formatRomanLargeLower = { { "i", null, null, null, "large" }, { "0", "0" }, @@ -293,7 +291,7 @@ public class NumberConverterTestCase { { "200000", "200000" }, }; - static private String[][] formatRomanLargeUpper = + private static String[][] formatRomanLargeUpper = { { "I", null, null, null, "large" }, { "0", "0" }, @@ -341,7 +339,7 @@ public class NumberConverterTestCase { { "200000", "200000" }, }; - static private String[][] formatRomanNumberFormsLower = + private static String[][] formatRomanNumberFormsLower = { { "i", null, null, null, "unicode-number-forms" }, { "0", "0" }, @@ -399,7 +397,7 @@ public class NumberConverterTestCase { { "200000", "200000" }, }; - static private String[][] formatRomanNumberFormsUpper = + private static String[][] formatRomanNumberFormsUpper = { { "I", null, null, null, "unicode-number-forms" }, { "0", "0" }, @@ -457,7 +455,7 @@ public class NumberConverterTestCase { { "200000", "200000" }, }; - static private String[][] formatAlphabeticLatinLower = + private static String[][] formatAlphabeticLatinLower = { { "a" }, { "0", "0" }, @@ -478,7 +476,7 @@ public class NumberConverterTestCase { { "1000000", "bdwgn" }, }; - static private String[][] formatAlphabeticLatinUpper = + private static String[][] formatAlphabeticLatinUpper = { { "A" }, { "0", "0" }, @@ -499,7 +497,7 @@ public class NumberConverterTestCase { { "1000000", "BDWGN" }, }; - static private String[][] formatAlphabeticArabicHijai = + private static String[][] formatAlphabeticArabicHijai = { { "\u0627", null, null, "alphabetic" }, { "0", "0" }, @@ -540,7 +538,7 @@ public class NumberConverterTestCase { { "1000000", "\u0623\u0638\u0636\u0635\u062F" }, }; - static private String[][] formatAlphabeticArabicAbjadi = + private static String[][] formatAlphabeticArabicAbjadi = { { "\u0627", null, null, "traditional" }, { "0", "0" }, @@ -581,7 +579,7 @@ public class NumberConverterTestCase { { "1000000", "\u0623\u0641\u0633\u0646\u062D" }, }; - static private String[][] formatNumeralArabicAbjadi = + private static String[][] formatNumeralArabicAbjadi = { { "\u0623", null, null, "traditional" }, { "0", "0" }, @@ -629,7 +627,7 @@ public class NumberConverterTestCase { { "2000", "2000" }, }; - static private String[][] formatAlphabeticHebrew = + private static String[][] formatAlphabeticHebrew = { { "\u05D0", null, null, "alphabetic" }, { "0", "0" }, @@ -669,7 +667,7 @@ public class NumberConverterTestCase { { "1000000", "\u05D0\u05DA\u05E9\u05E8\u05D0" }, }; - static private String[][] formatNumeralHebrewGematria = + private static String[][] formatNumeralHebrewGematria = { { "\u05D0", null, null, "traditional" }, { "0", "0" }, @@ -717,7 +715,7 @@ public class NumberConverterTestCase { { "2000", "2000" }, }; - static private String[][] formatAlphabeticThai = + private static String[][] formatAlphabeticThai = { { "\u0E01", null, null, "alphabetic" }, { "0", "0" }, @@ -738,7 +736,7 @@ public class NumberConverterTestCase { { "1000000", "\u0E0B\u0E20\u0E17\u0E0C" }, }; - static private String[][] formatWordEnglishLower = + private static String[][] formatWordEnglishLower = { { "w", null, null, null, null, "eng" }, { "0", "zero" }, @@ -762,7 +760,7 @@ public class NumberConverterTestCase { { "1000000000", "one billion" } }; - static private String[][] formatWordEnglishUpper = + private static String[][] formatWordEnglishUpper = { { "W", null, null, null, null, "eng" }, { "0", "ZERO" }, @@ -786,7 +784,7 @@ public class NumberConverterTestCase { { "1000000000", "ONE BILLION" } }; - static private String[][] formatWordEnglishTitle = + private static String[][] formatWordEnglishTitle = { { "Ww", null, null, null, null, "eng" }, { "0", "Zero" }, @@ -810,7 +808,7 @@ public class NumberConverterTestCase { { "1000000000", "One Billion" } }; - static private String[][] formatWordSpanishLower = + private static String[][] formatWordSpanishLower = { { "w", null, null, null, null, "spa" }, { "0", "cero" }, @@ -890,7 +888,7 @@ public class NumberConverterTestCase { { "1000000000", "mil millones" } }; - static private String[][] formatWordSpanishUpper = + private static String[][] formatWordSpanishUpper = { { "W", null, null, null, null, "spa" }, { "0", "CERO" }, @@ -970,7 +968,7 @@ public class NumberConverterTestCase { { "1000000000", "MIL MILLONES" } }; - static private String[][] formatWordSpanishTitle = + private static String[][] formatWordSpanishTitle = { { "Ww", null, null, null, null, "spa" }, { "0", "Cero" }, @@ -1050,7 +1048,7 @@ public class NumberConverterTestCase { { "1000000000", "Mil Millones" } }; - static private String[][] formatWordFrenchLower = + private static String[][] formatWordFrenchLower = { { "w", null, null, null, null, "fra" }, { "0", "z\u00e9ro" }, @@ -1141,7 +1139,7 @@ public class NumberConverterTestCase { { "1000000000", "un milliard" } }; - static private String[][] formatWordFrenchUpper = + private static String[][] formatWordFrenchUpper = { { "W", null, null, null, null, "fra" }, { "0", "Z\u00c9RO" }, @@ -1232,7 +1230,7 @@ public class NumberConverterTestCase { { "1000000000", "UN MILLIARD" } }; - static private String[][] formatWordFrenchTitle = + private static String[][] formatWordFrenchTitle = { { "Ww", null, null, null, null, "fra" }, { "0", "Z\u00e9ro" }, diff --git a/test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java b/test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java index 70bd568af..4407254a8 100644 --- a/test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java +++ b/test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java @@ -27,8 +27,6 @@ import org.junit.runners.Suite.SuiteClasses; * Test suite for bidirectional functionality. */ @RunWith(Suite.class) -@SuiteClasses({ - NumberConverterTestCase.class -}) +@SuiteClasses(NumberConverterTestCase.class) public class UtilTestSuite { } diff --git a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java index 8d7d46928..fa4babfa2 100644 --- a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java +++ b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java @@ -24,7 +24,6 @@ import java.io.IOException; import org.xml.sax.SAXException; import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.PDFRendererConfBuilder; /** diff --git a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java index 84e8ee804..591104412 100644 --- a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java +++ b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java @@ -24,7 +24,6 @@ import java.io.IOException; import org.xml.sax.SAXException; import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.PDFRendererConfBuilder; /** diff --git a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java index 3479c3794..11538dc33 100644 --- a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java +++ b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java @@ -24,7 +24,6 @@ import java.io.IOException; import org.xml.sax.SAXException; import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.PDFRendererConfBuilder; /** diff --git a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java index 800e06d32..4bacc180c 100644 --- a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java +++ b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java @@ -24,7 +24,6 @@ import java.io.IOException; import org.xml.sax.SAXException; import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.PDFRendererConfBuilder; /** diff --git a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java index c9f6d98ff..e05e44ab1 100644 --- a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java +++ b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java @@ -24,7 +24,6 @@ import java.io.IOException; import org.xml.sax.SAXException; import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.PDFRendererConfBuilder; public class FontsAutoDetectTestCase extends BaseConstructiveUserConfigTest { diff --git a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java index 2776c2cce..aab7a2e7c 100644 --- a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java +++ b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java @@ -24,7 +24,6 @@ import java.io.IOException; import org.xml.sax.SAXException; import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.PDFRendererConfBuilder; /** diff --git a/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java b/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java index 23af20a1a..f6e2b02ba 100644 --- a/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java +++ b/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java @@ -19,10 +19,10 @@ package org.apache.fop.datatypes; -import static org.junit.Assert.assertEquals; - import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * Tests for URISpecification. */ diff --git a/test/java/org/apache/fop/events/BasicEventTestCase.java b/test/java/org/apache/fop/events/BasicEventTestCase.java index 87fc04329..39e3fec98 100644 --- a/test/java/org/apache/fop/events/BasicEventTestCase.java +++ b/test/java/org/apache/fop/events/BasicEventTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.events; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -26,7 +28,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import org.apache.fop.events.model.EventSeverity; -import org.junit.Test; public class BasicEventTestCase { diff --git a/test/java/org/apache/fop/events/EventChecker.java b/test/java/org/apache/fop/events/EventChecker.java index 3f0eef6bb..506658467 100644 --- a/test/java/org/apache/fop/events/EventChecker.java +++ b/test/java/org/apache/fop/events/EventChecker.java @@ -27,7 +27,7 @@ import static org.junit.Assert.fail; /** * Class that checks that an expected event is produced, and only this one. */ -class EventChecker implements EventListener { +public class EventChecker implements EventListener { private final String expectedEventID; @@ -35,7 +35,7 @@ class EventChecker implements EventListener { private boolean eventReceived; - EventChecker(String expectedEventID, Map<String, Object> expectedParams) { + public EventChecker(String expectedEventID, Map<String, Object> expectedParams) { this.expectedEventID = expectedEventID; this.expectedParams = expectedParams; } @@ -51,9 +51,9 @@ class EventChecker implements EventListener { } } - void end() { + public void end() { if (!eventReceived) { - fail("Did not received expected event: " + expectedEventID); + fail("Did not receive expected event: " + expectedEventID); } } } diff --git a/test/java/org/apache/fop/events/TestEventProducer.java b/test/java/org/apache/fop/events/TestEventProducer.java index ff0bc2a81..ff19c7ea6 100644 --- a/test/java/org/apache/fop/events/TestEventProducer.java +++ b/test/java/org/apache/fop/events/TestEventProducer.java @@ -38,7 +38,10 @@ public interface TestEventProducer extends EventProducer { */ void enjoy(Object source, String what); - public class Provider { + public static final class Provider { + + private Provider() { + } public static TestEventProducer get(EventBroadcaster broadcaster) { return (TestEventProducer)broadcaster.getEventProducerFor(TestEventProducer.class); diff --git a/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java b/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java index 313379e02..226c551fb 100644 --- a/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java +++ b/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java @@ -19,8 +19,6 @@ package org.apache.fop.fo; -import static org.junit.Assert.assertArrayEquals; - import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -42,6 +40,8 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; +import static org.junit.Assert.assertArrayEquals; + import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; import org.apache.fop.fo.flow.BasicLink; diff --git a/test/java/org/apache/fop/fo/FODocumentParser.java b/test/java/org/apache/fop/fo/FODocumentParser.java index 7d03e38a6..2e691519b 100644 --- a/test/java/org/apache/fop/fo/FODocumentParser.java +++ b/test/java/org/apache/fop/fo/FODocumentParser.java @@ -64,7 +64,7 @@ public final class FODocumentParser { /** * A factory to create custom instances of {@link FOEventHandler}. */ - public static interface FOEventHandlerFactory { + public interface FOEventHandlerFactory { /** * Creates a new {@code FOEventHandler} instance parameterized with the given FO user agent. diff --git a/test/java/org/apache/fop/fo/FONodeMocks.java b/test/java/org/apache/fop/fo/FONodeMocks.java index ba969b9fa..97889c177 100644 --- a/test/java/org/apache/fop/fo/FONodeMocks.java +++ b/test/java/org/apache/fop/fo/FONodeMocks.java @@ -31,7 +31,6 @@ import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; import org.apache.fop.events.EventBroadcaster; import org.apache.fop.fo.flow.table.ColumnNumberManager; import org.apache.fop.fo.flow.table.ColumnNumberManagerHolder; @@ -46,7 +45,7 @@ public final class FONodeMocks { /** * Creates and returns a mock {@link FONode} configured with a mock * {@link FOEventHandler}. The FO event handler returns a mock {@link FOUserAgent}, - * which in turn returns a mock {@link FopFactory}, which returns a mock + * which in turn returns a mock {@link org.apache.fop.apps.FopFactory}, which returns a mock * {@link ImageManager}. * * @return a mock FO node diff --git a/test/java/org/apache/fop/fo/flow/MarkersTestCase.java b/test/java/org/apache/fop/fo/flow/MarkersTestCase.java index 983a531b0..09a4e129c 100644 --- a/test/java/org/apache/fop/fo/flow/MarkersTestCase.java +++ b/test/java/org/apache/fop/fo/flow/MarkersTestCase.java @@ -30,10 +30,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.flow.Marker; -import org.apache.fop.fo.flow.Markers; -import org.apache.fop.fo.flow.RetrieveMarker; -import org.apache.fop.fo.flow.RetrieveTableMarker; public class MarkersTestCase { diff --git a/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java b/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java index fb6ec6a25..0f0e347d3 100644 --- a/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java +++ b/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java @@ -24,8 +24,8 @@ import java.util.Iterator; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.FODocumentParser; -import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; +import org.apache.fop.fo.FOEventHandler; import org.apache.fop.util.ConsoleEventListenerForTests; /** diff --git a/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java b/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java index 7c0301ca7..75ba53525 100644 --- a/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java @@ -19,18 +19,20 @@ package org.apache.fop.fo.flow.table; -import static org.junit.Assert.assertEquals; - import java.awt.Color; import java.util.Iterator; import java.util.List; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode.FONodeIterator; import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; +// CSOFF: LineLength + /** * A testcase for the resolution of collapsed borders in the FO tree, taking * conditionality into account. The resolved borders are generated by the diff --git a/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java b/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java index 361517a66..884116441 100644 --- a/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java @@ -19,16 +19,16 @@ package org.apache.fop.fo.flow.table; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.util.Iterator; import java.util.List; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + /** * Tests that RowGroupBuilder returns, for each part of a table, the expected number of * row-groups with the expected number or rows in each. diff --git a/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java b/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java index a21806559..2df0cac2a 100644 --- a/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java +++ b/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java @@ -19,12 +19,12 @@ package org.apache.fop.fo.flow.table; -import static org.junit.Assert.assertEquals; - import java.util.Iterator; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.FObj; diff --git a/test/java/org/apache/fop/fo/flow/table/TableHandler.java b/test/java/org/apache/fop/fo/flow/table/TableHandler.java index 11f24b99b..04da32b47 100644 --- a/test/java/org/apache/fop/fo/flow/table/TableHandler.java +++ b/test/java/org/apache/fop/fo/flow/table/TableHandler.java @@ -24,7 +24,6 @@ import java.util.List; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.fo.flow.table.Table; public class TableHandler extends FOEventHandler { diff --git a/test/java/org/apache/fop/fo/pagination/AllTests.java b/test/java/org/apache/fop/fo/pagination/AllTests.java index 40990cb06..bd5b21c14 100644 --- a/test/java/org/apache/fop/fo/pagination/AllTests.java +++ b/test/java/org/apache/fop/fo/pagination/AllTests.java @@ -19,8 +19,8 @@ package org.apache.fop.fo.pagination; -import org.junit.runners.Suite; import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * All test to be added in FOTreeTestSuite @@ -28,6 +28,6 @@ import org.junit.runner.RunWith; */ @RunWith(Suite.class) @Suite.SuiteClasses({ PageSequenceMasterTestCase.class, - RepeatablePageMasterAlternativesTestCase.class}) + RepeatablePageMasterAlternativesTestCase.class }) public final class AllTests { } diff --git a/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java b/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java index ad4f991ac..d7bc2e11c 100644 --- a/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java +++ b/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java @@ -19,8 +19,10 @@ package org.apache.fop.fo.pagination; -import static org.junit.Assert.fail; +import org.junit.Test; +import org.xml.sax.Locator; +import static org.junit.Assert.fail; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyObject; @@ -33,8 +35,6 @@ import static org.mockito.Mockito.when; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.layoutmgr.BlockLevelEventProducer; -import org.junit.Test; -import org.xml.sax.Locator; /** diff --git a/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java b/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java index 5ac4860dc..ce1a97638 100644 --- a/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java +++ b/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java @@ -19,6 +19,8 @@ package org.apache.fop.fo.pagination; +import org.junit.Test; + import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; @@ -30,8 +32,6 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.NumericProperty; import org.apache.fop.fo.properties.Property; -import org.junit.Test; - /** * Unit Test for RepeatablePageMasterAlternatives * diff --git a/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java b/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java index cd5d545ff..89ed2733d 100644 --- a/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java +++ b/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java @@ -19,12 +19,12 @@ package org.apache.fop.fo.properties; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.junit.Test; - import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.Constants; diff --git a/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java b/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java index 352a39713..81ebc2f41 100644 --- a/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java +++ b/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java @@ -19,16 +19,16 @@ package org.apache.fop.fo.properties; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FONodeMocks; diff --git a/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java b/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java index 20212b002..4c89d00da 100644 --- a/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java +++ b/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java @@ -24,11 +24,11 @@ import java.io.File; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.fop.apps.io.InternalResourceResolver; import org.apache.fop.apps.io.ResourceResolverFactory; -import static org.junit.Assert.assertEquals; - /** * */ @@ -58,4 +58,17 @@ public class DejaVuLGCSerifTestCase { public void testFontName() { assertEquals("DejaVuLGCSerif", font.getFontName()); } + + @Test + public void testUnderline() { + assertEquals(-840, font.getUnderlinePosition(10)); + assertEquals(430, font.getUnderlineThickness(10)); + } + + @Test + public void testStrikeout() { + assertEquals(2340, font.getStrikeoutPosition(10)); + assertEquals(490, font.getStrikeoutThickness(10)); + } + } diff --git a/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java b/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java index ee3498a03..c8099f860 100644 --- a/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java +++ b/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java @@ -35,7 +35,7 @@ import static org.junit.Assert.assertTrue; */ public class EmbedFontInfoTestCase { - public EmbedFontInfoTestCase() {} + public EmbedFontInfoTestCase() { } private EmbedFontInfo sut; diff --git a/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java b/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java index 509ee56f4..b4271ba60 100644 --- a/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java +++ b/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java @@ -52,13 +52,4 @@ public class FontEventProcessingTestCase { MimeConstants.MIME_PDF); } - @Test - public void testSVGFontStrokedAsShapes() throws Exception { - // svg-fonts.fo embeds two fonts; one that is present in the system and the other is not; the - // missing font is stroked as shapes while the fonts that exists is stroked as text - InputStream inStream = getClass().getResourceAsStream("svg-fonts.fo"); - eventsTests.doTest(inStream, null, FontEventProducer.class.getName() + ".svgTextStrokedAsShapes", - MimeConstants.MIME_PDF); - } - } diff --git a/test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java b/test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java index 073743c13..d653171b7 100644 --- a/test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java +++ b/test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java @@ -20,7 +20,6 @@ package org.apache.fop.fonts; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; @@ -28,13 +27,14 @@ import org.junit.Before; import org.junit.Test; import org.xml.sax.SAXException; +import static org.junit.Assert.assertEquals; + import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.FopConfParser; import org.apache.fop.apps.FopFactory; import static org.apache.fop.apps.FopConfParserTestCase.getFopFactory; -import static org.junit.Assert.assertEquals; /** * A test case for {@link FontManagerConfigurator}. @@ -84,7 +84,7 @@ public class FontManagerConfiguratorTestCase { /** * This test is an interesting one; it's basically testing that if a base URI pointing to a * directory that doesn't exist is used, an error is not thrown. The URI resolver should handle - * any {@link FileNotFoundException}s, not the configuration. We're NOT testing whether a font + * any {@link java.io.FileNotFoundException}s, not the configuration. We're NOT testing whether a font * can be resolved here, just that the URI resolver accepts it as its base URI. */ @Test diff --git a/test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java b/test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java index 64c7642eb..97ea5c52b 100644 --- a/test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java +++ b/test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java @@ -26,14 +26,14 @@ import java.util.Random; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.fontbox.cff.CFFDataInput; import org.apache.fop.fonts.cff.CFFDataReader.CFFIndexData; import org.apache.fop.fonts.cff.CFFDataReader.DICTEntry; import org.apache.fop.fonts.truetype.OTFSubSetFile; -import static org.junit.Assert.assertEquals; - public class CFFDataReaderTestCase { private CFFDataReader cffReader; @@ -113,7 +113,7 @@ public class CFFDataReaderTestCase { //Array comparison int[] fontBBox = { -50, -40, 100, 120 }; DICTEntry fontBBoxEntry = dictMap.get("FontBBox"); - for (int i = 0;i < fontBBoxEntry.getOperands().size();i++) { + for (int i = 0; i < fontBBoxEntry.getOperands().size(); i++) { assertEquals(fontBBoxEntry.getOperands().get(i).intValue(), fontBBox[i]); } //Multi-byte offset (number) @@ -141,7 +141,7 @@ public class CFFDataReaderTestCase { }; Random randGen = new Random(); byte[] data = new byte[31]; - for (int i = 0;i < data.length;i++) { + for (int i = 0; i < data.length; i++) { data[i] = (byte)randGen.nextInt(255); } testIndex = OTFSubSetFile.concatArray(testIndex, data); diff --git a/test/java/org/apache/fop/fonts/svg-fonts.fo b/test/java/org/apache/fop/fonts/svg-fonts.fo deleted file mode 100644 index 0c5f3f599..000000000 --- a/test/java/org/apache/fop/fonts/svg-fonts.fo +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page"> - <fo:region-body /> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="page"> - <fo:flow flow-name="xsl-region-body"> - <fo:block> - <fo:instream-foreign-object> - <svg:svg width="250" height="50"> - <svg:font horiz-adv-x="1000"> - <svg:font-face font-family="Missing" units-per-em="1000" underline-position="-100" - underline-thickness="50" /> - <svg:glyph unicode="A" horiz-adv-x="686" d="M162,186l362,0l78,-186l84,0l-308,708l-70,0l-308,-708l84,0M343,624l153,-372l-307,0z" /> - <svg:glyph unicode="C" horiz-adv-x="704" d="M620,154C567,72 491,48 417,48C235,48 126,191 126,354C126,517 235,660 417,660C492,660 571,613 599,567l63,47C600,693 505,726 417,726C206,726 48,569 48,354C48,139 206,-18 417,-18C534,-18 632,39 679,112z" /> - <svg:glyph unicode="F" horiz-adv-x="556" d="M168,335l330,0l0,66l-330,0l0,241l355,0l0,66l-427,0l0,-708l72,0z" /> - <svg:glyph unicode="G" horiz-adv-x="778" d="M673,631C610,694 529,726 417,726C206,726 48,569 48,354C48,139 206,-18 417,-18C503,-18 606,7 685,54l0,347l-241,0l0,-66l169,0l0,-237C560,68 490,48 417,48C235,48 126,191 126,354C126,517 235,660 417,660C504,660 571,629 619,578z" /> - </svg:font> - <svg:font horiz-adv-x="1000"> - <!-- this is not Helvetica but it is here to increase coverage and show the code takes expected path --> - <svg:font-face font-family="Helvetica" units-per-em="1000" underline-position="-100" - underline-thickness="50" /> - <svg:glyph unicode="A" horiz-adv-x="686" d="M162,186l362,0l78,-186l84,0l-308,708l-70,0l-308,-708l84,0M343,624l153,-372l-307,0z" /> - <svg:glyph unicode="C" horiz-adv-x="704" d="M620,154C567,72 491,48 417,48C235,48 126,191 126,354C126,517 235,660 417,660C492,660 571,613 599,567l63,47C600,693 505,726 417,726C206,726 48,569 48,354C48,139 206,-18 417,-18C534,-18 632,39 679,112z" /> - <svg:glyph unicode="F" horiz-adv-x="556" d="M168,335l330,0l0,66l-330,0l0,241l355,0l0,66l-427,0l0,-708l72,0z" /> - <svg:glyph unicode="G" horiz-adv-x="778" d="M673,631C610,694 529,726 417,726C206,726 48,569 48,354C48,139 206,-18 417,-18C503,-18 606,7 685,54l0,347l-241,0l0,-66l169,0l0,-237C560,68 490,48 417,48C235,48 126,191 126,354C126,517 235,660 417,660C504,660 571,629 619,578z" /> - </svg:font> - <svg:text x="20" y="20" font-family="Missing" font-size="12">ACFG</svg:text> - <svg:text x="20" y="40" font-family="Helvetica" font-size="12">ACFG</svg:text> - </svg:svg> - </fo:instream-foreign-object> - </fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java b/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java index e794ab1a8..952c3ec1f 100644 --- a/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java +++ b/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java @@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue; */ public class GlyfTableTestCase { - private final static class DirData { + private static final class DirData { final long offset; final long length; diff --git a/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java b/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java index 737c2e05e..b4e2cee2e 100644 --- a/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java +++ b/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java @@ -20,7 +20,6 @@ package org.apache.fop.fonts.truetype; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import org.junit.Before; @@ -37,7 +36,7 @@ public class OTFFileTestCase { /** * Initializes fonts used for the testing of reading OTF CFF - * @throws IOException + * @throws java.io.IOException */ @Before public void setUp() throws Exception { @@ -75,11 +74,11 @@ public class OTFFileTestCase { int[] gids = {32, 42, 44, 47}; int[] sourceSansWidths = {516, 555, 572, 383}; - for (int i = 0;i < gids.length;i++) { + for (int i = 0; i < gids.length; i++) { assertEquals(sourceSansWidths[i], sourceSansProBold.getWidths()[gids[i]]); } int[] carolynaWidths = {842, 822, 658, 784}; - for (int i = 0;i < gids.length;i++) { + for (int i = 0; i < gids.length; i++) { assertEquals(carolynaWidths[i], alexBrush.getWidths()[gids[i]]); } } diff --git a/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java b/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java index 604cca3a8..fecb1e9f1 100644 --- a/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java +++ b/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java @@ -20,6 +20,8 @@ package org.apache.fop.fonts.truetype; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,18 +29,15 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; -import org.apache.fontbox.cff.CFFDataInput; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.apache.fontbox.cff.CFFFont; -import org.apache.fontbox.cff.CFFParser; -import org.apache.fontbox.cff.IndexData; -import org.apache.fontbox.cff.Type2CharStringParser; import org.apache.fop.fonts.cff.CFFDataReader; import org.apache.fop.fonts.cff.CFFDataReader.CFFIndexData; import org.apache.fop.fonts.cff.CFFDataReader.DICTEntry; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.apache.fop.fonts.truetype.OTFSubSetFile.BytesNumber; public class OTFSubSetFileTestCase extends OTFFileTestCase { @@ -47,10 +46,6 @@ public class OTFSubSetFileTestCase extends OTFFileTestCase { private byte[] sourceSansData; CFFDataReader cffReaderHeitiStd; - public OTFSubSetFileTestCase() throws IOException { - super(); - } - /** * Initialises the test by creating the font subset. A CFFDataReader is * also created based on the subset data for use in the tests. @@ -80,12 +75,17 @@ public class OTFSubSetFileTestCase extends OTFFileTestCase { public void testCharStringIndex() throws IOException { assertEquals(256, cffReaderSourceSans.getCharStringIndex().getNumObjects()); assertTrue(checkCorrectOffsets(cffReaderSourceSans.getCharStringIndex())); - validateCharStrings(cffReaderSourceSans); + validateCharStrings(cffReaderSourceSans, sourceSansSubset.getCFFReader()); } + /** + * Checks the index data to ensure that the offsets are valid + * @param indexData The index data to check + * @return Returns true if it is found to be valid + */ private boolean checkCorrectOffsets(CFFIndexData indexData) { int last = 0; - for (int i = 0;i < indexData.getOffsets().length;i++) { + for (int i = 0; i < indexData.getOffsets().length; i++) { if (indexData.getOffsets()[i] < last) { return false; } @@ -94,35 +94,268 @@ public class OTFSubSetFileTestCase extends OTFFileTestCase { return true; } - private void validateCharStrings(CFFDataReader cffReader) throws IOException { + /** + * Validates the subset font CharString data by comparing it with the original. + * @param subsetCFF The subset CFFDataReader containing the CharString data + * @param origCFF The original CFFDataReader containing the CharString data + * @throws IOException + */ + private void validateCharStrings(CFFDataReader subsetCFF, CFFDataReader origCFF) + throws IOException { CFFFont sourceSansOriginal = sourceSansProBold.fileFont; + CFFIndexData charStrings = subsetCFF.getCharStringIndex(); Map<String, byte[]> origCharStringData = sourceSansOriginal.getCharStringsDict(); - IndexData origGlobalIndex = sourceSansOriginal.getGlobalSubrIndex(); - IndexData origLocalIndex = sourceSansOriginal.getLocalSubrIndex(); + for (int i = 0; i < charStrings.getNumObjects(); i++) { + byte[] origCharData = origCharStringData.get(origCharStringData.keySet().toArray( + new String[0])[i]); + byte[] charData = charStrings.getValue(i); + List<BytesNumber> origOperands = getFullCharString(origCharData, origCFF); + List<BytesNumber> subsetOperands = getFullCharString(charData, subsetCFF); + for (int j = 0; j < origOperands.size(); j++) { + assertTrue(origOperands.get(j).equals(subsetOperands.get(j))); + } + } + } + + /** + * Recursively reads and constructs the full CharString for comparison + * @param data The original byte data of the CharString + * @param cffData The CFFDataReader containing the subroutine indexes + * @return Returns a list of parsed operands and operators + * @throws IOException + */ + private List<BytesNumber> getFullCharString(byte[] data, CFFDataReader cffData) throws IOException { + CFFIndexData localIndexSubr = cffData.getLocalIndexSubr(); + CFFIndexData globalIndexSubr = cffData.getGlobalIndexSubr(); + boolean hasLocalSubroutines = localIndexSubr != null && localIndexSubr.getNumObjects() > 0; + boolean hasGlobalSubroutines = globalIndexSubr != null && globalIndexSubr.getNumObjects() > 0; + ArrayList<BytesNumber> operands = new ArrayList<BytesNumber>(); + for (int dataPos = 0; dataPos < data.length; dataPos++) { + int b0 = data[dataPos] & 0xff; + if (b0 == 10 && hasLocalSubroutines) { + int subrNumber = getSubrNumber(localIndexSubr.getNumObjects(), + operands.get(operands.size() - 1).getNumber()); + byte[] subr = localIndexSubr.getValue(subrNumber); + List<BytesNumber> subrOperands = getFullCharString(subr, cffData); + operands = mergeOperands(operands, subrOperands); + } else if (b0 == 29 && hasGlobalSubroutines) { + int subrNumber = getSubrNumber(globalIndexSubr.getNumObjects(), + operands.get(operands.size() - 1).getNumber()); + byte[] subr = globalIndexSubr.getValue(subrNumber); + ArrayList<BytesNumber> subrOperands = (ArrayList<BytesNumber>)getFullCharString(subr, cffData); + operands = mergeOperands(operands, subrOperands); + } else if ((b0 >= 0 && b0 <= 27) || (b0 >= 29 && b0 <= 31)) { + int size = 1; + int b1 = -1; + if (b0 == 12) { + b1 = data[dataPos++] & 0xff; + size = 2; + } + if (b0 == 19 || b0 == 20) { + dataPos += 1; + size = 2; + } + operands.add(new Operator(b0, size, getOperatorName(b0, b1))); + } else if (b0 == 28 || (b0 >= 32 && b0 <= 255)) { + operands.add(readNumber(b0, data, dataPos)); + dataPos += operands.get(operands.size() - 1).getNumBytes() - 1; + } + } + return operands; + } + + /** + * Merges two lists of operands. This is typically used to merge the CharString + * data with that of a parsed and referenced subroutine. + * @param charString The parsed CharString data so far + * @param subroutine The parsed elements from a subroutine + * @return Returns a merged list of both CharString and subroutine elements. + */ + private ArrayList<BytesNumber> mergeOperands(List<BytesNumber> charString, + List<BytesNumber> subroutine) { + BytesNumber[] charStringOperands = charString.toArray(new BytesNumber[0]); + BytesNumber[] subroutineOperands = subroutine.toArray(new BytesNumber[0]); + BytesNumber[] mergeData = new BytesNumber[charStringOperands.length - 1 + + subroutineOperands.length - 1]; + System.arraycopy(charStringOperands, 0, mergeData, 0, charStringOperands.length - 1); + System.arraycopy(subroutineOperands, 0, mergeData, charStringOperands.length - 1, + subroutineOperands.length - 1); + ArrayList<BytesNumber> hello = new ArrayList<BytesNumber>(); + hello.addAll(Arrays.asList(mergeData)); + return hello; + } - CFFDataInput globalSubrs = new CFFDataInput(cffReader.getGlobalIndexSubr().getByteData()); - CFFDataInput localSubrs = new CFFDataInput(cffReader.getLocalIndexSubr().getByteData()); + /** + * Parses a number from one or more bytes + * @param b0 The first byte to identify how to interpret the number + * @param input The original byte data containing the number + * @param curPos The current position of the number + * @return Returns the number + * @throws IOException + */ + private BytesNumber readNumber(int b0, byte[] input, int curPos) throws IOException { + if (b0 == 28) { + int b1 = input[curPos + 1] & 0xff; + int b2 = input[curPos + 2] & 0xff; + return new BytesNumber(Integer.valueOf((short) (b1 << 8 | b2)), 3); + } else if (b0 >= 32 && b0 <= 246) { + return new BytesNumber(Integer.valueOf(b0 - 139), 1); + } else if (b0 >= 247 && b0 <= 250) { + int b1 = input[curPos + 1] & 0xff; + return new BytesNumber(Integer.valueOf((b0 - 247) * 256 + b1 + 108), 2); + } else if (b0 >= 251 && b0 <= 254) { + int b1 = input[curPos + 1] & 0xff; + return new BytesNumber(Integer.valueOf(-(b0 - 251) * 256 - b1 - 108), 2); + } else if (b0 == 255) { + int b1 = input[curPos + 1] & 0xff; + int b2 = input[curPos + 2] & 0xff; + return new BytesNumber(Integer.valueOf((short)(b1 << 8 | b2)), 5); + } else { + throw new IllegalArgumentException(); + } + } - IndexData globalIndexData = CFFParser.readIndexData(globalSubrs); - IndexData localIndexData = CFFParser.readIndexData(localSubrs); + /** + * Gets the subroutine number according to the number of subroutines + * and the provided operand. + * @param numSubroutines The number of subroutines used to calculate the + * subroutine reference. + * @param operand The operand for the subroutine + * @return Returns the calculated subroutine number + */ + private int getSubrNumber(int numSubroutines, int operand) { + int bias = getBias(numSubroutines); + return bias + operand; + } - CFFIndexData charStrings = cffReader.getCharStringIndex(); - for (int i = 0;i < charStrings.getNumObjects();i++) { - byte[] charData = charStrings.getValue(i); - Type2CharStringParser parser = new Type2CharStringParser(); + /** + * Gets the bias give the number of subroutines. This is used in the + * calculation to determine a subroutine's number + * @param subrCount The number of subroutines for a given index + * @return Returns the bias value + */ + private int getBias(int subrCount) { + if (subrCount < 1240) { + return 107; + } else if (subrCount < 33900) { + return 1131; + } else { + return 32768; + } + } - byte[] origCharData = origCharStringData.get(origCharStringData.keySet().toArray( - new String[0])[i]); - List<Object> origSeq = parser.parse(origCharData, origGlobalIndex, origLocalIndex); + /** + * A class representing an operator from the CharString data + */ + private class Operator extends BytesNumber { + private String opName = ""; - List<Object> subsetSeq = parser.parse(charData, globalIndexData, localIndexData); + public Operator(int number, int numBytes, String opName) { + super(number, numBytes); + this.opName = opName; + } + public String toString() { + return String.format("[%s]", opName); + } + } - //Validates the subset glyph render routines against the originals - assertEquals(origSeq, subsetSeq); + /** + * Gets the identifying name for the given operator. This is primarily + * used for debugging purposes. See the Type 2 CharString Format specification + * document (Technical Note #5177) Appendix A (Command Codes). + * @param operator The operator code + * @param codeb The second byte of the operator + * @return Returns the operator name. + */ + private String getOperatorName(int operator, int operatorB) { + switch (operator) { + case 0: return "Reserved"; + case 1: return "hstem"; + case 2: return "Reserved"; + case 3: return "vstem"; + case 4: return "vmoveto"; + case 5: return "rlineto"; + case 6: return "hlineto"; + case 7: return "vlineto"; + case 8: return "rrcurveto"; + case 9: return "Reserved"; + case 10: return "callsubr"; + case 11: return "return"; + case 12: return getDoubleOpName(operatorB); + case 13: return "Reserved"; + case 14: return "enchar"; + case 15: + case 16: + case 17: return "Reserved"; + case 18: return "hstemhm"; + case 19: return "hintmask"; + case 20: return "cntrmask"; + case 21: return "rmoveto"; + case 22: return "hmoveto"; + case 23: return "vstemhm"; + case 24: return "rcurveline"; + case 25: return "rlinecurve"; + case 26: return "vvcurveto"; + case 27: return "hhcurveto"; + case 28: return "shortint"; + case 29: return "callgsubr"; + case 30: return "vhcurveto"; + case 31: return "hvcurveto"; + default: return "Unknown"; } } /** + * Gets the name of a double byte operator code + * @param operator The second byte of the operator + * @return Returns the name + */ + private String getDoubleOpName(int operator) { + switch (operator) { + case 0: + case 1: + case 2: return "Reserved"; + case 3: return "and"; + case 4: return "or"; + case 5: return "not"; + case 6: + case 7: + case 8: return "Reserved"; + case 9: return "abs"; + case 10: return "add"; + case 11: return "sub"; + case 12: return "div"; + case 13: return "Reserved"; + case 14: return "neg"; + case 15: return "eq"; + case 16: + case 17: return "Reserved"; + case 18: return "drop"; + case 19: return "Reserved"; + case 20: return "put"; + case 21: return "get"; + case 22: return "ifelse"; + case 23: return "random"; + case 24: return "mul"; + case 25: return "Reserved"; + case 26: return "sqrt"; + case 27: return "dup"; + case 28: return "exch"; + case 29: return "index"; + case 30: return "roll"; + case 31: + case 32: + case 33: return "Reserved"; + case 34: return "hflex"; + case 35: return "flex"; + case 36: return "hflex1"; + case 37: return "flex1"; + case 38: return "Reserved"; + default: return "Unknown"; + } + } + + /** * Validates the String index data and size * @throws IOException */ diff --git a/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java b/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java index a390bef0f..a78b3e674 100644 --- a/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java +++ b/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java @@ -26,12 +26,12 @@ import java.util.Map; import org.junit.Test; -import org.apache.fop.fonts.truetype.OpenFont.PostScriptVersion; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.apache.fop.fonts.truetype.OpenFont.PostScriptVersion; + /** * Class for testing org.apache.fop.fonts.truetype.TTFFile */ @@ -430,6 +430,24 @@ public class TTFFileTestCase { assertEquals(true, droidmonoTTFFile.isEmbeddable()); } + /** Underline position and thickness. */ + @Test + public void testUnderline() { + assertEquals(-63, dejavuTTFFile.getUnderlinePosition()); + assertEquals(43, dejavuTTFFile.getUnderlineThickness()); + assertEquals(-75, droidmonoTTFFile.getUnderlinePosition()); + assertEquals(49, droidmonoTTFFile.getUnderlineThickness()); + } + + /** Strikeout position and thickness. */ + @Test + public void testStrikeout() { + assertEquals(258, dejavuTTFFile.getStrikeoutPosition()); + assertEquals(49, dejavuTTFFile.getStrikeoutThickness()); + assertEquals(243, droidmonoTTFFile.getStrikeoutPosition()); + assertEquals(49, droidmonoTTFFile.getStrikeoutThickness()); + } + /** * Test readFont() - Add implementation if necessary. */ diff --git a/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java b/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java index f50b116ac..899fe1d73 100644 --- a/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java +++ b/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java @@ -25,14 +25,14 @@ import java.net.URI; import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.fop.apps.io.InternalResourceResolver; import org.apache.fop.apps.io.ResourceResolverFactory; import org.apache.fop.fonts.EmbeddingMode; import org.apache.fop.fonts.EncodingMode; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - /** * Test case for {@link OFFontLoader}. */ diff --git a/test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java b/test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java index 93443a0d9..31a613567 100644 --- a/test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java +++ b/test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java @@ -19,9 +19,6 @@ package org.apache.fop.fonts.type1; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.awt.Rectangle; import java.io.IOException; import java.io.InputStream; @@ -29,6 +26,9 @@ import java.util.List; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** * Test case for {@link AFMParser}. */ @@ -128,4 +128,13 @@ public class AFMParserTestCase { private boolean objectEquals(Object o1, Object o2) { return o1 == null ? o2 == null : (o1 == o2 || o1.equals(o2)); } + + @Test + public void testUnderlinePositionAndThickness() throws IOException { + AFMFile afm = sut.parse(getClass().getResourceAsStream("underline.afm"), null); + AFMWritingDirectionMetrics metrics = afm.getWritingDirectionMetrics(0); + assertEquals(-96, metrics.getUnderlinePosition()); + assertEquals(58, metrics.getUnderlineThickness()); + } + } diff --git a/test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java b/test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java index 10ba42119..a3a3e1c40 100644 --- a/test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java +++ b/test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java @@ -19,8 +19,6 @@ package org.apache.fop.fonts.type1; -import static org.junit.Assert.assertEquals; - import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; @@ -30,6 +28,8 @@ import java.io.InputStreamReader; import org.junit.BeforeClass; import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * Test case for {@link AdobeStandardEncoding}. */ diff --git a/test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java b/test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java index de9af2d33..c3e9334dd 100644 --- a/test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java +++ b/test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java @@ -19,10 +19,6 @@ package org.apache.fop.fonts.type1; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.awt.Rectangle; import java.io.IOException; import java.util.HashMap; @@ -31,6 +27,10 @@ import java.util.Stack; import org.junit.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import org.apache.fop.fonts.NamedCharacter; import org.apache.fop.fonts.type1.AFMParser.ValueHandler; diff --git a/test/java/org/apache/fop/fonts/type1/underline.afm b/test/java/org/apache/fop/fonts/type1/underline.afm new file mode 100644 index 000000000..8137b41eb --- /dev/null +++ b/test/java/org/apache/fop/fonts/type1/underline.afm @@ -0,0 +1,4 @@ +StartFontMetrics 2.0 +UnderlinePosition -96 +UnderlineThickness 58 +EndFontMetrics diff --git a/test/java/org/apache/fop/fotreetest/ext/AssertElement.java b/test/java/org/apache/fop/fotreetest/ext/AssertElement.java index 5070984d1..955644ae4 100644 --- a/test/java/org/apache/fop/fotreetest/ext/AssertElement.java +++ b/test/java/org/apache/fop/fotreetest/ext/AssertElement.java @@ -20,6 +20,9 @@ package org.apache.fop.fotreetest.ext; +import org.xml.sax.Attributes; +import org.xml.sax.Locator; + import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOPropertyMapping; @@ -32,9 +35,6 @@ import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.fotreetest.ResultCollector; -import org.xml.sax.Attributes; -import org.xml.sax.Locator; - /** * Defines the assert element for the FOP Test extension. */ diff --git a/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java b/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java index eee0efac4..b61944eae 100644 --- a/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java +++ b/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java @@ -19,8 +19,8 @@ package org.apache.fop.fotreetest.ext; -import org.apache.fop.fo.FONode; import org.apache.fop.fo.ElementMapping; +import org.apache.fop.fo.FONode; /** * This class provides the element mapping for FOP. diff --git a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java index f4763512a..7f3036c24 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java @@ -19,10 +19,6 @@ package org.apache.fop.image.loader.batik; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - import java.awt.image.Raster; import java.awt.image.RenderedImage; import java.io.File; @@ -30,6 +26,10 @@ import java.io.File; import org.junit.Ignore; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageInfo; diff --git a/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java index efc5df1f7..3d690b67c 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java @@ -19,15 +19,15 @@ package org.apache.fop.image.loader.batik; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import java.io.File; import java.io.IOException; import org.junit.Ignore; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageManager; diff --git a/test/java/org/apache/fop/intermediate/AbstractIFTest.java b/test/java/org/apache/fop/intermediate/AbstractIFTest.java index 419db2c47..48c3f335b 100644 --- a/test/java/org/apache/fop/intermediate/AbstractIFTest.java +++ b/test/java/org/apache/fop/intermediate/AbstractIFTest.java @@ -34,7 +34,6 @@ import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; import org.w3c.dom.Document; - import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; diff --git a/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java b/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java index 3fc855cef..2003958c8 100644 --- a/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java +++ b/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java @@ -27,6 +27,6 @@ import org.junit.runners.Suite.SuiteClasses; * JUnit test suite for the area tree XML format */ @RunWith(Suite.class) -@SuiteClasses({ AreaTreeParserTestCase.class }) +@SuiteClasses(AreaTreeParserTestCase.class) public class AreaTreeXMLFormatTestSuite { } diff --git a/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java b/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java index 58281fc10..83dd88661 100644 --- a/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java +++ b/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java @@ -19,8 +19,6 @@ package org.apache.fop.intermediate; -import static org.junit.Assert.fail; - import java.io.File; import javax.xml.transform.ErrorListener; @@ -34,6 +32,8 @@ import javax.xml.transform.stream.StreamSource; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.fail; + import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; diff --git a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java index f960990b2..71b26cb9b 100644 --- a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java +++ b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java @@ -27,6 +27,6 @@ import org.junit.runners.Suite.SuiteClasses; * A test suite for testing the Intermediate Format output. */ @RunWith(Suite.class) -@SuiteClasses({ IFTestCase.class }) +@SuiteClasses(IFTestCase.class) public final class IntermediateFormatTestSuite { } diff --git a/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java b/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java index 5d87df1a5..ea60f2ff4 100644 --- a/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java +++ b/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java @@ -27,6 +27,6 @@ import org.junit.runners.Suite.SuiteClasses; * JUnit test suite for the intermediate format */ @RunWith(Suite.class) -@SuiteClasses({ IFParserTestCase.class }) +@SuiteClasses(IFParserTestCase.class) public final class LayoutIFTestSuite { } diff --git a/test/java/org/apache/fop/layoutengine/ElementListCheck.java b/test/java/org/apache/fop/layoutengine/ElementListCheck.java index e63fc3291..4d33d670b 100644 --- a/test/java/org/apache/fop/layoutengine/ElementListCheck.java +++ b/test/java/org/apache/fop/layoutengine/ElementListCheck.java @@ -22,16 +22,17 @@ package org.apache.fop.layoutengine; import java.util.Iterator; import java.util.List; -import org.apache.fop.layoutmgr.KnuthBox; -import org.apache.fop.layoutmgr.KnuthElement; -import org.apache.fop.layoutmgr.KnuthGlue; -import org.apache.fop.layoutmgr.KnuthPenalty; import org.w3c.dom.CDATASection; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; +import org.apache.fop.layoutmgr.KnuthBox; +import org.apache.fop.layoutmgr.KnuthElement; +import org.apache.fop.layoutmgr.KnuthGlue; +import org.apache.fop.layoutmgr.KnuthPenalty; + /** * Check implementation that checks a Knuth element list. */ diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java index e739221b0..ad0804af5 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java @@ -21,8 +21,12 @@ package org.apache.fop.layoutengine; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Source; @@ -41,10 +45,16 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import org.apache.fop.DebugHelper; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; @@ -53,6 +63,8 @@ import org.apache.fop.apps.FormattingResults; import org.apache.fop.area.AreaTreeModel; import org.apache.fop.area.AreaTreeParser; import org.apache.fop.area.RenderPagesModel; +import org.apache.fop.events.Event; +import org.apache.fop.events.EventListener; import org.apache.fop.events.model.EventSeverity; import org.apache.fop.fonts.FontInfo; import org.apache.fop.intermediate.IFTester; @@ -131,6 +143,8 @@ public class LayoutEngineTestCase { Fop fop; FopFactory effFactory; + EventsChecker eventsChecker = new EventsChecker( + new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN)); try { Document testDoc = testAssistant.loadTestCase(testFile); effFactory = testAssistant.getFopFactory(testDoc); @@ -146,8 +160,7 @@ public class LayoutEngineTestCase { //Setup FOP for area tree rendering FOUserAgent ua = effFactory.newFOUserAgent(); - ua.getEventBroadcaster().addEventListener( - new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN)); + ua.getEventBroadcaster().addEventListener(eventsChecker); XMLRenderer atrenderer = new XMLRenderer(ua); atrenderer.setContentHandler(athandler); @@ -167,7 +180,60 @@ public class LayoutEngineTestCase { } FormattingResults results = fop.getResults(); LayoutResult result = new LayoutResult(doc, elCollector, results); - checkAll(effFactory, testFile, result); + checkAll(effFactory, testFile, result, eventsChecker); + } + + private static class EventsChecker implements EventListener { + + private final List<Event> events = new ArrayList<Event>(); + + private final EventListener defaultListener; + + /** + * @param fallbackListener the listener to which this class will pass through + * events that are not being checked + */ + public EventsChecker(EventListener fallbackListener) { + this.defaultListener = fallbackListener; + } + + public void processEvent(Event event) { + events.add(event); + } + + public void checkEvent(String expectedKey, Map<String, String> expectedParams) { + boolean eventFound = false; + for (Iterator<Event> iter = events.iterator(); !eventFound && iter.hasNext();) { + Event event = iter.next(); + if (event.getEventKey().equals(expectedKey)) { + eventFound = true; + iter.remove(); + checkParameters(event, expectedParams); + } + } + if (!eventFound) { + fail("Event did not occur but was expected to: " + expectedKey + expectedParams); + } + } + + private void checkParameters(Event event, Map<String, String> expectedParams) { + Map<String, Object> actualParams = event.getParams(); + for (Map.Entry<String, String> expectedParam : expectedParams.entrySet()) { + assertTrue("Event \"" + event.getEventKey() + + "\" is missing parameter \"" + expectedParam.getKey() + '"', + actualParams.containsKey(expectedParam.getKey())); + assertEquals("Event \"" + event.getEventKey() + + "\" has wrong value for parameter \"" + expectedParam.getKey() + "\";", + actualParams.get(expectedParam.getKey()).toString(), + expectedParam.getValue()); + } + } + + public void emitUncheckedEvents() { + for (Event event : events) { + defaultListener.processEvent(event); + } + } } /** @@ -177,8 +243,8 @@ public class LayoutEngineTestCase { * @param result The layout results * @throws TransformerException if a problem occurs in XSLT/JAXP */ - protected void checkAll(FopFactory fopFactory, File testFile, LayoutResult result) - throws TransformerException { + protected void checkAll(FopFactory fopFactory, File testFile, LayoutResult result, + EventsChecker eventsChecker) throws TransformerException { Element testRoot = testAssistant.getTestRoot(testFile); NodeList nodes; @@ -196,6 +262,13 @@ public class LayoutEngineTestCase { Document ifDocument = createIF(fopFactory, testFile, result.getAreaTree()); ifTester.doIFChecks(testFile.getName(), ifChecks, ifDocument); } + + nodes = testRoot.getElementsByTagName("event-checks"); + if (nodes.getLength() > 0) { + Element eventChecks = (Element) nodes.item(0); + doEventChecks(eventChecks, eventsChecker); + } + eventsChecker.emitUncheckedEvents(); } private Document createIF(FopFactory fopFactory, File testFile, Document areaTreeXML) @@ -254,4 +327,28 @@ public class LayoutEngineTestCase { } } + private void doEventChecks(Element eventChecks, EventsChecker eventsChecker) { + NodeList events = eventChecks.getElementsByTagName("event"); + for (int i = 0; i < events.getLength(); i++) { + Element event = (Element) events.item(i); + NamedNodeMap attributes = event.getAttributes(); + Map<String, String> params = new HashMap<String, String>(); + String key = null; + for (int j = 0; j < attributes.getLength(); j++) { + Node attribute = attributes.item(j); + String name = attribute.getNodeName(); + String value = attribute.getNodeValue(); + if ("key".equals(name)) { + key = value; + } else { + params.put(name, value); + } + } + if (key == null) { + throw new RuntimeException("An event element must have a \"key\" attribute"); + } + eventsChecker.checkEvent(key, params); + } + } + } diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java index 2a70f255d..89bf28a55 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java @@ -27,6 +27,6 @@ import org.junit.runners.Suite.SuiteClasses; * JUnit test suit for running layout engine test under JUnit control. */ @RunWith(Suite.class) -@SuiteClasses({ LayoutEngineTestCase.class }) +@SuiteClasses(LayoutEngineTestCase.class) public class LayoutEngineTestSuite { } diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java index fb7f07023..963b66dff 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java @@ -162,7 +162,7 @@ public final class LayoutEngineTestUtils { Collection<File[]> parametersForJUnit4 = new ArrayList<File[]>(); int index = 0; for (File f : files) { - parametersForJUnit4.add(new File[] { f }); + parametersForJUnit4.add(new File[] {f}); if (DEBUG) { System.out.println(String.format("%3d %s", index++, f)); } diff --git a/test/java/org/apache/fop/layoutengine/LayoutResult.java b/test/java/org/apache/fop/layoutengine/LayoutResult.java index 52c83daa8..92c459234 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutResult.java +++ b/test/java/org/apache/fop/layoutengine/LayoutResult.java @@ -19,9 +19,10 @@ package org.apache.fop.layoutengine; -import org.apache.fop.apps.FormattingResults; import org.w3c.dom.Document; +import org.apache.fop.apps.FormattingResults; + /** * This class holds references to all the results from the FOP processing run. */ diff --git a/test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java b/test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java index c2fc84551..629e5f1c6 100644 --- a/test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java +++ b/test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java @@ -23,6 +23,10 @@ import java.awt.Color; import org.junit.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import org.apache.fop.fo.flow.table.PrimaryGridUnit; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableCell; @@ -37,10 +41,6 @@ import org.apache.fop.layoutmgr.PageSequenceLayoutManager; import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.RetrieveTableMarkerLayoutManager; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - public class TableCellLayoutManagerTestCase { // this test aims to check that the first call to addAreas() calls diff --git a/test/java/org/apache/fop/logging/LoggingElementListObserver.java b/test/java/org/apache/fop/logging/LoggingElementListObserver.java index 26c4db00e..7824a6b8b 100644 --- a/test/java/org/apache/fop/logging/LoggingElementListObserver.java +++ b/test/java/org/apache/fop/logging/LoggingElementListObserver.java @@ -24,9 +24,10 @@ import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + +import org.apache.fop.layoutmgr.ElementListObserver.Observer; import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.ListElement; -import org.apache.fop.layoutmgr.ElementListObserver.Observer; /** * <p>Logs all observed element lists. diff --git a/test/java/org/apache/fop/memory/MemoryEater.java b/test/java/org/apache/fop/memory/MemoryEater.java index 7afb80476..efe0cc489 100644 --- a/test/java/org/apache/fop/memory/MemoryEater.java +++ b/test/java/org/apache/fop/memory/MemoryEater.java @@ -45,7 +45,7 @@ import org.apache.fop.apps.MimeConstants; /** * Debug tool to create and process large FO files by replicating them a specified number of times. */ -public class MemoryEater { +public final class MemoryEater { private SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); @@ -53,7 +53,7 @@ public class MemoryEater { private Stats stats; - public MemoryEater() throws TransformerConfigurationException, MalformedURLException { + private MemoryEater() throws TransformerConfigurationException, MalformedURLException { File xsltFile = new File("test/xsl/fo-replicator.xsl"); Source xslt = new StreamSource(xsltFile); replicatorTemplates = tFactory.newTemplates(xslt); diff --git a/test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java b/test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java index 95d5c0a1d..dec62c0a4 100644 --- a/test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java +++ b/test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java @@ -23,10 +23,11 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * Test case for {@link AbstractPDFStream}. */ diff --git a/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java b/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java index a9d7bf4f6..3301fff9e 100644 --- a/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java +++ b/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java @@ -19,10 +19,6 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -33,6 +29,10 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + /** * Tests the {@link FileIDGenerator} class. */ @@ -96,7 +96,7 @@ public class FileIDGeneratorTestCase { assertTrue(Arrays.equals(originalFileID, updatedFileID)); } - private static interface TestGetter { + private interface TestGetter { FileIDGenerator getSut() throws Exception; } diff --git a/test/java/org/apache/fop/pdf/ObjectStreamManagerTestCase.java b/test/java/org/apache/fop/pdf/ObjectStreamManagerTestCase.java index 89d980029..21eb6088f 100644 --- a/test/java/org/apache/fop/pdf/ObjectStreamManagerTestCase.java +++ b/test/java/org/apache/fop/pdf/ObjectStreamManagerTestCase.java @@ -19,15 +19,15 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.OutputStream; import java.util.List; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.apache.fop.pdf.xref.CompressedObjectReference; public class ObjectStreamManagerTestCase { diff --git a/test/java/org/apache/fop/pdf/ObjectStreamTestCase.java b/test/java/org/apache/fop/pdf/ObjectStreamTestCase.java index 317828e4b..3512e1147 100644 --- a/test/java/org/apache/fop/pdf/ObjectStreamTestCase.java +++ b/test/java/org/apache/fop/pdf/ObjectStreamTestCase.java @@ -19,8 +19,6 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Arrays; @@ -29,6 +27,8 @@ import java.util.List; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; + public class ObjectStreamTestCase { private static final String OBJECT_CONTENT = "<<\n /Foo True\n /Bar False\n>>\n"; diff --git a/test/java/org/apache/fop/pdf/PDFAModeTestCase.java b/test/java/org/apache/fop/pdf/PDFAModeTestCase.java index 352e0710e..68609575a 100644 --- a/test/java/org/apache/fop/pdf/PDFAModeTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFAModeTestCase.java @@ -97,7 +97,7 @@ public class PDFAModeTestCase { } @Test - public void checkPDFA_1a() { + public void checkPDFA1a() { new PDFAModeChecker(PDFAMode.PDFA_1A) .isEnabled() .isPart1() @@ -106,7 +106,7 @@ public class PDFAModeTestCase { } @Test - public void checkPDFA_1b() { + public void checkPDFA1b() { new PDFAModeChecker(PDFAMode.PDFA_1B) .isEnabled() .isPart1() @@ -115,7 +115,7 @@ public class PDFAModeTestCase { } @Test - public void checkPDFA_2a() { + public void checkPDFA2a() { new PDFAModeChecker(PDFAMode.PDFA_2A) .isEnabled() .isNotPart1() @@ -124,7 +124,7 @@ public class PDFAModeTestCase { } @Test - public void checkPDFA_2b() { + public void checkPDFA2b() { new PDFAModeChecker(PDFAMode.PDFA_2B) .isEnabled() .isNotPart1() @@ -133,7 +133,7 @@ public class PDFAModeTestCase { } @Test - public void checkPDFA_2u() { + public void checkPDFA2u() { new PDFAModeChecker(PDFAMode.PDFA_2U) .isEnabled() .isNotPart1() diff --git a/test/java/org/apache/fop/pdf/PDFArrayTestCase.java b/test/java/org/apache/fop/pdf/PDFArrayTestCase.java index 418b2f1a9..53e9bdba0 100644 --- a/test/java/org/apache/fop/pdf/PDFArrayTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFArrayTestCase.java @@ -19,17 +19,17 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.junit.Before; import org.junit.Test; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Test case for {@link PDFArray}. diff --git a/test/java/org/apache/fop/pdf/PDFDestsTestCase.java b/test/java/org/apache/fop/pdf/PDFDestsTestCase.java index 49c1e6dab..4655b258d 100644 --- a/test/java/org/apache/fop/pdf/PDFDestsTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFDestsTestCase.java @@ -19,13 +19,13 @@ package org.apache.fop.pdf; -import org.junit.Before; -import org.junit.Test; - import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.junit.Before; +import org.junit.Test; + /** * Test case for {@link PDFDests}. */ diff --git a/test/java/org/apache/fop/pdf/PDFDictionaryTestCase.java b/test/java/org/apache/fop/pdf/PDFDictionaryTestCase.java index 00224e93e..267e05c2c 100644 --- a/test/java/org/apache/fop/pdf/PDFDictionaryTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFDictionaryTestCase.java @@ -19,17 +19,18 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.apache.commons.io.output.CountingOutputStream; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.apache.commons.io.output.CountingOutputStream; + /** * Test case for {@link PDFDictionary}. diff --git a/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java b/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java index c7eff506e..880613a78 100644 --- a/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java @@ -24,8 +24,6 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; -import junit.framework.Assert; - import org.junit.Test; import org.apache.commons.io.output.ByteArrayOutputStream; @@ -34,6 +32,8 @@ import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.svg.PDFDocumentGraphics2D; +import junit.framework.Assert; + /** * Tests for {@link PDFDocumentGraphics2D}. */ diff --git a/test/java/org/apache/fop/pdf/PDFDocumentTestCase.java b/test/java/org/apache/fop/pdf/PDFDocumentTestCase.java index 8965635b9..e58201f13 100644 --- a/test/java/org/apache/fop/pdf/PDFDocumentTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFDocumentTestCase.java @@ -19,12 +19,12 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import org.junit.Test; -import java.io.ByteArrayOutputStream; -import java.io.IOException; +import static org.junit.Assert.assertEquals; /** * Test case for {@link PDFDocument} diff --git a/test/java/org/apache/fop/pdf/PDFEncodingTestCase.java b/test/java/org/apache/fop/pdf/PDFEncodingTestCase.java index 34e48f1a6..2f80b077c 100644 --- a/test/java/org/apache/fop/pdf/PDFEncodingTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFEncodingTestCase.java @@ -19,11 +19,11 @@ package org.apache.fop.pdf; import org.junit.Test; -import org.apache.fop.fonts.CodePointMapping; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import org.apache.fop.fonts.CodePointMapping; + public class PDFEncodingTestCase { /** diff --git a/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java b/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java index ea3b011c7..e3f8344e0 100644 --- a/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java +++ b/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java @@ -19,10 +19,6 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -43,6 +39,10 @@ import javax.crypto.spec.SecretKeySpec; import org.junit.Test; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** * Tests the {@link PDFEncryptionJCE} class. */ diff --git a/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java b/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java index 5e4b9e2e4..edbc7e449 100644 --- a/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java @@ -53,7 +53,7 @@ public class PDFFactoryTestCase { @Override public int[] getWidths() { - return new int[] { 0 }; + return new int[] {0}; } @Override diff --git a/test/java/org/apache/fop/pdf/PDFFilterListTestCase.java b/test/java/org/apache/fop/pdf/PDFFilterListTestCase.java index 2504d871a..d1cc6273d 100644 --- a/test/java/org/apache/fop/pdf/PDFFilterListTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFFilterListTestCase.java @@ -19,10 +19,10 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertFalse; - import org.junit.Test; +import static org.junit.Assert.assertFalse; + public class PDFFilterListTestCase { @Test diff --git a/test/java/org/apache/fop/pdf/PDFNameTestCase.java b/test/java/org/apache/fop/pdf/PDFNameTestCase.java index 80917f416..8d7321496 100644 --- a/test/java/org/apache/fop/pdf/PDFNameTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFNameTestCase.java @@ -22,11 +22,13 @@ package org.apache.fop.pdf; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.apache.commons.io.output.CountingOutputStream; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.fail; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.apache.commons.io.output.CountingOutputStream; /** * Test class for {@link PDFName}. diff --git a/test/java/org/apache/fop/pdf/PDFNullTestCase.java b/test/java/org/apache/fop/pdf/PDFNullTestCase.java index 98427cd20..87dacc7f6 100644 --- a/test/java/org/apache/fop/pdf/PDFNullTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFNullTestCase.java @@ -19,12 +19,12 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import org.junit.Test; -import java.io.ByteArrayOutputStream; -import java.io.IOException; +import static org.junit.Assert.assertEquals; /** * Test case for {@link PDFNull}. diff --git a/test/java/org/apache/fop/pdf/PDFNumberTestCase.java b/test/java/org/apache/fop/pdf/PDFNumberTestCase.java index ed660af8d..65f484dc7 100644 --- a/test/java/org/apache/fop/pdf/PDFNumberTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFNumberTestCase.java @@ -19,13 +19,13 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import java.io.IOException; import org.junit.Before; import org.junit.Test; -import java.io.IOException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * This test tests PDFNumber's doubleOut() methods. diff --git a/test/java/org/apache/fop/pdf/PDFNumsArrayTestCase.java b/test/java/org/apache/fop/pdf/PDFNumsArrayTestCase.java index e0dca33bf..d36775cda 100644 --- a/test/java/org/apache/fop/pdf/PDFNumsArrayTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFNumsArrayTestCase.java @@ -19,11 +19,11 @@ package org.apache.fop.pdf; +import java.io.IOException; + import org.junit.Before; import org.junit.Test; -import java.io.IOException; - /** * Test case for {@link PDFNumsArray}. */ diff --git a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java index 10ffa3b27..f35d2a15c 100644 --- a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java @@ -19,17 +19,17 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.ByteArrayOutputStream; import java.io.IOException; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Tests the PDFObject class. */ diff --git a/test/java/org/apache/fop/pdf/PDFRectangleTestCase.java b/test/java/org/apache/fop/pdf/PDFRectangleTestCase.java index 24b6a1c71..ed87cd23e 100644 --- a/test/java/org/apache/fop/pdf/PDFRectangleTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFRectangleTestCase.java @@ -19,14 +19,14 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + /** * Test case for {@link PDFRectangle}. */ diff --git a/test/java/org/apache/fop/pdf/PDFReferenceTestCase.java b/test/java/org/apache/fop/pdf/PDFReferenceTestCase.java index a2c6193cf..4e0e8814d 100644 --- a/test/java/org/apache/fop/pdf/PDFReferenceTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFReferenceTestCase.java @@ -19,12 +19,12 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertEquals; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import org.junit.Test; -import java.io.ByteArrayOutputStream; -import java.io.IOException; +import static org.junit.Assert.assertEquals; /** * Test case for {@link PDFReference}. diff --git a/test/java/org/apache/fop/pdf/PDFStreamTestCase.java b/test/java/org/apache/fop/pdf/PDFStreamTestCase.java index 20e38a600..b5fb66e00 100644 --- a/test/java/org/apache/fop/pdf/PDFStreamTestCase.java +++ b/test/java/org/apache/fop/pdf/PDFStreamTestCase.java @@ -19,17 +19,17 @@ package org.apache.fop.pdf; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayOutputStream; import java.io.IOException; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class PDFStreamTestCase { private PDFStream stream; diff --git a/test/java/org/apache/fop/pdf/TableHeaderScopeTestCase.java b/test/java/org/apache/fop/pdf/TableHeaderScopeTestCase.java index a1d581402..2fa5008ed 100644 --- a/test/java/org/apache/fop/pdf/TableHeaderScopeTestCase.java +++ b/test/java/org/apache/fop/pdf/TableHeaderScopeTestCase.java @@ -109,14 +109,14 @@ public class TableHeaderScopeTestCase { } private PDFDictionary scopeAttribute(Scope scope) { - return argThat(new isScopeAttribute(scope)); + return argThat(new IsScopeAttribute(scope)); } - private static class isScopeAttribute extends ArgumentMatcher<PDFDictionary> { + private static class IsScopeAttribute extends ArgumentMatcher<PDFDictionary> { private final Scope expectedScope; - public isScopeAttribute(Scope expectedScope) { + public IsScopeAttribute(Scope expectedScope) { this.expectedScope = expectedScope; } diff --git a/test/java/org/apache/fop/pdf/VersionControllerTestCase.java b/test/java/org/apache/fop/pdf/VersionControllerTestCase.java index 74637c91f..e14fc9502 100644 --- a/test/java/org/apache/fop/pdf/VersionControllerTestCase.java +++ b/test/java/org/apache/fop/pdf/VersionControllerTestCase.java @@ -19,13 +19,13 @@ package org.apache.fop.pdf; +import org.junit.Before; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; -import org.junit.Before; -import org.junit.Test; - /** * A test class for {@link VersionController}. diff --git a/test/java/org/apache/fop/pdf/VersionTestCase.java b/test/java/org/apache/fop/pdf/VersionTestCase.java index 9c90f0966..dd2731d8b 100644 --- a/test/java/org/apache/fop/pdf/VersionTestCase.java +++ b/test/java/org/apache/fop/pdf/VersionTestCase.java @@ -19,11 +19,11 @@ package org.apache.fop.pdf; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.junit.Test; - /** * This is a test case for ({@link Version}. */ diff --git a/test/java/org/apache/fop/pdf/xref/CompressedObjectReferenceTestCase.java b/test/java/org/apache/fop/pdf/xref/CompressedObjectReferenceTestCase.java index 8b103d277..b7a326c64 100644 --- a/test/java/org/apache/fop/pdf/xref/CompressedObjectReferenceTestCase.java +++ b/test/java/org/apache/fop/pdf/xref/CompressedObjectReferenceTestCase.java @@ -19,14 +19,14 @@ package org.apache.fop.pdf.xref; -import static org.junit.Assert.assertArrayEquals; - import java.io.IOException; import java.util.Arrays; import java.util.List; import org.junit.Test; +import static org.junit.Assert.assertArrayEquals; + public class CompressedObjectReferenceTestCase extends ObjectReferenceTest { @Test diff --git a/test/java/org/apache/fop/pdf/xref/CrossReferenceObjectTest.java b/test/java/org/apache/fop/pdf/xref/CrossReferenceObjectTest.java index df1b86e53..cd55577cd 100644 --- a/test/java/org/apache/fop/pdf/xref/CrossReferenceObjectTest.java +++ b/test/java/org/apache/fop/pdf/xref/CrossReferenceObjectTest.java @@ -19,8 +19,6 @@ package org.apache.fop.pdf.xref; -import static org.junit.Assert.assertArrayEquals; - import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -32,6 +30,8 @@ import java.util.Map; import org.junit.Before; +import static org.junit.Assert.assertArrayEquals; + import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFInfo; import org.apache.fop.pdf.PDFPages; diff --git a/test/java/org/apache/fop/pdf/xref/UncompressedObjectReferenceTestCase.java b/test/java/org/apache/fop/pdf/xref/UncompressedObjectReferenceTestCase.java index b147084e8..a9f506aaa 100644 --- a/test/java/org/apache/fop/pdf/xref/UncompressedObjectReferenceTestCase.java +++ b/test/java/org/apache/fop/pdf/xref/UncompressedObjectReferenceTestCase.java @@ -19,8 +19,6 @@ package org.apache.fop.pdf.xref; -import static org.junit.Assert.assertArrayEquals; - import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -28,6 +26,8 @@ import java.util.List; import org.junit.Test; +import static org.junit.Assert.assertArrayEquals; + public class UncompressedObjectReferenceTestCase extends ObjectReferenceTest { @Test diff --git a/test/java/org/apache/fop/render/AbstractRenderingTest.java b/test/java/org/apache/fop/render/AbstractRenderingTest.java index 9d196e71d..297a9ba05 100644 --- a/test/java/org/apache/fop/render/AbstractRenderingTest.java +++ b/test/java/org/apache/fop/render/AbstractRenderingTest.java @@ -33,6 +33,7 @@ import javax.xml.transform.stream.StreamSource; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; + import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; diff --git a/test/java/org/apache/fop/render/RawPNGTestUtil.java b/test/java/org/apache/fop/render/RawPNGTestUtil.java index e6660bb42..506556c66 100644 --- a/test/java/org/apache/fop/render/RawPNGTestUtil.java +++ b/test/java/org/apache/fop/render/RawPNGTestUtil.java @@ -28,9 +28,9 @@ import org.apache.xmlgraphics.image.loader.ImageSize; public final class RawPNGTestUtil { - private static int NUM_ROWS = 32; - private static int NUM_COLUMNS = 32; - private static int DPI = 72; + private static final int NUM_ROWS = 32; + private static final int NUM_COLUMNS = 32; + private static final int DPI = 72; private RawPNGTestUtil() { @@ -83,7 +83,7 @@ public final class RawPNGTestUtil { } /** - * + * * @return a default ImageSize */ public static ImageSize getImageSize() { diff --git a/test/java/org/apache/fop/render/RendererFactoryTestCase.java b/test/java/org/apache/fop/render/RendererFactoryTestCase.java index 4bed835ec..1fa4ae0fa 100644 --- a/test/java/org/apache/fop/render/RendererFactoryTestCase.java +++ b/test/java/org/apache/fop/render/RendererFactoryTestCase.java @@ -19,13 +19,13 @@ package org.apache.fop.render; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.File; import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import org.apache.commons.io.output.NullOutputStream; import org.apache.fop.apps.FOPException; diff --git a/test/java/org/apache/fop/render/afp/AFPBorderPainterTestCase.java b/test/java/org/apache/fop/render/afp/AFPBorderPainterTestCase.java index 691d75f3f..dfe956d90 100644 --- a/test/java/org/apache/fop/render/afp/AFPBorderPainterTestCase.java +++ b/test/java/org/apache/fop/render/afp/AFPBorderPainterTestCase.java @@ -19,12 +19,15 @@ package org.apache.fop.render.afp; -import static org.junit.Assert.assertTrue; - import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.OutputStream; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + import org.apache.fop.afp.AFPBorderPainter; import org.apache.fop.afp.AFPLineDataInfo; import org.apache.fop.afp.AFPPaintingState; @@ -32,8 +35,6 @@ import org.apache.fop.afp.BorderPaintingInfo; import org.apache.fop.afp.DataStream; import org.apache.fop.afp.Factory; import org.apache.fop.fo.Constants; -import org.junit.Before; -import org.junit.Test; public class AFPBorderPainterTestCase { private ByteArrayOutputStream outStream; @@ -63,12 +64,12 @@ public class AFPBorderPainterTestCase { ds.endDocument(); assertTrue(line.getX1() == 4999 && line.getX2() == 8332); } - + class MyDataStream extends DataStream { public MyDataStream(Factory factory, AFPPaintingState paintingState, OutputStream outputStream) { super(factory, paintingState, outputStream); } - + public void createLine(AFPLineDataInfo lineDataInfo) { line = lineDataInfo; } diff --git a/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java index 799045872..8ed54049f 100644 --- a/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java +++ b/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java @@ -25,6 +25,10 @@ import java.util.Map; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import org.apache.fop.afp.AFPConstants; import org.apache.fop.apps.AFPRendererConfBuilder; import org.apache.fop.apps.AbstractRendererConfigParserTester; @@ -33,9 +37,6 @@ import org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions; import static org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions.MODE_COLOR; import static org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions.MODE_GRAYSCALE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; public class AFPRendererConfigParserTestCase extends AbstractRendererConfigParserTester<AFPRendererConfBuilder, AFPRendererConfig> { diff --git a/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java index 115b3149a..48cf89240 100644 --- a/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java +++ b/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java @@ -24,6 +24,9 @@ import java.util.Map; import org.junit.Test; import org.mockito.ArgumentCaptor; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.verify; + import org.apache.fop.afp.AFPResourceLevel; import org.apache.fop.afp.AFPResourceLevel.ResourceType; import org.apache.fop.afp.AFPResourceLevelDefaults; @@ -33,9 +36,6 @@ import org.apache.fop.apps.MimeConstants; import org.apache.fop.render.afp.AFPRendererConfig.AFPRendererConfigParser; import org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.verify; - public class AFPRendererConfiguratorTestCase extends AbstractRendererConfiguratorTest<AFPRendererConfigurator, AFPRendererConfBuilder> { diff --git a/test/java/org/apache/fop/render/afp/NoOperationTestCase.java b/test/java/org/apache/fop/render/afp/NoOperationTestCase.java index 78578a2b6..9e83829f8 100644 --- a/test/java/org/apache/fop/render/afp/NoOperationTestCase.java +++ b/test/java/org/apache/fop/render/afp/NoOperationTestCase.java @@ -19,20 +19,22 @@ package org.apache.fop.render.afp; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.apache.commons.io.IOUtils; + import org.apache.fop.afp.AFPConstants; import org.apache.fop.afp.parser.MODCAParser; import org.apache.fop.afp.parser.UnparsedStructuredField; import org.apache.fop.apps.FOUserAgent; -import org.junit.Test; /** * Tests generation of afp:no-operation (NOPs). diff --git a/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java b/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java index 04f872a84..cae184d51 100644 --- a/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java +++ b/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java @@ -24,6 +24,11 @@ import java.awt.image.BufferedImage; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.apache.fop.apps.AbstractRendererConfigParserTester; import org.apache.fop.apps.BitmapRendererConfBuilder; import org.apache.fop.render.bitmap.BitmapRendererConfig.BitmapRendererConfigParser; @@ -36,10 +41,6 @@ import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_RGBA; import static org.apache.fop.render.bitmap.BitmapRendererOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_QUALITY; import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_SPEED; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; public class AbstractBitmapRendererConfigParserTester extends AbstractRendererConfigParserTester<BitmapRendererConfBuilder, BitmapRendererConfig> { diff --git a/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfiguratorTest.java b/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfiguratorTest.java index 3e0c8c203..dcbb27754 100644 --- a/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfiguratorTest.java +++ b/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfiguratorTest.java @@ -23,6 +23,11 @@ import java.awt.image.BufferedImage; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + import org.apache.fop.apps.AbstractRendererConfiguratorTest; import org.apache.fop.apps.BitmapRendererConfBuilder; import org.apache.fop.render.intermediate.IFDocumentHandler; @@ -35,10 +40,6 @@ import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_RGB; import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_RGBA; import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_QUALITY; import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_SPEED; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; public abstract class AbstractBitmapRendererConfiguratorTest extends AbstractRendererConfiguratorTest<BitmapRendererConfigurator, BitmapRendererConfBuilder> { diff --git a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java index d33076983..8a5c2a72d 100644 --- a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java +++ b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java @@ -21,16 +21,16 @@ package org.apache.fop.render.bitmap; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.xmlgraphics.image.writer.Endianness; import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.TIFFRendererConfBuilder; import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class TIFFRendererConfigParserTestCase extends AbstractBitmapRendererConfigParserTester { diff --git a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java index b5e6318ce..e340830f4 100644 --- a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java +++ b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java @@ -23,6 +23,10 @@ import java.awt.image.BufferedImage; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.xmlgraphics.image.writer.Endianness; import org.apache.fop.apps.FopConfBuilder; @@ -32,9 +36,6 @@ import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser; import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T4; import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T6; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; public class TIFFRendererConfiguratorTestCase extends AbstractBitmapRendererConfiguratorTest { diff --git a/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTestCase.java b/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTestCase.java index 6e48845c1..e3f892e7c 100644 --- a/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTestCase.java +++ b/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTestCase.java @@ -19,15 +19,15 @@ package org.apache.fop.render.extensions.prepress; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - import java.awt.Dimension; import java.awt.Rectangle; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + /** * Tests for the fox:bleed, fox:crop-offset, fox:crop-box extension properties. */ diff --git a/test/java/org/apache/fop/render/extensions/prepress/PageScaleTestCase.java b/test/java/org/apache/fop/render/extensions/prepress/PageScaleTestCase.java index ff07e63ce..9de045cf7 100644 --- a/test/java/org/apache/fop/render/extensions/prepress/PageScaleTestCase.java +++ b/test/java/org/apache/fop/render/extensions/prepress/PageScaleTestCase.java @@ -19,14 +19,14 @@ package org.apache.fop.render.extensions.prepress; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - import java.awt.geom.Point2D; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + /** * Tests for the fox:scale extension property. */ diff --git a/test/java/org/apache/fop/render/intermediate/AbstractIFPainterTestCase.java b/test/java/org/apache/fop/render/intermediate/AbstractIFPainterTestCase.java index be8b5d718..ec0f35737 100644 --- a/test/java/org/apache/fop/render/intermediate/AbstractIFPainterTestCase.java +++ b/test/java/org/apache/fop/render/intermediate/AbstractIFPainterTestCase.java @@ -26,15 +26,15 @@ import org.junit.Before; import org.junit.Test; import org.w3c.dom.Document; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; import org.apache.fop.render.RenderingContext; import org.apache.fop.traits.BorderProps; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class AbstractIFPainterTestCase { private AbstractIFPainter<?> sut; diff --git a/test/java/org/apache/fop/render/intermediate/ArcToBezierCurveTransformerTestCase.java b/test/java/org/apache/fop/render/intermediate/ArcToBezierCurveTransformerTestCase.java index 61093c629..039ddcf90 100644 --- a/test/java/org/apache/fop/render/intermediate/ArcToBezierCurveTransformerTestCase.java +++ b/test/java/org/apache/fop/render/intermediate/ArcToBezierCurveTransformerTestCase.java @@ -76,4 +76,4 @@ public class ArcToBezierCurveTransformerTestCase { fail("Angle " + angle + " is in (0, " + Math.PI / 2 + ")"); } } -}
\ No newline at end of file +} diff --git a/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java b/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java index f0e9522d9..4a89b3ac6 100644 --- a/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java +++ b/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java @@ -575,4 +575,4 @@ public class BorderPainterTestCase { } -}
\ No newline at end of file +} diff --git a/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java b/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java index 4df3fe278..5546e5905 100644 --- a/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java +++ b/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java @@ -19,14 +19,6 @@ package org.apache.fop.render.intermediate; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatcher; @@ -36,6 +28,14 @@ import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.argThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fo.extensions.InternalElementMapping; diff --git a/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java b/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java index c5aad66d0..757d6620b 100644 --- a/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java +++ b/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java @@ -20,10 +20,6 @@ package org.apache.fop.render.intermediate; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import org.junit.Before; import org.junit.Test; import org.mockito.InOrder; @@ -32,6 +28,10 @@ import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + import org.apache.fop.render.intermediate.IFStructureTreeBuilder.SAXEventRecorder; import org.apache.fop.util.XMLUtil; diff --git a/test/java/org/apache/fop/render/java2d/Java2DRendererConfigParserTestcase.java b/test/java/org/apache/fop/render/java2d/Java2DRendererConfigParserTestcase.java index 00631af4b..e87c8713d 100644 --- a/test/java/org/apache/fop/render/java2d/Java2DRendererConfigParserTestcase.java +++ b/test/java/org/apache/fop/render/java2d/Java2DRendererConfigParserTestcase.java @@ -21,17 +21,14 @@ package org.apache.fop.render.java2d; import org.junit.Test; -import org.apache.avalon.framework.configuration.Configuration; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import org.apache.fop.apps.AbstractRendererConfigParserTester; -import org.apache.fop.apps.FOPException; import org.apache.fop.apps.Java2DRendererConfBuilder; import org.apache.fop.render.java2d.Java2DRendererConfig.Java2DRendererConfigParser; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - public class Java2DRendererConfigParserTestcase extends AbstractRendererConfigParserTester<Java2DRendererConfBuilder, Java2DRendererConfig> { diff --git a/test/java/org/apache/fop/render/pcl/PCLRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/pcl/PCLRendererConfigParserTestCase.java index 113c3e2bd..caf534854 100644 --- a/test/java/org/apache/fop/render/pcl/PCLRendererConfigParserTestCase.java +++ b/test/java/org/apache/fop/render/pcl/PCLRendererConfigParserTestCase.java @@ -21,13 +21,13 @@ package org.apache.fop.render.pcl; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.fop.apps.AbstractRendererConfigParserTester; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.MimeConstants; import org.apache.fop.render.pcl.PCLRendererConfig.PCLRendererConfigParser; -import static org.junit.Assert.assertEquals; - public class PCLRendererConfigParserTestCase extends AbstractRendererConfigParserTester<PCLRendererConfBuilder, PCLRendererConfig> { diff --git a/test/java/org/apache/fop/render/pcl/PCLRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/pcl/PCLRendererConfiguratorTestCase.java index 024104179..fc7175ad6 100644 --- a/test/java/org/apache/fop/render/pcl/PCLRendererConfiguratorTestCase.java +++ b/test/java/org/apache/fop/render/pcl/PCLRendererConfiguratorTestCase.java @@ -19,16 +19,16 @@ package org.apache.fop.render.pcl; import org.junit.Test; -import org.apache.fop.apps.AbstractRendererConfiguratorTest; -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.pcl.PCLRendererConfig.PCLRendererConfigParser; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; +import org.apache.fop.apps.AbstractRendererConfiguratorTest; +import org.apache.fop.apps.FOPException; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.pcl.PCLRendererConfig.PCLRendererConfigParser; + public class PCLRendererConfiguratorTestCase extends AbstractRendererConfiguratorTest<PCLRendererConfigurator, PCLRendererConfBuilder> { diff --git a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java index 94c842e68..b2b77e842 100644 --- a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java @@ -21,14 +21,19 @@ package org.apache.fop.render.pdf; import java.io.File; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import org.junit.Test; import org.xml.sax.SAXException; +import static org.junit.Assert.fail; + import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.events.EventChecker; +import org.apache.fop.pdf.PDFAMode; import org.apache.fop.pdf.PDFConformanceException; - -import static org.junit.Assert.fail; +import org.apache.fop.svg.SVGEventProducer; /** * Tests PDF/A-1 functionality. @@ -108,4 +113,17 @@ public class PDFAConformanceTestCase extends BasePDFTest { } } + @Test + public void svgTransparency() throws Exception { + Map<String, Object> params = new HashMap<String, Object>(); + params.put("pdfProfile", PDFAMode.PDFA_1B); + EventChecker eventChecker = new EventChecker(SVGEventProducer.class.getName() + + ".transparencyIgnored", params); + FOUserAgent ua = getUserAgent(); + ua.getEventBroadcaster().addEventListener(eventChecker); + File foFile = new File(foBaseDir, "svg-transparency.fo"); + convertFO(foFile, ua, dumpPDF); + eventChecker.end(); + } + } diff --git a/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java index 1606bf073..6ff40b3c3 100644 --- a/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java @@ -19,15 +19,14 @@ package org.apache.fop.render.pdf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - import java.util.Calendar; import java.util.TimeZone; -import org.apache.fop.pdf.PDFDocument; -import org.apache.fop.pdf.PDFInfo; -import org.apache.fop.pdf.PDFMetadata; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import org.apache.xmlgraphics.xmp.Metadata; import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter; import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema; @@ -35,7 +34,10 @@ import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter; import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema; import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFAdapter; import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFSchema; -import org.junit.Test; + +import org.apache.fop.pdf.PDFDocument; +import org.apache.fop.pdf.PDFInfo; +import org.apache.fop.pdf.PDFMetadata; /** * Test case for PDF/A metadata handling. diff --git a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java index fee2c07aa..bb0f2f92e 100644 --- a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java @@ -19,13 +19,14 @@ package org.apache.fop.render.pdf; -import static org.junit.Assert.assertEquals; - import java.io.StringWriter; -import org.apache.fop.pdf.CMapBuilder; import org.junit.Test; +import static org.junit.Assert.assertEquals; + +import org.apache.fop.pdf.CMapBuilder; + /** Simple sanity test of the PDFCmap class */ public class PDFCMapTestCase { private static final String EOL = "\n"; @@ -60,8 +61,7 @@ public class PDFCMapTestCase { + "end" + EOL + "end" + EOL + "%%EndResource" + EOL - + "%%EOF" + EOL - ; + + "%%EOF" + EOL; final StringWriter w = new StringWriter(); final CMapBuilder builder = new CMapBuilder(w, "test"); diff --git a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java index 34647818a..fc6212dcd 100644 --- a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java @@ -19,9 +19,6 @@ package org.apache.fop.render.pdf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.IOException; import java.util.StringTokenizer; @@ -30,6 +27,9 @@ import org.junit.Ignore; import org.junit.Test; import org.xml.sax.SAXException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.apache.fop.apps.FOUserAgent; /** Test that characters are correctly encoded in a generated PDF file */ diff --git a/test/java/org/apache/fop/render/pdf/PDFGraphicsPainterTestCase.java b/test/java/org/apache/fop/render/pdf/PDFGraphicsPainterTestCase.java index 4f3a5e628..3130a73e7 100644 --- a/test/java/org/apache/fop/render/pdf/PDFGraphicsPainterTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFGraphicsPainterTestCase.java @@ -24,12 +24,12 @@ import java.io.IOException; import org.junit.Before; import org.junit.Test; -import org.apache.fop.pdf.PDFNumber; - import static org.mockito.Matchers.endsWith; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import org.apache.fop.pdf.PDFNumber; + public class PDFGraphicsPainterTestCase { private PDFGraphicsPainter sut; diff --git a/test/java/org/apache/fop/render/pdf/PDFPainterTestCase.java b/test/java/org/apache/fop/render/pdf/PDFPainterTestCase.java index f431b3ee9..db1757847 100644 --- a/test/java/org/apache/fop/render/pdf/PDFPainterTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFPainterTestCase.java @@ -24,17 +24,17 @@ import java.awt.Rectangle; import org.junit.Test; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fo.Constants; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.traits.BorderProps; - import static org.mockito.Matchers.endsWith; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.fo.Constants; +import org.apache.fop.render.intermediate.IFContext; +import org.apache.fop.traits.BorderProps; + public class PDFPainterTestCase { @Test diff --git a/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java index 2d3dfb760..4dd3a6610 100644 --- a/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java @@ -21,6 +21,10 @@ package org.apache.fop.render.pdf; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.fop.apps.AbstractRendererConfigParserTester; import org.apache.fop.apps.PDFRendererConfBuilder; import org.apache.fop.pdf.PDFAMode; @@ -28,10 +32,6 @@ import org.apache.fop.pdf.PDFXMode; import org.apache.fop.pdf.Version; import org.apache.fop.render.pdf.PDFRendererConfig.PDFRendererConfigParser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class PDFRendererConfigParserTestCase extends AbstractRendererConfigParserTester<PDFRendererConfBuilder, PDFRendererConfig> { diff --git a/test/java/org/apache/fop/render/pdf/PDFRendererOptionsConfigTestCase.java b/test/java/org/apache/fop/render/pdf/PDFRendererOptionsConfigTestCase.java index 489d4dc96..699a8a186 100644 --- a/test/java/org/apache/fop/render/pdf/PDFRendererOptionsConfigTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFRendererOptionsConfigTestCase.java @@ -29,6 +29,8 @@ import java.util.Map; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.fop.pdf.PDFAMode; import org.apache.fop.pdf.PDFEncryptionParams; import org.apache.fop.pdf.PDFXMode; @@ -40,7 +42,6 @@ import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE; import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE; import static org.apache.fop.render.pdf.PDFRendererOption.PDF_X_MODE; import static org.apache.fop.render.pdf.PDFRendererOption.VERSION; -import static org.junit.Assert.assertEquals; public class PDFRendererOptionsConfigTestCase { @@ -51,7 +52,7 @@ public class PDFRendererOptionsConfigTestCase { static { final EnumMap<PDFRendererOption, Object> props = new EnumMap<PDFRendererOption, Object>(PDFRendererOption.class); - for(PDFRendererOption option : PDFRendererOption.values()) { + for (PDFRendererOption option : PDFRendererOption.values()) { props.put(option, option.getDefaultValue()); } DEFAULT_OPTIONS = Collections.unmodifiableMap(props); @@ -102,7 +103,7 @@ public class PDFRendererOptionsConfigTestCase { assertEncryptionParamsEquals(expectedEncryptionParams, actual.getEncryptionParameters()); } - private static void assertEncryptionParamsEquals(PDFEncryptionParams expected, + private static void assertEncryptionParamsEquals(PDFEncryptionParams expected, PDFEncryptionParams actual) { assertEquals(expected == null, actual == null); if (actual != null) { diff --git a/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java b/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java index d084aa618..965a8e30e 100644 --- a/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java @@ -19,14 +19,14 @@ package org.apache.fop.render.pdf; -import static org.junit.Assert.fail; - import java.io.File; import java.io.IOException; import org.junit.Test; import org.xml.sax.SAXException; +import static org.junit.Assert.fail; + import org.apache.fop.apps.FOUserAgent; /** diff --git a/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java b/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java index f41520bf3..e74251be1 100644 --- a/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java +++ b/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java @@ -28,8 +28,6 @@ import org.junit.runners.Suite.SuiteClasses; * A test suite for org.apache.fop.render.pdf.* */ @RunWith(Suite.class) -@SuiteClasses({ - PDFRendererConfigParserTestCase.class -}) +@SuiteClasses(PDFRendererConfigParserTestCase.class) public final class RenderPDFTestSuite { } diff --git a/test/java/org/apache/fop/render/ps/AbstractPostScriptTest.java b/test/java/org/apache/fop/render/ps/AbstractPostScriptTest.java index dcbc2d757..eb25c3f94 100644 --- a/test/java/org/apache/fop/render/ps/AbstractPostScriptTest.java +++ b/test/java/org/apache/fop/render/ps/AbstractPostScriptTest.java @@ -19,11 +19,11 @@ package org.apache.fop.render.ps; -import static org.junit.Assert.assertEquals; - import java.io.File; import java.io.IOException; +import static org.junit.Assert.assertEquals; + import org.apache.xmlgraphics.ps.PSResource; import org.apache.xmlgraphics.ps.dsc.DSCException; import org.apache.xmlgraphics.ps.dsc.DSCParser; diff --git a/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java b/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java index 458033dad..53654d76a 100644 --- a/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java +++ b/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java @@ -27,17 +27,16 @@ import java.io.IOException; import org.junit.Test; -import org.apache.xmlgraphics.image.loader.ImageSize; -import org.apache.xmlgraphics.image.loader.impl.ImageRawPNG; - -import org.apache.fop.render.RawPNGTestUtil; - import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; - import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import org.apache.xmlgraphics.image.loader.ImageSize; +import org.apache.xmlgraphics.image.loader.impl.ImageRawPNG; + +import org.apache.fop.render.RawPNGTestUtil; + public class ImageEncoderPNGTestCase { @Test diff --git a/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java b/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java index ba0598b52..02e96806f 100644 --- a/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java +++ b/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java @@ -18,15 +18,15 @@ /* $Id$ */ package org.apache.fop.render.ps; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.IOException; import java.io.InputStream; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.apache.commons.io.IOUtils; import org.apache.xmlgraphics.ps.DSCConstants; diff --git a/test/java/org/apache/fop/render/ps/PSPainterTestCase.java b/test/java/org/apache/fop/render/ps/PSPainterTestCase.java index 79e5bd9b6..b678fdb4b 100644 --- a/test/java/org/apache/fop/render/ps/PSPainterTestCase.java +++ b/test/java/org/apache/fop/render/ps/PSPainterTestCase.java @@ -146,11 +146,11 @@ public class PSPainterTestCase { int y = 100000; int letterSpacing = 0; int wordSpacing = 0; - int dp[][] = {{100, 100, 0, 0}, null, null, {200, 200, -100, -100}}; - double X = (x + dp[0][0]) / 1000.0; - double Y = (y - dp[0][1]) / 1000.0; - when(psGenerator.formatDouble(X)).thenReturn("100.100"); - when(psGenerator.formatDouble(Y)).thenReturn("99.900"); + int[][] dp = {{100, 100, 0, 0}, null, null, {200, 200, -100, -100}}; + double xAsDouble = (x + dp[0][0]) / 1000.0; + double yAsDouble = (y - dp[0][1]) / 1000.0; + when(psGenerator.formatDouble(xAsDouble)).thenReturn("100.100"); + when(psGenerator.formatDouble(yAsDouble)).thenReturn("99.900"); String text = "Hello Mock!"; try { psPainter.drawText(x, y, letterSpacing, wordSpacing, dp, text); diff --git a/test/java/org/apache/fop/render/ps/PSRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/ps/PSRendererConfigParserTestCase.java index fe59143b4..45642764c 100644 --- a/test/java/org/apache/fop/render/ps/PSRendererConfigParserTestCase.java +++ b/test/java/org/apache/fop/render/ps/PSRendererConfigParserTestCase.java @@ -21,14 +21,14 @@ package org.apache.fop.render.ps; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.fop.apps.AbstractRendererConfigParserTester; import org.apache.fop.apps.PSRendererConfBuilder; import org.apache.fop.render.ps.PSRendererConfig.PSRendererConfigParser; -import static org.junit.Assert.assertEquals; - public class PSRendererConfigParserTestCase extends AbstractRendererConfigParserTester<PSRendererConfBuilder, PSRendererConfig> { diff --git a/test/java/org/apache/fop/render/ps/PSRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/ps/PSRendererConfiguratorTestCase.java index 4d42a0aab..67ba24763 100644 --- a/test/java/org/apache/fop/render/ps/PSRendererConfiguratorTestCase.java +++ b/test/java/org/apache/fop/render/ps/PSRendererConfiguratorTestCase.java @@ -19,16 +19,16 @@ package org.apache.fop.render.ps; import org.junit.Test; -import org.apache.fop.apps.AbstractRendererConfiguratorTest; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.apps.PSRendererConfBuilder; -import org.apache.fop.render.ps.PSRendererConfig.PSRendererConfigParser; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; +import org.apache.fop.apps.AbstractRendererConfiguratorTest; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.apps.PSRendererConfBuilder; +import org.apache.fop.render.ps.PSRendererConfig.PSRendererConfigParser; + public class PSRendererConfiguratorTestCase extends AbstractRendererConfiguratorTest<PSRendererConfigurator, PSRendererConfBuilder> { private PSRenderingUtil psUtil; diff --git a/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java b/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java index 3f1088fe1..0a2c895be 100644 --- a/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java +++ b/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java @@ -23,13 +23,13 @@ import java.io.IOException; import org.junit.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.fop.render.ps.extensions.PSPageTrailerCodeBefore; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - public class PSRenderingUtilTestCase { private final String content = "<< /MyEntry 0 >> command"; diff --git a/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java b/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java index bfdb5f968..4f06938d2 100644 --- a/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java +++ b/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java @@ -19,11 +19,6 @@ package org.apache.fop.render.ps; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -33,6 +28,11 @@ import java.util.Set; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.apache.commons.io.IOUtils; import org.apache.xmlgraphics.ps.DSCConstants; diff --git a/test/java/org/apache/fop/render/ps/svg/PSSVGGraphics2DTestCase.java b/test/java/org/apache/fop/render/ps/svg/PSSVGGraphics2DTestCase.java index b48da4186..29a3a7bd3 100644 --- a/test/java/org/apache/fop/render/ps/svg/PSSVGGraphics2DTestCase.java +++ b/test/java/org/apache/fop/render/ps/svg/PSSVGGraphics2DTestCase.java @@ -29,6 +29,8 @@ import java.io.IOException; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.commons.io.FileUtils; import org.apache.batik.ext.awt.RadialGradientPaint; @@ -36,8 +38,6 @@ import org.apache.batik.ext.awt.RadialGradientPaint; import org.apache.xmlgraphics.java2d.GraphicContext; import org.apache.xmlgraphics.ps.PSGenerator; -import static org.junit.Assert.assertEquals; - public class PSSVGGraphics2DTestCase { float cx = 841.891f; diff --git a/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java b/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java index 283d3f4ad..3a6db4396 100644 --- a/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java +++ b/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java @@ -29,6 +29,8 @@ import java.io.IOException; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.commons.io.FileUtils; import org.apache.batik.ext.awt.LinearGradientPaint; @@ -36,13 +38,11 @@ import org.apache.batik.ext.awt.LinearGradientPaint; import org.apache.xmlgraphics.java2d.GraphicContext; import org.apache.xmlgraphics.ps.PSGenerator; -import static org.junit.Assert.assertEquals; - public class PSSVGLinearGraphics2DTestCase { float startX = 115f; float endX = 15f; float startY = 285f; - float endY=15f; + float endY = 15f; float[] fractions = {0.0f, 1.0f}; /** diff --git a/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java b/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java index c5821fff1..4c3c8446e 100644 --- a/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java +++ b/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java @@ -21,13 +21,14 @@ package org.apache.fop.render.rtf; import java.io.StringWriter; +import org.junit.Test; + import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; -import org.junit.Test; /** * Test for http://issues.apache.org/bugzilla/show_bug.cgi?id=39607 diff --git a/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java b/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java index d8296fc33..5b294bd9b 100644 --- a/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java +++ b/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java @@ -27,6 +27,6 @@ import org.junit.runners.Suite.SuiteClasses; * Test suite for FOP's RTF library. */ @RunWith(Suite.class) -@SuiteClasses({ Bug39607TestCase.class }) +@SuiteClasses(Bug39607TestCase.class) public class RichTextFormatTestSuite { } diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java index 07085059d..9df1c26ef 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java @@ -27,17 +27,15 @@ package org.apache.fop.render.rtf.rtflib.testdocs; +import java.io.IOException; + import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfHyperLink; - -import java.io.IOException; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; /** * Class <code>BasicLink</code> here. - * - * @author <a href="mailto:mks@ANDREAS">Andreas Putz</a> */ public class BasicLink extends TestDocument { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java index 16460cd1c..7f17514ef 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java @@ -29,11 +29,8 @@ package org.apache.fop.render.rtf.rtflib.testdocs; import java.io.File; import java.io.IOException; -//import org.apache.fop.render.rtf.rtflib.jfor.main.JForVersionInfo; /** Create test RTF documents from classes found in this package. - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch - * @author Andreas Putz a.putz@skynamics.com */ public class CreateTestDocuments { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java index 3329b26b9..1af4c7bed 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java @@ -33,8 +33,6 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableColumnsInfo; * to create documents without worrying about nested tables handling. * Might need to be replaced by more complete version in some sample * documents created by this package. - * - * @author bdelacretaz@codeconsult.ch */ class DummyTableColumnsInfo implements ITableColumnsInfo { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java index b957bc1fa..1127f3e72 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java @@ -27,16 +27,14 @@ package org.apache.fop.render.rtf.rtflib.testdocs; +import java.io.IOException; + import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; - -import java.io.IOException; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; /** * Generate a test document containing external graphics. - * - * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a> */ class ExternalGraphic extends TestDocument { private String file = "file:///tmp/jfor-images/logo."; diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java index 3ce05c606..6f4e27a59 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java @@ -30,13 +30,13 @@ package org.apache.fop.render.rtf.rtflib.testdocs; import java.io.IOException; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; /** Generates a simple RTF test document for the jfor rtflib package. */ diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java index f1817bf03..9be5e899a 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java @@ -32,11 +32,10 @@ import java.io.IOException; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; /** Generates an RTF test document containing merged table cells - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class MergedTableCells extends TestDocument { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java index 72dad7e98..c11fbc334 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java @@ -30,14 +30,13 @@ package org.apache.fop.render.rtf.rtflib.testdocs; import java.io.IOException; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; /** Generates an RTF document to test nested tables with the jfor rtflib package. - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class NestedTable extends TestDocument { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java index 2b38aa789..edce3264a 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java @@ -27,14 +27,13 @@ package org.apache.fop.render.rtf.rtflib.testdocs; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; /** Generates a simple RTF test document for the jfor rtflib package. - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ public class ParagraphAlignment extends TestDocument { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java index 2ca16c0e5..ca6ce79bc 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java @@ -30,11 +30,10 @@ package org.apache.fop.render.rtf.rtflib.testdocs; import java.io.IOException; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; /** Generates a simple RTF test document for the jfor rtflib package. - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class SimpleDocument diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java index eff3aa7ff..e817f6a13 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java @@ -30,15 +30,14 @@ package org.apache.fop.render.rtf.rtflib.testdocs; import java.io.IOException; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyleNumber; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; /** Generates a simple RTF test document for the jfor rtflib package. - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class SimpleLists extends TestDocument { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java index cf84b3ec4..10ddc11e7 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java @@ -32,11 +32,10 @@ import java.io.IOException; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; /** Generates a simple RTF test document for the jfor rtflib package. - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class SimpleTable extends TestDocument { /** generate the body of the test document */ diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java index 5274dc32e..266903766 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java @@ -27,19 +27,17 @@ package org.apache.fop.render.rtf.rtflib.testdocs; -import java.util.Date; import java.io.File; -import java.io.IOException; import java.io.FileWriter; +import java.io.IOException; +import java.util.Date; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; -//import org.apache.fop.render.rtf.rtflib.jfor.main.JForVersionInfo; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; /** Base class for generating RTF documents used to test the jfor rtflib package. - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ abstract class TestDocument { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java index 4ab48acb0..bb0614cee 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java @@ -29,14 +29,13 @@ package org.apache.fop.render.rtf.rtflib.testdocs; import java.io.IOException; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; /** Generates a simple RTF test document for the jfor rtflib package. - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class TextAttributes extends TestDocument { diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java index 4359822f6..a206e014f 100644 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java +++ b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java @@ -30,11 +30,10 @@ package org.apache.fop.render.rtf.rtflib.testdocs; import java.io.IOException; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; /** Generates an RTF document to test the WhitespaceCollapser - * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class Whitespace extends TestDocument { diff --git a/test/java/org/apache/fop/render/txt/TxtRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/txt/TxtRendererConfigParserTestCase.java index a7ae52c65..30fed05ea 100644 --- a/test/java/org/apache/fop/render/txt/TxtRendererConfigParserTestCase.java +++ b/test/java/org/apache/fop/render/txt/TxtRendererConfigParserTestCase.java @@ -21,13 +21,12 @@ package org.apache.fop.render.txt; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.fop.apps.AbstractRendererConfigParserTester; import org.apache.fop.apps.TxtRendererConfBuilder; -import org.apache.fop.render.RendererConfig.RendererConfigParser; -import org.apache.fop.render.txt.TxtRendererConfig.TxtRendererOption; import org.apache.fop.render.txt.TxtRendererConfig.TxtRendererConfigParser; - -import static org.junit.Assert.assertEquals; +import org.apache.fop.render.txt.TxtRendererConfig.TxtRendererOption; public class TxtRendererConfigParserTestCase extends AbstractRendererConfigParserTester<TxtRendererConfBuilder, TxtRendererConfig> { diff --git a/test/java/org/apache/fop/svg/NativeTextPainterTest.java b/test/java/org/apache/fop/svg/NativeTextPainterTest.java new file mode 100644 index 000000000..1c2c3b582 --- /dev/null +++ b/test/java/org/apache/fop/svg/NativeTextPainterTest.java @@ -0,0 +1,78 @@ +/* + * 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.svg; + +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.io.File; +import java.io.IOException; + +import org.w3c.dom.Document; + +import org.apache.batik.bridge.BridgeContext; +import org.apache.batik.bridge.GVTBuilder; +import org.apache.batik.dom.svg.SAXSVGDocumentFactory; +import org.apache.batik.gvt.GraphicsNode; +import org.apache.batik.gvt.TextPainter; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.FopFactory; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.base14.Base14FontCollection; +import org.apache.fop.svg.font.FOPFontFamilyResolverImpl; + +abstract class NativeTextPainterTest { + + protected final void runTest(String testcase, OperatorValidator validator) throws Exception { + FontInfo fontInfo = createFontInfo(); + BridgeContext bridgeContext = createBridgeContext(fontInfo); + GraphicsNode svg = loadSVG(bridgeContext, testcase); + Graphics2D g2d = createGraphics2D(fontInfo, validator); + svg.paint(g2d); + validator.end(); + } + + private FontInfo createFontInfo() { + FontInfo fontInfo = new FontInfo(); + new Base14FontCollection(true).setup(0, fontInfo); + return fontInfo; + } + + private BridgeContext createBridgeContext(FontInfo fontInfo) { + FOUserAgent userAgent = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); + SVGUserAgent svgUserAgent = new SVGUserAgent(userAgent, new FOPFontFamilyResolverImpl(fontInfo), + new AffineTransform()); + BridgeContext bridgeContext = new BridgeContext(svgUserAgent); + bridgeContext.setTextPainter(createTextPainter(fontInfo)); + return bridgeContext; + } + + protected abstract TextPainter createTextPainter(FontInfo fontInfo); + + private GraphicsNode loadSVG(BridgeContext bridgeContext, String resourceName) throws IOException { + SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(null); + Document svg = factory.createDocument(null, getClass().getResourceAsStream(resourceName)); + GVTBuilder builder = new GVTBuilder(); + return builder.build(bridgeContext, svg); + } + + protected abstract Graphics2D createGraphics2D(FontInfo fontInfo, OperatorValidator validator); + +} diff --git a/test/java/org/apache/fop/svg/OperatorValidator.java b/test/java/org/apache/fop/svg/OperatorValidator.java new file mode 100644 index 000000000..e94c8e404 --- /dev/null +++ b/test/java/org/apache/fop/svg/OperatorValidator.java @@ -0,0 +1,108 @@ +/* + * 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.svg; + +import java.util.LinkedList; +import java.util.Queue; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +class OperatorValidator { + + private interface Match { + + boolean match(String line); + } + + private static class MatchSequence implements OperatorValidator.Match { + + private final Queue<OperatorValidator.Match> expectedMatches = new LinkedList<OperatorValidator.Match>(); + + private OperatorValidator.Match currentMatch; + + private static final OperatorValidator.Match FINAL_MATCH = new Match() { + + public boolean match(String line) { + return false; + } + }; + + public boolean isExhausted() { + return currentMatch == FINAL_MATCH; + } + + public void addMatch(OperatorValidator.Match match) { + if (currentMatch == null) { + currentMatch = match; + } else { + expectedMatches.add(match); + } + } + + public boolean match(String line) { + boolean match = currentMatch.match(line); + if (match) { + if (expectedMatches.isEmpty()) { + currentMatch = FINAL_MATCH; + } else { + currentMatch = expectedMatches.remove(); + } + } + return match; + } + } + + private static class OperatorMatch implements OperatorValidator.Match { + + final String operator; + + final String line; + + OperatorMatch(String operator, String line) { + this.operator = operator; + this.line = line; + } + + public boolean match(String line) { + if (line.contains(operator)) { + assertEquals(this.line, line); + return true; + } + return false; + } + } + + private final OperatorValidator.MatchSequence matchSequence = new MatchSequence(); + + public OperatorValidator addOperatorMatch(String operator, String expectedLine) { + matchSequence.addMatch(new OperatorMatch(operator, expectedLine)); + return this; + } + + public void check(String line) { + matchSequence.match(line); + } + + public void end() { + assertTrue("Expected operators remain", matchSequence.isExhausted()); + } + +} diff --git a/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java b/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java new file mode 100644 index 000000000..e7e47e7ba --- /dev/null +++ b/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java @@ -0,0 +1,148 @@ +/* + * 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.svg; + +import java.awt.Graphics2D; +import java.io.StringWriter; + +import org.junit.Test; + +import org.apache.batik.gvt.TextPainter; + +import org.apache.xmlgraphics.java2d.GraphicContext; + +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.pdf.PDFDocument; + +public class PDFTextPainterTestCase extends NativeTextPainterTest { + + private static class OperatorCheckingPDFGraphics2D extends PDFGraphics2D { + + OperatorCheckingPDFGraphics2D(FontInfo fontInfo, final OperatorValidator validator) { + super(false, fontInfo, new PDFDocument("test"), null, null, null, 0, null); + this.currentStream = new StringWriter() { + + @Override + public void write(String str) { + validator.check(str); + } + + }; + } + } + + @Override + protected TextPainter createTextPainter(FontInfo fontInfo) { + return new PDFTextPainter(fontInfo); + } + + @Override + protected Graphics2D createGraphics2D(FontInfo fontInfo, OperatorValidator validator) { + PDFGraphics2D g2d = new OperatorCheckingPDFGraphics2D(fontInfo, validator); + g2d.setGraphicContext(new GraphicContext()); + return g2d; + } + + @Test + public void testRotatedGlyph() throws Exception { + runTest("rotated-glyph.svg", new OperatorValidator() + .addOperatorMatch("Tm", "1 0 0 -1 40 110 Tm ") + .addOperatorMatch("TJ", "[(A)] TJ\n") + .addOperatorMatch("Tm", "0.70710677 0.7071068 0.7071068 -0.70710677 106.69999695 110 Tm ") + .addOperatorMatch("TJ", "[(B)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 173.3999939 110 Tm ") + .addOperatorMatch("TJ", "[(C)] TJ\n")); + } + + @Test + public void testDxDy() throws Exception { + runTest("dx-dy.svg", new OperatorValidator() + .addOperatorMatch("Tm", "1 0 0 -1 55 35 Tm ") + .addOperatorMatch("TJ", "[(ABCDE)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 55 75 Tm ") + .addOperatorMatch("TJ", "[(A)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 69 85 Tm ") + .addOperatorMatch("TJ", "[(B)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 109 80 Tm ") + .addOperatorMatch("TJ", "[(C)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 91 65 Tm ") + .addOperatorMatch("TJ", "[(D)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 127 75 Tm ") + .addOperatorMatch("TJ", "[(E)] TJ\n")); + } + + @Test + public void testSpacing() throws Exception { + runTest("spacing.svg", new OperatorValidator() + .addOperatorMatch("Tm", "1 0 0 -1 0 0 Tm ") + .addOperatorMatch("TJ", "[(V) 80 (A) 70 (V)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 0 0 Tm ") + .addOperatorMatch("TJ", "[(V) 80 (A) 70 (V)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 0 0 Tm ") + .addOperatorMatch("TJ", "[(V) -20 (A) -30 (V)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 0 0 Tm ") + .addOperatorMatch("TJ", "[(ab) -111 ( ) -389 (cd)] TJ\n")); + } + + @Test + public void testGlyphOrientation() throws Exception { + runTest("glyph-orientation.svg", new OperatorValidator() + .addOperatorMatch("Tm", "0 1 1 0 738.5 0 Tm ") + .addOperatorMatch("TJ", "[(A)] TJ\n") + .addOperatorMatch("Tm", "0 1 1 0 738.5 667 Tm ") + .addOperatorMatch("TJ", "[(B)] TJ\n") + .addOperatorMatch("Tm", "0 1 1 0 738.5 1334 Tm ") + .addOperatorMatch("TJ", "[(C)] TJ\n") + .addOperatorMatch("Tm", "0 1 1 0 738.5 2056 Tm ") + .addOperatorMatch("TJ", "[(D)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 2149 718 Tm ") + .addOperatorMatch("TJ", "[(E)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 2165.5 1643 Tm ") + .addOperatorMatch("TJ", "[(F)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 2124 2568 Tm ") + .addOperatorMatch("TJ", "[(G)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 2138.5 3493 Tm ") + .addOperatorMatch("TJ", "[(H)] TJ\n") + .addOperatorMatch("Tm", "0 -1 -1 0 718 5000 Tm ") + .addOperatorMatch("TJ", "[(I)] TJ\n") + .addOperatorMatch("Tm", "0 -1 -1 0 1643 5000 Tm ") + .addOperatorMatch("TJ", "[(J)] TJ\n") + .addOperatorMatch("Tm", "0 -1 -1 0 2568 5000 Tm ") + .addOperatorMatch("TJ", "[(K)] TJ\n") + .addOperatorMatch("Tm", "0 -1 -1 0 3493 5000 Tm ") + .addOperatorMatch("TJ", "[(L)] TJ\n")); + } + + @Test + public void testBaselineShift() throws Exception { + runTest("baseline-shift.svg", new OperatorValidator() + .addOperatorMatch("Tm", "1 0 0 -1 0 0 Tm ") + .addOperatorMatch("TJ", "[(AB)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 1334 -462.5 Tm ") + .addOperatorMatch("TJ", "[(CD)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 2778 0 Tm ") + .addOperatorMatch("TJ", "[(EF)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 4056 462.5 Tm ") + .addOperatorMatch("TJ", "[(GH)] TJ\n") + .addOperatorMatch("Tm", "1 0 0 -1 5556 0 Tm ") + .addOperatorMatch("TJ", "[(IJ)] TJ\n")); + } + +} diff --git a/test/java/org/apache/fop/svg/PSTextPainterTestCase.java b/test/java/org/apache/fop/svg/PSTextPainterTestCase.java new file mode 100644 index 000000000..2d5de7455 --- /dev/null +++ b/test/java/org/apache/fop/svg/PSTextPainterTestCase.java @@ -0,0 +1,77 @@ +/* + * 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.svg; + +import java.awt.Graphics2D; +import java.io.IOException; + +import org.junit.Test; + +import org.apache.commons.io.output.NullOutputStream; + +import org.apache.batik.gvt.TextPainter; + +import org.apache.xmlgraphics.java2d.GraphicContext; +import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; +import org.apache.xmlgraphics.ps.PSGenerator; + +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.render.ps.PSTextPainter; + +public class PSTextPainterTestCase extends NativeTextPainterTest { + + private static class OperatorCheckingPSGraphics2D extends PSGraphics2D { + + OperatorCheckingPSGraphics2D(FontInfo fontInfo, final OperatorValidator validator) { + super(false, new PSGenerator(new NullOutputStream()) { + + @Override + public void writeln(String cmd) throws IOException { + validator.check(cmd); + } + + }); + } + } + + @Override + protected TextPainter createTextPainter(FontInfo fontInfo) { + return new PSTextPainter(fontInfo); + } + + @Override + protected Graphics2D createGraphics2D(FontInfo fontInfo, OperatorValidator validator) { + PSGraphics2D g2d = new OperatorCheckingPSGraphics2D(fontInfo, validator); + g2d.setGraphicContext(new GraphicContext()); + return g2d; + } + + @Test + public void testRotatedGlyph() throws Exception { + runTest("rotated-glyph.svg", new OperatorValidator() + .addOperatorMatch("Tm", "1 0 0 -1 40 110 Tm") + .addOperatorMatch("xshow", "(A)\n[0] xshow") + .addOperatorMatch("Tm", "0.70711 0.70711 0.70711 -0.70711 106.7 110 Tm") + .addOperatorMatch("xshow", "(B)\n[0] xshow") + .addOperatorMatch("Tm", "1 0 0 -1 173.39999 110 Tm") + .addOperatorMatch("xshow", "(C)\n[0] xshow")); + } + +} diff --git a/test/java/org/apache/fop/svg/baseline-shift.svg b/test/java/org/apache/fop/svg/baseline-shift.svg new file mode 100644 index 000000000..0f375b9af --- /dev/null +++ b/test/java/org/apache/fop/svg/baseline-shift.svg @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<svg width="150" height="60" xmlns="http://www.w3.org/2000/svg"> +<rect x="0" y="0" width="100%" height="100%" fill="none" stroke="black" stroke-width="2"/> +<g transform="translate(10, 40) scale(20) scale(0.001)"> +<text font-family="sans-serif" font-size="1000"> +AB<tspan baseline-shift="super">CD</tspan>EF<tspan baseline-shift="sub">GH</tspan>IJ +</text> +</g> +</svg> diff --git a/test/java/org/apache/fop/svg/dx-dy.svg b/test/java/org/apache/fop/svg/dx-dy.svg new file mode 100644 index 000000000..cfdc2de01 --- /dev/null +++ b/test/java/org/apache/fop/svg/dx-dy.svg @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<svg width="200" height="100" xmlns="http://www.w3.org/2000/svg"> +<rect x="0" y="0" width="100%" height="100%" stroke="black" stroke-width="2" fill="none"/> +<g font-family="monospace" font-size="30"> + <text x="55" y="35">ABCDE</text> + <text x="55" y="75" dx="0 -4 22 -36 18" dy="0 10 -5 -15 10">ABCDE</text> +</g> +</svg> diff --git a/test/java/org/apache/fop/svg/font/BasicGlyphVectorTestCase.java b/test/java/org/apache/fop/svg/font/BasicGlyphVectorTestCase.java new file mode 100644 index 000000000..c6f062a84 --- /dev/null +++ b/test/java/org/apache/fop/svg/font/BasicGlyphVectorTestCase.java @@ -0,0 +1,193 @@ +/* + * 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.svg.font; + +import java.awt.Rectangle; +import java.awt.font.GlyphMetrics; +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.text.CharacterIterator; +import java.text.StringCharacterIterator; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.batik.gvt.font.GVTGlyphMetrics; +import org.apache.batik.gvt.font.GVTLineMetrics; + +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontMetrics; + +/** + * Tests all the methods of {@link FOPGVTGlyphVector} with a mocked font. + */ +public class BasicGlyphVectorTestCase extends FOPGVTGlyphVectorTest { + + private final int fontSize = 10000; + + @Before + public void createGlyphVector() { + FontMetrics metrics = mockFontMetrics(); + Font font = mockFont(metrics); + FOPGVTFont gvtFont = mockGVTFont(font); + CharacterIterator it = new StringCharacterIterator("ABC"); + glyphVector = new FOPGVTGlyphVector(gvtFont, it, null); + glyphVector.performDefaultLayout(); + } + + private FontMetrics mockFontMetrics() { + FontMetrics metrics = mock(FontMetrics.class); + when(metrics.getAscender(eq(fontSize))).thenReturn(8000000); + when(metrics.getDescender(eq(fontSize))).thenReturn(-4000000); + when(metrics.getWidth(eq(1), eq(fontSize))).thenReturn(10000000); + when(metrics.getBoundingBox(eq(1), eq(fontSize))).thenReturn( + new Rectangle(-1000000, -2000000, 3000000, 4000000)); + when(metrics.getWidth(eq(2), eq(fontSize))).thenReturn(11000000); + when(metrics.getBoundingBox(eq(2), eq(fontSize))).thenReturn( + new Rectangle(-5000000, -6000000, 7000000, 9000000)); + when(metrics.getWidth(eq(3), eq(fontSize))).thenReturn(12000000); + when(metrics.getBoundingBox(eq(3), eq(fontSize))).thenReturn( + new Rectangle(-9000000, -10000000, 11000000, 14000000)); + return metrics; + } + + private Font mockFont(FontMetrics metrics) { + Font font = mock(Font.class); + when(font.getFontMetrics()).thenReturn(metrics); + when(font.getFontSize()).thenReturn(fontSize); + when(font.mapChar(eq('A'))).thenReturn((char) 1); + when(font.mapChar(eq('B'))).thenReturn((char) 2); + when(font.mapChar(eq('C'))).thenReturn((char) 3); + return font; + } + + private FOPGVTFont mockGVTFont(Font font) { + FOPGVTFont gvtFont = mock(FOPGVTFont.class); + when(gvtFont.getFont()).thenReturn(font); + when(gvtFont.getLineMetrics(anyInt())).thenReturn( + new GVTLineMetrics(8, 0, null, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0)); + return gvtFont; + } + + @Test + public void getGlyphCodeReturnsGlyphIndex() { + assertEquals(1, glyphVector.getGlyphCode(0)); + assertEquals(2, glyphVector.getGlyphCode(1)); + assertEquals(3, glyphVector.getGlyphCode(2)); + } + + @Test + public void testGetGlyphCodes() { + assertArrayEquals(new int[] {1, 2, 3}, glyphVector.getGlyphCodes(0, 3, null)); + assertArrayEquals(new int[] {2, 3}, glyphVector.getGlyphCodes(1, 2, null)); + } + + @Test + public void testGetGlyphMetrics() { + assertGlyphMetricsEqual(new GVTGlyphMetrics(10, 12, new Rectangle(-1, -2, 3, 4), GlyphMetrics.STANDARD), + glyphVector.getGlyphMetrics(0)); + assertGlyphMetricsEqual(new GVTGlyphMetrics(11, 12, new Rectangle(-5, -3, 7, 9), GlyphMetrics.STANDARD), + glyphVector.getGlyphMetrics(1)); + assertGlyphMetricsEqual(new GVTGlyphMetrics(12, 12, new Rectangle(-9, -4, 11, 14), GlyphMetrics.STANDARD), + glyphVector.getGlyphMetrics(2)); + } + + private void assertGlyphMetricsEqual(GVTGlyphMetrics expected, GVTGlyphMetrics actual) { + assertEquals(expected.getHorizontalAdvance(), actual.getHorizontalAdvance(), 0); + assertEquals(expected.getVerticalAdvance(), actual.getVerticalAdvance(), 0); + assertEquals(expected.getBounds2D(), actual.getBounds2D()); + assertEquals(expected.getLSB(), actual.getLSB(), 0); + assertEquals(expected.getRSB(), actual.getRSB(), 0); + assertEquals(expected.getType(), actual.getType()); + assertEquals(expected.isCombining(), actual.isCombining()); + assertEquals(expected.isComponent(), actual.isComponent()); + assertEquals(expected.isLigature(), actual.isLigature()); + assertEquals(expected.isStandard(), actual.isStandard()); + assertEquals(expected.isWhitespace(), actual.isWhitespace()); + } + + @Test + public void testGetGlyphPosition() { + assertEquals(new Point2D.Float(0, 0), glyphVector.getGlyphPosition(0)); + assertEquals(new Point2D.Float(10, 0), glyphVector.getGlyphPosition(1)); + assertEquals(new Point2D.Float(21, 0), glyphVector.getGlyphPosition(2)); + assertEquals(new Point2D.Float(33, 0), glyphVector.getGlyphPosition(3)); + } + + @Test + public void testGetGlyphPositions() { + float[] expectedPositions = new float[] {0, 0, 10, 0, 21, 0, 33, 0}; + assertArrayEquals(expectedPositions, glyphVector.getGlyphPositions(0, 4, null), 0); + assertArrayEquals(expectedPositions, glyphVector.getGlyphPositions(0, 4, new float[8]), 0); + } + + @Test + public void testGetGlyphOutline() { + assertEquals(new Rectangle(-1, -2, 3, 4), glyphVector.getGlyphOutline(0).getBounds()); + assertEquals(new Rectangle(5, -3, 7, 9), glyphVector.getGlyphOutline(1).getBounds()); + assertEquals(new Rectangle(12, -4, 11, 14), glyphVector.getGlyphOutline(2).getBounds()); + } + + @Test + public void testGetOutline() { + assertEquals(new Rectangle(-1, -4, 24, 14), glyphVector.getOutline().getBounds()); + } + + @Test + public void testGetLogicalBounds() { + assertEquals(new Rectangle(0, -8, 33, 12), glyphVector.getLogicalBounds()); + } + + @Test + public void testGetLogicalBoundsRotated() { + for (int i = 0; i < 3; i++) { + glyphVector.setGlyphTransform(i, new AffineTransform(0.7, 0.7, -0.7, 0.7, 0, 0)); + } + assertEquals(new Rectangle2D.Float(-2.8f, -5.6f, 37.8f, 16.8f), glyphVector.getLogicalBounds()); + } + + @Test + public void testGetBounds() { + assertEquals(new Rectangle(-1, -4, 24, 14), glyphVector.getBounds2D(null)); + } + + @Test + public void testGetGlyphVisualBounds() { + assertEquals(new Rectangle(-1, -2, 3, 4), glyphVector.getGlyphVisualBounds(0).getBounds()); + assertEquals(new Rectangle(5, -3, 7, 9), glyphVector.getGlyphVisualBounds(1).getBounds()); + assertEquals(new Rectangle(12, -4, 11, 14), glyphVector.getGlyphVisualBounds(2).getBounds()); + } + + @Test + public void testGetGlyphLogicalBounds() { + assertEquals(new Rectangle(0, -8, 10, 12), glyphVector.getGlyphLogicalBounds(0).getBounds()); + assertEquals(new Rectangle(10, -8, 11, 12), glyphVector.getGlyphLogicalBounds(1).getBounds()); + assertEquals(new Rectangle(21, -8, 12, 12), glyphVector.getGlyphLogicalBounds(2).getBounds()); + } + +} diff --git a/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java b/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java new file mode 100644 index 000000000..d14752b90 --- /dev/null +++ b/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java @@ -0,0 +1,127 @@ +/* + * 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.svg.font; + +import java.awt.FontFormatException; +import java.awt.GraphicsEnvironment; +import java.awt.font.FontRenderContext; +import java.awt.font.LineMetrics; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.Collections; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.apache.batik.gvt.font.GVTFontFamily; +import org.apache.batik.gvt.font.GVTLineMetrics; + +import org.apache.fop.fonts.FontInfo; + +public class FOPFontFamilyResolverTestCase { + + private static FontInfo fontInfo; + + private FOPFontFamilyResolver resolver; + + @BeforeClass + public static void setUpFontInfo() { + fontInfo = new FontInfoBuilder() + .useDejaVuLGCSerif() + .useDroidSansMono() + .build(); + } + + @Before + public void createFontFamilyResolver() { + resolver = new FOPFontFamilyResolverImpl(fontInfo); + } + + @Test + public void testResolve() { + assertNull(resolver.resolve("Unavailable")); + assertNotNull(resolver.resolve(FontInfoBuilder.DEJAVU_LGC_SERIF)); + } + + @Test + public void testGetFamilyThatCanDisplay() { + GVTFontFamily family = resolver.getFamilyThatCanDisplay('\u0180'); + assertEquals(FontInfoBuilder.DEJAVU_LGC_SERIF, family.getFamilyName()); + family = resolver.getFamilyThatCanDisplay('\u02F3'); + assertEquals(FontInfoBuilder.DROID_SANS_MONO, family.getFamilyName()); + family = resolver.getFamilyThatCanDisplay('\u02DF'); + assertNull(family); + } + + @Test + public void testDeriveFont() { + FOPGVTFontFamily family = resolver.resolve(FontInfoBuilder.DEJAVU_LGC_SERIF); + FOPGVTFont font = family.deriveFont(10, Collections.emptyMap()); + assertEquals(10, font.getSize(), 0); + assertTrue(font.canDisplay('\u01F6')); + assertFalse(font.canDisplay('\u01F7')); + } + + @Test + @Ignore("FOP metrics don't match AWT, but not sure who is right and who is wrong") + public void testLineMetrics() throws FontFormatException, IOException { + FOPGVTFontFamily family = resolver.resolve(FontInfoBuilder.DEJAVU_LGC_SERIF); + FOPGVTFont font = family.deriveFont(10, Collections.emptyMap()); + GVTLineMetrics fopMetrics = font.getLineMetrics("", null); + LineMetrics awtMetrics = getAWTLineMetrics(); + printDifference("Ascent", awtMetrics.getAscent(), fopMetrics.getAscent()); + printDifference("Descent", awtMetrics.getDescent(), fopMetrics.getDescent()); + printDifference("Height", awtMetrics.getHeight(), fopMetrics.getHeight()); + printDifference("Leading", awtMetrics.getLeading(), fopMetrics.getLeading()); + printDifference("StrikethroughOffset", awtMetrics.getStrikethroughOffset(), + fopMetrics.getStrikethroughOffset()); + printDifference("StrikethroughThickness", awtMetrics.getStrikethroughThickness(), + fopMetrics.getStrikethroughThickness()); + printDifference("UnderlineOffset", awtMetrics.getUnderlineOffset(), + fopMetrics.getUnderlineOffset()); + printDifference("UnderlineThickness", awtMetrics.getUnderlineThickness(), + fopMetrics.getUnderlineThickness()); + } + + private LineMetrics getAWTLineMetrics() throws FontFormatException, IOException { + File fontFile = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf"); + java.awt.Font awtFont = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, fontFile).deriveFont(10f); + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + BufferedImage dummyImage = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_RGB); + FontRenderContext frc = ge.createGraphics(dummyImage).getFontRenderContext(); + LineMetrics awtMetrics = awtFont.getLineMetrics("ABC", frc); + return awtMetrics; + } + + private void printDifference(String value, float awt, float fop) { + System.out.println(String.format("%22s AWT: %10f FOP: %10f Difference: %.2f%%", value, awt, fop, + (fop - awt) / awt * 100)); + } + +} diff --git a/test/java/org/apache/fop/svg/font/FOPGVTFontTestCase.java b/test/java/org/apache/fop/svg/font/FOPGVTFontTestCase.java new file mode 100644 index 000000000..b27dac5b2 --- /dev/null +++ b/test/java/org/apache/fop/svg/font/FOPGVTFontTestCase.java @@ -0,0 +1,71 @@ +/* + * 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.svg.font; + +import java.text.StringCharacterIterator; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.fop.fonts.Font; + +public class FOPGVTFontTestCase { + + private FOPGVTFont font; + + @Before + public void createFont() { + Font f = mock(Font.class); + when(f.hasChar(eq((char) 0))).thenReturn(false); + when(f.hasChar(eq((char) 1))).thenReturn(true); + font = new FOPGVTFont(f, null); + } + + @Test + public void testCanDisplayUpTo() { + char[] text = new char[] {1, 1, 1}; + testCanDisplayUpToVariants(text, -1, 0, 3); + testCanDisplayUpToVariants(text, -1, 1, 3); + text = new char[] {1, 1, 0, 1}; + testCanDisplayUpToVariants(text, 2, 0, 4); + testCanDisplayUpToVariants(text, 2, 1, 4); + testCanDisplayUpToVariants(text, 2, 2, 4); + testCanDisplayUpToVariants(text, -1, 3, 4); + testCanDisplayUpToVariants(text, -1, 1, 2); + } + + @Test + public void testCanDisplayUpToString() { + assertEquals(-1, font.canDisplayUpTo(new String(new char[] {1, 1, 1}))); + assertEquals(0, font.canDisplayUpTo(new String(new char[] {0, 1, 1}))); + assertEquals(1, font.canDisplayUpTo(new String(new char[] {1, 0, 1}))); + assertEquals(2, font.canDisplayUpTo(new String(new char[] {1, 1, 0}))); + } + + private void testCanDisplayUpToVariants(char[] text, int expected, int start, int limit) { + assertEquals(expected, font.canDisplayUpTo(text, start, limit)); + assertEquals(expected, font.canDisplayUpTo(new StringCharacterIterator(new String(text)), start, limit)); + } +} diff --git a/test/java/org/apache/fop/svg/font/FOPGVTGlyphVectorTest.java b/test/java/org/apache/fop/svg/font/FOPGVTGlyphVectorTest.java new file mode 100644 index 000000000..0995ab4df --- /dev/null +++ b/test/java/org/apache/fop/svg/font/FOPGVTGlyphVectorTest.java @@ -0,0 +1,27 @@ +/* + * 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.svg.font; + + +public abstract class FOPGVTGlyphVectorTest { + + protected FOPGVTGlyphVector glyphVector; + +} diff --git a/test/java/org/apache/fop/svg/font/FontInfoBuilder.java b/test/java/org/apache/fop/svg/font/FontInfoBuilder.java new file mode 100644 index 000000000..c9346588c --- /dev/null +++ b/test/java/org/apache/fop/svg/font/FontInfoBuilder.java @@ -0,0 +1,102 @@ +/* + * 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.svg.font; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.fop.apps.io.InternalResourceResolver; +import org.apache.fop.apps.io.ResourceResolverFactory; +import org.apache.fop.fonts.EmbeddingMode; +import org.apache.fop.fonts.EncodingMode; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontMetrics; +import org.apache.fop.fonts.truetype.OFFontLoader; + +class FontInfoBuilder { + + public static final String DEJAVU_LGC_SERIF = "DejaVu LGC Serif"; + + public static final String DROID_SANS_MONO = "Droid Sans Mono"; + + private static final boolean USE_ADVANCED_BY_DEFAULT = true; + + private FontInfo fontInfo; + + private int fontKey; + + public FontInfoBuilder() { + reset(); + } + + private void reset() { + fontInfo = new FontInfo(); + fontKey = 1; + } + + public FontInfoBuilder useDejaVuLGCSerif() { + return useDejaVuLGCSerif(USE_ADVANCED_BY_DEFAULT); + } + + public FontInfoBuilder useDejaVuLGCSerif(boolean useAdvanced) { + try { + return useFont(DEJAVU_LGC_SERIF, "DejaVuLGCSerif.ttf", useAdvanced); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public FontInfoBuilder useDroidSansMono() { + return useDroidSansMono(USE_ADVANCED_BY_DEFAULT); + } + + public FontInfoBuilder useDroidSansMono(boolean useAdvanced) { + try { + return useFont(DROID_SANS_MONO, "DroidSansMono.ttf", useAdvanced); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private FontInfoBuilder useFont(String fontName, String filename, boolean useAdvanced) + throws IOException, URISyntaxException { + URI baseURI = new File("test/resources/fonts/ttf").toURI(); + InternalResourceResolver resolver = ResourceResolverFactory.createDefaultInternalResourceResolver(baseURI); + OFFontLoader fontLoader = new OFFontLoader(new URI(filename), null, true, + EmbeddingMode.AUTO, EncodingMode.AUTO, true, useAdvanced, resolver); + FontMetrics font = fontLoader.getFont(); + registerFont(font, "F" + fontKey++, fontName); + return this; + } + + private void registerFont(FontMetrics font, String key, String familyName) { + fontInfo.addMetrics(key, font); + fontInfo.addFontProperties(key, familyName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL); + } + + public FontInfo build() { + FontInfo fontInfo = this.fontInfo; + reset(); + return fontInfo; + } +} diff --git a/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java b/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java new file mode 100644 index 000000000..5c1fb2c86 --- /dev/null +++ b/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java @@ -0,0 +1,91 @@ +/* + * 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.svg.font; + +import java.util.Collections; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import org.apache.fop.fonts.FontInfo; + +/** + * Specifically tests glyph positioning from a real font. + */ +public class GlyphLayoutTestCase extends FOPGVTGlyphVectorTest { + + /** + * Glyph positioning using the legacy kern table. + */ + @Test + public void testBasicGlyphPositioning() throws Exception { + testGlyphLayout(false); + } + + /** + * Glyph positioning using GPOS sub-tables. + */ + @Test + public void testAdvancedGlyphPositioning() throws Exception { + testGlyphLayout(true); + } + + private void testGlyphLayout(boolean useAdvanced) { + FOPGVTFont font = loadFont(useAdvanced); + glyphVector = (FOPGVTGlyphVector) font.createGlyphVector(null, "L\u201DP,V.F,A\u2019LT."); + glyphVector.performDefaultLayout(); + // Values in font units (unitsPerEm = 2048), glyph width - kern + int[] widths = { + /* L */ 1360 - 491, + /* " */ 1047, + /* P */ 1378 - 415, + /* , */ 651, + /* V */ 1479 - 358, + /* . */ 651, + /* F */ 1421 - 319, + /* , */ 651, + /* A */ 1479 - 301, + /* ' */ 651, + /* L */ 1360 - 167, + /* T */ 1366 - 301, + /* . */ 651}; + checkGlyphPositions(13, widths); + } + + private FOPGVTFont loadFont(boolean useAdvanced) { + FontInfo fontInfo = new FontInfoBuilder().useDejaVuLGCSerif(useAdvanced).build(); + FOPFontFamilyResolver resolver = new FOPFontFamilyResolverImpl(fontInfo); + FOPGVTFontFamily family = resolver.resolve(FontInfoBuilder.DEJAVU_LGC_SERIF); + return family.deriveFont(1000, Collections.emptyMap()); + } + + private void checkGlyphPositions(int expectedGlyphCount, int[] widths) { + assertEquals(expectedGlyphCount, glyphVector.getNumGlyphs()); + float[] positions = new float[2 * (widths.length + 1)]; + for (int i = 0, n = 2; i < widths.length; i++, n += 2) { + positions[n] = positions[n - 2] + widths[i] / 2.048f; + } + for (int i = 0; i <= widths.length; i++) { + assertEquals(positions[2 * i], glyphVector.getGlyphPosition(i).getX(), 3); + } + } + +} diff --git a/test/java/org/apache/fop/svg/glyph-orientation.svg b/test/java/org/apache/fop/svg/glyph-orientation.svg new file mode 100644 index 000000000..4900a3b02 --- /dev/null +++ b/test/java/org/apache/fop/svg/glyph-orientation.svg @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<svg width="100" height="140" xmlns="http://www.w3.org/2000/svg"> +<rect x="0" y="0" width="100%" height="100%" fill="none" stroke="black" stroke-width="2"/> +<g transform="translate(10) scale(20) scale(0.001) translate(0, 1000)" + font-family="sans-serif" font-size="1000"> + <text x="1000" writing-mode="tb">ABCD</text> + <text x="2500" writing-mode="tb" glyph-orientation-vertical="0">EFGH</text> + <text x="0" y="5000" glyph-orientation-horizontal="270">IJKL</text> +</g> +</svg> diff --git a/test/java/org/apache/fop/svg/rotated-glyph.svg b/test/java/org/apache/fop/svg/rotated-glyph.svg new file mode 100644 index 000000000..8b942905e --- /dev/null +++ b/test/java/org/apache/fop/svg/rotated-glyph.svg @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<svg width="300" height="150" xmlns="http://www.w3.org/2000/svg"> +<rect x="0" y="0" width="100%" height="100%" fill="none" stroke="black" stroke-width="2"/> +<text font-family="Helvetica" font-size="100" x="40" y="110" rotate="0 45 0">ABC</text> +</svg> diff --git a/test/java/org/apache/fop/svg/spacing.svg b/test/java/org/apache/fop/svg/spacing.svg new file mode 100644 index 000000000..943ab1d04 --- /dev/null +++ b/test/java/org/apache/fop/svg/spacing.svg @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<svg width="150" height="200" xmlns="http://www.w3.org/2000/svg"> +<rect x="0" y="0" width="100%" height="100%" stroke="black" stroke-width="2" fill="none"/> +<g transform="translate(10) scale(40) scale(0.001) translate(0, 1000)" + font-family="sans-serif" font-size="1000"> + <g transform=""> + <text>VAV</text> + <line x1="667" y1="-818" x2="667" y2="100" stroke-width="10" stroke="blue"/> + </g> + <g transform="translate(0, 1000)"> + <text kerning="0">VAV</text> + <line x1="667" y1="-818" x2="667" y2="100" stroke-width="10" stroke="blue"/> + </g> + <g transform="translate(0, 2000)"> + <text letter-spacing="100">VAV</text> + </g> + <g transform="translate(0, 3000)"> + <text word-spacing="500">ab cd</text> + </g> +</g> +</svg> diff --git a/test/java/org/apache/fop/text/linebreak/LineBreakStatusTestCase.java b/test/java/org/apache/fop/text/linebreak/LineBreakStatusTestCase.java index 42ca8dee6..d8813c3bc 100644 --- a/test/java/org/apache/fop/text/linebreak/LineBreakStatusTestCase.java +++ b/test/java/org/apache/fop/text/linebreak/LineBreakStatusTestCase.java @@ -19,10 +19,10 @@ package org.apache.fop.text.linebreak; -import static org.junit.Assert.assertTrue; - import org.junit.Test; +import static org.junit.Assert.assertTrue; + /** * JUnit test case for the LineBreakStatus class diff --git a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTestCase.java b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTestCase.java index 015c1846f..5fc5c7d50 100644 --- a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTestCase.java +++ b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTestCase.java @@ -19,10 +19,10 @@ package org.apache.fop.text.linebreak; -import static org.junit.Assert.assertEquals; - import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * TODO add javadoc * diff --git a/test/java/org/apache/fop/threading/FOProcessorImpl.java b/test/java/org/apache/fop/threading/FOProcessorImpl.java index 04fed19ba..721830aee 100644 --- a/test/java/org/apache/fop/threading/FOProcessorImpl.java +++ b/test/java/org/apache/fop/threading/FOProcessorImpl.java @@ -81,8 +81,8 @@ public class FOProcessorImpl extends AbstractLogEnabled } } - /** {@inheritDoc} - * @throws URISyntaxException + /** {@inheritDoc} + * @throws URISyntaxException * @throws SAXException */ public void process(Source src, Templates templates, OutputStream out) throws java.io.IOException, URISyntaxException, SAXException { diff --git a/test/java/org/apache/fop/threading/Main.java b/test/java/org/apache/fop/threading/Main.java index 7ff0cec4f..d18ae405a 100644 --- a/test/java/org/apache/fop/threading/Main.java +++ b/test/java/org/apache/fop/threading/Main.java @@ -32,7 +32,10 @@ import org.apache.avalon.framework.logger.ConsoleLogger; /** * Starter class for the multi-threading testbed. */ -public class Main { +public final class Main { + + private Main() { + } private static void prompt() throws IOException { BufferedReader in = new BufferedReader(new java.io.InputStreamReader(System.in)); diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java index ec93d708e..692e3059f 100644 --- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java +++ b/test/java/org/apache/fop/traits/BorderPropsTestCase.java @@ -23,14 +23,14 @@ import java.awt.Color; import org.junit.Test; +import static org.junit.Assert.assertEquals; + import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives; import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; import org.apache.fop.fo.Constants; import org.apache.fop.util.ColorUtil; -import static org.junit.Assert.assertEquals; - /** * Tests the BorderProps class. */ @@ -67,7 +67,7 @@ public class BorderPropsTestCase { Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f); //Normalize: Avoid false alarms due to color conversion (rounding) col = ColorUtil.parseColorString(null, ColorUtil.colorToString(col)); - for(BorderProps.Mode mode : BorderProps.Mode.values()) { + for (BorderProps.Mode mode : BorderProps.Mode.values()) { BorderProps sut = BorderProps.makeRectangular(Constants.EN_SOLID, 10, col, mode); testSerialization(sut); sut = new BorderProps(Constants.EN_SOLID, 10, 4, 3, col, mode); diff --git a/test/java/org/apache/fop/traits/MinOptMaxTestCase.java b/test/java/org/apache/fop/traits/MinOptMaxTestCase.java index 73465fdcc..ba6862785 100644 --- a/test/java/org/apache/fop/traits/MinOptMaxTestCase.java +++ b/test/java/org/apache/fop/traits/MinOptMaxTestCase.java @@ -19,13 +19,13 @@ package org.apache.fop.traits; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import org.junit.Test; - /** * Tests the {@link MinOptMax} class. */ diff --git a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java index c4b9446ac..5e75f2563 100644 --- a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java +++ b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java @@ -19,15 +19,16 @@ package org.apache.fop.util; -import static org.junit.Assert.assertEquals; - import java.util.Map; -import org.apache.fop.events.model.EventSeverity; -import org.apache.fop.util.text.AdvancedMessageFormat; import org.junit.Test; import org.xml.sax.helpers.LocatorImpl; +import static org.junit.Assert.assertEquals; + +import org.apache.fop.events.model.EventSeverity; +import org.apache.fop.util.text.AdvancedMessageFormat; + /** * Tests for EventFormatter. */ diff --git a/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java b/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java index 3afcc3a2e..8bda99785 100644 --- a/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java +++ b/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java @@ -19,8 +19,6 @@ package org.apache.fop.util; -import static org.junit.Assert.assertEquals; - import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; @@ -31,13 +29,18 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + import org.apache.commons.io.IOUtils; -import org.apache.fop.util.bitmap.BitmapImageUtil; -import org.apache.fop.util.bitmap.MonochromeBitmapConverter; + import org.apache.xmlgraphics.image.writer.ImageWriterUtil; import org.apache.xmlgraphics.util.WriterOutputStream; import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream; -import org.junit.Test; + +import org.apache.fop.util.bitmap.BitmapImageUtil; +import org.apache.fop.util.bitmap.MonochromeBitmapConverter; /** * Tests {@link BitmapImageUtil}. diff --git a/test/java/org/apache/fop/util/ColorUtilTestCase.java b/test/java/org/apache/fop/util/ColorUtilTestCase.java index 6e65004a3..c86ebbeac 100644 --- a/test/java/org/apache/fop/util/ColorUtilTestCase.java +++ b/test/java/org/apache/fop/util/ColorUtilTestCase.java @@ -26,6 +26,11 @@ import java.net.URI; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.apache.xmlgraphics.java2d.color.ColorSpaces; import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives; import org.apache.xmlgraphics.java2d.color.NamedColorSpace; @@ -34,11 +39,6 @@ import org.apache.xmlgraphics.java2d.color.RenderingIntent; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - /** * Tests the ColorUtil class. */ diff --git a/test/java/org/apache/fop/util/DigestFilter.java b/test/java/org/apache/fop/util/DigestFilter.java index 94e8d67d2..9e62fdc1c 100644 --- a/test/java/org/apache/fop/util/DigestFilter.java +++ b/test/java/org/apache/fop/util/DigestFilter.java @@ -95,9 +95,6 @@ public class DigestFilter extends XMLFilterImpl { super.endDocument(); } - /* (non-Javadoc) - * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) - */ public void startElement( String url, String localName, diff --git a/test/java/org/apache/fop/util/ElementListUtilsTestCase.java b/test/java/org/apache/fop/util/ElementListUtilsTestCase.java index 342488a93..5e4f38b0b 100644 --- a/test/java/org/apache/fop/util/ElementListUtilsTestCase.java +++ b/test/java/org/apache/fop/util/ElementListUtilsTestCase.java @@ -19,17 +19,18 @@ package org.apache.fop.util; +import java.util.LinkedList; + +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import java.util.LinkedList; - import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthGlue; import org.apache.fop.layoutmgr.KnuthPenalty; -import org.junit.Test; /** * Test class for ElementListUtils. diff --git a/test/java/org/apache/fop/util/LanguageTagsTestCase.java b/test/java/org/apache/fop/util/LanguageTagsTestCase.java index f7383c720..91861dcc6 100644 --- a/test/java/org/apache/fop/util/LanguageTagsTestCase.java +++ b/test/java/org/apache/fop/util/LanguageTagsTestCase.java @@ -19,12 +19,12 @@ package org.apache.fop.util; -import static org.junit.Assert.assertEquals; - import java.util.Locale; import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * Tests {@link LanguageTags}. */ diff --git a/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java b/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java index 26cfa4406..60aa16d83 100644 --- a/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java +++ b/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java @@ -19,15 +19,15 @@ package org.apache.fop.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + /** * Tests for XMLResourceBundle. */ diff --git a/test/java/org/apache/fop/visual/BitmapComparator.java b/test/java/org/apache/fop/visual/BitmapComparator.java index e0c1d5bd4..f2157176b 100644 --- a/test/java/org/apache/fop/visual/BitmapComparator.java +++ b/test/java/org/apache/fop/visual/BitmapComparator.java @@ -30,11 +30,12 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import org.apache.commons.io.IOUtils; + import org.apache.batik.ext.awt.image.GraphicsUtil; import org.apache.batik.ext.awt.image.renderable.Filter; import org.apache.batik.ext.awt.image.spi.ImageTagRegistry; import org.apache.batik.util.ParsedURL; -import org.apache.commons.io.IOUtils; /** * Helper class to visually compare two bitmap images. @@ -45,7 +46,11 @@ import org.apache.commons.io.IOUtils; * <p> * TODO Move as utility class to XML Graphics Commons when possible */ -public class BitmapComparator { +public final class BitmapComparator { + + + private BitmapComparator() { + } /** * Builds a new BufferedImage that is the difference between the two input images @@ -79,15 +84,14 @@ public class BitmapComparator { int w = ref.getWidth(); int h = ref.getHeight(); - int y, i, val; int [] refPix = null; int [] genPix = null; - for (y = 0; y < h; y++) { - refPix = refWR.getPixels (0, y, w, 1, refPix); - genPix = genWR.getPixels (0, y, w, 1, genPix); - for (i = 0; i < refPix.length; i++) { + for (int y = 0; y < h; y++) { + refPix = refWR.getPixels(0, y, w, 1, refPix); + genPix = genWR.getPixels(0, y, w, 1, genPix); + for (int i = 0; i < refPix.length; i++) { // val = ((genPix[i] - refPix[i]) * 5) + 128; - val = ((refPix[i] - genPix[i]) * 10) + 128; + int val = ((refPix[i] - genPix[i]) * 10) + 128; if ((val & 0xFFFFFF00) != 0) { if ((val & 0x80000000) != 0) { val = 0; diff --git a/test/java/org/apache/fop/visual/ConvertUtils.java b/test/java/org/apache/fop/visual/ConvertUtils.java index e83322f90..aa4dadf47 100644 --- a/test/java/org/apache/fop/visual/ConvertUtils.java +++ b/test/java/org/apache/fop/visual/ConvertUtils.java @@ -27,7 +27,10 @@ import org.apache.commons.logging.Log; /** * Utilities for converting files with external converters. */ -public class ConvertUtils { +public final class ConvertUtils { + + private ConvertUtils() { + } /** * Calls an external converter application (GhostScript, for example). |