diff options
author | Glenn Adams <gadams@apache.org> | 2016-03-03 09:49:26 +0000 |
---|---|---|
committer | Glenn Adams <gadams@apache.org> | 2016-03-03 09:49:26 +0000 |
commit | c8cde713f54ca731f4a7f3bfaef8af9e8a1b9262 (patch) | |
tree | f553e13b28bd90fd2067bf390509f9290260d330 /test | |
parent | 82804d6ffcb68841cd7adf9740469f3a79c372c8 (diff) | |
download | xmlgraphics-fop-c8cde713f54ca731f4a7f3bfaef8af9e8a1b9262.tar.gz xmlgraphics-fop-c8cde713f54ca731f4a7f3bfaef8af9e8a1b9262.zip |
Transition source to standard maven hierarchy (initial).
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/maven@1733433 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
1053 files changed, 0 insertions, 53303 deletions
diff --git a/test/java/META-INF/services/org.apache.fop.fo.ElementMapping b/test/java/META-INF/services/org.apache.fop.fo.ElementMapping deleted file mode 100644 index f270d50b3..000000000 --- a/test/java/META-INF/services/org.apache.fop.fo.ElementMapping +++ /dev/null @@ -1,2 +0,0 @@ -org.apache.fop.fotreetest.ext.TestElementMapping
-
diff --git a/test/java/org/apache/fop/AbstractBasicTranscoderTest.java b/test/java/org/apache/fop/AbstractBasicTranscoderTest.java deleted file mode 100644 index 7a40b353a..000000000 --- a/test/java/org/apache/fop/AbstractBasicTranscoderTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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; - -import java.io.File; -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 static org.apache.fop.FOPTestUtils.getBaseDir; - -/** - * Basic runtime test for FOP's transcoders. It is used to verify that - * nothing obvious is broken after compiling. - */ -public abstract class AbstractBasicTranscoderTest { - - /** - * Creates the transcoder to test. - * @return the newly instantiated transcoder - */ - protected abstract Transcoder createTranscoder(); - - /** - * Runs the PDF transcoder as if it were called by Batik's rasterizer. - * Without special configuration stuff. - * @throws Exception if a problem occurs - */ - @Test - public void testGenericPDFTranscoder() throws Exception { - //Create transcoder - Transcoder transcoder = createTranscoder(); - - //Setup input - File svgFile = new File(getBaseDir(), "test/resources/fop/svg/text.svg"); - InputStream in = new java.io.FileInputStream(svgFile); - try { - TranscoderInput input = new TranscoderInput(in); - - //Setup output - ByteArrayOutputStream out = new ByteArrayOutputStream(); - try { - TranscoderOutput output = new TranscoderOutput(out); - - //Do the transformation - transcoder.transcode(input, output); - } finally { - out.close(); - } - assertTrue("Some output expected", out.size() > 0); - } finally { - in.close(); - } - } - -} diff --git a/test/java/org/apache/fop/BasicDriverTestCase.java b/test/java/org/apache/fop/BasicDriverTestCase.java deleted file mode 100644 index e89a1c558..000000000 --- a/test/java/org/apache/fop/BasicDriverTestCase.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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; - -import java.io.File; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -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; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.cli.InputHandler; - -import static org.apache.fop.FOPTestUtils.getBaseDir; - -/** - * Basic runtime test for the old Fop class. It is used to verify that - * nothing obvious is broken after compiling. - */ -public class BasicDriverTestCase { - - private FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - - /** - * Tests Fop with JAXP and OutputStream generating PDF. - * @throws Exception if anything fails - */ - @Test - public void testFO2PDFWithJAXP() throws Exception { - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, baout); - - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); //Identity transf. - Source src = new StreamSource(foFile); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - - assertTrue("Generated PDF has zero length", baout.size() > 0); - } - - /** - * Tests Fop with JAXP and OutputStream generating PostScript. - * @throws Exception if anything fails - */ - @Test - public void testFO2PSWithJAXP() throws Exception { - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - Fop fop = fopFactory.newFop(MimeConstants.MIME_POSTSCRIPT, foUserAgent, baout); - - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); //Identity transf. - Source src = new StreamSource(foFile); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - - assertTrue("Generated PostScript has zero length", baout.size() > 0); - } - - /** - * Tests Fop with JAXP and OutputStream generating RTF. - * @throws Exception if anything fails - */ - @Test - public void testFO2RTFWithJAXP() throws Exception { - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, foUserAgent, baout); - - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); //Identity transf. - Source src = new StreamSource(foFile); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - - assertTrue("Generated RTF has zero length", baout.size() > 0); - } - - /** - * Tests Fop with XsltInputHandler and OutputStream. - * @throws Exception if anything fails - */ - @Test - public void testFO2PDFWithXSLTInputHandler() throws Exception { - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - File xmlFile = new File(getBaseDir(), "test/xml/1.xml"); - File xsltFile = new File(getBaseDir(), "test/xsl/doc.xsl"); - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - - InputHandler handler = new InputHandler(xmlFile, xsltFile, null); - handler.renderTo(foUserAgent, MimeConstants.MIME_PDF, baout); - - assertTrue("Generated PDF has zero length", baout.size() > 0); - } - - @Test - public void testXSLILoop() throws Exception { - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - File xmlFile = new File(getBaseDir(), "test/xml/1.xml"); - File xsltFile = new File(getBaseDir(), "test/xsl/iloop.xsl"); - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - InputHandler handler = new InputHandler(xmlFile, xsltFile, null); - try { - handler.renderTo(foUserAgent, MimeConstants.MIME_PDF, baout); - } catch (FOPException e) { /* NOP */ } - } - -} diff --git a/test/java/org/apache/fop/BasicDriverTestSuite.java b/test/java/org/apache/fop/BasicDriverTestSuite.java deleted file mode 100644 index 68619926a..000000000 --- a/test/java/org/apache/fop/BasicDriverTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for basic functionality of FOP's Driver API. - */ -@RunWith(Suite.class) -@SuiteClasses(BasicDriverTestCase.class) -public class BasicDriverTestSuite { -} diff --git a/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java b/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java deleted file mode 100644 index 0f20a1967..000000000 --- a/test/java/org/apache/fop/BasicPDFTranscoderTestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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; - -import org.apache.batik.transcoder.Transcoder; - -import org.apache.fop.svg.PDFTranscoder; - -/** - * Basic runtime test for the PDF transcoder. It is used to verify that - * nothing obvious is broken after compiling. - */ -public class BasicPDFTranscoderTestCase extends AbstractBasicTranscoderTest { - - @Override - protected Transcoder createTranscoder() { - return new PDFTranscoder(); - } - -} diff --git a/test/java/org/apache/fop/BasicPSTranscoderTestCase.java b/test/java/org/apache/fop/BasicPSTranscoderTestCase.java deleted file mode 100644 index 2d6fc0d81..000000000 --- a/test/java/org/apache/fop/BasicPSTranscoderTestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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; - -import org.apache.batik.transcoder.Transcoder; - -import org.apache.fop.render.ps.PSTranscoder; - -/** - * Basic runtime test for the PS transcoder. It is used to verify that - * nothing obvious is broken after compiling. - */ -public class BasicPSTranscoderTestCase extends AbstractBasicTranscoderTest { - - @Override - protected Transcoder createTranscoder() { - return new PSTranscoder(); - } - -} diff --git a/test/java/org/apache/fop/BasicTranscoderTestSuite.java b/test/java/org/apache/fop/BasicTranscoderTestSuite.java deleted file mode 100644 index a372f737a..000000000 --- a/test/java/org/apache/fop/BasicTranscoderTestSuite.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for basic functionality of FOP's transcoders. - */ -@RunWith(Suite.class) -@SuiteClasses({ - BasicPDFTranscoderTestCase.class, - BasicPSTranscoderTestCase.class -}) -public class BasicTranscoderTestSuite { -} diff --git a/test/java/org/apache/fop/DebugHelper.java b/test/java/org/apache/fop/DebugHelper.java deleted file mode 100644 index 1fb7074ee..000000000 --- a/test/java/org/apache/fop/DebugHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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; - -import org.apache.fop.layoutmgr.ElementListObserver; -import org.apache.fop.logging.LoggingElementListObserver; - -/** - * Handles some standard tasks for debugging. - */ -public final class DebugHelper { - - private DebugHelper() { - } - - private static boolean elObserversRegistered; - - /** - * Registers the default element list observers used for debugging. - */ - public static void registerStandardElementListObservers() { - if (!elObserversRegistered) { - ElementListObserver.addObserver(new LoggingElementListObserver()); - elObserversRegistered = true; - } - } - -} diff --git a/test/java/org/apache/fop/DigestFilterTestCase.java b/test/java/org/apache/fop/DigestFilterTestCase.java deleted file mode 100644 index 679b65aee..000000000 --- a/test/java/org/apache/fop/DigestFilterTestCase.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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; - -import java.io.IOException; -import java.io.StringReader; -import java.security.NoSuchAlgorithmException; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; - -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. - * - */ -public class DigestFilterTestCase { - - private SAXParserFactory parserFactory; - - @Before - public void setUp() { - parserFactory = SAXParserFactory.newInstance(); - parserFactory.setNamespaceAware(true); - } - - private boolean compareDigest(byte[] a, byte[] b) { - if (a.length != b.length) { - return false; - } - for (int i = 0; i < a.length; i++) { - if (a[i] != b[i]) { - return false; - } - } - return true; - } - - private String digestToString(byte[] digest) { - StringBuffer buffer = new StringBuffer(2 * digest.length); - for (int i = 0; i < digest.length; i++) { - int val = digest[i]; - int hi = (val >> 4) & 0xF; - int lo = val & 0xF; - if (hi < 10) { - buffer.append((char) (hi + 0x30)); - } else { - buffer.append((char) (hi + 0x61 - 10)); - } - if (lo < 10) { - buffer.append((char) (lo + 0x30)); - } else { - buffer.append((char) (lo + 0x61 - 10)); - } - } - return buffer.toString(); - } - - private byte[] runTest(String input) - throws - NoSuchAlgorithmException, - ParserConfigurationException, - SAXException, - IOException { - XMLReader parser = parserFactory.newSAXParser().getXMLReader(); - DigestFilter digestFilter = new DigestFilter("MD5"); - digestFilter.setParent(parser); - digestFilter.setFeature("http://xml.org/sax/features/namespaces", true); - parser.setContentHandler(digestFilter); - InputSource inputSource = new InputSource(new StringReader(input)); - parser.parse(inputSource); - return digestFilter.getDigestValue(); - } - - @Test - public final void testLineFeed() - throws - NoSuchAlgorithmException, - ParserConfigurationException, - SAXException, - IOException { - byte[] lfDigest = runTest("<a>\n</a>"); - byte[] crlfDigest = runTest("<a>\r\n</a>"); - assertTrue( - "LF: " - + digestToString(lfDigest) - + " CRLF: " - + digestToString(crlfDigest), - compareDigest(lfDigest, crlfDigest)); - } - - @Test - public final void testAttributeOrder() - throws - NoSuchAlgorithmException, - ParserConfigurationException, - SAXException, - IOException { - byte[] sortDigest = runTest("<a a1='1' a2='2' a3='3'/>"); - byte[] permutationDigest = runTest("<a a2='2' a3='3' a1='1'/>"); - assertTrue( - "Sort: " - + digestToString(sortDigest) - + " permuted: " - + digestToString(permutationDigest), - compareDigest(sortDigest, permutationDigest)); - byte[] reverseDigest = runTest("<a a3='3' a2='2' a1='1'/>"); - assertTrue( - "Sort: " - + digestToString(sortDigest) - + " permuted: " - + digestToString(reverseDigest), - compareDigest(sortDigest, reverseDigest)); - } - - @Test - public final void testNamespacePrefix() - throws - NoSuchAlgorithmException, - ParserConfigurationException, - SAXException, - IOException { - byte[] prefix1Digest = runTest("<a:a xmlns:a='foo'/>"); - byte[] prefix2Digest = runTest("<b:a xmlns:b='foo'/>"); - assertTrue( - "prefix1: " - + digestToString(prefix1Digest) - + " prefix2: " - + digestToString(prefix2Digest), - compareDigest(prefix1Digest, prefix2Digest)); - } - -} diff --git a/test/java/org/apache/fop/FOPTestUtils.java b/test/java/org/apache/fop/FOPTestUtils.java deleted file mode 100644 index 429bef187..000000000 --- a/test/java/org/apache/fop/FOPTestUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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; - -import java.io.File; - -/** - * Abstract base test class for FOP's tests. - */ -public final class FOPTestUtils { - - private FOPTestUtils() { - } - - /** - * Returns the base directory to use for the tests. - * @return the base directory - */ - public static File getBaseDir() { - return new File(".").getAbsoluteFile(); - } - -} diff --git a/test/java/org/apache/fop/KnuthAlgorithmTestCase.java b/test/java/org/apache/fop/KnuthAlgorithmTestCase.java deleted file mode 100644 index aa92191de..000000000 --- a/test/java/org/apache/fop/KnuthAlgorithmTestCase.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -import org.apache.fop.layoutmgr.BlockKnuthSequence; -import org.apache.fop.layoutmgr.BreakingAlgorithm; -import org.apache.fop.layoutmgr.ElementListObserver; -import org.apache.fop.layoutmgr.KnuthBox; -import org.apache.fop.layoutmgr.KnuthGlue; -import org.apache.fop.layoutmgr.KnuthPenalty; -import org.apache.fop.layoutmgr.KnuthSequence; - -/** - * Tests the Knuth algorithm implementation. - */ -public class KnuthAlgorithmTestCase { - - @Before - public void setUp() { - DebugHelper.registerStandardElementListObservers(); - } - - private KnuthSequence getKnuthSequence1() { - KnuthSequence seq = new BlockKnuthSequence(); - for (int i = 0; i < 5; i++) { - seq.add(new KnuthBox(0, null, true)); - seq.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, true)); - seq.add(new KnuthGlue(5000, 0, 0, null, true)); - seq.add(new KnuthBox(10000, null, false)); - if (i < 4) { - seq.add(new KnuthPenalty(0, 0, false, null, false)); - seq.add(new KnuthGlue(-5000, 0, 0, null, true)); - } - } - - seq.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, false)); - seq.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false)); - seq.add(new KnuthPenalty(0, -KnuthPenalty.INFINITE, false, null, false)); - ElementListObserver.observe(seq, "test", null); - return seq; - } - - /** - * Tests a special condition where a negative-length glue occurs directly after a break - * possibility. - * @throws Exception if an error occurs - */ - @Test - public void test1() throws Exception { - MyBreakingAlgorithm algo = new MyBreakingAlgorithm(0, 0, true, true, 0); - algo.setConstantLineWidth(30000); - KnuthSequence seq = getKnuthSequence1(); - algo.findBreakingPoints(seq, 1, true, BreakingAlgorithm.ALL_BREAKS); - Part[] parts = algo.getParts(); - assertEquals("Sequence must produce 3 parts", 3, parts.length); - assertEquals(5000, parts[0].difference); - assertEquals(5000, parts[1].difference); - } - - private class Part { - private int difference; - private double ratio; - private int position; - } - - private class MyBreakingAlgorithm extends BreakingAlgorithm { - - private final List<Part> parts = new java.util.ArrayList<Part>(); - - public MyBreakingAlgorithm(int align, int alignLast, boolean first, - boolean partOverflowRecovery, int maxFlagCount) { - super(align, alignLast, first, partOverflowRecovery, maxFlagCount); - } - - public Part[] getParts() { - return parts.toArray(new Part[parts.size()]); - } - - @Override - public void updateData1(int total, double demerits) { - //nop - } - - @Override - public void updateData2(KnuthNode bestActiveNode, KnuthSequence sequence, int total) { - int difference = bestActiveNode.difference; - // it is always allowed to adjust space, so the ratio must be set regardless of - // the value of the property display-align; the ratio must be <= 1 - double ratio = bestActiveNode.adjustRatio; - if (ratio < 0) { - // page break with a negative difference: - // spaces always have enough shrink - difference = 0; - } else if (ratio <= 1 && bestActiveNode.line < total) { - // not-last page break with a positive difference smaller than the available - // stretch: spaces can stretch to fill the whole difference - difference = 0; - } else if (ratio > 1) { - // not-last page with a positive difference greater than the available stretch - // spaces can stretch to fill the difference only partially - ratio = 1; - difference -= bestActiveNode.availableStretch; - } else { - // last page with a positive difference: - // spaces do not need to stretch - ratio = 0; - } - - // add nodes at the beginning of the list, as they are found - // backwards, from the last one to the first one - Part part = new Part(); - part.difference = difference; - part.ratio = ratio; - part.position = bestActiveNode.position; - parts.add(0, part); - } - - @Override - protected int filterActiveNodes() { - //nop - return 0; - } - - } - -} diff --git a/test/java/org/apache/fop/StandardTestSuite.java b/test/java/org/apache/fop/StandardTestSuite.java deleted file mode 100644 index c7c1db9aa..000000000 --- a/test/java/org/apache/fop/StandardTestSuite.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.apache.fop.afp.fonts.CharactersetEncoderTestCase; -import org.apache.fop.afp.parser.MODCAParserTestCase; -import org.apache.fop.area.ViewportTestSuite; -import org.apache.fop.fonts.truetype.GlyfTableTestCase; -import org.apache.fop.fonts.type1.AFMParserTestCase; -import org.apache.fop.fonts.type1.AdobeStandardEncodingTestCase; -import org.apache.fop.image.loader.batik.ImageLoaderTestCase; -import org.apache.fop.image.loader.batik.ImagePreloaderTestCase; -import org.apache.fop.intermediate.IFMimickingTestCase; -import org.apache.fop.layoutmgr.PageSequenceLayoutManagerTestCase; -import org.apache.fop.pdf.PDFLibraryTestSuite; -import org.apache.fop.render.extensions.prepress.PageBoundariesTestCase; -import org.apache.fop.render.extensions.prepress.PageScaleTestCase; -import org.apache.fop.render.pdf.PDFAConformanceTestCase; -import org.apache.fop.render.pdf.PDFCMapTestCase; -import org.apache.fop.render.pdf.PDFEncodingTestCase; -import org.apache.fop.render.pdf.PDFsRGBSettingsTestCase; -import org.apache.fop.render.pdf.RenderPDFTestSuite; -import org.apache.fop.render.ps.PSTestSuite; -import org.apache.fop.render.rtf.RichTextFormatTestSuite; -import org.apache.fop.traits.MinOptMaxTestCase; - -/** - * Test suite for basic functionality of FOP. - */ -@RunWith(Suite.class) -@SuiteClasses({ - BasicDriverTestSuite.class, - UtilityCodeTestSuite.class, - PDFAConformanceTestCase.class, - PDFEncodingTestCase.class, - PDFCMapTestCase.class, - PDFsRGBSettingsTestCase.class, - RichTextFormatTestSuite.class, - ImageLoaderTestCase.class, - ImagePreloaderTestCase.class, - IFMimickingTestCase.class, - PageSequenceLayoutManagerTestCase.class, - PageBoundariesTestCase.class, - PageScaleTestCase.class, - org.apache.fop.afp.AFPTestSuite.class, - GlyfTableTestCase.class, - ViewportTestSuite.class, - RenderPDFTestSuite.class, - MODCAParserTestCase.class, - CharactersetEncoderTestCase.class, - org.apache.fop.render.afp.AFPTestSuite.class, - PDFLibraryTestSuite.class, - PSTestSuite.class, - MinOptMaxTestCase.class, - AdobeStandardEncodingTestCase.class, - AFMParserTestCase.class, - org.apache.fop.render.intermediate.IFStructureTreeBuilderTestCase.class, - org.apache.fop.fonts.FontsTestSuite.class -}) -public class StandardTestSuite { -} diff --git a/test/java/org/apache/fop/URIResolutionTestCase.java b/test/java/org/apache/fop/URIResolutionTestCase.java deleted file mode 100644 index e01271f2b..000000000 --- a/test/java/org/apache/fop/URIResolutionTestCase.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.URI; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.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; -import org.apache.xpath.objects.XObject; - -import org.apache.xmlgraphics.io.Resource; -import org.apache.xmlgraphics.io.ResourceResolver; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.FopFactoryBuilder; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.apps.io.ResourceResolverFactory; -import org.apache.fop.render.xml.XMLRenderer; - -import static org.apache.fop.FOPTestUtils.getBaseDir; - -/** - * Tests URI resolution facilities. - */ -public class URIResolutionTestCase { - - private SAXTransformerFactory tfactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); - - private static final File BACKUP_DIR = new File(getBaseDir(), "build/test-results"); - - private static FopFactory fopFactory; - - @BeforeClass - public static void makeDirs() { - BACKUP_DIR.mkdirs(); - fopFactory = new FopFactoryBuilder(new File(".").getAbsoluteFile().toURI(), - new CustomURIResolver()).build(); - } - - private static File getTestDir() { - return new File(getBaseDir(), "test/xml/uri-testing/"); - } - - @Test - public void innerTestFO1() throws Exception { - File foFile = new File(getTestDir(), "custom-scheme/only-scheme-specific-part.fo"); - - FOUserAgent ua = fopFactory.newFOUserAgent(); - - Document doc = createAreaTree(foFile, ua); - - // XPath checking on the area tree - assertEquals("viewport for external-graphic is missing", - "true", evalXPath(doc, "boolean(//flow/block[1]/lineArea/viewport)")); - assertEquals("46080", evalXPath(doc, "//flow/block[1]/lineArea/viewport/@ipd")); - assertEquals("46080", evalXPath(doc, "//flow/block[1]/lineArea/viewport/@bpd")); - } - - /** - * Test custom URI resolution with a hand-written URIResolver. - * @throws Exception if anything fails - */ - @Test - public void testFO2() throws Exception { - File foFile = new File(getTestDir(), "custom-scheme/only-scheme-specific-part-svg.fo"); - - FOUserAgent ua = fopFactory.newFOUserAgent(); - - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - - Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, ua, baout); - - Transformer transformer = tfactory.newTransformer(); //Identity transf. - Source src = new StreamSource(foFile); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - - OutputStream out = new java.io.FileOutputStream( - new File(BACKUP_DIR, foFile.getName() + ".pdf")); - try { - baout.writeTo(out); - } finally { - IOUtils.closeQuietly(out); - } - - //Test using PDF as the area tree doesn't invoke Batik so we could check - //if the resolver is actually passed to Batik by FOP - assertTrue("Generated PDF has zero length", baout.size() > 0); - } - - private Document createAreaTree(File fo, FOUserAgent ua) - throws TransformerException, FOPException { - DOMResult domres = new DOMResult(); - //Setup Transformer to convert the area tree to a DOM - TransformerHandler athandler = tfactory.newTransformerHandler(); - athandler.setResult(domres); - - XMLRenderer atrenderer = new XMLRenderer(ua); - atrenderer.setContentHandler(athandler); - ua.setRendererOverride(atrenderer); - - Fop fop = fopFactory.newFop(ua); - - Transformer transformer = tfactory.newTransformer(); //Identity transf. - Source src = new StreamSource(fo); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - - Document doc = (Document) domres.getNode(); - saveAreaTreeXML(doc, new File(BACKUP_DIR, fo.getName() + ".at.xml")); - return doc; - } - - private String evalXPath(Document doc, String xpath) { - XObject res; - try { - res = XPathAPI.eval(doc, xpath); - } catch (TransformerException e) { - throw new RuntimeException("XPath evaluation failed: " + e.getMessage()); - } - return res.str(); - } - - /** - * Save the area tree XML for later inspection. - * @param doc area tree as a DOM document - * @param target target file - * @throws TransformerException if a problem occurs during serialization - */ - protected void saveAreaTreeXML(Document doc, File target) throws TransformerException { - Transformer transformer = tfactory.newTransformer(); - Source src = new DOMSource(doc); - Result res = new StreamResult(target); - transformer.transform(src, res); - } - - private static final class CustomURIResolver implements ResourceResolver { - private final ResourceResolver defaultImpl = ResourceResolverFactory.createDefaultResourceResolver(); - - public Resource getResource(URI uri) throws IOException { - if (uri.getScheme().equals("funky") && uri.getSchemeSpecificPart().equals("myimage123")) { - return new Resource("", new FileInputStream("test/resources/images/bgimg300dpi.jpg")); - } - - return defaultImpl.getResource(uri); - } - - public OutputStream getOutputStream(URI uri) throws IOException { - return defaultImpl.getOutputStream(uri); - } - - } -} diff --git a/test/java/org/apache/fop/UtilityCodeTestSuite.java b/test/java/org/apache/fop/UtilityCodeTestSuite.java deleted file mode 100644 index 762b86b14..000000000 --- a/test/java/org/apache/fop/UtilityCodeTestSuite.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.apache.fop.events.BasicEventTestCase; -import org.apache.fop.pdf.FileIDGeneratorTestCase; -import org.apache.fop.pdf.PDFDocumentGraphics2DTestCase; -import org.apache.fop.pdf.PDFEncryptionJCETestCase; -import org.apache.fop.pdf.PDFFactoryTestCase; -import org.apache.fop.pdf.PDFNumberTestCase; -import org.apache.fop.pdf.PDFObjectTestCase; -import org.apache.fop.traits.BorderPropsTestCase; -import org.apache.fop.util.BitmapImageUtilTestCase; -import org.apache.fop.util.ColorUtilTestCase; -import org.apache.fop.util.ElementListUtilsTestCase; -import org.apache.fop.util.HexEncoderTestCase; -import org.apache.fop.util.XMLResourceBundleTestCase; - -/** - * Test suite for FOP's utility classes. - */ -@RunWith(Suite.class) -@SuiteClasses({ - ColorUtilTestCase.class, - BorderPropsTestCase.class, - ElementListUtilsTestCase.class, - BasicEventTestCase.class, - XMLResourceBundleTestCase.class, - URIResolutionTestCase.class, - FileIDGeneratorTestCase.class, - PDFFactoryTestCase.class, - PDFEncryptionJCETestCase.class, - BitmapImageUtilTestCase.class, - PDFDocumentGraphics2DTestCase.class, - PDFNumberTestCase.class, - PDFObjectTestCase.class, - HexEncoderTestCase.class -}) -public class UtilityCodeTestSuite { -} diff --git a/test/java/org/apache/fop/accessibility/fo/DOMResultUtil.java b/test/java/org/apache/fop/accessibility/fo/DOMResultUtil.java deleted file mode 100644 index 5b4e264f2..000000000 --- a/test/java/org/apache/fop/accessibility/fo/DOMResultUtil.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.accessibility.fo; - -import java.io.File; - -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -/** - * Utility class to stream an instance of {@link DOMResult} into a file. May be - * useful for debugging. - */ -final class DOMResultUtil { - - private DOMResultUtil() { - } - - /** - * Streams the given result into a file of the given name. - * - * @param result the result of a transformation - * @param filename name of the file into which to stream the result - * @throws TransformerException if a problem occurs when streaming - */ - public static void streamToFile(DOMResult result, String filename) throws TransformerException { - DOMSource source = new DOMSource(result.getNode()); - TransformerFactory tFactory = TransformerFactory.newInstance(); - Transformer transformer = tFactory.newTransformer(); - transformer.transform(source, new StreamResult(new File(filename))); - } - -} diff --git a/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java b/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java deleted file mode 100644 index eddd90ec4..000000000 --- a/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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.accessibility.fo; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.custommonkey.xmlunit.Diff; -import org.junit.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.apache.fop.accessibility.StructureTree2SAXEventAdapter; -import org.apache.fop.accessibility.StructureTreeEventHandler; -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.fo.FODocumentParser; -import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; -import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.fo.LoadingException; -import org.apache.fop.fotreetest.DummyFOEventHandler; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.pdf.PDFDocumentHandler; - -public class FO2StructureTreeConverterTestCase { - - private static class FOLoader { - - private final String resourceName; - - FOLoader(String resourceName) { - this.resourceName = resourceName; - } - - public InputStream getFoInputStream() { - return getResource(resourceName); - } - } - - private static final String STRUCTURE_TREE_SEQUENCE_NAME = "structure-tree-sequence"; - - private FOLoader foLoader; - - @Test - public void testCompleteDocument() throws Exception { - testConverter("/org/apache/fop/fo/complete_document.fo"); - } - - @Test - public void testAbbreviationProperty() throws Exception { - testConverter("abb.fo"); - } - - @Test - public void testTableFooters() throws Exception { - testConverter("table-footers.fo"); - } - - @Test - public void testArtifact() throws Exception { - testConverter("artifact.fo"); - } - - @Test - public void testSideRegions() throws Exception { - testConverter("/org/apache/fop/fo/pagination/side-regions.fo"); - } - - @Test - public void headerTableCellMustPropagateScope() throws Exception { - testConverter("table-header_scope.fo"); - } - - @Test - public void testLanguage() throws Exception { - testConverter("language.fo"); - } - - private static InputStream getResource(String name) { - return FO2StructureTreeConverterTestCase.class.getResourceAsStream(name); - } - - @Test - public void testPDFA() throws Exception { - FOUserAgent userAgent = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); - userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); - userAgent.setAccessibility(true); - PDFDocumentHandler d = new PDFDocumentHandler(new IFContext(userAgent)); - OutputStream writer = new ByteArrayOutputStream(); - StreamResult result = new StreamResult(writer); - d.setResult(result); - d.getStructureTreeEventHandler(); - d.startDocument(); - assertNull(d.getStructureTreeEventHandler().startNode("table-body", null, null)); - } - - private void testConverter(String foResourceName) throws Exception { - foLoader = new FOLoader(foResourceName); - DOMResult expectedStructureTree = loadExpectedStructureTree(); - DOMResult actualStructureTree = buildActualStructureTree(); - final Diff diff = createDiff(expectedStructureTree, actualStructureTree); - assertTrue(diff.toString(), diff.identical()); - } - - private DOMResult loadExpectedStructureTree() { - DOMResult expectedStructureTree = new DOMResult(); - InputStream xslt = getResource("fo2StructureTree.xsl"); - runXSLT(xslt, foLoader.getFoInputStream(), expectedStructureTree); - return expectedStructureTree; - } - - private static void runXSLT(InputStream xslt, InputStream doc, Result result) { - Source fo = new StreamSource(doc); - try { - Transformer transformer = TransformerFactory.newInstance() - .newTransformer(new StreamSource(xslt)); - transformer.transform(fo, result); - } catch (TransformerConfigurationException e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } finally { - closeStream(xslt); - closeStream(doc); - } - } - - private static void closeStream(InputStream stream) { - try { - stream.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private DOMResult buildActualStructureTree() throws Exception { - DOMResult actualStructureTree = new DOMResult(); - createStructureTreeFromDocument(foLoader.getFoInputStream(), actualStructureTree); - return actualStructureTree; - } - - private static void createStructureTreeFromDocument(InputStream foInputStream, - Result result) throws Exception { - TransformerHandler tHandler = createTransformerHandler(result); - startStructureTreeSequence(tHandler); - StructureTreeEventHandler structureTreeEventHandler - = StructureTree2SAXEventAdapter.newInstance(tHandler); - FODocumentParser documentParser = createDocumentParser(structureTreeEventHandler); - FOUserAgent userAgent = createFOUserAgent(documentParser); - parseDocument(foInputStream, documentParser, userAgent); - endStructureTreeSequence(tHandler); - } - - private static TransformerHandler createTransformerHandler(Result domResult) - throws TransformerConfigurationException, TransformerFactoryConfigurationError { - SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); - TransformerHandler transformerHandler = factory.newTransformerHandler(); - transformerHandler.setResult(domResult); - return transformerHandler; - } - - private static void startStructureTreeSequence(TransformerHandler tHandler) throws SAXException { - tHandler.startDocument(); - tHandler.startElement("", STRUCTURE_TREE_SEQUENCE_NAME, STRUCTURE_TREE_SEQUENCE_NAME, - new AttributesImpl()); - } - - private static FODocumentParser createDocumentParser( - final StructureTreeEventHandler structureTreeEventHandler) { - return FODocumentParser.newInstance(new FOEventHandlerFactory() { - public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) { - return new FO2StructureTreeConverter(structureTreeEventHandler, - new DummyFOEventHandler(foUserAgent)); - } - }); - } - - private static FOUserAgent createFOUserAgent(FODocumentParser documentParser) { - FOUserAgent userAgent = documentParser.createFOUserAgent(); - userAgent.setAccessibility(true); - return userAgent; - } - - private static void parseDocument(InputStream foInputStream, FODocumentParser documentParser, - FOUserAgent userAgent) throws FOPException, LoadingException { - try { - documentParser.parse(foInputStream, userAgent); - } finally { - closeStream(foInputStream); - } - } - - private static void endStructureTreeSequence(TransformerHandler tHandler) throws SAXException { - tHandler.endElement("", STRUCTURE_TREE_SEQUENCE_NAME, STRUCTURE_TREE_SEQUENCE_NAME); - tHandler.endDocument(); - } - - private static Diff createDiff(DOMResult expected, DOMResult actual) { - Diff diff = new Diff(getDocument(expected), getDocument(actual)); - return diff; - } - - private static Document getDocument(DOMResult result) { - return (Document) result.getNode(); - } -} diff --git a/test/java/org/apache/fop/accessibility/fo/PDFUAWarningTestCase.java b/test/java/org/apache/fop/accessibility/fo/PDFUAWarningTestCase.java deleted file mode 100644 index 3940ada7e..000000000 --- a/test/java/org/apache/fop/accessibility/fo/PDFUAWarningTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.accessibility.fo; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import org.xml.sax.helpers.AttributesImpl; - -import org.apache.fop.pdf.PDFDocument; -import org.apache.fop.pdf.PDFFactory; -import org.apache.fop.pdf.PDFParentTree; -import org.apache.fop.pdf.PDFStructElem; -import org.apache.fop.pdf.PDFUAMode; -import org.apache.fop.render.pdf.PDFStructureTreeBuilder; - -public class PDFUAWarningTestCase { - - PDFFactory pdfFactory; - - @Test - public void nestedTableWarningTestCase() throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - PDFStructElem emptyElem = new PDFStructElem(); - PDFStructElem block = PDFStructureTreeBuilder.createStructureElement("block", emptyElem, - new AttributesImpl(), pdfFactory, null); - PDFStructureTreeBuilder.createStructureElement("table", block, new AttributesImpl(), pdfFactory, null); - block.output(bos); - Assert.assertEquals("Div", block.getStructureType().toString()); - } - - @Before - public void setUp() { - PDFParentTree tree = new PDFParentTree(); - PDFDocument doc = new PDFDocument(""); - doc.makeStructTreeRoot(tree); - doc.getProfile().setPDFUAMode(PDFUAMode.PDFUA_1); - pdfFactory = new PDFFactory(doc); - } -} diff --git a/test/java/org/apache/fop/accessibility/fo/abb.fo b/test/java/org/apache/fop/accessibility/fo/abb.fo deleted file mode 100644 index 4ebc16398..000000000 --- a/test/java/org/apache/fop/accessibility/fo/abb.fo +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="220pt" page-width="320pt" margin="10pt"> - <fo:region-body/> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="page" language="en" country="GB"> - <fo:flow flow-name="xsl-region-body"> - <fo:block>Apache <fo:inline fox:abbreviation ="Formatting Objects Processor">FOP</fo:inline> is a print - formatter driven by XSL - </fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/accessibility/fo/artifact.fo b/test/java/org/apache/fop/accessibility/fo/artifact.fo deleted file mode 100644 index c3d5fadf3..000000000 --- a/test/java/org/apache/fop/accessibility/fo/artifact.fo +++ /dev/null @@ -1,97 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="500pt" page-width="300pt" margin="20pt"> - <fo:region-body/> - </fo:simple-page-master> - </fo:layout-master-set> - - <fo:page-sequence master-reference="page"> - <fo:flow flow-name="xsl-region-body" text-align="justify"> - - <fo:block>This piece of text is normal content that should be read out loud by a screen - reader.</fo:block> - - <fo:block space-before="10pt">The following content will be treated as artifact:</fo:block> - - <fo:wrapper role="artifact"> - <fo:block-container border="1pt solid black" padding="5pt" background-color="#F0F0F0" - space-before="10pt" start-indent="6pt" end-indent="6pt" color="#606060"> - <fo:block start-indent="0" end-indent="0"> - <fo:block>A block as artifact.</fo:block> - <fo:table space-before="5pt" width="100%" table-layout="fixed"> - <fo:table-column column-width="proportional-column-width(1)"/> - <fo:table-column column-width="proportional-column-width(2)"/> - <fo:table-header> - <fo:table-cell border="1pt solid #606060"><fo:block>Header 1.1</fo:block></fo:table-cell> - <fo:table-cell border="1pt solid #606060"><fo:block>Header 1.2</fo:block></fo:table-cell> - </fo:table-header> - <fo:table-footer> - <fo:table-cell border="1pt solid #606060"><fo:block>Footer 1.1</fo:block></fo:table-cell> - <fo:table-cell border="1pt solid #606060"><fo:block>Footer 1.2</fo:block></fo:table-cell> - </fo:table-footer> - <fo:table-body> - <fo:table-row> - <fo:table-cell border="1pt solid #606060"><fo:block>Cell 1.1</fo:block></fo:table-cell> - <fo:table-cell border="1pt solid #606060"><fo:block>Cell 1.2</fo:block></fo:table-cell> - </fo:table-row> - <fo:table-row> - <fo:table-cell border="1pt solid #606060"><fo:block>Cell 2.1</fo:block></fo:table-cell> - <fo:table-cell border="1pt solid #606060"><fo:block>Cell 2.2</fo:block></fo:table-cell> - </fo:table-row> - </fo:table-body> - </fo:table> - <fo:list-block space-before="7pt" provisional-distance-between-starts="8pt" - provisional-label-separation="5pt"> - <fo:list-item> - <fo:list-item-label end-indent="label-end()"> - <fo:block>•</fo:block> - </fo:list-item-label> - <fo:list-item-body start-indent="body-start()"> - <fo:block>Item 1.</fo:block> - </fo:list-item-body> - </fo:list-item> - <fo:list-item> - <fo:list-item-label end-indent="label-end()"> - <fo:block>•</fo:block> - </fo:list-item-label> - <fo:list-item-body start-indent="body-start()"> - <fo:block>Item 2.</fo:block> - </fo:list-item-body> - </fo:list-item> - <fo:list-item> - <fo:list-item-label end-indent="label-end()"> - <fo:block>•</fo:block> - </fo:list-item-label> - <fo:list-item-body start-indent="body-start()"> - <fo:block>Item 3.</fo:block> - </fo:list-item-body> - </fo:list-item> - </fo:list-block> - <fo:wrapper> - <fo:block>A block in a nested wrapper.</fo:block> - </fo:wrapper> - <fo:wrapper role="artifact"> - <fo:block>A block in a nested artifact wrapper.</fo:block> - </fo:wrapper> - <fo:wrapper> - <fo:block>Inside a nested wrapper. - <fo:wrapper role="artifact">An artifact wrapper inside the nested wrapper. - <fo:inline><fo:wrapper>Inside a wrapper inside the artifact wrapper that is inside - the nested wrapper.</fo:wrapper> Outside the wrapper inside the artifact - wrapper that is inside the nested wrapper.</fo:inline> - </fo:wrapper> Outside the artifact wrapper.</fo:block> - </fo:wrapper> - </fo:block> - </fo:block-container> - </fo:wrapper> - - <fo:block space-before="10pt">Now we are back to normal content that is part of the logical - structure, should appear in the structure tree and should be read out loud by the screen - reader.</fo:block> - - </fo:flow> - </fo:page-sequence> - -</fo:root> diff --git a/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl b/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl deleted file mode 100644 index f21b079a4..000000000 --- a/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl +++ /dev/null @@ -1,186 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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$ --> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" - xmlns:foi="http://xmlgraphics.apache.org/fop/internal"> - - <xsl:output method="xml" indent="yes"/> - - <xsl:template name="copy"> - <xsl:copy> - <xsl:apply-templates select="@*|node()"/> - </xsl:copy> - </xsl:template> - - - <!-- Ignore fo:root --> - <xsl:template match="fo:root"> - <structure-tree-sequence> - <xsl:apply-templates/> - </structure-tree-sequence> - </xsl:template> - - <!-- fo:page-sequence maps to structure-tree --> - <xsl:template match="fo:page-sequence"> - <structure-tree xmlns="http://xmlgraphics.apache.org/fop/intermediate"> - <xsl:apply-templates/> - </structure-tree> - </xsl:template> - - - <!-- Declarations and Pagination and Layout Formatting Objects --> - <xsl:template match="fo:static-content|fo:flow"> - <xsl:call-template name="copy"/> - </xsl:template> - - <xsl:template match="fo:static-content/@flow-name|fo:flow/@flow-name"> - <xsl:choose> - <xsl:when test=". = 'xsl-region-body' or - . = 'xsl-region-before' or - . = 'xsl-region-after' or - . = 'xsl-region-start' or - . = 'xsl-region-end' or - . = 'xsl-before-float-separator' or - . = 'xsl-footnote-separator'"> - <xsl:copy/> - </xsl:when> - <xsl:otherwise> - <xsl:attribute name="{local-name()}"> - <xsl:value-of select="concat('xsl-', local-name(//*[@region-name = current()]))"/> - </xsl:attribute> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - - <!-- Block-level Formatting Objects --> - <xsl:template match="fo:block|fo:block-container"> - <xsl:call-template name="copy"/> - </xsl:template> - - <!-- Inline-level Formatting Objects --> - <xsl:template match="fo:character|fo:inline|fo:inline-container"> - <xsl:call-template name="copy"/> - </xsl:template> - - <xsl:template match="fo:external-graphic|fo:instream-foreign-object"> - <xsl:call-template name="copy"/> - </xsl:template> - - <xsl:template match="fo:page-number|fo:page-number-citation|fo:page-number-citation-last"> - <xsl:call-template name="copy"/> - </xsl:template> - - <!-- Formatting Objects for Tables --> - <xsl:template match="fo:table-and-caption|fo:table-caption"> - <xsl:call-template name="copy"/> - </xsl:template> - - <xsl:template match="fo:table|fo:table-header|fo:table-footer|fo:table-body|fo:table-row"> - <xsl:call-template name="copy"/> - </xsl:template> - - <xsl:template name="get.column.header"> - <xsl:value-of select="ancestor::fo:table/fo:table-column[ - count(preceding-sibling::fo:table-column) = count(current()/preceding-sibling::fo:table-cell)]/@fox:header"/> - </xsl:template> - - <xsl:template match="fo:table-cell"> - <xsl:variable name="header"><xsl:call-template name="get.column.header"/></xsl:variable> - <xsl:copy> - <xsl:if test="$header = 'true'"> - <xsl:attribute name="role">TH</xsl:attribute> - <xsl:attribute name="scope" namespace="http://xmlgraphics.apache.org/fop/internal">Row</xsl:attribute> - </xsl:if> - <xsl:apply-templates select="@*|node()"/> - </xsl:copy> - </xsl:template> - - <xsl:template match="fo:table-header/fo:table-cell|fo:table-header/fo:table-row/fo:table-cell"> - <xsl:variable name="header"><xsl:call-template name="get.column.header"/></xsl:variable> - <xsl:copy> - <xsl:attribute name="role">TH</xsl:attribute> - <xsl:if test="$header = 'true'"> - <xsl:attribute name="scope" namespace="http://xmlgraphics.apache.org/fop/internal">Both</xsl:attribute> - </xsl:if> - <xsl:apply-templates select="@*|node()"/> - </xsl:copy> - </xsl:template> - - <!-- Formatting Objects for Lists --> - <xsl:template match="fo:list-block|fo:list-item|fo:list-item-label|fo:list-item-body"> - <xsl:call-template name="copy"/> - </xsl:template> - - <!-- Dynamic Effects: Link and Multi Formatting Objects --> - <xsl:template match="fo:basic-link"> - <xsl:call-template name="copy"/> - </xsl:template> - - <!-- Out-of-Line Formatting Objects --> - <xsl:template match="fo:float|fo:footnote|fo:footnote-body"> - <xsl:call-template name="copy"/> - </xsl:template> - - <!-- Other Formatting Objects --> - <xsl:template match="fo:wrapper|fo:marker"> - <xsl:call-template name="copy"/> - </xsl:template> - - <xsl:template match="fo:wrapper[translate(normalize-space(@role), 'ARTIFCT', 'artifct') = 'artifact']"/> - - - <!-- Discard descendants of fo:leader --> - <xsl:template match="fo:leader"/> - - - <!-- Keep the relevant attributes, discard everything else --> - <xsl:template match="@fox:alt-text|@role|@fox:abbreviation"> - <xsl:copy-of select="."/> - </xsl:template> - - <xsl:template match="fo:block/@language[. != ../ancestor::*[@language][1]/@language] - |fo:character/@language[. != ../ancestor::*[@language][1]/@language]"> - <xsl:attribute name="xml:lang"> - <xsl:value-of select="."/> - <xsl:if test="../@country[. != 'none']"> - <xsl:text>-</xsl:text> - <xsl:value-of select="../@country"/> - </xsl:if> - </xsl:attribute> - </xsl:template> - - <xsl:template match="@*"/> - - - <!-- Discard text nodes... --> - <xsl:template match="text()"/> - - <!-- ...except those that will result into marked content --> - <xsl:template match="fo:title/text() - |fo:block/text() - |fo:bidi-override/text() - |fo:inline/text() - |fo:basic-link/text() - |fo:wrapper/text() - |fo:marker/text()"> - <marked-content xmlns="http://xmlgraphics.apache.org/fop/intermediate"/> - </xsl:template> - -</xsl:stylesheet> diff --git a/test/java/org/apache/fop/accessibility/fo/language.fo b/test/java/org/apache/fop/accessibility/fo/language.fo deleted file mode 100644 index 8dfb2694a..000000000 --- a/test/java/org/apache/fop/accessibility/fo/language.fo +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" - font-family="sans-serif"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="170pt" page-width="220pt" margin="10pt"> - <fo:region-body display-align="center"/> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="page" language="en" country="GB"> - <fo:flow flow-name="xsl-region-body" line-height="10pt" font-size="8pt" space-before="5pt" - space-after="5pt"> - <fo:block>This block of text is written in the default language of the page sequence, which is - British English.</fo:block> - <fo:block language="fr" country="FR" space-before="inherit" space-after="inherit">Ce text est - écrit dans une autre langue, en l’occurence le français de France. - <fo:block language="en" country="US" space-before="inherit" start-indent="1em" - space-after="inherit">However, this block of French text encloses a block of American - English. - <fo:block space-before="inherit" start-indent="2em" space-after="inherit" language="en" - country="US">The structure element corresponding to this block should have no language - set as it is the same as on the parent block.</fo:block></fo:block> - Maintenant on revient au français.</fo:block> - <fo:block space-before="inherit">And now we are back to the English language, with a - <fo:character character="F" language="fr" country="none" color="blue"/>rench - character.</fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/accessibility/fo/table-footers.fo b/test/java/org/apache/fop/accessibility/fo/table-footers.fo deleted file mode 100644 index 6dcb9b68d..000000000 --- a/test/java/org/apache/fop/accessibility/fo/table-footers.fo +++ /dev/null @@ -1,195 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="440pt" page-width="420pt" margin="10pt"> - <fo:region-body display-align="center"/> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="page"> - <fo:flow flow-name="xsl-region-body" line-height="10pt" font-size="8pt"> - <fo:table width="100% - 6pt" table-layout="fixed" - border-collapse="separate" border="2pt solid black" border-separation="2pt" padding="1pt" - start-indent="3pt" end-indent="3pt" space-after="2pt"> - <fo:table-header start-indent="0" end-indent="0"> - <fo:table-cell background-color="#E0E0E0" padding="2pt"> - <fo:block>Start Outer Header</fo:block> - <fo:table width="100% - 6pt" table-layout="fixed" - border="2pt solid red" padding="1pt" - start-indent="3pt" end-indent="3pt" space-after="2pt"> - <fo:table-header start-indent="0" end-indent="0"> - <fo:table-cell background-color="#FFB0B0" padding="2pt"> - <fo:block>Inner Header 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="#FFB0B0" padding="2pt"> - <fo:block>Inner Header 1.2</fo:block> - </fo:table-cell> - </fo:table-header> - <fo:table-footer start-indent="0" end-indent="0"> - <fo:table-cell background-color="#FFB0B0" padding="2pt"> - <fo:block>Inner Footer 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="#FFB0B0" padding="2pt"> - <fo:block>Inner Footer 1.2</fo:block> - </fo:table-cell> - </fo:table-footer> - <fo:table-body start-indent="0" end-indent="0"> - <fo:table-row> - <fo:table-cell background-color="#FFB0B0" padding="2pt"> - <fo:block>Inner Body 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="#FFB0B0" padding="2pt"> - <fo:block>Inner Body 1.2</fo:block> - </fo:table-cell> - </fo:table-row> - <fo:table-row> - <fo:table-cell background-color="#FFB0B0" padding="2pt"> - <fo:block>Inner Body 2.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="#FFB0B0" padding="2pt"> - <fo:block>Inner Body 2.2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-body> - </fo:table> - <fo:block>End Outer Header</fo:block> - </fo:table-cell> - </fo:table-header> - <fo:table-footer start-indent="0" end-indent="0"> - <fo:table-cell background-color="#E0E0E0" padding="2pt"> - <fo:block>Start Outer Footer</fo:block> - <fo:table width="100% - 6pt" table-layout="fixed" - border="2pt solid green" padding="1pt" - start-indent="3pt" end-indent="3pt" space-after="2pt"> - <fo:table-header start-indent="0" end-indent="0"> - <fo:table-cell background-color="lightgreen" padding="2pt"> - <fo:block>Inner Header 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="lightgreen" padding="2pt"> - <fo:block>Inner Header 1.2</fo:block> - </fo:table-cell> - </fo:table-header> - <fo:table-footer start-indent="0" end-indent="0"> - <fo:table-cell background-color="lightgreen" padding="2pt"> - <fo:block>Start Inner Footer 1.1</fo:block> - <fo:table width="100% - 6pt" table-layout="fixed" - border="2pt solid yellow" padding="1pt" - start-indent="3pt" end-indent="3pt" space-after="2pt"> - <fo:table-header start-indent="0" end-indent="0"> - <fo:table-cell background-color="yellow" padding="2pt"> - <fo:block>Inner Inner Header 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="yellow" padding="2pt"> - <fo:block>Inner Inner Header 1.2</fo:block> - </fo:table-cell> - </fo:table-header> - <fo:table-footer start-indent="0" end-indent="0"> - <fo:table-cell background-color="yellow" padding="2pt"> - <fo:block>Inner Inner Footer 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="yellow" padding="2pt"> - <fo:block>Inner Inner Footer 1.2</fo:block> - </fo:table-cell> - </fo:table-footer> - <fo:table-body start-indent="0" end-indent="0"> - <fo:table-row> - <fo:table-cell background-color="yellow" padding="2pt"> - <fo:block>Inner Inner Body 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="yellow" padding="2pt"> - <fo:block>Inner Inner Body 1.2</fo:block> - </fo:table-cell> - </fo:table-row> - <fo:table-row> - <fo:table-cell background-color="yellow" padding="2pt"> - <fo:block>Inner Inner Body 2.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="yellow" padding="2pt"> - <fo:block>Inner Inner Body 2.2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-body> - </fo:table> - <fo:block>End Inner Footer 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="lightgreen" padding="2pt"> - <fo:block>Inner Footer 1.2</fo:block> - </fo:table-cell> - </fo:table-footer> - <fo:table-body start-indent="0" end-indent="0"> - <fo:table-row> - <fo:table-cell background-color="lightgreen" padding="2pt"> - <fo:block>Inner Body 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="lightgreen" padding="2pt"> - <fo:block>Inner Body 1.2</fo:block> - </fo:table-cell> - </fo:table-row> - <fo:table-row> - <fo:table-cell background-color="lightgreen" padding="2pt"> - <fo:block>Inner Body 2.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="lightgreen" padding="2pt"> - <fo:block>Inner Body 2.2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-body> - </fo:table> - <fo:block>End Outer Footer</fo:block> - </fo:table-cell> - </fo:table-footer> - <fo:table-body start-indent="0" end-indent="0"> - <fo:table-row> - <fo:table-cell background-color="#E0E0E0" padding="2pt"> - <fo:block>Outer Body Cell 1</fo:block> - </fo:table-cell> - </fo:table-row> - <fo:table-row> - <fo:table-cell background-color="#E0E0E0" padding="2pt"> - <fo:block>Start Outer Body Cell 2</fo:block> - <fo:table width="100% - 6pt" table-layout="fixed" - border="2pt solid blue" padding="1pt" - start-indent="3pt" end-indent="3pt" space-after="2pt"> - <fo:table-header start-indent="0" end-indent="0"> - <fo:table-cell background-color="lightblue" padding="2pt"> - <fo:block>Inner Footer 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="lightblue" padding="2pt"> - <fo:block>Inner Footer 1.2</fo:block> - </fo:table-cell> - </fo:table-header> - <fo:table-footer start-indent="0" end-indent="0"> - <fo:table-cell background-color="lightblue" padding="2pt"> - <fo:block>Inner Header 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="lightblue" padding="2pt"> - <fo:block>Inner Header 1.2</fo:block> - </fo:table-cell> - </fo:table-footer> - <fo:table-body start-indent="0" end-indent="0"> - <fo:table-row> - <fo:table-cell background-color="lightblue" padding="2pt"> - <fo:block>Inner Body 1.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="lightblue" padding="2pt"> - <fo:block>Inner Body 1.2</fo:block> - </fo:table-cell> - </fo:table-row> - <fo:table-row> - <fo:table-cell background-color="lightblue" padding="2pt"> - <fo:block>Inner Body 2.1</fo:block> - </fo:table-cell> - <fo:table-cell background-color="lightblue" padding="2pt"> - <fo:block>Inner Body 2.2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-body> - </fo:table> - <fo:block>End Outer Body Cell 2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-body> - </fo:table> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/accessibility/fo/table-header_scope.fo b/test/java/org/apache/fop/accessibility/fo/table-header_scope.fo deleted file mode 100644 index c6272d546..000000000 --- a/test/java/org/apache/fop/accessibility/fo/table-header_scope.fo +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" - font-family="sans-serif"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="120pt" page-width="220pt" margin="10pt"> - <fo:region-body display-align="center"/> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="page"> - <fo:flow flow-name="xsl-region-body" line-height="10pt" font-size="8pt"> - <fo:table width="100%" table-layout="fixed"> - <fo:table-column fox:header="true" column-width="proportional-column-width(1)"/> - <fo:table-column column-width="proportional-column-width(1)"/> - <fo:table-column column-width="proportional-column-width(1)"/> - <fo:table-header font-weight="bold"> - <fo:table-row> - <fo:table-cell border="1pt solid black" padding-left="1pt"> - <fo:block>Table Header</fo:block> - </fo:table-cell> - <fo:table-cell border="1pt solid black" padding-left="1pt"> - <fo:block>Column 1</fo:block> - </fo:table-cell> - <fo:table-cell border="1pt solid black" padding-left="1pt"> - <fo:block>Column 2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-header> - <fo:table-body> - <fo:table-row> - <fo:table-cell id="Row1" border="1pt solid black" padding-left="1pt" font-weight="bold"> - <fo:block>Row 1</fo:block> - </fo:table-cell> - <fo:table-cell border="1pt solid black" padding-left="1pt"> - <fo:block>Cell 1.1</fo:block> - </fo:table-cell> - <fo:table-cell border="1pt solid black" padding-left="1pt"> - <fo:block>Cell 1.2</fo:block> - </fo:table-cell> - </fo:table-row> - <fo:table-row> - <fo:table-cell border="1pt solid black" padding-left="1pt" font-weight="bold" role="TH"> - <fo:block>Row 2</fo:block> - </fo:table-cell> - <fo:table-cell border="1pt solid black" padding-left="1pt"> - <fo:block>Cell 2.1</fo:block> - </fo:table-cell> - <fo:table-cell border="1pt solid black" padding-left="1pt"> - <fo:block>Cell 2.2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-body> - </fo:table> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/accessibility/pdf/FootnoteSeparatorTestCase.java b/test/java/org/apache/fop/accessibility/pdf/FootnoteSeparatorTestCase.java deleted file mode 100644 index 1da88b2eb..000000000 --- a/test/java/org/apache/fop/accessibility/pdf/FootnoteSeparatorTestCase.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.accessibility.pdf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Test; - -import org.xml.sax.helpers.AttributesImpl; -import static org.junit.Assert.assertEquals; - -import org.apache.fop.pdf.PDFArray; -import org.apache.fop.pdf.PDFDocument; -import org.apache.fop.pdf.PDFFactory; -import org.apache.fop.pdf.PDFParentTree; -import org.apache.fop.pdf.PDFStructElem; -import org.apache.fop.pdf.PDFStructTreeRoot; -import org.apache.fop.render.pdf.PDFStructureTreeBuilder; - -public class FootnoteSeparatorTestCase { - - @Test - public void testFootNoteSeparatorText() throws IOException { - PDFParentTree tree = new PDFParentTree(); - AttributesImpl attributes = new AttributesImpl(); - attributes.addAttribute("", "role", "role", "CDATA", null); - PDFDocument doc = new PDFDocument(""); - PDFStructTreeRoot strucRoot = doc.makeStructTreeRoot(tree); - PDFFactory factory = new PDFFactory(doc); - PDFStructElem part = PDFStructureTreeBuilder.createStructureElement("page-sequence", strucRoot, attributes, - factory, null); - AttributesImpl att = new AttributesImpl(); - att.addAttribute("", "flow-name", "flow-name", "CDATA", "xsl-footnote-separator"); - PDFStructElem staticSection = PDFStructureTreeBuilder.createStructureElement("static-content", part, att, - factory, null); - PDFStructElem block = PDFStructureTreeBuilder.createStructureElement("block", part, new AttributesImpl(), - factory, null); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - part.output(bos); - PDFArray array = (PDFArray)part.get("K"); - PDFStructElem elem1 = (PDFStructElem)array.get(0); - String test = elem1.getStructureType().getName().getName(); - String expected = "P"; - assertEquals(test, expected); - PDFStructElem elem2 = (PDFStructElem)array.get(1); - test = elem2.getStructureType().getName().getName(); - expected = "Sect"; - assertEquals(test, expected); - } -} diff --git a/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java b/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java deleted file mode 100644 index c5d161194..000000000 --- a/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.accessibility.pdf; - -import java.io.File; -import java.util.Arrays; -import java.util.LinkedList; - -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -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.commons.io.output.NullOutputStream; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.events.Event; -import org.apache.fop.events.EventListener; -import org.apache.fop.render.pdf.PDFEventProducer; - -public class MissingLanguageWarningTestCase { - - private Fop fop; - - private MissingLanguageEventChecker eventChecker; - - private static class MissingLanguageEventChecker implements EventListener { - - private final String unknownLanguageEventID = PDFEventProducer.class.getName() + ".unknownLanguage"; - - private final LinkedList<String> expectedLocations = new LinkedList<String>( - Arrays.asList("30:37", "34:40")); - - public void processEvent(Event event) { - if (event.getEventID().equals(unknownLanguageEventID)) { - assertFalse("Too many unknownLanguage events", expectedLocations.isEmpty()); - assertEquals(expectedLocations.removeFirst(), event.getParam("location")); - } - } - - void end() { - assertTrue("Expected more unknownLanguage events", expectedLocations.isEmpty()); - } - - } - - @Before - public void setUp() throws Exception { - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - userAgent.setAccessibility(true); - eventChecker = new MissingLanguageEventChecker(); - userAgent.getEventBroadcaster().addEventListener(eventChecker); - fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, new NullOutputStream()); - } - - @Test - public void testMissingLanguage() throws Exception { - Source src = new StreamSource(getClass().getResourceAsStream("missing-language.fo")); - SAXResult res = new SAXResult(fop.getDefaultHandler()); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.transform(src, res); - eventChecker.end(); - } - -} diff --git a/test/java/org/apache/fop/accessibility/pdf/missing-language.fo b/test/java/org/apache/fop/accessibility/pdf/missing-language.fo deleted file mode 100644 index a774d3c3b..000000000 --- a/test/java/org/apache/fop/accessibility/pdf/missing-language.fo +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="320pt" page-width="420pt" margin="10pt"> - <fo:region-body/> - </fo:simple-page-master> - </fo:layout-master-set> - - <fo:page-sequence master-reference="page"> - <fo:flow flow-name="xsl-region-body" text-align="justify" space-before="10pt"> - - <fo:block language="en" country="GB" space-before="inherit">This block of text is written in - British English. The following block is in French and translates as: “This block contains - French text and is tagged as such.”</fo:block> - - <fo:block language="fr" country="FR" space-before="inherit">Ce block contient du texte en - français et est marqué comme tel.</fo:block> - - <fo:block language="en" country="GB" space-before="inherit">The following block has no - language information, but since it contains no text no warning should be issued.</fo:block> - - <fo:block border="0.2pt solid black" space-before="inherit"> </fo:block> - - <fo:block language="en" country="GB" space-before="inherit">The following block has no - language information and contains an image with an alt-text, for which a warning should be - issued.</fo:block> - - <fo:block text-align="center"><fo:external-graphic - src="test/resources/images/fop-logo-color-24bit.png" - fox:alt-text="FOP logo"/></fo:block> - - <fo:block space-before="inherit">This block contains no language information. However, only - one warning should be issued for all of its lines.</fo:block> - - </fo:flow> - </fo:page-sequence> - -</fo:root> diff --git a/test/java/org/apache/fop/afp/AFPEventProcessingTestCase.java b/test/java/org/apache/fop/afp/AFPEventProcessingTestCase.java deleted file mode 100644 index d1b47846b..000000000 --- a/test/java/org/apache/fop/afp/AFPEventProcessingTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.afp; - -import java.io.InputStream; -import java.net.URI; - -import org.junit.Test; - -import org.apache.xmlgraphics.util.MimeConstants; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.events.EventProcessingTestCase; - - -/** - * A test class for testing AFP events. - */ -public class AFPEventProcessingTestCase { - - private EventProcessingTestCase eventsTests = new EventProcessingTestCase(); - private static final URI CONFIG_BASE_DIR = EventProcessingTestCase.CONFIG_BASE_DIR; - - private void testInvalidConfigEvent(String xconf, String eventId) - throws Exception { - InputStream inStream = getClass().getResourceAsStream("simple.fo"); - eventsTests.doTest(inStream, CONFIG_BASE_DIR.resolve(xconf), - AFPEventProducer.class.getName() + eventId, MimeConstants.MIME_AFP); - } - - @Test - public void testMissingFontConfigurationElement() throws Exception { - testInvalidConfigEvent("afp-font-missing.xconf", ".fontConfigMissing"); - } - - @Test(expected = FOPException.class) - public void testInvalidCharactersetName() throws Exception { - testInvalidConfigEvent("afp-invalid-characterset.xconf", ".characterSetNameInvalid"); - } - - @Test(expected = FOPException.class) - public void testinvalidConfig() throws Exception { - testInvalidConfigEvent("afp-invalid-config.xconf", ".invalidConfiguration"); - } - - @Test - public void testRasterFontElementMissing() throws Exception { - testInvalidConfigEvent("afp-raster-font-missing.xconf", ".fontConfigMissing"); - } - - @Test - public void testTripletElementMissing() throws Exception { - testInvalidConfigEvent("afp-triplet-missing.xconf", ".fontConfigMissing"); - } -} diff --git a/test/java/org/apache/fop/afp/AFPGraphics2DTestCase.java b/test/java/org/apache/fop/afp/AFPGraphics2DTestCase.java deleted file mode 100644 index 7b261d482..000000000 --- a/test/java/org/apache/fop/afp/AFPGraphics2DTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.afp; - -import java.awt.BasicStroke; - -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.afp.modca.GraphicsObject; -import org.apache.fop.fonts.FontInfo; - -public class AFPGraphics2DTestCase { - - private final float lineWidth = 1.0f; - private final float correction = 2.5f; - private final BasicStroke stroke = mock(BasicStroke.class); - private final GraphicsObject gObject = mock(GraphicsObject.class); - private final AFPPaintingState paintingState = mock(AFPPaintingState.class); - private final AFPResourceManager resourceManager = mock(AFPResourceManager.class); - private final AFPResourceInfo resourceInfo = mock(AFPResourceInfo.class); - private final FontInfo fontInfo = mock(FontInfo.class); - private AFPGraphics2D graphics2D = new AFPGraphics2D(false, paintingState, resourceManager, resourceInfo, - fontInfo); - - @Test - public void testApplyStroke() { - // note: this only tests the setLineWidth in the GraphicsObject - float correctedLineWidth = lineWidth * correction; - when(stroke.getLineWidth()).thenReturn(lineWidth); - when(paintingState.getLineWidthCorrection()).thenReturn(correction); - graphics2D.setGraphicsObject(gObject); - graphics2D.applyStroke(stroke); - verify(gObject).setLineWidth(correctedLineWidth); - } - -} diff --git a/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java b/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java deleted file mode 100644 index e9134a90b..000000000 --- a/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.afp; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Test case for {@link AFPObjectAreaInfo}. - */ -public class AFPObjectAreaInfoTestCase { - - private AFPObjectAreaInfo sut; - - /** - * Instantiate the system under test - */ - @Before - public void setUp() { - sut = new AFPObjectAreaInfo(1, 2, 3, 4, 5, 6); - } - - /** - * Test the getter functions with arbitrary data. - */ - @Test - public void testGetters() { - assertEquals(1, sut.getX()); - assertEquals(2, sut.getY()); - assertEquals(3, sut.getWidth()); - assertEquals(4, sut.getHeight()); - assertEquals(5, sut.getWidthRes()); - assertEquals(5, sut.getHeightRes()); - assertEquals(6, sut.getRotation()); - } - - /** - * Test the resolution setters with arbitrary data. - */ - @Test - public void testSetters() { - assertEquals(5, sut.getWidthRes()); - assertEquals(5, sut.getHeightRes()); - - sut.setResolution(20); - assertEquals(20, sut.getWidthRes()); - assertEquals(20, sut.getHeightRes()); - - sut.setHeightRes(10); - assertEquals(20, sut.getWidthRes()); - assertEquals(10, sut.getHeightRes()); - - sut.setWidthRes(9); - assertEquals(9, sut.getWidthRes()); - assertEquals(10, sut.getHeightRes()); - } -} diff --git a/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java b/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java deleted file mode 100644 index e9806f944..000000000 --- a/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.afp; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Test case for {@link AFPPaintingState}. - */ -public class AFPPaintingStateTestCase { - private AFPPaintingState sut; - - /** - * Set up the system under test - */ - @Before - public void setUp() { - sut = new AFPPaintingState(); - } - - /** - * Test {get,set}BitmapEncodingQuality() - */ - @Test - public void testGetSetBitmapEncodingQuality() { - sut.setBitmapEncodingQuality(0.5f); - assertEquals(0.5f, sut.getBitmapEncodingQuality(), 0.01f); - - sut.setBitmapEncodingQuality(0.9f); - assertEquals(0.9f, sut.getBitmapEncodingQuality(), 0.01f); - } - - /** - * Test {,set}CanEmbedJpeg - */ - public void testGetSetCanEmbedJpeg() { - assertEquals(false, sut.canEmbedJpeg()); - sut.setCanEmbedJpeg(true); - assertEquals(true, sut.canEmbedJpeg()); - } -} diff --git a/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java b/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java deleted file mode 100644 index 9d805a7da..000000000 --- a/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.afp; - -import java.io.ByteArrayOutputStream; -import java.io.File; -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; - -/** - * Test case for {@link AFPResourceManager}. - */ -public class AFPResourceManagerTestCase { - - private AFPResourceManager sut; - - @Before - public void setUp() throws IOException { - sut = new AFPResourceManager(ResourceResolverFactory.createDefaultInternalResourceResolver( - new File(".").toURI())); - AFPPaintingState paintingState = new AFPPaintingState(); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - DataStream stream = sut.createDataStream(paintingState, outStream); - stream.startPage(0, 0, 0, 10, 10); - } - - /** - * Ensures that if tryIncludeObject() is called with a new object, it returns false suggesting - * that we have to create said object. However, if it is called with an object that has already - * been created, it returns true suggesting that we don't have to create that object again. - * Page-segment is false. - * - * @throws IOException if an I/O error occurs - */ - @Test - public void testTryIncludeObjectWithPageSegFalse() throws IOException { - AFPDataObjectInfo dataInfo = createAFPDataObjectInfo(); - // An empty object needs to be created every time! - assertFalse(sut.tryIncludeObject(dataInfo)); - sut.createObject(dataInfo); - assertTrue(sut.tryIncludeObject(dataInfo)); - } - - /** - * {@code testTryIncludeObjectWithPageSegFalse()} but with page-segment true. - * - * @throws IOException if an I/O error occurs - */ - @Test - public void testTryIncludeObjectWithPageSegTrue() throws IOException { - AFPDataObjectInfo dataInfo = createAFPDataObjectInfo(); - dataInfo.setCreatePageSegment(true); - // An empty object needs to be created every time! - assertFalse(sut.tryIncludeObject(dataInfo)); - sut.createObject(dataInfo); - assertTrue(sut.tryIncludeObject(dataInfo)); - } - - private AFPDataObjectInfo createAFPDataObjectInfo() { - AFPDataObjectInfo dataInfo = new AFPDataObjectInfo(); - dataInfo.setMimeType(MimeConstants.MIME_TIFF); - dataInfo.setData(new byte[1]); - AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(0, 0, 10, 10, 1, 0); - dataInfo.setObjectAreaInfo(objectAreaInfo); - return dataInfo; - } -} diff --git a/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java b/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java deleted file mode 100644 index 178e5c6ad..000000000 --- a/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.afp; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -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; - -/** - * Tests the {@link AFPResourceUtil} class. - */ -public class AFPResourceUtilTestCase { - - private static final String RESOURCE_FILENAME = "expected_resource.afp"; - private static final String NAMED_RESOURCE_FILENAME = "expected_named_resource.afp"; - - private static final String RESOURCE_ANY_NAME = "resource_any_name.afp"; - private static final String RESOURCE_NAME_MATCH = "resource_name_match.afp"; - private static final String RESOURCE_NAME_MISMATCH = "resource_name_mismatch.afp"; - private static final String RESOURCE_NO_END_NAME = "resource_no_end_name.afp"; - - private static final String PSEG_A = "XFEATHER"; - private static final String PSEG_B = "S1CODEQR"; - - /** - * Tests copyResourceFile() - * @throws Exception - - */ - @Test - public void testCopyResourceFile() throws Exception { - compareResources(new ResourceCopier() { - public void copy(InputStream in, OutputStream out) throws IOException { - AFPResourceUtil.copyResourceFile(in, out); - } - }, RESOURCE_FILENAME, RESOURCE_FILENAME); - } - - /** - * Tests copyNamedResource() - * @throws Exception - - */ - @Test - public void testCopyNamedResource() throws Exception { - compareResources(new ResourceCopier() { - public void copy(InputStream in, OutputStream out) throws IOException { - AFPResourceUtil.copyNamedResource(PSEG_A, in, out); - } - }, RESOURCE_FILENAME, NAMED_RESOURCE_FILENAME); - } - - private void compareResources(ResourceCopier copyResource, String resourceA, String resourceB) - throws IOException { - ByteArrayOutputStream baos = copyResource(resourceA, copyResource); - byte[] expectedBytes = resourceAsByteArray(resourceB); - assertTrue(Arrays.equals(expectedBytes, baos.toByteArray())); - } - - private ByteArrayOutputStream copyResource(String resource, ResourceCopier resourceCopier) - throws IOException { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - InputStream in = null; - try { - in = getClass().getResourceAsStream(resource); - resourceCopier.copy(in, baos); - } finally { - in.close(); - } - return baos; - } - - private byte[] resourceAsByteArray(String resource) throws IOException { - InputStream in = null; - byte[] expectedBytes = null; - try { - in = getClass().getResourceAsStream(resource); - expectedBytes = IOUtils.toByteArray(in); - } finally { - in.close(); - } - return expectedBytes; - } - - /** - * Tests the validity of a closing structured field having an FF FF name which - * allows it to match any existing matching starting field - * @throws Exception - - */ - @Test - public void testResourceAnyName() throws Exception { - testResource(RESOURCE_ANY_NAME, PSEG_B); - } - - /** - * Tests a matching end structured field name - * @throws Exception - - */ - @Test - public void testResourceNameMatch() throws Exception { - testResource(RESOURCE_NAME_MATCH, PSEG_B); - } - - /** - * Tests to see whether a matching structured field pair with mismatching - * names fails. - * @throws Exception - - */ - @Test(expected = Exception.class) - public void testResourceNameMismatch() throws Exception { - testResource(RESOURCE_NAME_MISMATCH, PSEG_B); - } - - /** - * Tests a matching structured end field with no name - * @throws Exception - - */ - @Test - public void testResourceNoEndName() throws Exception { - testResource(RESOURCE_NO_END_NAME, PSEG_B); - } - - private void testResource(String resource, final String pseg) throws Exception { - copyResource(resource, new ResourceCopier() { - public void copy(InputStream in, OutputStream out) throws IOException { - AFPResourceUtil.copyNamedResource(pseg, in, out); - } - }); - } - - private interface ResourceCopier { - void copy(InputStream in, OutputStream out) throws IOException; - } -} diff --git a/test/java/org/apache/fop/afp/AFPTestSuite.java b/test/java/org/apache/fop/afp/AFPTestSuite.java deleted file mode 100644 index ac983f2db..000000000 --- a/test/java/org/apache/fop/afp/AFPTestSuite.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.afp; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.apache.fop.afp.modca.IncludeObjectTestCase; - -/** - * Test suite for FOP's AFP classes. - */ -@RunWith(Suite.class) -@SuiteClasses({ - IncludeObjectTestCase.class, - AFPObjectAreaInfoTestCase.class, - AFPPaintingStateTestCase.class -}) -public class AFPTestSuite { -} diff --git a/test/java/org/apache/fop/afp/expected_named_resource.afp b/test/java/org/apache/fop/afp/expected_named_resource.afp Binary files differdeleted file mode 100644 index 9fe45c388..000000000 --- a/test/java/org/apache/fop/afp/expected_named_resource.afp +++ /dev/null diff --git a/test/java/org/apache/fop/afp/expected_resource.afp b/test/java/org/apache/fop/afp/expected_resource.afp Binary files differdeleted file mode 100644 index a98ac0e5e..000000000 --- a/test/java/org/apache/fop/afp/expected_resource.afp +++ /dev/null diff --git a/test/java/org/apache/fop/afp/fonts/CharactersetEncoderTestCase.java b/test/java/org/apache/fop/afp/fonts/CharactersetEncoderTestCase.java deleted file mode 100644 index ee2fd7876..000000000 --- a/test/java/org/apache/fop/afp/fonts/CharactersetEncoderTestCase.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.charset.CharacterCodingException; - -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; - -/** - * Test {@link CharactersetEncoder} - */ -public class CharactersetEncoderTestCase { - private CharactersetEncoder singlebyteEncoder; - private CharactersetEncoder doublebyteEncoder; - - @Before - public void setUp() { - singlebyteEncoder = CharacterSetType.SINGLE_BYTE.getEncoder("cp500"); - doublebyteEncoder = CharacterSetType.DOUBLE_BYTE_LINE_DATA.getEncoder("cp937"); - } - - // This is just an arbitrary CJK string - private final String testCJKText = "\u8ACB\u65BC\u627F\u505A\u65E5\u4E03\u65E5\u5167\u672A\u9054" - + "\u4E03\u65E5\u4E4B\u5B9A\u5B58\u8005\u4EE5\u5BE6\u969B\u5230\u671F\u65E5\u5167\u78BA" - + "\u8A8D\u672C\u4EA4\u6613\u5167\u5BB9\u3002\u5982\u672A\u65BC\u4E0A\u8FF0\u671F\u9593" - + "\u5167\u63D0\u51FA\u7570\u8B70\uFF0C\u8996\u540C\u610F\u627F\u8A8D\u672C\u4EA4\u6613" - + "\u3002"; - - private final byte[] test6CJKChars = { - (byte) 0x61, (byte) 0x99, - (byte) 0x50, (byte) 0xf4, - (byte) 0x50, (byte) 0xd4, - (byte) 0x56, (byte) 0x99, - (byte) 0x4c, (byte) 0xc9, - (byte) 0x4c, (byte) 0x44 }; - - private final String testEngText = "Hello World!"; - private final byte[] testEngChars = { - (byte) 0xc8, // H - (byte) 0x85, // e - (byte) 0x93, // l - (byte) 0x93, // l - (byte) 0x96, // o - (byte) 0x40, // " " - (byte) 0xe6, // W - (byte) 0x96, // o - (byte) 0x99, // r - (byte) 0x93, // l - (byte) 0x84, // d - (byte) 0x4f // ! - }; - - /** - * Tests canEncode() - tests that canEncode() responds properly to various input characters. - */ - @Test - public void testCanEncode() { - // Both SBCS and DBCS should support Latin characters - for (char c = '!'; c < '~'; c++) { - assertTrue(singlebyteEncoder.canEncode(c)); - assertTrue(doublebyteEncoder.canEncode(c)); - } - // ONLY the double byte characters can handle CJK text - for (char c : testCJKText.toCharArray()) { - assertFalse(singlebyteEncoder.canEncode(c)); - assertTrue(doublebyteEncoder.canEncode(c)); - } - // Ensure that double byte encoder doesn't just return true all the time... - assertFalse(doublebyteEncoder.canEncode('\u00BB')); - } - - @Test - public void testEncode() throws CharacterCodingException, IOException { - CharactersetEncoder.EncodedChars encChars; // = doublebyteEncoder.encode(testCJKText); - ByteArrayOutputStream bOut = new ByteArrayOutputStream(); - // JAVA 1.5 has a bug in the JVM in which these err for some reason... JAVA 1.6 no issues - /*encChars.writeTo(bOut, 0, encChars.getLength()); - byte[] bytes = bOut.toByteArray(); - for (int i = 0; i < 12; i++) { - assertEquals(test6CJKChars[i], bytes[i]); - } - bOut.reset();*/ - - encChars = singlebyteEncoder.encode(testEngText); - encChars.writeTo(bOut, 0, encChars.getLength()); - byte[] engBytes = bOut.toByteArray(); - for (int i = 0; i < testEngChars.length; i++) { - assertEquals(testEngChars[i], engBytes[i]); - } - assertEquals(testEngChars.length, engBytes.length); - } -} diff --git a/test/java/org/apache/fop/afp/fonts/IntegerKeyStoreTestCase.java b/test/java/org/apache/fop/afp/fonts/IntegerKeyStoreTestCase.java deleted file mode 100644 index 96c0618a7..000000000 --- a/test/java/org/apache/fop/afp/fonts/IntegerKeyStoreTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 deleted file mode 100644 index 17c47743c..000000000 --- a/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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. - */ -package org.apache.fop.afp.goca; - -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; - -public class GraphicsCharacterStringTestCase { - private GraphicsCharacterString gcsCp500; - private GraphicsCharacterString gcsCp1146; - // consider the EBCDIC code page variants Cp500 and Cp1146 - // the <A3> (pound sign) corresponds to byte 5B (position 91) in the CCSID 285 and CCSID 1146 - // the $ corresponds to byte 5B (position 91) in the CCSID 500 - private final String poundsText = "\u00A3\u00A3\u00A3\u00A3"; - private final String dollarsText = "$$$$"; - private final byte[] bytesToCheck = {(byte) 0x5b, (byte) 0x5b, (byte) 0x5b, (byte) 0x5b}; - - @Before - public void setUp() throws Exception { - CharacterSetBuilder csb = CharacterSetBuilder.getSingleByteInstance(); - CharacterSet cs1146 = csb.build("C0H200B0", "T1V10500", "Cp1146", - Class.forName("org.apache.fop.fonts.base14.Helvetica").asSubclass(Typeface.class) - .newInstance(), null); - gcsCp1146 = new GraphicsCharacterString(poundsText, 0, 0, cs1146); - CharacterSet cs500 = csb.build("C0H200B0", "T1V10500", "Cp500", - Class.forName("org.apache.fop.fonts.base14.Helvetica").asSubclass(Typeface.class) - .newInstance(), null); - gcsCp500 = new GraphicsCharacterString(dollarsText, 0, 0, cs500); - } - - @Test - public void testWriteToStream() throws IOException { - // check pounds - ByteArrayOutputStream baos1146 = new ByteArrayOutputStream(); - gcsCp1146.writeToStream(baos1146); - byte[] bytes1146 = baos1146.toByteArray(); - for (int i = 0; i < bytesToCheck.length; i++) { - assertEquals(bytesToCheck[i], bytes1146[6 + i]); - } - assertEquals(bytesToCheck.length + 6, bytes1146.length); - // check dollars - ByteArrayOutputStream baos500 = new ByteArrayOutputStream(); - gcsCp500.writeToStream(baos500); - byte[] bytes500 = baos500.toByteArray(); - for (int i = 0; i < bytesToCheck.length; i++) { - assertEquals(bytesToCheck[i], bytes500[6 + i]); - } - assertEquals(bytesToCheck.length + 6, bytes500.length); - } -} diff --git a/test/java/org/apache/fop/afp/goca/GraphicsSetFractionalLineWidthTestCase.java b/test/java/org/apache/fop/afp/goca/GraphicsSetFractionalLineWidthTestCase.java deleted file mode 100644 index f34275de0..000000000 --- a/test/java/org/apache/fop/afp/goca/GraphicsSetFractionalLineWidthTestCase.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.goca; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Arrays; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class GraphicsSetFractionalLineWidthTestCase { - - private final float multiplier = 5.25f; - private final GraphicsSetFractionalLineWidth gsflw = new GraphicsSetFractionalLineWidth(multiplier); - - @Test - public void testGetDataLength() { - assertEquals(4, gsflw.getDataLength()); - } - - @Test - public void testWriteToStream() throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - gsflw.writeToStream(baos); - baos.close(); - // note: 0.25 = 64/256 and 64 = 4*16, so 0x40 - // expected: 0x11 (order code), 0x02 (2 bytes next), 0x05 (integral multiplier), 0x40 (fractional - // multiplier) - byte[] expected = new byte[] {0x11, 0x02, 0x05, 0x40}; - assertTrue(Arrays.equals(expected, baos.toByteArray())); - } - - @Test - public void testToString() { - // lets make sure we keep good coverage... - assertEquals("GraphicsSetFractionalLineWidth{multiplier=" + multiplier + "}", gsflw.toString()); - } - -} diff --git a/test/java/org/apache/fop/afp/goca/GraphicsSetLineWidthTestCase.java b/test/java/org/apache/fop/afp/goca/GraphicsSetLineWidthTestCase.java deleted file mode 100644 index c0a18a551..000000000 --- a/test/java/org/apache/fop/afp/goca/GraphicsSetLineWidthTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.goca; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Arrays; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class GraphicsSetLineWidthTestCase { - - private final int multiplier = 5; - private final GraphicsSetLineWidth gslw = new GraphicsSetLineWidth(multiplier); - - @Test - public void testGetDataLength() { - assertEquals(2, gslw.getDataLength()); - } - - @Test - public void testWriteToStream() throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - gslw.writeToStream(baos); - baos.close(); - // expected: 0x19 (order code), 0x05 (integral multiplier) - byte[] expected = new byte[] {0x19, 0x05}; - assertTrue(Arrays.equals(expected, baos.toByteArray())); - } - - @Test - public void testToString() { - // lets make sure we keep good coverage... - assertEquals("GraphicsSetLineWidth{multiplier=" + multiplier + "}", gslw.toString()); - } - -} diff --git a/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java deleted file mode 100644 index a4c80cc65..000000000 --- a/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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.modca; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -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. - */ -public abstract class AbstractAFPObjectTest<S extends AbstractAFPObject> { - - private S sut; - - protected final S getSut() { - return sut; - } - - protected final void setSut(S sut) { - if (this.sut == null) { - this.sut = sut; - } - } - - - private byte[] header = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - 0x00, // Structured field id byte 1 - 0x00, // Structured field id byte 2 - 0x00, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00 // Reserved - }; - - @Test - public void testCopySFStatic() { - byte[] actual = new byte[9]; - Arrays.fill(actual, (byte)-1); - - S.copySF(actual, (byte)0, (byte)0, (byte)0); - - assertTrue(Arrays.equals(actual, header)); - - byte[] expected2 = new byte[9]; - System.arraycopy(header, 0, expected2, 0, header.length); - - final byte clazz = (byte) 0x01; - final byte type = (byte) 0x02; - final byte catagory = (byte) 0x03; - expected2[3] = clazz; - expected2[4] = type; - expected2[5] = catagory; - - AbstractAFPObject.copySF(actual, clazz, type, catagory); - - assertTrue(Arrays.equals(actual, expected2)); - } - - @Test - public void testCopySF() { - byte[] expected = new byte[9]; - S.copySF(expected, (byte) 0xD3, (byte)0, (byte)0); - - byte[] actual = new byte[9]; - Arrays.fill(actual, (byte)-1); - - getSut().copySF(actual, (byte)0, (byte)0); - - assertTrue(Arrays.equals(actual, expected)); - - byte[] expected2 = new byte[9]; - System.arraycopy(expected, 0, expected2, 0, expected.length); - - final byte type = (byte)1; - final byte catagory = (byte)2; - expected2[4] = type; - expected2[5] = catagory; - - getSut().copySF(actual, type, catagory); - - assertTrue(Arrays.equals(actual, expected2)); - } - - /** - * - */ - @Test - public void testwriteObjects() { - final byte[][] expected = {{(byte)0, (byte)1}, {(byte)2, (byte)3}, {(byte)4, (byte)5}}; - - List<Streamable> objects = new ArrayList<Streamable>() { - { - add(StreamableObject.instance(expected[0])); - add(StreamableObject.instance(expected[1])); - add(StreamableObject.instance(expected[2])); - } }; - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - try { - getSut().writeObjects(objects, baos); - } catch (IOException e) { - fail(); - } - - byte[] actual = baos.toByteArray(); - - int index = 0; - for (int i = 0; i < expected.length; i++) { - for (int j = 0; j < expected[i].length; j++) { - assertTrue("" + index, actual[index] == expected[i][j]); - index++; - } - } - } - - /** - * - */ - @Test - public void testTruncate() { - String expected = "abc"; - assertTrue(AbstractAFPObject.truncate(expected, 4) == expected); - assertTrue(AbstractAFPObject.truncate(expected, 3) == expected); - assertEquals(AbstractAFPObject.truncate(expected + "d", 3), expected); - assertEquals(AbstractAFPObject.truncate(expected, 0), ""); - try { - assertTrue(AbstractAFPObject.truncate(null, 4) == null); - fail(); - } catch (NullPointerException e) { - // PASS - } - } - - /** - * - */ - @Test - public void testWriteChunksToStream() throws IOException { - final byte[] data = new byte[256]; - int counter = 0; - for (int i = 0; i < data.length; i++) { - data[i] = (byte) counter++; - } - - byte[] header = new byte[9]; - // Test when chunk size % data.length == 0 - testWithGivenChunkSize(data, header, 16); - - // test when chunk size % data.length != 0 - testWithGivenChunkSize(data, header, 10); - - // test with an odd number... - testWithGivenChunkSize(data, header, 13); - } - - private void testWithGivenChunkSize(byte[] data, byte[] header, int chunkSize) - throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - S.writeChunksToStream(data, header, 0, chunkSize, baos); - byte[] testData = baos.toByteArray(); - - int numberOfFullDataChunks = data.length / chunkSize; - int lastChunkSize = data.length % chunkSize; - int lengthOfTestData = numberOfFullDataChunks * (chunkSize + header.length); - lengthOfTestData += lastChunkSize == 0 ? 0 : header.length + lastChunkSize; - - putLengthInHeader(header, chunkSize); - - assertEquals(lengthOfTestData, testData.length); - int testIndex = 0; - int expectedIndex = 0; - for (int i = 0; i < numberOfFullDataChunks; i++) { - checkHeaderAndData(header, data, testData, expectedIndex, testIndex, chunkSize); - expectedIndex += chunkSize + header.length; - testIndex += chunkSize; - } - - putLengthInHeader(header, lastChunkSize); - // check last chunk - if (lastChunkSize != 0) { - checkHeaderAndData(header, data, testData, expectedIndex, testIndex, lastChunkSize); - } - } - - private void putLengthInHeader(byte[] header, int chunkSize) { - header[0] = 0; - header[1] = (byte) (chunkSize + header.length); - } - - private void checkHeaderAndData(byte[] header, byte[] data, byte[] testData, int expectedIndex, - int testIndex, int chunkSize) { - for (int i = 0; i < header.length; i++) { - assertEquals(testData[expectedIndex++], header[i]); - } - for (int i = 0; i < chunkSize; i++) { - assertEquals(testData[expectedIndex++], data[i + testIndex]); - } - } - - /** - * - */ - private static class StreamableObject implements Streamable { - private byte[] bytes; - - StreamableObject(byte[] bytes) { - this.bytes = new byte[bytes.length]; - System.arraycopy(bytes, 0, this.bytes, 0, bytes.length); - } - - private static Streamable instance(byte[] bytes) { - return new StreamableObject(bytes); - } - - public void writeToStream(OutputStream os) throws IOException { - os.write(bytes); - } - } -} diff --git a/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java deleted file mode 100644 index 0593ae637..000000000 --- a/test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.modca; - -import java.util.Arrays; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * Tests the {@linkplain AbstractAFPObject} class. - */ -public abstract class AbstractNamedAFPObjectTest<S extends AbstractNamedAFPObject> - extends AbstractAFPObjectTest<S> { - @Test - public void testCopySF() { - - final S sut = getSut(); - - byte[] expected = new byte[17]; - S.copySF(expected, (byte) 0xD3, (byte)0, (byte)0); - - byte[] nameData = sut.getNameBytes(); - System.arraycopy(nameData, 0, expected, 9, nameData.length); - - byte[] actual = new byte[17]; - Arrays.fill(actual, (byte)-1); - - getSut().copySF(actual, (byte)0, (byte)0); - - assertTrue(Arrays.equals(actual, expected)); - - byte[] expected2 = new byte[17]; - System.arraycopy(expected, 0, expected2, 0, expected.length); - System.arraycopy(nameData, 0, expected, 9, nameData.length); - - final byte type = (byte)1; - final byte catagory = (byte)2; - expected2[4] = type; - expected2[5] = catagory; - - getSut().copySF(actual, type, catagory); - - assertTrue(Arrays.equals(actual, expected2)); - } -} diff --git a/test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java deleted file mode 100644 index d0a543087..000000000 --- a/test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; - -public abstract class AbstractStructuredObjectTest<S extends AbstractStructuredObject> - extends AbstractAFPObjectTest<S> { - - /** - * Test writeStart() - test that the contract is maintained with - * {@link AbstractStructuredObject}. - * - * @throws IOException - */ - public void testwriteStart() throws IOException { - } - - /** - * Test writeEnd() - test that the contract is maintained with {@link AbstractStructuredObject}. - * - * @throws IOException - */ - public void testWriteEnd() throws IOException { - } - - /** - * Test writeContent() - test that the contract is maintained with - * {@link AbstractStructuredObject}. - * - * @throws IOException - */ - public void testWriteContent() throws IOException { - } - - /** - * Test writeToStream() - test that the contract is maintained with - * {@link AbstractStructuredObject}. - * - * @throws IOException - */ - public void testWriteToStream() throws IOException { - testwriteStart(); - testWriteEnd(); - testWriteContent(); - } -} diff --git a/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java b/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java deleted file mode 100644 index fe25996bb..000000000 --- a/test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.modca; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -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; -import org.apache.fop.afp.modca.triplets.ObjectAreaSizeTriplet; -import org.apache.fop.afp.modca.triplets.Triplet; - -/** - * Test {@link AbstractTripletStructuredObject} - */ -public class AbstractTripletStructuredObjectTest<S extends AbstractTripletStructuredObject> - extends AbstractStructuredObjectTest<AbstractTripletStructuredObject> { - - private static final List<AbstractTriplet> TRIPLETS; - - static { - List<AbstractTriplet> triplets = new ArrayList<AbstractTriplet>(); - - triplets.add(new CommentTriplet((byte) 0x01, "test comment")); - - triplets.add(new AttributeQualifierTriplet(1, 1)); - - triplets.add(new ObjectAreaSizeTriplet(10, 20)); - - TRIPLETS = Collections.unmodifiableList(triplets); - } - - private AbstractTripletStructuredObject emptyStructuredObject - = new AbstractTripletStructuredObject() { }; - - @Before - public void setUp() throws Exception { - AbstractTripletStructuredObject sut = getSut(); - - for (AbstractTriplet triplet : TRIPLETS) { - sut.addTriplet(triplet); - } - } - - - /** - * Test getTripletLength() - ensure a sum of all enclosing object lengths is returned. - */ - public void testGetTripletLength() { - - int dataLength = 0; - for (Triplet t : TRIPLETS) { - dataLength += t.getDataLength(); - } - assertEquals(dataLength, getSut().getTripletDataLength()); - assertEquals(0, emptyStructuredObject.getTripletDataLength()); - } - - /** - * Test hasTriplets() - */ - public void testHasTriplets() { - assertTrue(getSut().hasTriplets()); - assertFalse(emptyStructuredObject.hasTriplets()); - } - - /** - * Test writeTriplets() - Ensure the triplets are written properly. - * - * @throws IOException - - */ - public void testWriteObjects() throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - for (AbstractTriplet triplet : TRIPLETS) { - triplet.writeToStream(baos); - } - byte[] expected = baos.toByteArray(); - baos.reset(); - getSut().writeTriplets(baos); - assertTrue(Arrays.equals(expected, baos.toByteArray())); - - baos.reset(); - // Ensure it doesn't die if no data has been added - emptyStructuredObject.writeTriplets(baos); - byte[] emptyArray = baos.toByteArray(); - assertTrue(Arrays.equals(emptyArray, new byte[0])); - } - - /** - * Test hasTriplet() - ensure both positive and negative values are returned. - */ - public void testHasTriplet() { - for (AbstractTriplet triplet : TRIPLETS) { - assertTrue(getSut().hasTriplet(triplet.getId())); - assertFalse(emptyStructuredObject.hasTriplet(triplet.getId())); - } - CommentTriplet notInSystem = new CommentTriplet((byte) 0x30, "This should return false"); - assertFalse(getSut().hasTriplet(notInSystem.getId())); - } - - /** - * Test addTriplet() - mostly tested above, but check boundary cases - */ - public void testAddTriplet() { - // ensure null doesn't kill it... not sure what else to test - getSut().addTriplet(null); - } - - /** - * Test addTriplets() - ensure all triplets are added. - */ - @Test - public void testAddTriplets() { - // Tested on empty object - List<AbstractTriplet> expectedList = TRIPLETS; - emptyStructuredObject.addTriplets(expectedList); - // checks equals() on each member of both lists - assertEquals(expectedList, emptyStructuredObject.getTriplets()); - - // Add a list to an already populated list - getSut().addTriplets(expectedList); - - List<AbstractTriplet> newExpected = new ArrayList<AbstractTriplet>(expectedList); - newExpected.addAll(expectedList); - assertEquals(newExpected, getSut().getTriplets()); - - // Ensure null doesn't throw exception - emptyStructuredObject.addTriplets(null); - } - -} diff --git a/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java b/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java deleted file mode 100644 index 7e096f98b..000000000 --- a/test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.modca; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Arrays; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -import org.apache.fop.afp.util.BinaryUtils; - -/** - * Test {@link IncludeObject} - */ -public class IncludeObjectTestCase extends AbstractNamedAFPObjectTest<IncludeObject> { - - @Before - public void setUp() throws Exception { - setSut(new IncludeObject("8__chars")); - } - - /** - * Test writeToStream() - * @throws IOException - - */ - @Test - public void testWriteToStream() throws IOException { - final IncludeObject sut = getSut(); - - byte[] expected = defaultIncludeObjectBytes(sut.getTripletDataLength(), sut.getNameBytes()); - - testWriteToStreamHelper(sut, expected); - } - - /** - * Test writeToStream() - the orientation of the referenced object is a right- - * handed with a 180 x-axis - * @throws IOException - - */ - @Test - public void testWriteToStreamForOrientation() throws IOException { - final IncludeObject sut = getSut(); - - byte[] expected = defaultIncludeObjectBytes(sut.getTripletDataLength(), sut.getNameBytes()); - - expected[25] = (byte)0x5A; - expected[26] = (byte)0x00; - expected[27] = (byte)0x87; - expected[28] = (byte)0x00; - - sut.setObjectAreaOrientation(180); - - testWriteToStreamHelper(sut, expected); - } - - private void testWriteToStreamHelper(IncludeObject sut, byte[] expected) throws IOException { - - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - sut.writeToStream(baos); - - byte[] actual = baos.toByteArray(); - - assertTrue(Arrays.equals(actual, expected)); - } - - private byte[] defaultIncludeObjectBytes(int tripletDataLength, byte[] nameData) { - - byte[] expected = new byte[36]; - - byte[] header = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xAF, // Structured field id byte 2 - type 'input' - (byte)0xC3, // Structured field id byte 3 - category 'data resource' - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - }; - - System.arraycopy(header, 0, expected, 0, header.length); - - byte[] lengthBytes = BinaryUtils.convert(35 + tripletDataLength, 2); //Ignore first byte - expected[1] = lengthBytes[0]; - expected[2] = lengthBytes[1]; - - System.arraycopy(nameData, 0, expected, 9, nameData.length); - - expected[18] = (byte)0x92; // object type 'other' - - expected[27] = (byte)0x2D; // orientation of the reference object - writeOsetTo(expected, 29, -1); // the X-axis origin defined in the object - writeOsetTo(expected, 32, -1); // the Y-axis origin defined in the object - - expected[35] = 0x01; // Page or overlay coordinate system - - return expected; - } - - private static void writeOsetTo(byte[] out, int offset, int oset) { - if (oset > -1) { - byte[] y = BinaryUtils.convert(oset, 3); - out[offset] = y[0]; - out[offset + 1] = y[1]; - out[offset + 2] = y[2]; - } else { - out[offset] = (byte)0xFF; - out[offset + 1] = (byte)0xFF; - out[offset + 2] = (byte)0xFF; - } - } -} diff --git a/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java b/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java deleted file mode 100644 index 176344618..000000000 --- a/test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * 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.parser; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.EOFException; -import java.io.InputStream; -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 - */ -public class MODCAParserTestCase { - - /** The carriage control character (0x5A) used to indicate the start of a structured field. */ - public static final byte CARRIAGE_CONTROL_CHAR = (byte)0x5A; - /**ASCII carriage return control character*/ - public static final byte CARRIAGE_RETURN = (byte)0x0A; - /**ASCII line feed control character */ - public static final byte LINE_FEED = (byte)0x0D; - /** 8 byte introducer describe the SF */ - private static final int INTRODUCER_LENGTH = 8; - - /** - * Test that the MODCA parser recognises carriage control (0x5A) as the Structured Field - * delimeter - * - * @throws Exception * - */ - @Test - public void testReadNextStructuredField1() throws Exception { - - // carriage control (0x5A) delimits structured fields, - // and control is handed to readStructuredField(DataInputStream) - byte[][] goodInputStream = new byte[][]{ - new byte[]{CARRIAGE_CONTROL_CHAR} - }; - - for (byte[] b : goodInputStream) { - try { - new MODCAParser(new ByteArrayInputStream(b)) - .readNextStructuredField(); - fail("BAD SF should throw EOF: " + byteArrayToString(b)); - } catch (EOFException eof) { - //passed - } - } - - // EOFException thrown when reading the input stream are caught and - // a null value is returned - byte[][] badInputStream = new byte[][]{ - new byte[]{}, - new byte[]{CARRIAGE_RETURN}, - new byte[]{LINE_FEED} - }; - - for (byte[] b : badInputStream) { - UnparsedStructuredField usf = new MODCAParser(new ByteArrayInputStream(b)) - .readNextStructuredField(); - assertNull(usf); - } - } - - - /** - * Test that the MODCA parser correctly constructs an UnparsedStructuredField - * from a well formed structured field - * - * @throws Exception * - */ - @Test - public void testReadNextStructuredField2() throws Exception { - - // no extension data - testSF((byte)0xd3, (byte)0xa8, (byte)0x89, //SFTypeID - (byte)0, //flags excluding the bits for - //extension present, segmented data and padding present - false, false, - new byte[]{0, 0}, - new byte[]{1}, null); - - // with extension data - testSF((byte)0xd3, (byte)0xa8, (byte)0x89, //SFTypeID - (byte)0, //flags excluding the bits for - //extension present, segmented data and padding present - false, false, - new byte[]{0, 0}, - new byte[]{1}, new byte[]{10}); - - // with ignored reserved bits - testSF((byte)0xd3, (byte)0xa8, (byte)0x89, //SFTypeID - (byte)0, //flags excluding the bits for - //extension present, segmented data and padding present - false, false, - new byte[]{1, 2}, - new byte[]{1}, null); - - // with padding present and segmented data - testSF((byte)0xd3, (byte)0xa8, (byte)0x89, //SFTypeID - (byte)(1 << 3), //flags excluding the bits for - //extension present, segmented data and padding present - true, true, - new byte[]{0, 0}, - new byte[]{1}, null); - - // with flags non zero - testSF((byte)0xd3, (byte)0xa8, (byte)0x89, //SFTypeID - (byte)(1 << 3), //flags excluding the bits for - //extension present, segmented data and padding present - false, false, - new byte[]{0, 0}, - new byte[]{1}, null); - } - - - private void testSF(byte classCode, byte typeCode, byte categoryCode, - byte flags, boolean segmentedData, boolean paddingPresent, byte[] reserved, - byte[] data, byte[] extData) throws Exception { - - byte extDataLength = 0; - boolean extensionPresent = (extData != null); - - if (extensionPresent) { - flags = (byte)(flags | 0x01); - extDataLength = (byte)(extData.length + 1); //length includes length byte - } - - if (segmentedData) { - flags = (byte)(flags | 0x04); - } - - if (paddingPresent) { - flags = (byte)(flags | 0x10); - } - - short length = (short)(INTRODUCER_LENGTH + data.length + extDataLength); - byte[] lengthBytes = new byte[]{(byte)(length >> 8), (byte)(length & 0xFF)}; - - byte[] sfBytes = new byte[length]; - - //introducer bytes - sfBytes[0] = lengthBytes[0]; - sfBytes[1] = lengthBytes[1]; - sfBytes[2] = classCode; - sfBytes[3] = typeCode; - sfBytes[4] = categoryCode; - sfBytes[5] = flags; - sfBytes[6] = reserved[0]; - sfBytes[7] = reserved[1]; - - if (extDataLength > 0) { - sfBytes[8] = (byte)(extData.length + 1); - System.arraycopy(extData, 0, sfBytes, 9, extData.length); - } - - System.arraycopy(data, 0, sfBytes, length - data.length, data.length); - - - byte[] delimiteredSF = new byte[length + 1]; - - delimiteredSF[0] = (byte)0x5A; - - System.arraycopy(sfBytes, 0, delimiteredSF, 1, length); - - InputStream bis = new ByteArrayInputStream(delimiteredSF); - - UnparsedStructuredField actual = new MODCAParser(bis) - .readNextStructuredField(); - - //check introducer - assertEquals(length, actual.getSfLength()); - assertEquals(classCode, actual.getSfClassCode()); - assertEquals(typeCode, actual.getSfTypeCode()); - assertEquals(categoryCode, actual.getSfCategoryCode()); - assertEquals(extensionPresent, actual.isSfiExtensionPresent()); - assertEquals(segmentedData, actual.isSfiSegmentedData()); - assertEquals(paddingPresent, actual.isSfiPaddingPresent()); - - byte[] introducerData = new byte[]{(byte)(length >> 8), (byte)(length & 0xFF), - classCode, typeCode, categoryCode, flags, reserved[0], reserved[1]}; - - assertTrue(Arrays.equals(introducerData, actual.getIntroducerData())); - - //check data - assertTrue(Arrays.equals(data, actual.getData())); - - //check extension data - if (extData != null) { - assertTrue(Arrays.equals(extData, actual.getExtData())); - } - assertEquals( - (extData == null) ? 0 : extData.length + 1, // 1 byte for length byte - actual.getExtLength()); - - assertTrue(Arrays.equals(data, actual.getData())); - - int expectedSfTypeID = ((classCode & 0xFF) << 16) - | ((typeCode & 0xFF) << 8) - | (categoryCode & 0xFF); - - assertEquals(expectedSfTypeID, actual.getSfTypeID()); - - assertTrue(Arrays.equals(sfBytes, actual.getCompleteFieldAsBytes())); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - actual.writeTo(baos); - assertTrue(Arrays.equals(sfBytes, baos.toByteArray())); - - } - - - private static String byteArrayToString(byte[] byteArray) { - StringBuilder sb = new StringBuilder(); - for (byte b : byteArray) { - sb.append(Integer.toHexString(b & 0xFF)).append(" "); - } - return sb.toString(); - } - -} diff --git a/test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java b/test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java deleted file mode 100644 index 8d6c79d05..000000000 --- a/test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.ptoca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.junit.Test; - -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; - private final OutputStream outStream = mock(OutputStream.class); - - @Test - public void testSingleByteCharacterSet() throws IOException { - testTRNs(false); - } - - @Test - public void testDoubleByteCharacterSets() throws IOException { - testTRNs(true); - } - - public void testTRNs(boolean isDBCS) throws IOException { - for (int length = 100; length < 10000; length += 1000) { - createTRNControlSequence(isDBCS, length); - int maxTRNSize = TRANSPARENT_DATA_MAX_SIZE - (isDBCS ? 1 : 0); - int numberOfTRNs = length / maxTRNSize; - for (int i = 0; i < numberOfTRNs; i++) { - verify(encodedChars, times(1)).writeTo(outStream, i * maxTRNSize, maxTRNSize); - } - int lastOffset = numberOfTRNs * maxTRNSize; - verify(encodedChars, times(1)).writeTo(outStream, numberOfTRNs * maxTRNSize, - length - lastOffset); - } - } - - private void createTRNControlSequence(boolean isDBCS, int length) throws IOException { - encodedChars = mock(EncodedChars.class); - when(encodedChars.isDBCS()).thenReturn(isDBCS); - when(encodedChars.getLength()).thenReturn(length); - for (TransparentData trn : new TransparentDataControlSequence(encodedChars)) { - trn.writeTo(outStream); - } - } -} diff --git a/test/java/org/apache/fop/afp/resource_any_name.afp b/test/java/org/apache/fop/afp/resource_any_name.afp Binary files differdeleted file mode 100644 index a91cabfae..000000000 --- a/test/java/org/apache/fop/afp/resource_any_name.afp +++ /dev/null diff --git a/test/java/org/apache/fop/afp/resource_name_match.afp b/test/java/org/apache/fop/afp/resource_name_match.afp Binary files differdeleted file mode 100644 index 53999574e..000000000 --- a/test/java/org/apache/fop/afp/resource_name_match.afp +++ /dev/null diff --git a/test/java/org/apache/fop/afp/resource_name_mismatch.afp b/test/java/org/apache/fop/afp/resource_name_mismatch.afp Binary files differdeleted file mode 100644 index d4f2c7f81..000000000 --- a/test/java/org/apache/fop/afp/resource_name_mismatch.afp +++ /dev/null diff --git a/test/java/org/apache/fop/afp/resource_no_end_name.afp b/test/java/org/apache/fop/afp/resource_no_end_name.afp Binary files differdeleted file mode 100644 index 517e4cb15..000000000 --- a/test/java/org/apache/fop/afp/resource_no_end_name.afp +++ /dev/null diff --git a/test/java/org/apache/fop/afp/simple.fo b/test/java/org/apache/fop/afp/simple.fo deleted file mode 100644 index 760ff4b63..000000000 --- a/test/java/org/apache/fop/afp/simple.fo +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="420pt" page-width="320pt" margin="10pt"> - <fo:region-body background-color="#F0F0F0"/> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="page"> - <fo:flow flow-name="xsl-region-body"> - <fo:block>This is a simple document.</fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/afp/util/AFPResourceAccessorTestCase.java b/test/java/org/apache/fop/afp/util/AFPResourceAccessorTestCase.java deleted file mode 100644 index d729d336d..000000000 --- a/test/java/org/apache/fop/afp/util/AFPResourceAccessorTestCase.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.afp.util; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.apache.fop.apps.io.InternalResourceResolver; - -public class AFPResourceAccessorTestCase { - - private InternalResourceResolver nullBaseResourceResolver; - private InternalResourceResolver absoluteBaseResourceResolver; - private InternalResourceResolver relativeBaseResourceResolver; - private final URI absoluteBaseURI = URI.create("this:///purely.for.testing"); - private final URI relativeBaseURI = URI.create("./this.is.purely.for.testing"); - private AFPResourceAccessor nullBaseURISut; - private AFPResourceAccessor absoluteBaseURISut; - private AFPResourceAccessor relativeBaseURISut; - - @Before - public void setUp() { - nullBaseResourceResolver = mock(InternalResourceResolver.class); - absoluteBaseResourceResolver = mock(InternalResourceResolver.class); - relativeBaseResourceResolver = mock(InternalResourceResolver.class); - nullBaseURISut = new AFPResourceAccessor(nullBaseResourceResolver); - absoluteBaseURISut = new AFPResourceAccessor(absoluteBaseResourceResolver, - absoluteBaseURI.toASCIIString()); - relativeBaseURISut = new AFPResourceAccessor(relativeBaseResourceResolver, - relativeBaseURI.toASCIIString()); - } - - @Test - public void testCreateInputStream() throws IOException, URISyntaxException { - URI testURI = URI.create("test"); - nullBaseURISut.createInputStream(testURI); - verify(nullBaseResourceResolver).getResource(testURI); - - absoluteBaseURISut.createInputStream(testURI); - verify(absoluteBaseResourceResolver).getResource(getActualURI(absoluteBaseURI, testURI)); - - relativeBaseURISut.createInputStream(testURI); - verify(relativeBaseResourceResolver).getResource(getActualURI(relativeBaseURI, testURI)); - } - - private URI getActualURI(URI baseURI, URI testURI) throws URISyntaxException { - return InternalResourceResolver.getBaseURI(baseURI.toASCIIString()).resolve(testURI); - } - - @Test - public void testResolveURI() throws URISyntaxException { - String testURI = "anotherTestURI"; - assertEquals(URI.create("./" + testURI), nullBaseURISut.resolveURI(testURI)); - - assertEquals(getActualURI(absoluteBaseURI, URI.create(testURI)), - absoluteBaseURISut.resolveURI(testURI)); - - assertEquals(getActualURI(relativeBaseURI, URI.create(testURI)), - relativeBaseURISut.resolveURI(testURI)); - } -} diff --git a/test/java/org/apache/fop/apps/AFPRendererConfBuilder.java b/test/java/org/apache/fop/apps/AFPRendererConfBuilder.java deleted file mode 100644 index f108e4d44..000000000 --- a/test/java/org/apache/fop/apps/AFPRendererConfBuilder.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.apps; - -import java.util.Map; - -import org.w3c.dom.Element; - -import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; -import org.apache.fop.render.afp.AFPRendererConfig; -import org.apache.fop.render.afp.AFPRendererOption; -import org.apache.fop.render.afp.AFPShadingMode; - -import static org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions.MODE_GRAYSCALE; -import static org.apache.fop.render.afp.AFPRendererOption.DEFAULT_RESOURCE_LEVELS; -import static org.apache.fop.render.afp.AFPRendererOption.IMAGES; -import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_DITHERING_QUALITY; -import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_FS45; -import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_JPEG; -import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_MAPPING_OPTION; -import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_MODE; -import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_NATIVE; -import static org.apache.fop.render.afp.AFPRendererOption.IMAGES_WRAP_PSEG; -import static org.apache.fop.render.afp.AFPRendererOption.JPEG_ALLOW_JPEG_EMBEDDING; -import static org.apache.fop.render.afp.AFPRendererOption.JPEG_BITMAP_ENCODING_QUALITY; -import static org.apache.fop.render.afp.AFPRendererOption.LINE_WIDTH_CORRECTION; -import static org.apache.fop.render.afp.AFPRendererOption.RENDERER_RESOLUTION; -import static org.apache.fop.render.afp.AFPRendererOption.RESOURCE_GROUP_URI; -import static org.apache.fop.render.afp.AFPRendererOption.SHADING; - -/** - * A config builder specific to a particular renderer for specific MIME type. - */ -public final class AFPRendererConfBuilder extends RendererConfBuilder { - - private ImagesBuilder images; - - public AFPRendererConfBuilder() { - super(MimeConstants.MIME_AFP); - } - - private AFPRendererConfBuilder createTextElement(AFPRendererOption option, String value) { - createTextElement(option.getName(), value); - return this; - } - - public AFPRendererConfBuilder setShading(AFPShadingMode mode) { - return createTextElement(SHADING, mode.getName()); - } - - public AFPRendererConfBuilder setRenderingResolution(int res) { - return createTextElement(RENDERER_RESOLUTION, String.valueOf(res)); - } - - public AFPRendererConfBuilder setLineWidthCorrection(float value) { - return createTextElement(LINE_WIDTH_CORRECTION, String.valueOf(value)); - } - - public ImagesBuilder startImages(AFPRendererConfig.ImagesModeOptions mode) { - images = new ImagesBuilder(mode); - return images; - } - - public ImagesBuilder startImages() { - return startImages(MODE_GRAYSCALE); - } - - public AFPRendererConfBuilder endImages() { - images = null; - return this; - } - - public AFPRendererConfBuilder setResourceGroupUri(String uri) { - createTextElement(RESOURCE_GROUP_URI, uri); - return this; - } - - public AFPRendererConfBuilder setDefaultResourceLevels(Map<String, String> levels) { - Element e = createElement(DEFAULT_RESOURCE_LEVELS.getName()); - for (String key : levels.keySet()) { - e.setAttribute(key, levels.get(key)); - } - return this; - } - - public final class ImagesBuilder { - - private final Element el; - - private Element jpeg; - - private ImagesBuilder(AFPRendererConfig.ImagesModeOptions mode) { - el = createElement(IMAGES.getName()); - setAttribute(IMAGES_MODE, mode.getName()); - } - - public ImagesBuilder setModeAttribute(String name, String value) { - return setAttribute(name, value); - } - - public ImagesBuilder setAllowJpegEmbedding(boolean value) { - getJpeg().setAttribute(JPEG_ALLOW_JPEG_EMBEDDING.getName(), String.valueOf(value)); - return this; - } - - public ImagesBuilder setBitmapEncodingQuality(float value) { - getJpeg().setAttribute(JPEG_BITMAP_ENCODING_QUALITY.getName(), String.valueOf(value)); - return this; - } - - public ImagesBuilder setDitheringQuality(String value) { - return setAttribute(IMAGES_DITHERING_QUALITY, value); - } - - public ImagesBuilder setDitheringQuality(float value) { - return setAttribute(IMAGES_DITHERING_QUALITY, value); - } - - public ImagesBuilder setFs45(boolean value) { - return setAttribute(IMAGES_FS45, value); - } - - public ImagesBuilder setMappingOption(String value) { - return setAttribute(IMAGES_MAPPING_OPTION, value); - } - - public ImagesBuilder setWrapPseg(boolean value) { - return setAttribute(IMAGES_WRAP_PSEG, value); - } - - public ImagesBuilder setNativeImageSupport(boolean value) { - return setAttribute(IMAGES_NATIVE, value); - } - - public AFPRendererConfBuilder endImages() { - return AFPRendererConfBuilder.this.endImages(); - } - - private ImagesBuilder setAttribute(AFPRendererOption options, Object value) { - return setAttribute(options.getName(), value); - } - - private ImagesBuilder setAttribute(String name, Object value) { - el.setAttribute(name, String.valueOf(value)); - return this; - } - - private Element getJpeg() { - if (jpeg == null) { - jpeg = createElement(IMAGES_JPEG.getName(), el); - } - return jpeg; - } - } -} diff --git a/test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java b/test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java deleted file mode 100644 index e4c9ceb44..000000000 --- a/test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.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; - -import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; -import org.apache.fop.events.DefaultEventBroadcaster; -import org.apache.fop.fonts.FontManager; -import org.apache.fop.render.RendererConfig; -import org.apache.fop.render.RendererConfig.RendererConfigParser; - -public abstract class AbstractRendererConfigParserTester<B extends RendererConfBuilder, - C extends RendererConfig> { - - protected B builder; - - protected C conf; - - protected final RendererConfigParser configBuilder; - - private final Class<B> type; - - public AbstractRendererConfigParserTester(RendererConfigParser configBuilder, Class<B> type) { - this.configBuilder = configBuilder; - this.type = type; - } - - protected void parseConfig() throws Exception { - parseConfig(createRenderer()); - } - - protected void parseConfig(B rendererConfBuilder) throws Exception { - DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); - Configuration cfg = cfgBuilder.build(rendererConfBuilder.endRendererConfig().build()) - .getChild("renderers") - .getChild("renderer"); - FOUserAgent userAgent = mock(FOUserAgent.class); - when(userAgent.validateStrictly()).thenReturn(true); - FontManager fontManager = mock(FontManager.class); - when(userAgent.getFontManager()).thenReturn(fontManager); - when(userAgent.getEventBroadcaster()).thenReturn(new DefaultEventBroadcaster()); - conf = (C) configBuilder.build(userAgent, cfg); - } - - protected B createRenderer() { - return createRenderer(type); - } - - protected B createRenderer(Class<B> type) { - builder = new FopConfBuilder().setStrictValidation(true).startRendererConfig(type); - return builder; - } - - protected void dump() throws Exception { - builder.dump(); - } -} diff --git a/test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java b/test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java deleted file mode 100644 index 2487c0a63..000000000 --- a/test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.apps; - -import java.io.File; -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; - -public abstract class AbstractRendererConfiguratorTest<T extends PrintRendererConfigurator, - B extends RendererConfBuilder> { - - protected final String mimeType; - protected FOUserAgent userAgent; - protected T sut; - protected IFDocumentHandler docHandler; - private final Class<B> builderClass; - - public abstract void setUpDocumentHandler(); - - public AbstractRendererConfiguratorTest(String mimeType, Class<B> builderClass, - Class<? extends IFDocumentHandler> docHandlerClass) { - this.mimeType = mimeType; - this.builderClass = builderClass; - this.docHandler = mock(docHandlerClass); - when(this.docHandler.getMimeType()).thenReturn(mimeType); - } - - protected B createBuilder() { - return builderClass.cast(new FopConfBuilder().startRendererConfig(builderClass)); - } - - protected abstract T createConfigurator(); - - protected void parseConfig(RendererConfBuilder builder) - throws ConfigurationException, SAXException, IOException { - userAgent = FopFactory.newInstance( - new File(".").toURI(), builder.endRendererConfig().build()).newFOUserAgent(); - setUpDocumentHandler(); - sut = createConfigurator(); - sut.configure(docHandler); - } -} diff --git a/test/java/org/apache/fop/apps/BitmapRendererConfBuilder.java b/test/java/org/apache/fop/apps/BitmapRendererConfBuilder.java deleted file mode 100644 index 9ea2a4e9e..000000000 --- a/test/java/org/apache/fop/apps/BitmapRendererConfBuilder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.apps; - -import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; - -import static org.apache.fop.render.bitmap.BitmapRendererOption.ANTI_ALIASING; -import static org.apache.fop.render.bitmap.BitmapRendererOption.BACKGROUND_COLOR; -import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE; -import static org.apache.fop.render.bitmap.BitmapRendererOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; -import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_QUALITY_ELEMENT; - -public class BitmapRendererConfBuilder extends RendererConfBuilder { - - protected BitmapRendererConfBuilder(String mimeType) { - super(mimeType); - } - - protected BitmapRendererConfBuilder() { - super(getMimeType()); - } - - public BitmapRendererConfBuilder setPageBackgroundTransparency(boolean isTransparent) { - createTextElement(JAVA2D_TRANSPARENT_PAGE_BACKGROUND, String.valueOf(isTransparent)); - return this; - } - - public BitmapRendererConfBuilder setBackgroundColor(String color) { - createTextElement(BACKGROUND_COLOR, color); - return this; - } - - public BitmapRendererConfBuilder setAntiAliasing(boolean antiAlias) { - createTextElement(ANTI_ALIASING, String.valueOf(antiAlias)); - return this; - } - - public BitmapRendererConfBuilder setRenderingQuality(String quality) { - createTextElement(RENDERING_QUALITY_ELEMENT, quality); - return this; - } - - public BitmapRendererConfBuilder setColorMode(String colorMode) { - createTextElement(COLOR_MODE, colorMode); - return this; - } - - public static String getMimeType() { - return "Bitmap"; - } -} diff --git a/test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java b/test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java deleted file mode 100644 index 83bfd2076..000000000 --- a/test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.apps; - -import java.net.URI; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -import org.apache.xmlgraphics.io.ResourceResolver; - -public class EnvironmentalProfileFactoryTestCase { - - private final URI testURI = URI.create("this.is.purely.for.test.purposes"); - - @Test - public void testCreateDefault() { - ResourceResolver mockedResolver = mock(ResourceResolver.class); - EnvironmentProfile sut = EnvironmentalProfileFactory.createDefault(testURI, mockedResolver); - assertEquals(mockedResolver, sut.getResourceResolver()); - } -} diff --git a/test/java/org/apache/fop/apps/FontConfigurator.java b/test/java/org/apache/fop/apps/FontConfigurator.java deleted file mode 100644 index e9b8b8ff1..000000000 --- a/test/java/org/apache/fop/apps/FontConfigurator.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.apps; - -public interface FontConfigurator<P> { - P endFontsConfig(); -} diff --git a/test/java/org/apache/fop/apps/FopConfBuilder.java b/test/java/org/apache/fop/apps/FopConfBuilder.java deleted file mode 100644 index 8dd882d8a..000000000 --- a/test/java/org/apache/fop/apps/FopConfBuilder.java +++ /dev/null @@ -1,546 +0,0 @@ -/* - * 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.apps; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import org.apache.fop.render.RendererConfigOption; - -/** - * A builder class for creating fop.xconf XML DOMs for test purposes. You can set all the necessary - * fields inline and build the fop conf DOM into an {@link InputStream}. - * <pre> - * {@code - * new FopConfBuilder().setStrictValidation(true) - * .startRendererBuilder(RendererConfBuilder.class) - * .startFontsConfig() - * .startFont(null, null) - * .addTriplet("Gladiator", "normal", "normal") - * .endFont() - * .endFontConfig() - * .endRendererConfigBuilder().build() - * } - * </pre> - */ -public class FopConfBuilder implements FontConfigurator<FopConfBuilder> { - - private final Element root; - private final Document fopConfDOM; - private RendererConfBuilder currentRendererConfig; - private FontsConfBuilder<FopConfBuilder> currentFontsConfig; - - /** - * Constructs the FopConfBuilder and initializes the underlying DOM. - */ - public FopConfBuilder() { - try { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - DocumentBuilder db = dbf.newDocumentBuilder(); - fopConfDOM = db.newDocument(); - root = fopConfDOM.createElement("fop"); - fopConfDOM.appendChild(root); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } - } - - private FopConfBuilder createElement(String elementName, String elementValue) { - Element el = fopConfDOM.createElement(elementName); - el.appendChild(fopConfDOM.createTextNode(elementValue)); - root.appendChild(el); - return this; - } - - /** - * Set the <font-base> tag within the fop.xconf. - * - * @param fontBase the font base value - * @return <b>this</b> - */ - public FopConfBuilder setFontBaseURI(String fontBase) { - return createElement("font-base", fontBase); - } - - /** - * Set the <base> tag within the fop.xconf. - * - * @param baseURI the base URI - * @return <b>this</b> - */ - public FopConfBuilder setBaseURI(String baseURI) { - return createElement("base", baseURI); - } - - /** - * Set the <strict-validation> tag within the fop.xconf. - * - * @param validateStrictly true to enforce strict FO validation - * @return <b>this</b> - */ - public FopConfBuilder setStrictConfiguration(boolean validateStrictly) { - return createElement("strict-configuration", String.valueOf(validateStrictly)); - } - - /** - * Set the <strict-validation> tag within the fop.xconf. - * - * @param validateStrictly true to enforce strict configuration validation - * @return <b>this</b> - */ - public FopConfBuilder setStrictValidation(boolean validateStrictly) { - return createElement("strict-validation", String.valueOf(validateStrictly)); - } - - /** - * Set the <accessibility> tag within the fop.xconf. - * - * @param setAccessibility true to enable accessibility features - * @return <b>this</b> - */ - public FopConfBuilder setAccessibility(boolean setAccessibility) { - return createElement("accessibility", String.valueOf(setAccessibility)); - } - - @Deprecated - public FopConfBuilder setHyphenationBaseURI(String uri) { - return createElement("hyphenation-base", uri); - } - - /** - * Set the <source-resolution> tag within the fop.xconf. - * - * @param srcRes the source resolution - * @return <b>this</b> - */ - public FopConfBuilder setSourceResolution(float srcRes) { - return createElement("source-resolution", String.valueOf(srcRes)); - } - - /** - * Set the <target-resolution> tag within the fop.xconf. - * - * @param targetRes the target resolution - * @return <b>this</b> - */ - public FopConfBuilder setTargetResolution(float targetRes) { - return createElement("target-resolution", String.valueOf(targetRes)); - } - - /** - * Set the <break-indent-inheritance> tag within the fop.xconf. - * - * @param value true to break indent inheritance - * @return <b>this</b> - */ - public FopConfBuilder setBreakIndentInheritance(boolean value) { - return createElement("break-indent-inheritance", String.valueOf(value)); - } - - /** - * Set the <prefer-renderer> tag within the fop.xconf. - * - * @param value true to prefer the renderer - * @return <b>this</b> - */ - public FopConfBuilder setPreferRenderer(boolean value) { - return createElement("prefer-renderer", String.valueOf(value)); - } - - /** - * Set the <default-page-settings> tag within the fop.xconf. - * - * @param height the height of the page - * @param width the width of the page - * @return <b>this</b> - */ - public FopConfBuilder setDefaultPageSettings(float height, float width) { - Element el = fopConfDOM.createElement("default-page-settings"); - el.setAttribute("height", String.valueOf(height)); - el.setAttribute("width", String.valueOf(width)); - root.appendChild(el); - return this; - } - - /** - * Sets whether the fonts cache is used or not. - * - * @param enableFontCaching true to enable font data caching. - * @return <b>this</b> - */ - public FopConfBuilder useCache(boolean enableFontCaching) { - return createElement("use-cache", String.valueOf(enableFontCaching)); - } - - /** - * Starts a renderer specific config builder. - * - * @param mimeType the MIME type of the builder - * @return the renderer config builder - */ - public <T extends RendererConfBuilder> T startRendererConfig(Class<T> rendererConfigClass) { - try { - currentRendererConfig = rendererConfigClass.newInstance(); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - currentRendererConfig.init(this, fopConfDOM); - return rendererConfigClass.cast(currentRendererConfig); - } - - /** - * Ends a renderer specific config builder. - * - * @return <b>this</b> - */ - private FopConfBuilder endRendererConfig() { - Element renderersEl = fopConfDOM.createElement("renderers"); - renderersEl.appendChild(currentRendererConfig.rendererEl); - root.appendChild(renderersEl); - currentRendererConfig = null; - return this; - } - - /** - * Starts a fonts config builder, for configuring the fonts handling system within FOP i.e. - * the <fonts> element. - * - * @return the fop config builder - */ - public FontsConfBuilder<FopConfBuilder> startFontsConfig() { - currentFontsConfig = new FontsConfBuilder<FopConfBuilder>(this); - currentFontsConfig.setFopConfDOM(fopConfDOM); - return currentFontsConfig; - } - - /** - * Ends the fonts config builder. - * - * @return <b>this</b> - */ - public FopConfBuilder endFontsConfig() { - root.appendChild(currentFontsConfig.fontsEl); - currentFontsConfig = null; - return this; - } - - /** - * Converts the underlying DOM into an {@link InputStream} for building. - * - * @return an {@link InputStream} - */ - public InputStream build() { - try { - Source src = new DOMSource(fopConfDOM); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - Result res = new StreamResult(baos); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.transform(src, res); - return new ByteArrayInputStream(baos.toByteArray()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public void dump() { - dump(System.out); - } - - public void dump(OutputStream out) { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer; - try { - transformer = tf.newTransformer(); - } catch (TransformerConfigurationException e1) { - throw new RuntimeException(e1); - } - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - try { - transformer.transform(new DOMSource(fopConfDOM), - new StreamResult(new OutputStreamWriter(out, "UTF-8"))); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - } - - public abstract static class RendererConfBuilder implements FontConfigurator<RendererConfBuilder> { - - private Element rendererEl; - - private FopConfBuilder fopConfBuilder; - - private Document fopConfDOM; - - private final String mimeType; - - private FontsConfBuilder<RendererConfBuilder> fontsConfBuilder; - - protected RendererConfBuilder(String mimeType) { - this.mimeType = mimeType; - } - - private void init(FopConfBuilder fopConfBuilder, Document fopConfDOM) { - this.fopConfBuilder = fopConfBuilder; - this.fopConfDOM = fopConfDOM; - rendererEl = fopConfDOM.createElement("renderer"); - rendererEl.setAttribute("mime", mimeType); - } - - protected final Element createElement(String name) { - return createElement(name, rendererEl); - } - - protected final Element createElement(String name, Element parent) { - Element el = fopConfDOM.createElement(name); - parent.appendChild(el); - return el; - } - - protected final Element createTextElement(String name, String value) { - return createTextElement(name, value, rendererEl); - } - - protected final Element createTextElement(RendererConfigOption option, String value) { - return createTextElement(option.getName(), value, rendererEl); - } - - protected final Element createTextElement(String name, String value, Element parent) { - Element el = createElement(name, parent); - el.setTextContent(value); - return el; - } - - /** - * Starts a fonts config builder, for configuring the fonts handling system within FOP i.e. - * the <fonts> element. - * - * @return the fonts config builder - */ - public final FontsConfBuilder<RendererConfBuilder> startFontsConfig() { - fontsConfBuilder = new FontsConfBuilder<RendererConfBuilder>(this); - fontsConfBuilder.setFopConfDOM(fopConfBuilder.fopConfDOM); - return fontsConfBuilder; - } - - /** - * Ends the fonts config builder. - * - * @return <b>this</b> - */ - public final RendererConfBuilder endFontsConfig() { - rendererEl.appendChild(fontsConfBuilder.fontsEl); - fontsConfBuilder = null; - return this; - } - - /** - * Ends the renderer specific config. - * - * @return the parent - */ - public final FopConfBuilder endRendererConfig() { - return fopConfBuilder.endRendererConfig(); - } - - public void dump() { - fopConfBuilder.dump(); - } - - public void dump(OutputStream out) { - fopConfBuilder.dump(out); - } - } - - public static final class FontsConfBuilder<P extends FontConfigurator<P>> { - private Element fontsEl; - private final P parent; - private Document fopConfDOM; - private Element fontSubstitutions; - private FontTripletInfo<P> currentTripletInfo; - - private FontsConfBuilder(P parent) { - this.parent = parent; - } - - private void setFopConfDOM(Document fopConfDOM) { - this.fopConfDOM = fopConfDOM; - fontsEl = fopConfDOM.createElement("fonts"); - } - - /** - * Add <auto-detect> to find fonts. - * - * @return <b>this</b> - */ - public FontsConfBuilder<P> addAutoDetect() { - fontsEl.appendChild(fopConfDOM.createElement("auto-detect")); - return this; - } - - /** - * Add a <directory> for specifying a directory to check fonts in. - * - * @param directory the directory to find fonts within - * @param recursive true to recurse through sub-directories - * @return <b>this</b> - */ - public FontsConfBuilder<P> addDirectory(String directory, boolean recursive) { - Element dir = fopConfDOM.createElement("directory"); - dir.setAttribute("recursive", String.valueOf(recursive)); - dir.setTextContent(directory); - fontsEl.appendChild(dir); - return this; - } - - /** - * Create a font <substitution>. - * - * @param fromFamily from font family name - * @param fromStyle from font style - * @param fromWeight from font weight - * @param toFamily to font family name - * @param toStyle to font style - * @param toWeight to font weight - * @return <b>this</b> - */ - public P substituteFonts(String fromFamily, String fromStyle, - String fromWeight, String toFamily, String toStyle, String toWeight) { - if (fontSubstitutions == null) { - fontSubstitutions = fopConfDOM.createElement("substitutions"); - } - Element fontSubEl = fopConfDOM.createElement("substitution"); - fontSubEl.appendChild(createSubstitutionEl("from", fromFamily, fromStyle, fromWeight)); - fontSubEl.appendChild(createSubstitutionEl("to", toFamily, toStyle, toWeight)); - fontSubstitutions.appendChild(fontSubEl); - fontsEl.appendChild(fontSubstitutions); - return parent; - } - - private Element createSubstitutionEl(String elName, String family, String style, - String weight) { - Element element = fopConfDOM.createElement(elName); - addAttribute(element, "font-family", family); - addAttribute(element, "font-style", style); - addAttribute(element, "font-weight", weight); - return element; - } - - private void addAttribute(Element fontSub, String attName, String attValue) { - if (attName != null && attValue != null) { - fontSub.setAttribute(attName, attValue); - } - } - - /** - * Start a <font> configuration element. - * - * @param metricsURL the URL to the metrics resource - * @param embedURL the URL to the font resource - * @return <b>this</b> - */ - public FontTripletInfo<P> startFont(String metricsURL, String embedURL) { - currentTripletInfo = new FontTripletInfo<P>(this, metricsURL, embedURL); - return currentTripletInfo; - } - - private FontsConfBuilder<P> endFontTriplet(Element el) { - fontsEl.appendChild(el); - currentTripletInfo = null; - return this; - } - - /** - * Ends a font configuration element . - * - * @return the parent - */ - public P endFontConfig() { - return parent.endFontsConfig(); - } - - public final class FontTripletInfo<T> { - private final Element fontEl; - private final FontsConfBuilder<P> parent; - - private FontTripletInfo(FontsConfBuilder<P> parent, - String metricsURL, String embedURL) { - this.parent = parent; - fontEl = fopConfDOM.createElement("font"); - addAttribute(fontEl, "metrics-url", metricsURL); - addAttribute(fontEl, "embed-url", embedURL); - } - - /** - * Add triplet information to a font. - * - * @param name the font name - * @param style the font style - * @param weight the font weight - * @return <b>this</b> - */ - public FontTripletInfo<T> addTriplet(String name, String style, String weight) { - Element tripletEl = fopConfDOM.createElement("font-triplet"); - addAttribute(tripletEl, "name", name); - addAttribute(tripletEl, "style", style); - addAttribute(tripletEl, "weight", weight); - fontEl.appendChild(tripletEl); - return this; - } - - /** - * Ends the font configuration element. - * - * @return the parent - */ - public FontsConfBuilder<P> endFont() { - return parent.endFontTriplet(fontEl); - } - } - } -} diff --git a/test/java/org/apache/fop/apps/FopConfParserTestCase.java b/test/java/org/apache/fop/apps/FopConfParserTestCase.java deleted file mode 100644 index dc794fdb8..000000000 --- a/test/java/org/apache/fop/apps/FopConfParserTestCase.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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.apps; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; - -import org.junit.Before; -import org.junit.Test; -import org.xml.sax.SAXException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * Test case for {@link FopConfParser}. - */ -public class FopConfParserTestCase { - - private final URI baseURI = URI.create("test/config/fop_factory_tests/"); - private FopConfBuilder builder; - - @Before - public void setUp() { - builder = new FopConfBuilder(); - } - - public static FopFactory getFopFactory(InputStream fopConfStream, URI baseURI) { - FopConfParser confParser; - try { - confParser = new FopConfParser(fopConfStream, baseURI); - return confParser.getFopFactoryBuilder().build(); - } catch (SAXException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private FopFactory buildFactory() { - FopConfParser confParser; - try { - confParser = new FopConfParser(builder.build(), baseURI); - return confParser.getFopFactoryBuilder().build(); - } catch (SAXException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Test - public void testDefaults() { - FopFactory config = buildFactory(); - FopFactoryBuilderTestCase.testDefaults(config, baseURI); - } - - @Test - public void testStrictFOValidation() { - builder.setStrictValidation(false); - assertFalse(buildFactory().validateStrictly()); - } - - @Test - public void testStrictUserValidation() { - builder.setStrictConfiguration(false); - assertFalse(buildFactory().validateUserConfigStrictly()); - } - - @Test - public void testAccessibility() { - builder.setAccessibility(false); - assertFalse(buildFactory().isAccessibilityEnabled()); - } - - @Test - public void testSourceResolution() { - float srcRes = 123.456f; - builder.setSourceResolution(srcRes); - assertEquals(srcRes, buildFactory().getSourceResolution(), 0.0001f); - } - - @Test - public void testTargetResolution() { - float targetRes = 123.456f; - builder.setTargetResolution(targetRes); - assertEquals(targetRes, buildFactory().getTargetResolution(), 0.0001f); - } - - @Test - public void testBreakIndentInheritance() { - builder.setBreakIndentInheritance(true); - assertTrue(buildFactory().isBreakIndentInheritanceOnReferenceAreaBoundary()); - } - - @Test - public void testDefaultPageSettings() { - float height = 12.345f; - float width = 67.89f; - builder.setDefaultPageSettings(height, width); - FopFactory factory = buildFactory(); - assertEquals("12.345", factory.getPageHeight()); - assertEquals("67.89", factory.getPageWidth()); - } - - @Test - public void testPreferRenderer() { - builder.setPreferRenderer(true); - assertTrue(buildFactory().getRendererFactory().isRendererPreferred()); - } - - @Test - public void testRelativeURINoBaseNoFont() throws Exception { - checkRelativeURIs("test/config/relative-uri/no-base_no-font.xconf", - "", ""); - } - - @Test - public void testRelativeURINoBaseFont() throws Exception { - checkRelativeURIs("test/config/relative-uri/no-base_font.xconf", - "", "test/config/relative-uri/fonts/"); - } - - @Test - public void testRelativeURIBaseNoFont() throws Exception { - checkRelativeURIs("test/config/relative-uri/base_no-font.xconf", - "test/config/relative-uri/relative/", "test/config/relative-uri/relative/"); - } - - @Test - public void testRelativeURIBaseFont() throws Exception { - checkRelativeURIs("test/config/relative-uri/base_font.xconf", - "test/config/relative-uri/relative/", "test/config/relative-uri/fonts/"); - } - - private void checkRelativeURIs(String conf, String expectedBase, String expectedFontBase) - throws SAXException, IOException { - File configFile = new File(conf); - URI currentDir = new File(".").getCanonicalFile().toURI(); - FopConfParser parser = new FopConfParser(configFile, currentDir); - FopFactoryBuilder fopFactoryBuilder = parser.getFopFactoryBuilder(); - assertEquals("base URI", currentDir.resolve(expectedBase), - fopFactoryBuilder.getBaseURI()); - assertEquals("font base", currentDir.resolve(expectedFontBase), - fopFactoryBuilder.getFontManager().getResourceResolver().getBaseURI()); - } - -} diff --git a/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java b/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java deleted file mode 100644 index 86b4e7c04..000000000 --- a/test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * 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.apps; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -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; -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.extensions.ExternalDocument; -import org.apache.fop.fo.pagination.Flow; -import org.apache.fop.fo.pagination.PageSequence; -import org.apache.fop.fo.pagination.SideRegion; -import org.apache.fop.fo.pagination.StaticContent; -import org.apache.fop.fo.pagination.Title; -import org.apache.fop.layoutmgr.ExternalDocumentLayoutManager; -import org.apache.fop.layoutmgr.FlowLayoutManager; -import org.apache.fop.layoutmgr.LayoutManager; -import org.apache.fop.layoutmgr.LayoutManagerMaker; -import org.apache.fop.layoutmgr.PageSequenceLayoutManager; -import org.apache.fop.layoutmgr.StaticContentLayoutManager; -import org.apache.fop.layoutmgr.inline.ContentLayoutManager; - -/** - * Test case for {@link FopFactoryBuilder}. - */ -public class FopFactoryBuilderTestCase { - - private FopFactoryBuilder defaultBuilder; - private static final String POST_SET_ERROR_MSG = "Should not be able to set any properties" - + " once the builder has built a FopFactory."; - - @Before - public void setUp() { - defaultBuilder = new FopFactoryBuilder(URI.create(".")); - } - - @Test(expected = IllegalArgumentException.class) - public void testNullParamsInConstructor() throws URISyntaxException { - new FopFactoryBuilder(null, ResourceResolverFactory.createDefaultResourceResolver()); - } - - @Test - public void testDefaultImplementation() { - testDefaults(defaultBuilder.build(), URI.create(".")); - } - - private FopFactory buildFopFactory() { - return defaultBuilder.build(); - } - - public static void testDefaults(FopFactory factory, URI baseURI) { - assertFalse(factory.isAccessibilityEnabled()); - assertNull(factory.getLayoutManagerMakerOverride()); - assertEquals(FopFactoryConfig.DEFAULT_STRICT_FO_VALIDATION, factory.validateStrictly()); - assertEquals(FopFactoryConfig.DEFAULT_STRICT_USERCONFIG_VALIDATION, - factory.validateUserConfigStrictly()); - assertEquals(FopFactoryConfig.DEFAULT_BREAK_INDENT_INHERITANCE, - factory.isBreakIndentInheritanceOnReferenceAreaBoundary()); - assertEquals(FopFactoryConfig.DEFAULT_SOURCE_RESOLUTION, factory.getSourceResolution(), - 0.001f); - assertEquals(FopFactoryConfig.DEFAULT_TARGET_RESOLUTION, factory.getTargetResolution(), - 0.001f); - assertEquals(FopFactoryConfig.DEFAULT_PAGE_HEIGHT, factory.getPageHeight()); - assertEquals(FopFactoryConfig.DEFAULT_PAGE_WIDTH, factory.getPageWidth()); - assertFalse(factory.getRendererFactory().isRendererPreferred()); - } - - @Test - public void testSetGetAccessibility() { - runSetterTest(new Runnable() { - public void run() { - defaultBuilder.setAccessibility(true); - assertTrue(buildFopFactory().isAccessibilityEnabled()); - } - }); - } - - @Test - public void testsetGetLMM() { - runSetterTest(new Runnable() { - public void run() { - LayoutManagerMaker testLmm = new LayoutManagerMaker() { - - public StaticContentLayoutManager makeStaticContentLayoutManager( - PageSequenceLayoutManager pslm, StaticContent sc, Block block) { - return null; - } - - public StaticContentLayoutManager makeStaticContentLayoutManager( - PageSequenceLayoutManager pslm, StaticContent sc, SideRegion reg) { - return null; - } - - public PageSequenceLayoutManager makePageSequenceLayoutManager(AreaTreeHandler ath, - PageSequence ps) { - return null; - } - - public void makeLayoutManagers(FONode node, List lms) { - } - - public LayoutManager makeLayoutManager(FONode node) { - return null; - } - - public FlowLayoutManager makeFlowLayoutManager(PageSequenceLayoutManager pslm, - Flow flow) { - return null; - } - - public ExternalDocumentLayoutManager makeExternalDocumentLayoutManager( - AreaTreeHandler ath, ExternalDocument ed) { - return null; - } - - public ContentLayoutManager makeContentLayoutManager(PageSequenceLayoutManager pslm, - Title title) { - return null; - } - }; - defaultBuilder.setLayoutManagerMakerOverride(testLmm); - assertEquals(testLmm, buildFopFactory().getLayoutManagerMakerOverride()); - } - }); - - } - - @Test - public void testSetGetBaseURI() { - runSetterTest(new Runnable() { - public void run() { - URI nonDefaultURI = URI.create("./test/"); - defaultBuilder.setBaseURI(nonDefaultURI); - assertEquals(nonDefaultURI, defaultBuilder.buildConfiguration().getBaseURI()); - } - }); - } - - @Test - public void testGetSetValidateFO() { - runSetterTest(new Runnable() { - public void run() { - defaultBuilder.setStrictFOValidation(false); - assertFalse(buildFopFactory().validateStrictly()); - } - }); - } - - @Test - public void testGetSetValidateUserConfig() { - runSetterTest(new Runnable() { - public void run() { - defaultBuilder.setStrictUserConfigValidation(false); - assertFalse(buildFopFactory().validateUserConfigStrictly()); - } - }); - } - - @Test - public void testGetSetBreakInheritance() { - runSetterTest(new Runnable() { - public void run() { - defaultBuilder.setBreakIndentInheritanceOnReferenceAreaBoundary(true); - assertTrue(buildFopFactory().isBreakIndentInheritanceOnReferenceAreaBoundary()); - } - }); - } - - @Test - public void testGetSetSourceRes() { - runSetterTest(new Runnable() { - public void run() { - float testRes = 10f; - defaultBuilder.setSourceResolution(testRes); - assertEquals(testRes, buildFopFactory().getSourceResolution(), 0.0001); - } - }); - } - - @Test - public void testGetSetTargetRes() { - runSetterTest(new Runnable() { - public void run() { - float testRes = 10f; - defaultBuilder.setTargetResolution(testRes); - assertEquals(testRes, buildFopFactory().getTargetResolution(), 0.0001f); - } - }); - } - - @Test - public void testGetSetPageHeight() { - runSetterTest(new Runnable() { - public void run() { - String testString = "Purely for testing"; - defaultBuilder.setPageHeight(testString); - assertEquals(testString, buildFopFactory().getPageHeight()); - } - }); - } - - @Test - public void testGetSetPageWidth() { - runSetterTest(new Runnable() { - public void run() { - String testString = "Purely for testing"; - defaultBuilder.setPageWidth(testString); - assertEquals(testString, buildFopFactory().getPageWidth()); - } - }); - } - - @Test - public void testGetSetIsNamespaceIgnored() { - runSetterTest(new Runnable() { - public void run() { - String testString = "Purely for testing"; - defaultBuilder.ignoreNamespace(testString); - assertTrue(buildFopFactory().isNamespaceIgnored(testString)); - } - }); - } - - @Test - public void testGetSetListNamespaceIgnored() { - runSetterTest(new Runnable() { - public void run() { - List<String> strings = new ArrayList<String>(); - strings.add("1"); - strings.add("2"); - strings.add("3"); - defaultBuilder.ignoreNamespaces(strings); - FopFactory factory = buildFopFactory(); - assertTrue(factory.isNamespaceIgnored("1")); - assertTrue(factory.isNamespaceIgnored("2")); - assertTrue(factory.isNamespaceIgnored("3")); - } - }); - } - - @Test - public void testGetSetPreferRenderer() { - runSetterTest(new Runnable() { - public void run() { - defaultBuilder.setPreferRenderer(true); - assertTrue(buildFopFactory().getRendererFactory().isRendererPreferred()); - } - }); - } - - private void runSetterTest(Runnable setterTest) { - setterTest.run(); - try { - setterTest.run(); - fail(POST_SET_ERROR_MSG); - } catch (IllegalStateException e) { - // Expected - } - } -} diff --git a/test/java/org/apache/fop/apps/FopFactoryTestCase.java b/test/java/org/apache/fop/apps/FopFactoryTestCase.java deleted file mode 100644 index 439ffa44e..000000000 --- a/test/java/org/apache/fop/apps/FopFactoryTestCase.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.apps; - -import java.io.IOException; - -import org.junit.Test; -import org.xml.sax.SAXException; - -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 { - super(new FopConfBuilder().setStrictValidation(true) - .startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .startFont(null, "test/resources/fonts/ttf/glb12.ttf.xml") - .addTriplet("Gladiator", "normal", "normal") - .endFont() - .endFontConfig() - .endRendererConfig().build()); - } - - @Test - @Override - public void testUserConfig() throws Exception { - RendererConfigParser mock = mock(RendererConfigParser.class); - when(mock.getMimeType()).thenReturn(MimeConstants.MIME_PDF); - try { - convertFO(); - PDFRendererConfig config = (PDFRendererConfig) fopFactory.getRendererConfig(null, null, - mock); - convertFO(); - assertEquals(config, fopFactory.getRendererConfig(null, null, mock)); - } catch (Exception e) { - // this should *not* happen! - e.printStackTrace(); - fail(e.getMessage()); - } - } -} diff --git a/test/java/org/apache/fop/apps/Java2DRendererConfBuilder.java b/test/java/org/apache/fop/apps/Java2DRendererConfBuilder.java deleted file mode 100644 index 00568cfc5..000000000 --- a/test/java/org/apache/fop/apps/Java2DRendererConfBuilder.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.apps; - -import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; - -import static org.apache.fop.render.java2d.Java2DRendererOption.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; - -public class Java2DRendererConfBuilder extends RendererConfBuilder { - - protected Java2DRendererConfBuilder() { - super("Java2D"); - } - - public Java2DRendererConfBuilder setPageBackgroundTransparency(boolean value) { - createTextElement(JAVA2D_TRANSPARENT_PAGE_BACKGROUND, String.valueOf(value)); - return this; - } -} diff --git a/test/java/org/apache/fop/apps/MutableConfig.java b/test/java/org/apache/fop/apps/MutableConfig.java deleted file mode 100644 index 3ff3c10fa..000000000 --- a/test/java/org/apache/fop/apps/MutableConfig.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.apps; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import org.apache.avalon.framework.configuration.Configuration; - -import org.apache.xmlgraphics.image.loader.ImageManager; -import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver; -import org.apache.xmlgraphics.io.ResourceResolver; - -import org.apache.fop.fonts.FontManager; -import org.apache.fop.layoutmgr.LayoutManagerMaker; - -/** - * This is a mutable implementation of the {@link FopFactoryConfig} to be used for testing purposes. - * This is also an example of how to make the seemingly immutable {@link FopFactory} mutable should - * a client need to, though this is ill-advised. - */ -public final class MutableConfig implements FopFactoryConfig { - - private final FopFactoryConfig delegate; - - private boolean setBreakInheritance; - private float sourceResolution; - - public MutableConfig(FopFactoryBuilder factoryBuilder) { - delegate = factoryBuilder.buildConfiguration(); - setBreakInheritance = delegate.isBreakIndentInheritanceOnReferenceAreaBoundary(); - sourceResolution = delegate.getSourceResolution(); - } - - public boolean isAccessibilityEnabled() { - return delegate.isAccessibilityEnabled(); - } - - public LayoutManagerMaker getLayoutManagerMakerOverride() { - return delegate.getLayoutManagerMakerOverride(); - } - - public ResourceResolver getResourceResolver() { - return delegate.getResourceResolver(); - } - - public URI getBaseURI() { - return delegate.getBaseURI(); - } - - public boolean validateStrictly() { - return delegate.validateStrictly(); - } - - public boolean validateUserConfigStrictly() { - return delegate.validateUserConfigStrictly(); - } - - public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() { - return setBreakInheritance; - } - - public void setBreakIndentInheritanceOnReferenceAreaBoundary(boolean value) { - setBreakInheritance = value; - } - - public float getSourceResolution() { - return sourceResolution; - } - - public void setSourceResolution(float srcRes) { - sourceResolution = srcRes; - } - - public float getTargetResolution() { - return delegate.getTargetResolution(); - } - - public String getPageHeight() { - return delegate.getPageHeight(); - } - - public String getPageWidth() { - return delegate.getPageWidth(); - } - - public Set<String> getIgnoredNamespaces() { - return delegate.getIgnoredNamespaces(); - } - - public boolean isNamespaceIgnored(String namespace) { - return delegate.isNamespaceIgnored(namespace); - } - - public Configuration getUserConfig() { - return delegate.getUserConfig(); - } - - public boolean preferRenderer() { - return delegate.preferRenderer(); - } - - public FontManager getFontManager() { - return delegate.getFontManager(); - } - - public ImageManager getImageManager() { - return delegate.getImageManager(); - } - - public boolean isComplexScriptFeaturesEnabled() { - return delegate.isComplexScriptFeaturesEnabled(); - } - - public Map<String, String> getHyphenationPatternNames() { - return delegate.getHyphenationPatternNames(); - } - - public FallbackResolver getFallbackResolver() { - return delegate.getFallbackResolver(); - } -} diff --git a/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java b/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java deleted file mode 100644 index 3da4e1daf..000000000 --- a/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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.apps; - -import org.w3c.dom.Element; - -import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; -import org.apache.fop.render.RendererConfigOption; -import org.apache.fop.render.pdf.PDFEncryptionOption; - -import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_LENGTH; -import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_PARAMS; -import static org.apache.fop.render.pdf.PDFEncryptionOption.OWNER_PASSWORD; -import static org.apache.fop.render.pdf.PDFEncryptionOption.USER_PASSWORD; -import static org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE; -import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST; -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; - -/** - * A config builder specific to a particular renderer for specific MIME type. - */ -public final class PDFRendererConfBuilder extends RendererConfBuilder { - - private EncryptionParamsBuilder accessConf; - - public PDFRendererConfBuilder() { - super(MimeConstants.MIME_PDF); - } - - public EncryptionParamsBuilder startEncryptionParams() { - accessConf = new EncryptionParamsBuilder(); - return accessConf; - } - - public PDFRendererConfBuilder endEncryptionParams() { - accessConf = null; - return this; - } - - public PDFRendererConfBuilder createFilterList(String type, String... filters) { - Element filterListEl = createElement(FILTER_LIST.getName()); - if (type != null) { - filterListEl.setAttribute("type", type); - } - for (String filter : filters) { - createTextElement("value", filter, filterListEl); - } - return this; - } - - public PDFRendererConfBuilder setPDFAMode(String value) { - createTextElement(PDF_A_MODE, value); - return this; - } - - public PDFRendererConfBuilder setPDFXMode(String value) { - createTextElement(PDF_X_MODE, value); - return this; - } - - public PDFRendererConfBuilder setPDFVersion(String version) { - createTextElement(VERSION, version); - return this; - } - - public PDFRendererConfBuilder setOutputProfile(String profile) { - createTextElement(OUTPUT_PROFILE, profile); - return this; - } - - public PDFRendererConfBuilder disableSRGBColorSpace(boolean disable) { - createTextElement(DISABLE_SRGB_COLORSPACE, String.valueOf(disable)); - return this; - } - - public final class EncryptionParamsBuilder { - private final Element el; - - private EncryptionParamsBuilder() { - el = createElement(ENCRYPTION_PARAMS); - } - - public EncryptionParamsBuilder setEncryptionLength(int length) { - createTextElement(ENCRYPTION_LENGTH, String.valueOf(length)); - return this; - } - - public EncryptionParamsBuilder setUserPassword(String password) { - createTextElement(USER_PASSWORD, password); - return this; - } - - public EncryptionParamsBuilder setOwnerPassword(String password) { - createTextElement(OWNER_PASSWORD, password); - return this; - } - - public EncryptionParamsBuilder setAllowParam(PDFEncryptionOption option) { - el.appendChild(createElement(option.getName())); - return this; - } - - public PDFRendererConfBuilder endEncryptionParams() { - return PDFRendererConfBuilder.this.endEncryptionParams(); - } - - private void createTextElement(RendererConfigOption name, String value) { - PDFRendererConfBuilder.this.createTextElement(name.getName(), value, el); - } - - } -} diff --git a/test/java/org/apache/fop/apps/PSRendererConfBuilder.java b/test/java/org/apache/fop/apps/PSRendererConfBuilder.java deleted file mode 100644 index 92d2ce45e..000000000 --- a/test/java/org/apache/fop/apps/PSRendererConfBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.apps; - -import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; - -import static org.apache.fop.render.ps.PSRendererOption.AUTO_ROTATE_LANDSCAPE; -import static org.apache.fop.render.ps.PSRendererOption.DSC_COMPLIANT; -import static org.apache.fop.render.ps.PSRendererOption.LANGUAGE_LEVEL; -import static org.apache.fop.render.ps.PSRendererOption.OPTIMIZE_RESOURCES; -import static org.apache.fop.render.ps.PSRendererOption.SAFE_SET_PAGE_DEVICE; - -/** - * A fop conf builder specific to a particular renderer for Postscript. - */ -public final class PSRendererConfBuilder extends RendererConfBuilder { - - public PSRendererConfBuilder() { - super(MimeConstants.MIME_POSTSCRIPT); - } - - public PSRendererConfBuilder setAutoRotateLandscape(boolean value) { - createTextElement(AUTO_ROTATE_LANDSCAPE, String.valueOf(value)); - return this; - } - - public PSRendererConfBuilder setSafeSetPageDevice(boolean value) { - createTextElement(SAFE_SET_PAGE_DEVICE, String.valueOf(value)); - return this; - } - - public PSRendererConfBuilder setDscCompliant(boolean value) { - createTextElement(DSC_COMPLIANT, String.valueOf(value)); - return this; - } - - public PSRendererConfBuilder setLanguageLevel(int value) { - createTextElement(LANGUAGE_LEVEL, String.valueOf(value)); - return this; - } - - public PSRendererConfBuilder setOptimizeResources(boolean value) { - createTextElement(OPTIMIZE_RESOURCES, String.valueOf(value)); - return this; - } -} diff --git a/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java b/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java deleted file mode 100644 index e2262017f..000000000 --- a/test/java/org/apache/fop/apps/TIFFRendererConfBuilder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.apps; - -import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererOption.COMPRESSION; -import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererOption.ENDIANNESS; -import static org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererOption.SINGLE_STRIP; -public class TIFFRendererConfBuilder extends BitmapRendererConfBuilder { - - public TIFFRendererConfBuilder() { - super(MimeConstants.MIME_TIFF); - } - - public TIFFRendererConfBuilder setCompressionMode(String mode) { - createTextElement(COMPRESSION, mode); - return this; - } - - public TIFFRendererConfBuilder setSingleStrip(boolean single) { - createTextElement(SINGLE_STRIP, String.valueOf(single)); - return this; - } - - public TIFFRendererConfBuilder setEndianness(String endianness) { - createTextElement(ENDIANNESS, endianness); - return this; - } -} diff --git a/test/java/org/apache/fop/apps/TxtRendererConfBuilder.java b/test/java/org/apache/fop/apps/TxtRendererConfBuilder.java deleted file mode 100644 index 816b59b11..000000000 --- a/test/java/org/apache/fop/apps/TxtRendererConfBuilder.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.apps; - -import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; - -import static org.apache.fop.render.txt.TxtRendererConfig.TxtRendererOption.ENCODING; - -public class TxtRendererConfBuilder extends RendererConfBuilder { - - protected TxtRendererConfBuilder() { - super(MimeConstants.MIME_PLAIN_TEXT); - } - - public TxtRendererConfBuilder setEncoding(String value) { - createTextElement(ENCODING, value); - return this; - } -} diff --git a/test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java b/test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java deleted file mode 100644 index e04283718..000000000 --- a/test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.apps.io; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXTransformerFactory; -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; - -import org.apache.xmlgraphics.io.ResourceResolver; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopConfParser; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.FopFactoryBuilder; -import org.apache.fop.apps.MimeConstants; - -import static org.apache.fop.FOPTestUtils.getBaseDir; - -public abstract class BaseURIResolutionTest { - - private final FopFactory fopFactory; - private SAXTransformerFactory tfactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); - private static final File BACKUP_DIR = new File(getBaseDir(), "build/test-results"); - - public BaseURIResolutionTest(FopFactoryBuilder builder, File foFile) throws FOPException, - TransformerException, IOException { - fopFactory = builder.build(); - createDocument(foFile); - } - - public BaseURIResolutionTest(InputStream confStream, ResourceResolver resolver, File foFile) - throws FOPException, TransformerException, SAXException, IOException { - this(new FopConfParser(confStream, getBaseDir().toURI(), resolver).getFopFactoryBuilder(), - foFile); - } - - private void createDocument(File foFile) throws TransformerException, FOPException, - IOException { - FOUserAgent ua = fopFactory.newFOUserAgent(); - - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - - Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, ua, baout); - - Transformer transformer = tfactory.newTransformer(); //Identity transf. - Source src = new StreamSource(foFile); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - - OutputStream out = new java.io.FileOutputStream( - new File(BACKUP_DIR, foFile.getName() + ".pdf")); - try { - baout.writeTo(out); - } finally { - IOUtils.closeQuietly(out); - } - - //Test using PDF as the area tree doesn't invoke Batik so we could check - //if the resolver is actually passed to Batik by FOP - assertTrue("Generated PDF has zero length", baout.size() > 0); - } - - public abstract void testAssertions(); - - static File getFODirectory() { - return new File(getBaseDir(), "test/xml/uri-testing/"); - } -} diff --git a/test/java/org/apache/fop/apps/io/FontURIResolver.java b/test/java/org/apache/fop/apps/io/FontURIResolver.java deleted file mode 100644 index 781aca368..000000000 --- a/test/java/org/apache/fop/apps/io/FontURIResolver.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.apps.io; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.transform.TransformerException; - -import org.junit.Test; -import org.xml.sax.SAXException; - -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 { - TTF, - TYPE1; - } - - private static final InputStream FOP_CONF_STREAM = new FopConfBuilder() - .setBaseURI(".") - .setFontBaseURI("fonts:///") - .useCache(false) - .startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .startFont(null, "gladiator?type=ttf") - .addTriplet("gladttf", "normal", "normal") - .endFont() - .startFont(null, "gladiator?type=type1") - .addTriplet("gladtype1", "normal", "normal") - .endFont() - .endFontConfig() - .endRendererConfig().build(); - - private static final class CustomFontURIResolver extends TestingResourceResolver { - - private final File fontsDir = new File("test/resources/fonts/ttf/"); - - public Resource getResource(URI uri) throws IOException { - if (uri.getScheme().equals("fonts") && uri.getPath().equals("/gladiator")) { - if (uri.getQuery().startsWith("type")) { - String typeArg = uri.getQuery().split("=")[1]; - if (typeArg.equals("ttf")) { - recordProperty(uri, Event.TTF); - return new Resource(new FileInputStream(new File(fontsDir, "glb12.ttf"))); - } else if (typeArg.equals("type1")) { - recordProperty(uri, Event.TYPE1); - return new Resource(new FileInputStream(new File(fontsDir, "glb12.ttf"))); - } - } - } - return null; - } - - public OutputStream getOutputStream(URI uri) throws IOException { - return null; - } - } - - private static final CustomFontURIResolver RESOLVER = new CustomFontURIResolver(); - - public FontURIResolver() throws TransformerException, SAXException, IOException { - super(FOP_CONF_STREAM, RESOLVER, new File(getFODirectory(), "font.fo")); - } - - @Test - @Override - public void testAssertions() { - Map<URI, Object> expectedEvent = new HashMap<URI, Object>(); - expectedEvent.put(URI.create("fonts:/gladiator?type=type1"), Event.TYPE1); - expectedEvent.put(URI.create("fonts:/gladiator?type=ttf"), Event.TTF); - - Map<URI, Object> propertyMap = RESOLVER.getMap(); - assertTrue(propertyMap.equals(expectedEvent)); - } - -} diff --git a/test/java/org/apache/fop/apps/io/ResourceResolverFactoryTestCase.java b/test/java/org/apache/fop/apps/io/ResourceResolverFactoryTestCase.java deleted file mode 100644 index 6ae34b4f9..000000000 --- a/test/java/org/apache/fop/apps/io/ResourceResolverFactoryTestCase.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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.apps.io; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; - -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.apache.xmlgraphics.io.Resource; -import org.apache.xmlgraphics.io.ResourceResolver; -import org.apache.xmlgraphics.io.TempResourceResolver; - -public class ResourceResolverFactoryTestCase { - - private static final byte[] DATA = new byte[]{(byte) 0, (byte) 1, (byte) 2}; - - private void writeDataTo(File f) throws IOException { - writeDataTo(new FileOutputStream(f)); - } - - private void writeDataTo(OutputStream os) throws IOException { - os.write(DATA); - os.close(); - } - - private void checkStream(InputStream inputStream) throws IOException { - byte[] actual = new byte[DATA.length]; - for (int i = 0; i < DATA.length; i++) { - actual[i] = (byte) inputStream.read(); - } - assertEquals(-1, inputStream.read()); - assertArrayEquals(DATA, actual); - } - - @Test - public void testDefaultResourceResolverGetResource() throws Exception { - ResourceResolver sut = ResourceResolverFactory.createDefaultResourceResolver(); - File inputFile = File.createTempFile("prefix", "suffix"); - InputStream is = null; - try { - writeDataTo(inputFile); - is = sut.getResource(inputFile.toURI()); - checkStream(is); - } finally { - if (is != null) { - is.close(); - } - inputFile.delete(); - } - } - - @Test - public void testDefaultResourceResolverGetOutput() throws Exception { - ResourceResolver sut = ResourceResolverFactory.createDefaultResourceResolver(); - File outputFile = File.createTempFile("prefix", "suffix"); - outputFile.deleteOnExit(); - writeDataTo(sut.getOutputStream(outputFile.toURI())); - InputStream is = new FileInputStream(outputFile); - try { - checkStream(is); - } finally { - is.close(); - } - } - - private static class TestCreateTempAwareResourceResolverHelper implements ResourceResolver { - - final TempResourceResolver tempResourceResolver = mock(TempResourceResolver.class); - - final ResourceResolver defaultResourceResolver = mock(ResourceResolver.class); - - final ResourceResolver sut = ResourceResolverFactory.createTempAwareResourceResolver( - tempResourceResolver, defaultResourceResolver); - - public Resource getResource(URI uri) throws IOException { - return sut.getResource(uri); - } - public OutputStream getOutputStream(URI uri) throws IOException { - return sut.getOutputStream(uri); - } - } - - @Test - public void testCreateTempAwareResourceResolverForTmpResource() throws Exception { - URI uri = URI.create("tmp:///id"); - TestCreateTempAwareResourceResolverHelper helper = new TestCreateTempAwareResourceResolverHelper(); - helper.getResource(uri); - verify(helper.tempResourceResolver, times(1)).getResource(uri.getPath()); - verify(helper.defaultResourceResolver, never()).getResource(uri); - } - - @Test - public void testCreateTempAwareResourceResolverForRegularResource() throws Exception { - URI uri = URI.create("file:///path/to/file"); - TestCreateTempAwareResourceResolverHelper helper = new TestCreateTempAwareResourceResolverHelper(); - helper.getResource(uri); - verify(helper.tempResourceResolver, never()).getResource(uri.getPath()); - verify(helper.defaultResourceResolver, times(1)).getResource(uri); - } - - @Test - public void testCreateTempAwareResourceResolverForTmpOuput() throws Exception { - URI uri = URI.create("tmp:///id"); - TestCreateTempAwareResourceResolverHelper helper = new TestCreateTempAwareResourceResolverHelper(); - helper.getOutputStream(uri); - verify(helper.tempResourceResolver, times(1)).getOutputStream(uri.getPath()); - verify(helper.defaultResourceResolver, never()).getOutputStream(uri); - } - - @Test - public void testCreateTempAwareResourceResolverForRegularOutput() throws Exception { - URI uri = URI.create("file:///path/to/file"); - TestCreateTempAwareResourceResolverHelper helper = new TestCreateTempAwareResourceResolverHelper(); - helper.getOutputStream(uri); - verify(helper.tempResourceResolver, never()).getOutputStream(uri.getPath()); - verify(helper.defaultResourceResolver, times(1)).getOutputStream(uri); - } - - @Test - public void testCreateSchemaAwareResourceResolverForDefaultResource() throws Exception { - URI uri = URI.create("file:///path/to/file"); - TestCreateSchemaAwareResourceResolverBuilderHelper helper - = new TestCreateSchemaAwareResourceResolverBuilderHelper(); - helper.getResource(uri); - verify(helper.registedResourceResolver, never()).getResource(uri); - verify(helper.defaultResourceResolver, times(1)).getResource(uri); - } - - @Test - public void testCreateSchemaAwareResourceResolverForRegisteredResource() throws Exception { - URI uri = URI.create(TestCreateSchemaAwareResourceResolverBuilderHelper.SCHEMA + ":///path"); - TestCreateSchemaAwareResourceResolverBuilderHelper helper - = new TestCreateSchemaAwareResourceResolverBuilderHelper(); - helper.getResource(uri); - verify(helper.registedResourceResolver, times(1)).getResource(uri); - verify(helper.defaultResourceResolver, never()).getResource(uri); - } - - @Test - public void testCreateSchemaAwareResourceResolverForDefaultOutput() throws Exception { - URI uri = URI.create("file:///path/to/file"); - TestCreateSchemaAwareResourceResolverBuilderHelper helper - = new TestCreateSchemaAwareResourceResolverBuilderHelper(); - helper.getOutputStream(uri); - verify(helper.registedResourceResolver, never()).getOutputStream(uri); - verify(helper.defaultResourceResolver, times(1)).getOutputStream(uri); - } - - @Test - public void testCreateSchemaAwareResourceResolverForRegisteredOutput() throws Exception { - URI uri = URI.create(TestCreateSchemaAwareResourceResolverBuilderHelper.SCHEMA + ":///path"); - TestCreateSchemaAwareResourceResolverBuilderHelper helper - = new TestCreateSchemaAwareResourceResolverBuilderHelper(); - helper.getOutputStream(uri); - verify(helper.registedResourceResolver, times(1)).getOutputStream(uri); - verify(helper.defaultResourceResolver, never()).getOutputStream(uri); - } - - private static class TestCreateSchemaAwareResourceResolverBuilderHelper implements ResourceResolver { - - private static final String SCHEMA = "protocol"; - - final ResourceResolver registedResourceResolver = mock(ResourceResolver.class); - - final ResourceResolver defaultResourceResolver = mock(ResourceResolver.class); - - final ResourceResolver sut; - - TestCreateSchemaAwareResourceResolverBuilderHelper() { - ResourceResolverFactory.SchemeAwareResourceResolverBuilder builder - = ResourceResolverFactory.createSchemeAwareResourceResolverBuilder( - defaultResourceResolver); - builder.registerResourceResolverForScheme(SCHEMA, registedResourceResolver); - sut = builder.build(); - - } - - public Resource getResource(URI uri) throws IOException { - return sut.getResource(uri); - } - public OutputStream getOutputStream(URI uri) throws IOException { - return sut.getOutputStream(uri); - } - } - -} - diff --git a/test/java/org/apache/fop/apps/io/TestingResourceResolver.java b/test/java/org/apache/fop/apps/io/TestingResourceResolver.java deleted file mode 100644 index f1cd06138..000000000 --- a/test/java/org/apache/fop/apps/io/TestingResourceResolver.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.apps.io; - -import java.net.URI; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.xmlgraphics.io.ResourceResolver; - -abstract class TestingResourceResolver implements ResourceResolver { - - private final Map<URI, Object> checker; - - TestingResourceResolver() { - checker = new HashMap<URI, Object>(); - } - - void recordProperty(URI uri, Object obj) { - checker.put(uri, obj); - } - - Map<URI, Object> getMap() { - return Collections.unmodifiableMap(checker); - } - -} diff --git a/test/java/org/apache/fop/apps/io/URIResolverWrapperTestCase.java b/test/java/org/apache/fop/apps/io/URIResolverWrapperTestCase.java deleted file mode 100644 index b2044e3b9..000000000 --- a/test/java/org/apache/fop/apps/io/URIResolverWrapperTestCase.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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.apps.io; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -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 static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.apache.xmlgraphics.io.ResourceResolver; - -public class URIResolverWrapperTestCase { - - private static final List<String> BASE_URIS = Collections.unmodifiableList(Arrays.asList( - new String[] { - ".", - "../", - "some/path", - "file:///absolute/file/path"} - )); - - private URI base; - - @Before - public void setup() throws URISyntaxException { - setBase("."); - } - - private void setBase(String baseStr) throws URISyntaxException { - base = new URI(baseStr); - } - - @Test - public void testResolveIn() throws Exception { - String[] uris = new String[] {".", "resource", "path/to/resource"}; - for (String base : BASE_URIS) { - setBase(base); - for (String uriStr : uris) { - URI uri = new URI(uriStr); - URI expected = resolveFromBase(uri); - test(uriStr, uri, expected); - } - } - } - - @Test - public void testResolveInBadUri() throws Exception { - String[] uris = new String[] {"path\\to\\resource", "bad resource name"}; - for (String base : BASE_URIS) { - setBase(base); - for (String uriStr : uris) { - assertBadSyntax(uriStr); - URI uri = cleanURI(uriStr); - URI expected = resolveFromBase(uri); - test(uriStr, uri, expected); - } - } - } - - @Test - public void getBaseURI() throws URISyntaxException { - assertEquals(InternalResourceResolver.getBaseURI("x/y/z/"), new URI("x/y/z/")); - assertEquals(InternalResourceResolver.getBaseURI("x/y/z"), new URI("x/y/z/")); - } - - @Test - public void cleanURI() throws URISyntaxException { - String[] uris = new String[] {".", "path/to/resource", "path\\to\\resource", - "bad resource name"}; - for (String uri : uris) { - assertEquals(InternalResourceResolver.cleanURI(uri), cleanURI(uri)); - } - assertNull(InternalResourceResolver.cleanURI(null)); - } - - private void test(String uriStr, URI uri, URI expected) throws IOException, URISyntaxException { - ResourceResolver resolver = mock(ResourceResolver.class); - InternalResourceResolver sut = new InternalResourceResolver(base, resolver); - sut.getResource(uriStr); - verify(resolver).getResource(eq(expected)); - resolver = mock(ResourceResolver.class); - sut = new InternalResourceResolver(base, resolver); - sut.getResource(uri); - verify(resolver).getResource(eq(expected)); - } - - private URI resolveFromBase(URI uri) { - return base.resolve(uri); - } - - private URI cleanURI(String raw) throws URISyntaxException { - String fixedUri = raw.replace('\\', '/'); - fixedUri = fixedUri.replace(" ", "%20"); - return new URI(fixedUri); - } - - private void assertBadSyntax(String badUri) { - try { - new URI(badUri); - fail(badUri + " is correctly formed."); - } catch (URISyntaxException e) { - // PASS - } - } -} diff --git a/test/java/org/apache/fop/area/BlockViewportTestCase.java b/test/java/org/apache/fop/area/BlockViewportTestCase.java deleted file mode 100644 index f825fdda5..000000000 --- a/test/java/org/apache/fop/area/BlockViewportTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.area; - -import org.junit.Test; - -/** - * Tests the {@linkplain BlockViewport} class. - */ -public class BlockViewportTestCase extends ViewportTest { - - @Test - public void testNonClip() throws Exception { - BlockViewport bv = new BlockViewport(); - bv.setIPD(100); - bv.setBPD(50); - checkNonClip(bv); - } - - @Test - public void testClip() throws Exception { - BlockViewport bv = new BlockViewport(); - int ipd = 100; - int bpd = 50; - bv.setIPD(ipd); - bv.setBPD(bpd); - bv.setClip(true); - checkClip(bv, ipd, bpd); - } -} diff --git a/test/java/org/apache/fop/area/RegionViewportTestCase.java b/test/java/org/apache/fop/area/RegionViewportTestCase.java deleted file mode 100644 index 638126efb..000000000 --- a/test/java/org/apache/fop/area/RegionViewportTestCase.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.area; - -import java.awt.Rectangle; -import java.awt.geom.Rectangle2D; - -import org.junit.Test; - -/** - * Tests the {@linkplain RegionViewport} class. - */ -public class RegionViewportTestCase extends ViewportTest { - - private RegionViewport createRegionViewport(int x, int y, int ipd, int bpd) { - Rectangle2D v = new Rectangle(x, y, ipd, bpd); - RegionViewport viewport = new RegionViewport(v); - viewport.setIPD(ipd); - viewport.setBPD(bpd); - return viewport; - } - - @Test - public void testNonClip() throws Exception { - RegionViewport viewport = createRegionViewport(10, 10, 100, 20); - checkNonClip(viewport); - } - - @Test - public void testClip() throws Exception { - int ipd = 150; - int bpd = 20; - RegionViewport viewport = createRegionViewport(10, 10, ipd, bpd); - viewport.setClip(true); - checkClip(viewport, ipd, bpd); - } -} diff --git a/test/java/org/apache/fop/area/TraitTestCase.java b/test/java/org/apache/fop/area/TraitTestCase.java deleted file mode 100644 index 2c77228c5..000000000 --- a/test/java/org/apache/fop/area/TraitTestCase.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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: ActiveLayouts.java 99 2008-11-24 11:06:55Z vincent $ */ - -package org.apache.fop.area; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class TraitTestCase { - - @Test - public void testImageTargetWidthAndHeight() { - int width = 2911; - int height = 1911; - Trait.Background background = new Trait.Background(); - background.setImageTargetWidth(width); - background.setImageTargetHeight(height); - assertEquals(width, background.getImageTargetWidth()); - assertEquals(height, background.getImageTargetHeight()); - assertTrue(background.toString().contains(Integer.toString(width))); - assertTrue(background.toString().contains(Integer.toString(height))); - } - -} diff --git a/test/java/org/apache/fop/area/ViewportTest.java b/test/java/org/apache/fop/area/ViewportTest.java deleted file mode 100644 index 46412c83d..000000000 --- a/test/java/org/apache/fop/area/ViewportTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.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; - -/** - * Tests implementations of the {@linkplain Viewport} interface. - */ -public abstract class ViewportTest { - - protected void checkNonClip(Viewport v) throws Exception { - assertFalse(v.hasClip()); - assertNull(v.getClipRectangle()); - } - - protected void checkClip(Viewport v, int expectedWidth, int expectedHeight) throws Exception { - assertTrue(v.hasClip()); - assertEquals(new Rectangle(0, 0, expectedWidth, expectedHeight), v.getClipRectangle()); - } -} diff --git a/test/java/org/apache/fop/area/ViewportTestSuite.java b/test/java/org/apache/fop/area/ViewportTestSuite.java deleted file mode 100644 index 891f1d081..000000000 --- a/test/java/org/apache/fop/area/ViewportTestSuite.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.area; - -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. - */ -@RunWith(Suite.class) -@SuiteClasses({ - RegionViewportTestCase.class, - BlockViewportTestCase.class, - InlineViewportTestCase.class -}) -public final class ViewportTestSuite { -} diff --git a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java deleted file mode 100644 index cba5759cf..000000000 --- a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.area.inline; - -import org.junit.Test; - -import org.apache.fop.area.ViewportTest; - -/** - * Tests the {@linkplain InlineViewport} class. - */ -public class InlineViewportTestCase extends ViewportTest { - - @Test - public void testNonClip() throws Exception { - InlineViewport v = new InlineViewport(null); - v.setIPD(50); - v.setBPD(25); - checkNonClip(v); - } - - @Test - public void testClip() throws Exception { - InlineViewport v = new InlineViewport(null); - int ipd = 50; - int bpd = 25; - v.setIPD(ipd); - v.setBPD(bpd); - v.setClip(true); - checkClip(v, ipd, bpd); - } - -} diff --git a/test/java/org/apache/fop/check/Check.java b/test/java/org/apache/fop/check/Check.java deleted file mode 100644 index ffc7e3cbc..000000000 --- a/test/java/org/apache/fop/check/Check.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.check; - -/** - * A marker interface to identify checks in XML test cases. - */ -public interface Check { - -} diff --git a/test/java/org/apache/fop/check/ChecksFactory.java b/test/java/org/apache/fop/check/ChecksFactory.java deleted file mode 100644 index d77ce422d..000000000 --- a/test/java/org/apache/fop/check/ChecksFactory.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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.check; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * A factory class for creating checks that belong to a same family. - * @param <C> a family of checks - */ -public abstract class ChecksFactory<C extends Check> { - - /** - * A factory to create a particular kind of check. - */ - protected interface CheckFactory<C> { - - /** - * Creates a {@link Check} instance from the given XML element. - * - * @param element an element representing a check - * @return the corresponding check - */ - C createCheck(Element element); - } - - private final Map<String, CheckFactory<C>> checkFactories - = new HashMap<String, CheckFactory<C>>(); - - /** Default constructor. */ - protected ChecksFactory() { } - - /** - * Registers a factory for a new kind of check. - * - * @param elementName the name of the element under which the check is identified in - * the XML test case - * @param factory the corresponding factory - */ - protected void registerCheckFactory(String elementName, CheckFactory<C> factory) { - checkFactories.put(elementName, factory); - } - - /** - * Creates a new {@link Check} instance corresponding to the given element. - * - * @param element an element in the XML test case that identifies a particular check - * @return the corresponding check - * @throws IllegalArgumentException if not check corresponding to the given element - * has been found - */ - public final C createCheck(Element element) { - String name = element.getTagName(); - CheckFactory<C> factory = checkFactories.get(name); - if (factory == null) { - throw new IllegalArgumentException("No check class found for " + name); - } else { - return factory.createCheck(element); - } - } - - public final List<C> createCheckList(Element container) { - List<C> checks = new ArrayList<C>(); - NodeList nodes = container.getChildNodes(); - for (int i = 0; i < nodes.getLength(); i++) { - Node node = nodes.item(i); - if (node instanceof Element) { - checks.add(createCheck((Element) node)); - } - } - return checks; - } -} diff --git a/test/java/org/apache/fop/check/package-info.java b/test/java/org/apache/fop/check/package-info.java deleted file mode 100644 index 5785f7a4b..000000000 --- a/test/java/org/apache/fop/check/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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$ */ - -/** - * A framework for creating checks from elements stored in an XML test case. The test case - * typically contains the XML document under test, along with a series of checks expressed - * as XML elements. - */ -package org.apache.fop.check; diff --git a/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java b/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java deleted file mode 100644 index 1be3daa84..000000000 --- a/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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: CommandLineOptions.java 1293736 2012-02-26 02:29:01Z gadams $ */ - -package org.apache.fop.cli; - -import java.io.IOException; - -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(); - private final String commandLine = "-fo examples/fo/basic/simple.fo -print"; - private String[] cmd; - private boolean parsed; - - @Before - public void setUp() throws Exception { - cmd = commandLine.split(" "); - parsed = clo.parse(cmd); - } - - @Test - public void testParse() { - assertTrue(parsed); - } - - @Test - public void testGetOutputFormat() throws FOPException { - assertEquals(clo.getOutputFormat(), "application/X-fop-print"); - } - - @Test - public void testVandVersionSwitchs() throws FOPException, IOException { - // test -v - String cl1 = "-v"; - String[] cmd1 = cl1.split(" "); - CommandLineOptions clo1 = new CommandLineOptions(); - assertTrue(!clo1.parse(cmd1)); - // test -version - String cl2 = "-version"; - String[] cmd2 = cl2.split(" "); - CommandLineOptions clo2 = new CommandLineOptions(); - assertTrue(!clo2.parse(cmd2)); - // test -v + more switches - String cl3 = "-v " + commandLine; - String[] cmd3 = cl3.split(" "); - CommandLineOptions clo3 = new CommandLineOptions(); - assertTrue(clo3.parse(cmd3)); - } -} diff --git a/test/java/org/apache/fop/complexscripts/ComplexScriptsTestSuite.java b/test/java/org/apache/fop/complexscripts/ComplexScriptsTestSuite.java deleted file mode 100644 index 1dc0610b9..000000000 --- a/test/java/org/apache/fop/complexscripts/ComplexScriptsTestSuite.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.complexscripts; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.apache.fop.complexscripts.bidi.BidiTestSuite; -import org.apache.fop.complexscripts.fonts.FontsTestSuite; -import org.apache.fop.complexscripts.scripts.ScriptsTestSuite; -import org.apache.fop.complexscripts.util.UtilTestSuite; - -/** - * Test suite for complex scripts functionality. - */ -@RunWith(Suite.class) -@SuiteClasses({ - BidiTestSuite.class, - FontsTestSuite.class, - ScriptsTestSuite.class, - UtilTestSuite.class -}) -public class ComplexScriptsTestSuite { -} diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java b/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java deleted file mode 100644 index 8ed1af217..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * 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.complexscripts.bidi; - -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> - */ -public class BidiAlgorithmTestCase { - - /** - * logging instance - */ - private static final Log log = LogFactory.getLog(BidiAlgorithmTestCase.class); - - /** - * Concatenated array of <test-set,test-sequence> tuples - * specifying which sequences are to be excluded from testing, - * where -1 for either component is a wildcard. - */ - private static final int[] EXCLUSIONS = { - // no exclusions - }; - - /** - * Concatenated array of <test-set,test-sequence> tuples - * specifying which sequences are to be included in testing, where - * -1 for either component is a wildcard. - */ - private static final int[] INCLUSIONS = { - -1, -1 // all sequences - }; - - /** - * Concatenated array of <start,end> tuples expressing ranges of - * test sets to be tested, where -1 in the end position signifies - * all remaining test sets. - */ - private static final int[] TEST_SET_RANGES = { - 0, -1 // all test sets - }; - - // instrumentation - private int includedSequences; - private int excludedSequences; - private int passedSequences; - - @Test - public void testBidiAlgorithm() throws Exception { - String ldPfx = BidiTestData.LD_PFX; - int ldCount = BidiTestData.LD_CNT; - for (int i = 0; i < ldCount; i++) { - int[] da = BidiTestData.readTestData(ldPfx, i); - if (da != null) { - testBidiAlgorithm(i, da); - } else { - fail("unable to read bidi test data for resource at index " + i); - } - } - // ensure we passed all test sequences - assertEquals("did not pass all test sequences", BidiTestData.NUM_TEST_SEQUENCES, passedSequences); - if (log.isDebugEnabled()) { - log.debug("Included Sequences : " + includedSequences); - log.debug("Excluded Sequences : " + excludedSequences); - log.debug("Passed Sequences : " + passedSequences); - } - } - - private void testBidiAlgorithm(int testSet, int[] da) throws Exception { - if (da.length < 1) { - fail("test data is empty"); - } else if (da.length < ((da[0] * 2) + 1)) { - fail("test data is truncated"); - } else { - int k = 0; - // extract level count - int n = da[k++]; - // extract level array - int[] la = new int [ n ]; - for (int i = 0; i < n; i++) { - la[i] = da[k++]; - } - // extract reorder array - int[] ra = new int [ n ]; - for (int i = 0; i < n; i++) { - ra[i] = da[k++]; - } - // extract and test each test sequence - int testSequence = 0; - int[] ta = new int [ n ]; - while ((k + (1 + n)) <= da.length) { - int bs = da[k++]; - for (int i = 0; i < n; i++) { - ta[i] = da[k++]; - } - if (includeSequence(testSet, testSequence)) { - includedSequences++; - if (!excludeSequence(testSet, testSequence)) { - if (testBidiAlgorithm(testSet, testSequence, la, ra, ta, bs)) { - passedSequences++; - } - } else { - excludedSequences++; - } - } - testSequence++; - } - // ensure we exhausted test data - assertEquals("extraneous test data", da.length, k); - } - } - - private boolean includeTestSet(int testSet) { - for (int i = 0, n = TEST_SET_RANGES.length / 2; i < n; i++) { - int s = TEST_SET_RANGES [ (i * 2) + 0 ]; - int e = TEST_SET_RANGES [ (i * 2) + 1 ]; - if (testSet >= s) { - if ((e < 0) || (testSet <= e)) { - return true; - } - } - } - return false; - } - - private boolean includeSequence(int testSet, int testSequence) { - if (!includeTestSet(testSet)) { - return false; - } else { - for (int i = 0, n = INCLUSIONS.length / 2; i < n; i++) { - int setno = INCLUSIONS [ (i * 2) + 0 ]; - int seqno = INCLUSIONS [ (i * 2) + 1 ]; - if (setno < 0) { - if (seqno < 0) { - return true; - } else if (seqno == testSequence) { - return true; - } - } else if (setno == testSet) { - if (seqno < 0) { - return true; - } else if (seqno == testSequence) { - return true; - } - } - } - return false; - } - } - - private boolean excludeSequence(int testSet, int testSequence) { - for (int i = 0, n = EXCLUSIONS.length / 2; i < n; i++) { - int setno = EXCLUSIONS [ (i * 2) + 0 ]; - int seqno = EXCLUSIONS [ (i * 2) + 1 ]; - if (setno < 0) { - if (seqno < 0) { - return true; - } else if (seqno == testSequence) { - return true; - } - } else if (setno == testSet) { - if (seqno < 0) { - return true; - } else if (seqno == testSequence) { - return true; - } - } - } - return false; - } - - 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) { - fail("bad reorder array length, expected " + n + ", got " + ra.length); - } else if (ta.length != n) { - fail("bad test array length, expected " + n + ", got " + ta.length); - } else { - // auto-LTR - if ((bs & 1) != 0) { - // auto-LTR is performed at higher level - } - // LTR - if ((bs & 2) != 0) { - int[] levels = UnicodeBidiAlgorithm.resolveLevels(null, ta, 0, new int [ n ], true); - 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)) { - passed = false; - } - } - } - return passed; - } - - private boolean verifyResults(int[] laExp, int[] laOut, int[] ta, int dl, int testSet, int testSequence) { - if (laOut.length != laExp.length) { - fail("output levels array length mismatch, expected " + laExp.length + ", got " + laOut.length); - return false; - } else { - int numMatch = 0; - for (int i = 0, n = laExp.length; i < n; i++) { - if (laExp[i] >= 0) { - int lo = laOut[i]; - int le = laExp[i]; - if (lo != le) { - assertEquals(getMismatchMessage(testSet, testSequence, i, dl), le, lo); - } else { - numMatch++; - } - } else { - numMatch++; - } - } - return numMatch == laExp.length; - } - } - - private String getMismatchMessage(int testSet, int testSequence, int seqIndex, int defaultLevel) { - StringBuffer sb = new StringBuffer(); - sb.append("level mismatch for default level "); - sb.append(defaultLevel); - sb.append(" at sequence index "); - sb.append(seqIndex); - sb.append(" in test sequence "); - sb.append(testSequence); - sb.append(" of test set "); - sb.append(testSet); - return sb.toString(); - } - -} diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java b/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java deleted file mode 100644 index f393e5b70..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.complexscripts.bidi; - -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 - public void testBidiClasses() throws Exception { - String tdPfx = BidiTestData.TD_PFX; - int tdCount = BidiTestData.TD_CNT; - for (int i = 0; i < tdCount; i++) { - int[] da = BidiTestData.readTestData(tdPfx, i); - if (da != null) { - testBidiClass(da); - } else { - fail("unable to read bidi test data for resource at index " + i); - } - } - } - - 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]; - 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$LD0.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD0.ser Binary files differdeleted file mode 100644 index 6eccb4b6f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD0.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD1.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD1.ser Binary files differdeleted file mode 100644 index 8a7a802d2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD1.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD10.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD10.ser Binary files differdeleted file mode 100644 index 74a52f212..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD10.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD100.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD100.ser Binary files differdeleted file mode 100644 index 4058da121..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD100.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD101.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD101.ser Binary files differdeleted file mode 100644 index 321ed2682..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD101.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD102.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD102.ser Binary files differdeleted file mode 100644 index f5e3973dd..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD102.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD103.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD103.ser Binary files differdeleted file mode 100644 index 0235952c9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD103.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD104.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD104.ser Binary files differdeleted file mode 100644 index 00d9ff6b4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD104.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD105.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD105.ser Binary files differdeleted file mode 100644 index b924c8d19..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD105.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD106.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD106.ser Binary files differdeleted file mode 100644 index 2cdabbf17..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD106.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD107.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD107.ser Binary files differdeleted file mode 100644 index 24e41ceab..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD107.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD108.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD108.ser Binary files differdeleted file mode 100644 index 8c9d014f2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD108.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD109.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD109.ser Binary files differdeleted file mode 100644 index fc2fc255e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD109.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD11.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD11.ser Binary files differdeleted file mode 100644 index 2a40fe758..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD11.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD110.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD110.ser Binary files differdeleted file mode 100644 index 89ef3a341..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD110.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD111.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD111.ser Binary files differdeleted file mode 100644 index 0691f5f96..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD111.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD112.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD112.ser Binary files differdeleted file mode 100644 index c3bd6103e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD112.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD113.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD113.ser Binary files differdeleted file mode 100644 index 54d27e213..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD113.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD114.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD114.ser Binary files differdeleted file mode 100644 index 0ba52993a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD114.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD115.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD115.ser Binary files differdeleted file mode 100644 index 0b95e6283..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD115.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD116.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD116.ser Binary files differdeleted file mode 100644 index ca1111447..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD116.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD117.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD117.ser Binary files differdeleted file mode 100644 index fbce0f949..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD117.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD118.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD118.ser Binary files differdeleted file mode 100644 index c7bee5162..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD118.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD119.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD119.ser Binary files differdeleted file mode 100644 index 83ad166ef..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD119.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD12.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD12.ser Binary files differdeleted file mode 100644 index 81ff5dcbd..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD12.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD120.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD120.ser Binary files differdeleted file mode 100644 index 2a84369ef..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD120.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD121.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD121.ser Binary files differdeleted file mode 100644 index 3c3f08edf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD121.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD122.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD122.ser Binary files differdeleted file mode 100644 index 81a342bc0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD122.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD123.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD123.ser Binary files differdeleted file mode 100644 index f2fdba316..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD123.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD124.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD124.ser Binary files differdeleted file mode 100644 index 5bebb054f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD124.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD125.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD125.ser Binary files differdeleted file mode 100644 index 1292a8a01..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD125.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD126.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD126.ser Binary files differdeleted file mode 100644 index f7c910fb0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD126.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD127.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD127.ser Binary files differdeleted file mode 100644 index bb2d2353a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD127.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD128.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD128.ser Binary files differdeleted file mode 100644 index 4ef886527..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD128.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD129.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD129.ser Binary files differdeleted file mode 100644 index 7538307f8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD129.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD13.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD13.ser Binary files differdeleted file mode 100644 index 5a81f8f76..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD13.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD130.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD130.ser Binary files differdeleted file mode 100644 index dfa56bb42..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD130.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD131.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD131.ser Binary files differdeleted file mode 100644 index 04c0e6b02..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD131.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD132.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD132.ser Binary files differdeleted file mode 100644 index 5389ec53c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD132.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD133.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD133.ser Binary files differdeleted file mode 100644 index 6ec49f1c7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD133.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD134.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD134.ser Binary files differdeleted file mode 100644 index 381b6b741..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD134.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD135.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD135.ser Binary files differdeleted file mode 100644 index e991a278f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD135.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD136.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD136.ser Binary files differdeleted file mode 100644 index 84eb27fa3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD136.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD137.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD137.ser Binary files differdeleted file mode 100644 index 3e3ceb4f0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD137.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD138.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD138.ser Binary files differdeleted file mode 100644 index 52f01ebbf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD138.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD139.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD139.ser Binary files differdeleted file mode 100644 index 54a66ac43..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD139.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD14.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD14.ser Binary files differdeleted file mode 100644 index 5bad9fe23..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD14.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD140.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD140.ser Binary files differdeleted file mode 100644 index 7e58aea97..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD140.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD141.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD141.ser Binary files differdeleted file mode 100644 index 60811580c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD141.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD142.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD142.ser Binary files differdeleted file mode 100644 index bfa39bf75..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD142.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD143.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD143.ser Binary files differdeleted file mode 100644 index 5df598aa7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD143.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD144.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD144.ser Binary files differdeleted file mode 100644 index f46f6a289..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD144.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD145.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD145.ser Binary files differdeleted file mode 100644 index 825930ea8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD145.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD146.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD146.ser Binary files differdeleted file mode 100644 index 3d2efe600..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD146.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD147.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD147.ser Binary files differdeleted file mode 100644 index 5e3667df8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD147.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD148.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD148.ser Binary files differdeleted file mode 100644 index 4a04343a5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD148.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD149.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD149.ser Binary files differdeleted file mode 100644 index 85260e0f8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD149.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD15.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD15.ser Binary files differdeleted file mode 100644 index c1cb2878d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD15.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD150.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD150.ser Binary files differdeleted file mode 100644 index ab5dd0c00..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD150.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD151.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD151.ser Binary files differdeleted file mode 100644 index df304a84b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD151.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD152.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD152.ser Binary files differdeleted file mode 100644 index 887699163..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD152.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD153.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD153.ser Binary files differdeleted file mode 100644 index fa70ead76..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD153.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD154.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD154.ser Binary files differdeleted file mode 100644 index 73402d898..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD154.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD155.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD155.ser Binary files differdeleted file mode 100644 index c611d952e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD155.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD156.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD156.ser Binary files differdeleted file mode 100644 index a5a70cf81..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD156.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD157.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD157.ser Binary files differdeleted file mode 100644 index 736576c15..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD157.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD158.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD158.ser Binary files differdeleted file mode 100644 index 4667a5a4a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD158.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD159.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD159.ser Binary files differdeleted file mode 100644 index 9a07236c3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD159.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD16.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD16.ser Binary files differdeleted file mode 100644 index 6a8e667fb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD16.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD160.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD160.ser Binary files differdeleted file mode 100644 index abfeac3ec..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD160.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD161.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD161.ser Binary files differdeleted file mode 100644 index 1b225c825..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD161.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD162.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD162.ser Binary files differdeleted file mode 100644 index 36aab1fd1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD162.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD163.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD163.ser Binary files differdeleted file mode 100644 index 77a744263..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD163.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD164.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD164.ser Binary files differdeleted file mode 100644 index 6f340e971..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD164.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD165.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD165.ser Binary files differdeleted file mode 100644 index 92ab48e50..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD165.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD166.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD166.ser Binary files differdeleted file mode 100644 index 412885433..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD166.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD167.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD167.ser Binary files differdeleted file mode 100644 index 3b4b83607..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD167.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD168.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD168.ser Binary files differdeleted file mode 100644 index 3e04f60f7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD168.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD169.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD169.ser Binary files differdeleted file mode 100644 index 5e58d00f8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD169.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD17.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD17.ser Binary files differdeleted file mode 100644 index 290d0e5b4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD17.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD170.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD170.ser Binary files differdeleted file mode 100644 index fb1f6b7ae..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD170.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD171.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD171.ser Binary files differdeleted file mode 100644 index 7ba80984d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD171.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD172.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD172.ser Binary files differdeleted file mode 100644 index 594645bdc..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD172.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD173.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD173.ser Binary files differdeleted file mode 100644 index 5d995d076..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD173.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD174.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD174.ser Binary files differdeleted file mode 100644 index e57c46d8e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD174.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD175.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD175.ser Binary files differdeleted file mode 100644 index ad4317529..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD175.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD176.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD176.ser Binary files differdeleted file mode 100644 index 52cdcd567..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD176.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD177.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD177.ser Binary files differdeleted file mode 100644 index e786ab17e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD177.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD178.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD178.ser Binary files differdeleted file mode 100644 index 2f9e41f08..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD178.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD179.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD179.ser Binary files differdeleted file mode 100644 index 94f739223..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD179.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD18.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD18.ser Binary files differdeleted file mode 100644 index 53073211e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD18.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD180.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD180.ser Binary files differdeleted file mode 100644 index 172498f80..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD180.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD181.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD181.ser Binary files differdeleted file mode 100644 index c5a9b434d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD181.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD182.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD182.ser Binary files differdeleted file mode 100644 index 1c98e34a4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD182.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD183.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD183.ser Binary files differdeleted file mode 100644 index 4e8c8e30c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD183.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD184.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD184.ser Binary files differdeleted file mode 100644 index 824fad23d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD184.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD185.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD185.ser Binary files differdeleted file mode 100644 index 969e34a37..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD185.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD186.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD186.ser Binary files differdeleted file mode 100644 index 0867d2e55..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD186.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD187.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD187.ser Binary files differdeleted file mode 100644 index dd052d7a1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD187.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD188.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD188.ser Binary files differdeleted file mode 100644 index d52c97d1d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD188.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD189.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD189.ser Binary files differdeleted file mode 100644 index 2bdb9dab4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD189.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD19.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD19.ser Binary files differdeleted file mode 100644 index 21128bf86..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD19.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD190.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD190.ser Binary files differdeleted file mode 100644 index d153d3442..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD190.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD191.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD191.ser Binary files differdeleted file mode 100644 index 5019d6fea..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD191.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD192.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD192.ser Binary files differdeleted file mode 100644 index e726e2651..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD192.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD193.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD193.ser Binary files differdeleted file mode 100644 index c37e1cdd0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD193.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD194.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD194.ser Binary files differdeleted file mode 100644 index 1ba7b2877..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD194.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD195.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD195.ser Binary files differdeleted file mode 100644 index 62215ed07..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD195.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD196.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD196.ser Binary files differdeleted file mode 100644 index 709279994..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD196.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD197.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD197.ser Binary files differdeleted file mode 100644 index 788ac372f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD197.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD198.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD198.ser Binary files differdeleted file mode 100644 index 9d4a14249..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD198.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD199.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD199.ser Binary files differdeleted file mode 100644 index 6cbb79535..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD199.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD2.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD2.ser Binary files differdeleted file mode 100644 index 05cf07859..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD2.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD20.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD20.ser Binary files differdeleted file mode 100644 index 9c10e367c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD20.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD200.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD200.ser Binary files differdeleted file mode 100644 index 583084f0b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD200.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD201.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD201.ser Binary files differdeleted file mode 100644 index d8ed032c6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD201.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD202.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD202.ser Binary files differdeleted file mode 100644 index 21e97fff0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD202.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD203.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD203.ser Binary files differdeleted file mode 100644 index 5e3e01293..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD203.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD204.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD204.ser Binary files differdeleted file mode 100644 index eba9874c5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD204.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD205.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD205.ser Binary files differdeleted file mode 100644 index 182c5fc35..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD205.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD206.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD206.ser Binary files differdeleted file mode 100644 index 47ed04ba6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD206.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD207.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD207.ser Binary files differdeleted file mode 100644 index b56f3ee7c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD207.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD208.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD208.ser Binary files differdeleted file mode 100644 index 302b20c39..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD208.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD209.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD209.ser Binary files differdeleted file mode 100644 index c97cbbe12..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD209.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD21.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD21.ser Binary files differdeleted file mode 100644 index e7eb886be..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD21.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD210.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD210.ser Binary files differdeleted file mode 100644 index 4da33f6c0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD210.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD211.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD211.ser Binary files differdeleted file mode 100644 index 46f29b71a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD211.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD212.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD212.ser Binary files differdeleted file mode 100644 index b84d2efaa..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD212.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD213.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD213.ser Binary files differdeleted file mode 100644 index 2d0995a6f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD213.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD214.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD214.ser Binary files differdeleted file mode 100644 index 66a505aae..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD214.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD215.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD215.ser Binary files differdeleted file mode 100644 index cbd99924e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD215.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD216.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD216.ser Binary files differdeleted file mode 100644 index 46b5315a0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD216.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD217.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD217.ser Binary files differdeleted file mode 100644 index 4afc67dbc..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD217.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD218.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD218.ser Binary files differdeleted file mode 100644 index 992177ded..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD218.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD219.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD219.ser Binary files differdeleted file mode 100644 index e75b1d344..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD219.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD22.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD22.ser Binary files differdeleted file mode 100644 index ca7478b6c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD22.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD220.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD220.ser Binary files differdeleted file mode 100644 index 3f754847c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD220.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD221.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD221.ser Binary files differdeleted file mode 100644 index 02efa8786..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD221.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD222.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD222.ser Binary files differdeleted file mode 100644 index 1897b09f8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD222.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD223.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD223.ser Binary files differdeleted file mode 100644 index cd24d1101..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD223.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD224.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD224.ser Binary files differdeleted file mode 100644 index aba011dba..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD224.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD225.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD225.ser Binary files differdeleted file mode 100644 index dad463960..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD225.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD226.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD226.ser Binary files differdeleted file mode 100644 index 6430967e4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD226.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD227.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD227.ser Binary files differdeleted file mode 100644 index 4f2bde014..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD227.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD228.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD228.ser Binary files differdeleted file mode 100644 index 7be09ec92..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD228.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD229.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD229.ser Binary files differdeleted file mode 100644 index 6ffa285db..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD229.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD23.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD23.ser Binary files differdeleted file mode 100644 index d6c532596..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD23.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD230.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD230.ser Binary files differdeleted file mode 100644 index 3519adb5e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD230.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD231.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD231.ser Binary files differdeleted file mode 100644 index 7540663aa..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD231.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD232.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD232.ser Binary files differdeleted file mode 100644 index 788e4c7e1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD232.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD233.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD233.ser Binary files differdeleted file mode 100644 index c36265614..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD233.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD234.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD234.ser Binary files differdeleted file mode 100644 index 772b72aef..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD234.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD235.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD235.ser Binary files differdeleted file mode 100644 index e5fa50b85..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD235.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD236.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD236.ser Binary files differdeleted file mode 100644 index 13fdb364c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD236.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD237.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD237.ser Binary files differdeleted file mode 100644 index c600524d6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD237.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD238.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD238.ser Binary files differdeleted file mode 100644 index 6043e0155..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD238.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD239.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD239.ser Binary files differdeleted file mode 100644 index 14250a315..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD239.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD24.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD24.ser Binary files differdeleted file mode 100644 index 209e8179e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD24.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD240.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD240.ser Binary files differdeleted file mode 100644 index bdbc02f69..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD240.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD241.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD241.ser Binary files differdeleted file mode 100644 index d3f40a8de..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD241.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD242.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD242.ser Binary files differdeleted file mode 100644 index 03b94bc76..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD242.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD243.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD243.ser Binary files differdeleted file mode 100644 index cb0321933..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD243.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD244.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD244.ser Binary files differdeleted file mode 100644 index 3cdc87c9c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD244.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD245.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD245.ser Binary files differdeleted file mode 100644 index 7c50f1284..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD245.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD246.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD246.ser Binary files differdeleted file mode 100644 index b04164e4c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD246.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD247.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD247.ser Binary files differdeleted file mode 100644 index bdce40f9c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD247.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD248.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD248.ser Binary files differdeleted file mode 100644 index e50ed7988..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD248.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD249.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD249.ser Binary files differdeleted file mode 100644 index 14ac62043..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD249.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD25.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD25.ser Binary files differdeleted file mode 100644 index c1b31fcce..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD25.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD250.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD250.ser Binary files differdeleted file mode 100644 index d96343972..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD250.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD251.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD251.ser Binary files differdeleted file mode 100644 index 7b3168b23..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD251.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD252.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD252.ser Binary files differdeleted file mode 100644 index 7f9b9056d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD252.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD253.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD253.ser Binary files differdeleted file mode 100644 index d5849ec9d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD253.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD254.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD254.ser Binary files differdeleted file mode 100644 index 00a2b4a0e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD254.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD255.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD255.ser Binary files differdeleted file mode 100644 index 5cc330f12..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD255.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD256.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD256.ser Binary files differdeleted file mode 100644 index 23e032ac9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD256.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD257.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD257.ser Binary files differdeleted file mode 100644 index 7ba16c21a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD257.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD258.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD258.ser Binary files differdeleted file mode 100644 index 334737ecd..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD258.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD259.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD259.ser Binary files differdeleted file mode 100644 index 26defabff..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD259.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD26.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD26.ser Binary files differdeleted file mode 100644 index 09dc4ca08..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD26.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD260.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD260.ser Binary files differdeleted file mode 100644 index 03cb82426..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD260.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD261.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD261.ser Binary files differdeleted file mode 100644 index 6d00960cf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD261.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD262.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD262.ser Binary files differdeleted file mode 100644 index 920e4c5b1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD262.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD263.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD263.ser Binary files differdeleted file mode 100644 index dbbee5d7f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD263.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD264.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD264.ser Binary files differdeleted file mode 100644 index 716661a75..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD264.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD265.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD265.ser Binary files differdeleted file mode 100644 index b418d9b9f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD265.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD266.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD266.ser Binary files differdeleted file mode 100644 index bc16ddcff..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD266.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD267.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD267.ser Binary files differdeleted file mode 100644 index a105347f0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD267.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD268.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD268.ser Binary files differdeleted file mode 100644 index f75552dc3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD268.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD269.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD269.ser Binary files differdeleted file mode 100644 index a3f6eab8f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD269.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD27.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD27.ser Binary files differdeleted file mode 100644 index 604170dcc..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD27.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD270.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD270.ser Binary files differdeleted file mode 100644 index 755d6cd60..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD270.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD271.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD271.ser Binary files differdeleted file mode 100644 index 9b29a7d1e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD271.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD272.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD272.ser Binary files differdeleted file mode 100644 index 5685e40b8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD272.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD273.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD273.ser Binary files differdeleted file mode 100644 index 49a7c0739..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD273.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD274.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD274.ser Binary files differdeleted file mode 100644 index 1697a421b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD274.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD275.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD275.ser Binary files differdeleted file mode 100644 index ea0d9adf1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD275.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD276.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD276.ser Binary files differdeleted file mode 100644 index 067dca228..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD276.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD277.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD277.ser Binary files differdeleted file mode 100644 index 9f9078678..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD277.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD278.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD278.ser Binary files differdeleted file mode 100644 index 9cd498c3c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD278.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD279.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD279.ser Binary files differdeleted file mode 100644 index c5c4c6ab0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD279.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD28.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD28.ser Binary files differdeleted file mode 100644 index 890ce30bb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD28.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD280.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD280.ser Binary files differdeleted file mode 100644 index fac475452..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD280.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD281.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD281.ser Binary files differdeleted file mode 100644 index 4711e4586..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD281.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD282.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD282.ser Binary files differdeleted file mode 100644 index 1fcea5dbf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD282.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD283.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD283.ser Binary files differdeleted file mode 100644 index bf2a0bcc5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD283.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD284.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD284.ser Binary files differdeleted file mode 100644 index 29a3c23d4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD284.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD285.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD285.ser Binary files differdeleted file mode 100644 index fea28c7d2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD285.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD286.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD286.ser Binary files differdeleted file mode 100644 index 48663053e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD286.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD287.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD287.ser Binary files differdeleted file mode 100644 index 43f440cf7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD287.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD288.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD288.ser Binary files differdeleted file mode 100644 index 385ac7184..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD288.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD289.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD289.ser Binary files differdeleted file mode 100644 index 8a032f261..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD289.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD29.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD29.ser Binary files differdeleted file mode 100644 index fdc27290b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD29.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD290.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD290.ser Binary files differdeleted file mode 100644 index 264c28e08..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD290.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD291.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD291.ser Binary files differdeleted file mode 100644 index daf236abf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD291.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD292.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD292.ser Binary files differdeleted file mode 100644 index 8f972bf5a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD292.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD293.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD293.ser Binary files differdeleted file mode 100644 index 647424ee0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD293.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD294.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD294.ser Binary files differdeleted file mode 100644 index 9e8b99773..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD294.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD295.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD295.ser Binary files differdeleted file mode 100644 index 486bcf475..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD295.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD296.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD296.ser Binary files differdeleted file mode 100644 index 856d72fd1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD296.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD297.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD297.ser Binary files differdeleted file mode 100644 index ce0b5bf4c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD297.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD298.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD298.ser Binary files differdeleted file mode 100644 index cad0d5049..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD298.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD299.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD299.ser Binary files differdeleted file mode 100644 index b14aa4597..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD299.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD3.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD3.ser Binary files differdeleted file mode 100644 index 6657a3593..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD3.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD30.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD30.ser Binary files differdeleted file mode 100644 index b30faf809..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD30.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD300.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD300.ser Binary files differdeleted file mode 100644 index 4baca2704..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD300.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD301.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD301.ser Binary files differdeleted file mode 100644 index 630a13467..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD301.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD302.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD302.ser Binary files differdeleted file mode 100644 index 0f8e3d7d8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD302.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD303.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD303.ser Binary files differdeleted file mode 100644 index 42a05ced7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD303.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD304.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD304.ser Binary files differdeleted file mode 100644 index 13ba94a7e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD304.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD305.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD305.ser Binary files differdeleted file mode 100644 index e5a3a925e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD305.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD306.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD306.ser Binary files differdeleted file mode 100644 index 1ada57413..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD306.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD307.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD307.ser Binary files differdeleted file mode 100644 index a14a0bebf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD307.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD308.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD308.ser Binary files differdeleted file mode 100644 index c66ae933f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD308.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD309.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD309.ser Binary files differdeleted file mode 100644 index fd1e62ca8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD309.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD31.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD31.ser Binary files differdeleted file mode 100644 index 4914c3b65..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD31.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD310.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD310.ser Binary files differdeleted file mode 100644 index e8aad8cad..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD310.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD311.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD311.ser Binary files differdeleted file mode 100644 index 0d8f4cf1e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD311.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD312.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD312.ser Binary files differdeleted file mode 100644 index 54d856156..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD312.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD313.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD313.ser Binary files differdeleted file mode 100644 index 5bd0e8286..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD313.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD314.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD314.ser Binary files differdeleted file mode 100644 index 37a4d8c68..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD314.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD315.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD315.ser Binary files differdeleted file mode 100644 index a16a7b8f9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD315.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD316.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD316.ser Binary files differdeleted file mode 100644 index 6e5747ed9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD316.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD317.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD317.ser Binary files differdeleted file mode 100644 index 3ee6650ed..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD317.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD318.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD318.ser Binary files differdeleted file mode 100644 index 8c6f200a2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD318.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD319.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD319.ser Binary files differdeleted file mode 100644 index 4774611b5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD319.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD32.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD32.ser Binary files differdeleted file mode 100644 index 09332a05e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD32.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD320.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD320.ser Binary files differdeleted file mode 100644 index 88327e077..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD320.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD321.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD321.ser Binary files differdeleted file mode 100644 index 600eb2ac3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD321.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD322.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD322.ser Binary files differdeleted file mode 100644 index eed01d875..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD322.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD323.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD323.ser Binary files differdeleted file mode 100644 index cc2db9896..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD323.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD324.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD324.ser Binary files differdeleted file mode 100644 index d0ae70999..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD324.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD325.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD325.ser Binary files differdeleted file mode 100644 index eb2a30d19..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD325.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD326.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD326.ser Binary files differdeleted file mode 100644 index 5825c9571..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD326.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD327.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD327.ser Binary files differdeleted file mode 100644 index c1b927a19..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD327.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD328.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD328.ser Binary files differdeleted file mode 100644 index 5d7eb7f7e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD328.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD329.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD329.ser Binary files differdeleted file mode 100644 index a78094615..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD329.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD33.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD33.ser Binary files differdeleted file mode 100644 index efb28b562..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD33.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD330.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD330.ser Binary files differdeleted file mode 100644 index 686c66e20..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD330.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD331.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD331.ser Binary files differdeleted file mode 100644 index b210f7896..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD331.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD332.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD332.ser Binary files differdeleted file mode 100644 index da93f81fc..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD332.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD333.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD333.ser Binary files differdeleted file mode 100644 index 8a0f567f1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD333.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD334.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD334.ser Binary files differdeleted file mode 100644 index 622bdd1e1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD334.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD335.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD335.ser Binary files differdeleted file mode 100644 index 4baa13941..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD335.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD336.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD336.ser Binary files differdeleted file mode 100644 index 1d40b0818..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD336.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD337.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD337.ser Binary files differdeleted file mode 100644 index ef0b76e42..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD337.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD338.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD338.ser Binary files differdeleted file mode 100644 index bd0a0456f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD338.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD339.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD339.ser Binary files differdeleted file mode 100644 index 73ee20cbe..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD339.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD34.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD34.ser Binary files differdeleted file mode 100644 index 9e33d39e9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD34.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD340.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD340.ser Binary files differdeleted file mode 100644 index 6afa6bf7c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD340.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD341.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD341.ser Binary files differdeleted file mode 100644 index 84782b980..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD341.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD342.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD342.ser Binary files differdeleted file mode 100644 index fdde6d7a5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD342.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD343.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD343.ser Binary files differdeleted file mode 100644 index 2654a884a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD343.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD344.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD344.ser Binary files differdeleted file mode 100644 index b24a2a444..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD344.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD345.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD345.ser Binary files differdeleted file mode 100644 index 613d80bee..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD345.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD346.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD346.ser Binary files differdeleted file mode 100644 index df1df5fbf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD346.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD347.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD347.ser Binary files differdeleted file mode 100644 index 3f68bd344..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD347.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD348.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD348.ser Binary files differdeleted file mode 100644 index 361734a3c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD348.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD349.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD349.ser Binary files differdeleted file mode 100644 index 009e2419c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD349.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD35.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD35.ser Binary files differdeleted file mode 100644 index 7c142c3e3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD35.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD350.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD350.ser Binary files differdeleted file mode 100644 index 6e14a51a4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD350.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD351.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD351.ser Binary files differdeleted file mode 100644 index ed8f2450d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD351.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD352.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD352.ser Binary files differdeleted file mode 100644 index 80489aa41..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD352.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD353.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD353.ser Binary files differdeleted file mode 100644 index ede61bef1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD353.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD354.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD354.ser Binary files differdeleted file mode 100644 index e837ec5a6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD354.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD355.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD355.ser Binary files differdeleted file mode 100644 index 0dbeb4a18..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD355.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD356.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD356.ser Binary files differdeleted file mode 100644 index fdbc6a8f2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD356.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD357.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD357.ser Binary files differdeleted file mode 100644 index 47665da0c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD357.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD358.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD358.ser Binary files differdeleted file mode 100644 index aae718782..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD358.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD359.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD359.ser Binary files differdeleted file mode 100644 index 5bc6e4083..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD359.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD36.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD36.ser Binary files differdeleted file mode 100644 index 07d3b8d15..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD36.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD360.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD360.ser Binary files differdeleted file mode 100644 index 81af1c964..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD360.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD361.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD361.ser Binary files differdeleted file mode 100644 index 4abfa7c14..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD361.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD362.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD362.ser Binary files differdeleted file mode 100644 index aec3af860..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD362.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD363.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD363.ser Binary files differdeleted file mode 100644 index ac1eecb96..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD363.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD364.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD364.ser Binary files differdeleted file mode 100644 index 1f1367be6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD364.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD365.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD365.ser Binary files differdeleted file mode 100644 index 3cf337cda..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD365.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD366.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD366.ser Binary files differdeleted file mode 100644 index 19f7fd9e9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD366.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD367.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD367.ser Binary files differdeleted file mode 100644 index 8c92df043..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD367.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD368.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD368.ser Binary files differdeleted file mode 100644 index dad7f014b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD368.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD369.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD369.ser Binary files differdeleted file mode 100644 index b0022c672..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD369.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD37.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD37.ser Binary files differdeleted file mode 100644 index bfbb586fb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD37.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD370.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD370.ser Binary files differdeleted file mode 100644 index b435feea0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD370.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD371.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD371.ser Binary files differdeleted file mode 100644 index dafe64d04..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD371.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD372.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD372.ser Binary files differdeleted file mode 100644 index 973fcdc92..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD372.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD373.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD373.ser Binary files differdeleted file mode 100644 index a49d73cfe..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD373.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD374.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD374.ser Binary files differdeleted file mode 100644 index 892a50d1b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD374.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD375.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD375.ser Binary files differdeleted file mode 100644 index 0fa29c84b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD375.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD376.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD376.ser Binary files differdeleted file mode 100644 index a29b52179..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD376.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD377.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD377.ser Binary files differdeleted file mode 100644 index e7c2a5a36..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD377.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD378.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD378.ser Binary files differdeleted file mode 100644 index 0ec361014..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD378.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD379.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD379.ser Binary files differdeleted file mode 100644 index bca795879..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD379.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD38.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD38.ser Binary files differdeleted file mode 100644 index 49ca3d106..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD38.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD380.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD380.ser Binary files differdeleted file mode 100644 index 0a340e65e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD380.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD381.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD381.ser Binary files differdeleted file mode 100644 index 2e73aff87..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD381.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD382.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD382.ser Binary files differdeleted file mode 100644 index d3a437077..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD382.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD383.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD383.ser Binary files differdeleted file mode 100644 index 963e0a877..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD383.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD384.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD384.ser Binary files differdeleted file mode 100644 index 092300f46..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD384.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD385.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD385.ser Binary files differdeleted file mode 100644 index 0c4c00312..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD385.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD386.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD386.ser Binary files differdeleted file mode 100644 index 9abf70ed9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD386.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD387.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD387.ser Binary files differdeleted file mode 100644 index 7e518db09..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD387.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD388.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD388.ser Binary files differdeleted file mode 100644 index 797d08f9c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD388.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD389.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD389.ser Binary files differdeleted file mode 100644 index 672e36e4a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD389.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD39.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD39.ser Binary files differdeleted file mode 100644 index de9d5aadb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD39.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD390.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD390.ser Binary files differdeleted file mode 100644 index 44c076196..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD390.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD391.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD391.ser Binary files differdeleted file mode 100644 index 2706725f7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD391.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD392.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD392.ser Binary files differdeleted file mode 100644 index 1cc61a4ed..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD392.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD393.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD393.ser Binary files differdeleted file mode 100644 index 33305fe62..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD393.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD394.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD394.ser Binary files differdeleted file mode 100644 index 278fb38d7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD394.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD395.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD395.ser Binary files differdeleted file mode 100644 index 3d2ff817c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD395.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD396.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD396.ser Binary files differdeleted file mode 100644 index 45833bacc..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD396.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD397.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD397.ser Binary files differdeleted file mode 100644 index 54e88ffc0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD397.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD398.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD398.ser Binary files differdeleted file mode 100644 index 751b118a7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD398.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD399.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD399.ser Binary files differdeleted file mode 100644 index 4acd804ca..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD399.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD4.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD4.ser Binary files differdeleted file mode 100644 index c65761df1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD4.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD40.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD40.ser Binary files differdeleted file mode 100644 index d6759145b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD40.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD400.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD400.ser Binary files differdeleted file mode 100644 index 4c9b21368..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD400.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD401.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD401.ser Binary files differdeleted file mode 100644 index e3e6c6ec2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD401.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD402.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD402.ser Binary files differdeleted file mode 100644 index 92e5a6187..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD402.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD403.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD403.ser Binary files differdeleted file mode 100644 index 873595ead..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD403.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD404.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD404.ser Binary files differdeleted file mode 100644 index 1709012da..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD404.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD405.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD405.ser Binary files differdeleted file mode 100644 index 5ad6315e3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD405.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD406.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD406.ser Binary files differdeleted file mode 100644 index aa04c95e2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD406.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD407.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD407.ser Binary files differdeleted file mode 100644 index 12edd65ab..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD407.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD408.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD408.ser Binary files differdeleted file mode 100644 index 40290ec4c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD408.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD409.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD409.ser Binary files differdeleted file mode 100644 index b59671610..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD409.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD41.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD41.ser Binary files differdeleted file mode 100644 index 5d664e82c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD41.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD410.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD410.ser Binary files differdeleted file mode 100644 index 9c5866504..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD410.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD411.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD411.ser Binary files differdeleted file mode 100644 index 01fe69955..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD411.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD412.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD412.ser Binary files differdeleted file mode 100644 index b71d6c546..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD412.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD413.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD413.ser Binary files differdeleted file mode 100644 index 5ad3f0613..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD413.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD414.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD414.ser Binary files differdeleted file mode 100644 index b89491a41..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD414.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD415.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD415.ser Binary files differdeleted file mode 100644 index 289f9b48d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD415.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD416.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD416.ser Binary files differdeleted file mode 100644 index 24d1e1cbe..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD416.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD417.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD417.ser Binary files differdeleted file mode 100644 index 927349572..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD417.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD418.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD418.ser Binary files differdeleted file mode 100644 index 8208a5005..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD418.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD419.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD419.ser Binary files differdeleted file mode 100644 index 346fb131d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD419.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD42.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD42.ser Binary files differdeleted file mode 100644 index 28c0e15e1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD42.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD420.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD420.ser Binary files differdeleted file mode 100644 index 53d6b158d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD420.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD421.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD421.ser Binary files differdeleted file mode 100644 index c324000e4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD421.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD422.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD422.ser Binary files differdeleted file mode 100644 index d99423cbb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD422.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD423.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD423.ser Binary files differdeleted file mode 100644 index d78b800db..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD423.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD424.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD424.ser Binary files differdeleted file mode 100644 index eabb33cc3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD424.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD425.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD425.ser Binary files differdeleted file mode 100644 index 571728da3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD425.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD426.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD426.ser Binary files differdeleted file mode 100644 index 25d9cb0aa..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD426.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD427.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD427.ser Binary files differdeleted file mode 100644 index d493f3859..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD427.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD428.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD428.ser Binary files differdeleted file mode 100644 index 06b90d501..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD428.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD429.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD429.ser Binary files differdeleted file mode 100644 index 5b97f90ca..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD429.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD43.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD43.ser Binary files differdeleted file mode 100644 index 22b1b8d9b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD43.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD430.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD430.ser Binary files differdeleted file mode 100644 index db3749949..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD430.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD431.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD431.ser Binary files differdeleted file mode 100644 index 272364c6f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD431.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD432.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD432.ser Binary files differdeleted file mode 100644 index 078a31f84..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD432.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD433.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD433.ser Binary files differdeleted file mode 100644 index b4aaf015b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD433.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD434.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD434.ser Binary files differdeleted file mode 100644 index 52c01f7e9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD434.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD435.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD435.ser Binary files differdeleted file mode 100644 index 626e52df0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD435.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD436.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD436.ser Binary files differdeleted file mode 100644 index 2de03dae5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD436.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD437.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD437.ser Binary files differdeleted file mode 100644 index 041c1a4cf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD437.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD438.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD438.ser Binary files differdeleted file mode 100644 index c8da3b083..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD438.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD439.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD439.ser Binary files differdeleted file mode 100644 index 74f71d784..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD439.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD44.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD44.ser Binary files differdeleted file mode 100644 index d1321181b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD44.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD440.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD440.ser Binary files differdeleted file mode 100644 index bcf11b73c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD440.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD441.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD441.ser Binary files differdeleted file mode 100644 index a9ba2dea1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD441.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD442.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD442.ser Binary files differdeleted file mode 100644 index fe728d89c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD442.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD443.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD443.ser Binary files differdeleted file mode 100644 index 23d7eb22b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD443.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD444.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD444.ser Binary files differdeleted file mode 100644 index 58f06cbce..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD444.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD445.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD445.ser Binary files differdeleted file mode 100644 index bd56f8524..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD445.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD446.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD446.ser Binary files differdeleted file mode 100644 index 54d14da06..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD446.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD447.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD447.ser Binary files differdeleted file mode 100644 index ee6f83422..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD447.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD448.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD448.ser Binary files differdeleted file mode 100644 index f94d24f69..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD448.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD449.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD449.ser Binary files differdeleted file mode 100644 index feef36694..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD449.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD45.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD45.ser Binary files differdeleted file mode 100644 index 93720aeac..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD45.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD450.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD450.ser Binary files differdeleted file mode 100644 index d1a58aaa5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD450.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD451.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD451.ser Binary files differdeleted file mode 100644 index 11f0d14b3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD451.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD452.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD452.ser Binary files differdeleted file mode 100644 index 2aef6789e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD452.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD453.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD453.ser Binary files differdeleted file mode 100644 index e60e00a75..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD453.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD454.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD454.ser Binary files differdeleted file mode 100644 index e7ed6f17e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD454.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD455.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD455.ser Binary files differdeleted file mode 100644 index 49062bd27..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD455.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD456.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD456.ser Binary files differdeleted file mode 100644 index 5b4049240..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD456.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD457.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD457.ser Binary files differdeleted file mode 100644 index c051bb336..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD457.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD458.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD458.ser Binary files differdeleted file mode 100644 index bb781c485..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD458.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD459.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD459.ser Binary files differdeleted file mode 100644 index 289e7e587..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD459.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD46.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD46.ser Binary files differdeleted file mode 100644 index c4b5db34b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD46.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD460.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD460.ser Binary files differdeleted file mode 100644 index bacc29cf6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD460.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD461.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD461.ser Binary files differdeleted file mode 100644 index d791c7d59..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD461.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD462.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD462.ser Binary files differdeleted file mode 100644 index eac181fa5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD462.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD463.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD463.ser Binary files differdeleted file mode 100644 index 4d4c36621..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD463.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD464.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD464.ser Binary files differdeleted file mode 100644 index ab10d3c9d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD464.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD465.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD465.ser Binary files differdeleted file mode 100644 index ada0cfb53..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD465.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD466.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD466.ser Binary files differdeleted file mode 100644 index b2f924cb4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD466.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD467.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD467.ser Binary files differdeleted file mode 100644 index 4965ccab3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD467.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD468.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD468.ser Binary files differdeleted file mode 100644 index f04ae6182..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD468.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD469.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD469.ser Binary files differdeleted file mode 100644 index 27fc5e31f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD469.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD47.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD47.ser Binary files differdeleted file mode 100644 index dd2f2f73d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD47.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD470.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD470.ser Binary files differdeleted file mode 100644 index 868c0718f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD470.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD471.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD471.ser Binary files differdeleted file mode 100644 index 95ba064e9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD471.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD472.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD472.ser Binary files differdeleted file mode 100644 index ec1bcb735..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD472.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD473.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD473.ser Binary files differdeleted file mode 100644 index d4bfab753..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD473.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD474.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD474.ser Binary files differdeleted file mode 100644 index bf4de5393..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD474.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD475.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD475.ser Binary files differdeleted file mode 100644 index b01e493df..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD475.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD476.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD476.ser Binary files differdeleted file mode 100644 index 247977216..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD476.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD477.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD477.ser Binary files differdeleted file mode 100644 index 0a4655675..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD477.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD478.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD478.ser Binary files differdeleted file mode 100644 index 7847c8b34..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD478.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD479.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD479.ser Binary files differdeleted file mode 100644 index 6ac093714..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD479.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD48.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD48.ser Binary files differdeleted file mode 100644 index 1fb8a568a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD48.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD480.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD480.ser Binary files differdeleted file mode 100644 index 4f5ce8e37..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD480.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD481.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD481.ser Binary files differdeleted file mode 100644 index b9cf2310e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD481.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD482.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD482.ser Binary files differdeleted file mode 100644 index d8cc78a39..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD482.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD483.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD483.ser Binary files differdeleted file mode 100644 index 44438e065..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD483.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD484.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD484.ser Binary files differdeleted file mode 100644 index a6227255a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD484.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD485.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD485.ser Binary files differdeleted file mode 100644 index 415f6c049..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD485.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD486.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD486.ser Binary files differdeleted file mode 100644 index 8ea2f93ad..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD486.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD487.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD487.ser Binary files differdeleted file mode 100644 index ca7f77129..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD487.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD488.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD488.ser Binary files differdeleted file mode 100644 index 5aaf07824..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD488.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD489.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD489.ser Binary files differdeleted file mode 100644 index 655516191..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD489.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD49.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD49.ser Binary files differdeleted file mode 100644 index 3cc2d4a75..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD49.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD490.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD490.ser Binary files differdeleted file mode 100644 index 94f1d83fd..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD490.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD491.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD491.ser Binary files differdeleted file mode 100644 index 14b49f0a4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD491.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD492.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD492.ser Binary files differdeleted file mode 100644 index adb3d3737..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD492.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD493.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD493.ser Binary files differdeleted file mode 100644 index b2c4902eb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD493.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD494.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD494.ser Binary files differdeleted file mode 100644 index 8b28deac8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD494.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD495.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD495.ser Binary files differdeleted file mode 100644 index 5d238271b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD495.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD496.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD496.ser Binary files differdeleted file mode 100644 index ab8f4d6d1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD496.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD497.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD497.ser Binary files differdeleted file mode 100644 index 901e4173d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD497.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD498.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD498.ser Binary files differdeleted file mode 100644 index d6fd495bb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD498.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD499.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD499.ser Binary files differdeleted file mode 100644 index 52400b507..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD499.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD5.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD5.ser Binary files differdeleted file mode 100644 index 4d03b7211..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD5.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD50.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD50.ser Binary files differdeleted file mode 100644 index 975618522..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD50.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD500.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD500.ser Binary files differdeleted file mode 100644 index 33e7b0c7d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD500.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD501.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD501.ser Binary files differdeleted file mode 100644 index 8e101db57..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD501.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD502.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD502.ser Binary files differdeleted file mode 100644 index f8246c2d2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD502.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD503.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD503.ser Binary files differdeleted file mode 100644 index c8707cd48..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD503.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD504.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD504.ser Binary files differdeleted file mode 100644 index 41e6c694a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD504.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD505.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD505.ser Binary files differdeleted file mode 100644 index 595e24ff2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD505.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD506.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD506.ser Binary files differdeleted file mode 100644 index 731b47fd2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD506.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD507.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD507.ser Binary files differdeleted file mode 100644 index 8bf1d99fa..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD507.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD508.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD508.ser Binary files differdeleted file mode 100644 index bc63d7e97..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD508.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD509.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD509.ser Binary files differdeleted file mode 100644 index d7415c13a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD509.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD51.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD51.ser Binary files differdeleted file mode 100644 index e8d28148e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD51.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD510.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD510.ser Binary files differdeleted file mode 100644 index b94811af6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD510.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD511.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD511.ser Binary files differdeleted file mode 100644 index 91a3bd4ea..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD511.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD512.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD512.ser Binary files differdeleted file mode 100644 index 2e31b49d8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD512.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD513.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD513.ser Binary files differdeleted file mode 100644 index 2cef55911..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD513.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD514.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD514.ser Binary files differdeleted file mode 100644 index 84c1bdeb8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD514.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD515.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD515.ser Binary files differdeleted file mode 100644 index 431fe2dd8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD515.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD516.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD516.ser Binary files differdeleted file mode 100644 index 37c17f168..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD516.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD517.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD517.ser Binary files differdeleted file mode 100644 index 087847d57..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD517.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD518.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD518.ser Binary files differdeleted file mode 100644 index 8bd76318d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD518.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD519.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD519.ser Binary files differdeleted file mode 100644 index 318fc84a7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD519.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD52.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD52.ser Binary files differdeleted file mode 100644 index 5e853ec29..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD52.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD520.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD520.ser Binary files differdeleted file mode 100644 index e72f8d30e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD520.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD521.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD521.ser Binary files differdeleted file mode 100644 index cbd161b83..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD521.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD522.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD522.ser Binary files differdeleted file mode 100644 index a2c4ccff7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD522.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD523.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD523.ser Binary files differdeleted file mode 100644 index cbd7fa3b8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD523.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD524.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD524.ser Binary files differdeleted file mode 100644 index b876b1b27..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD524.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD525.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD525.ser Binary files differdeleted file mode 100644 index 64e50de82..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD525.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD526.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD526.ser Binary files differdeleted file mode 100644 index e5f094eeb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD526.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD527.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD527.ser Binary files differdeleted file mode 100644 index 537459e7f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD527.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD528.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD528.ser Binary files differdeleted file mode 100644 index 577b66158..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD528.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD529.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD529.ser Binary files differdeleted file mode 100644 index 4679568f4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD529.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD53.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD53.ser Binary files differdeleted file mode 100644 index 389261a05..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD53.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD530.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD530.ser Binary files differdeleted file mode 100644 index 635151fa9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD530.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD531.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD531.ser Binary files differdeleted file mode 100644 index 69e85f02b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD531.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD532.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD532.ser Binary files differdeleted file mode 100644 index c28ba450a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD532.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD533.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD533.ser Binary files differdeleted file mode 100644 index fe26705e5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD533.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD534.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD534.ser Binary files differdeleted file mode 100644 index 19595d9e3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD534.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD535.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD535.ser Binary files differdeleted file mode 100644 index 95e9836b4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD535.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD536.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD536.ser Binary files differdeleted file mode 100644 index d179f7c8c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD536.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD537.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD537.ser Binary files differdeleted file mode 100644 index 1b91641ad..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD537.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD538.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD538.ser Binary files differdeleted file mode 100644 index fc83f4562..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD538.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD539.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD539.ser Binary files differdeleted file mode 100644 index ea2af6364..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD539.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD54.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD54.ser Binary files differdeleted file mode 100644 index 0f76396bb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD54.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD540.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD540.ser Binary files differdeleted file mode 100644 index 143d5894a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD540.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD541.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD541.ser Binary files differdeleted file mode 100644 index 671cf26d1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD541.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD542.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD542.ser Binary files differdeleted file mode 100644 index 1a7fda27b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD542.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD543.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD543.ser Binary files differdeleted file mode 100644 index 5aee466d8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD543.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD544.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD544.ser Binary files differdeleted file mode 100644 index 37f124113..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD544.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD545.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD545.ser Binary files differdeleted file mode 100644 index 8bc00e144..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD545.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD546.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD546.ser Binary files differdeleted file mode 100644 index 9d9b9c119..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD546.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD547.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD547.ser Binary files differdeleted file mode 100644 index 88411a216..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD547.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD548.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD548.ser Binary files differdeleted file mode 100644 index f8324788b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD548.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD549.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD549.ser Binary files differdeleted file mode 100644 index 2d3118a56..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD549.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD55.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD55.ser Binary files differdeleted file mode 100644 index 51a8b7095..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD55.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD550.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD550.ser Binary files differdeleted file mode 100644 index e939d4754..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD550.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD551.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD551.ser Binary files differdeleted file mode 100644 index 61e5e3f3c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD551.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD552.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD552.ser Binary files differdeleted file mode 100644 index 496e6912a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD552.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD553.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD553.ser Binary files differdeleted file mode 100644 index 0fc2f1a23..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD553.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD554.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD554.ser Binary files differdeleted file mode 100644 index dc5183342..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD554.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD555.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD555.ser Binary files differdeleted file mode 100644 index de477db15..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD555.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD556.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD556.ser Binary files differdeleted file mode 100644 index 6a4e51c29..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD556.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD557.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD557.ser Binary files differdeleted file mode 100644 index fccb593ae..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD557.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD558.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD558.ser Binary files differdeleted file mode 100644 index 828b3a72e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD558.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD559.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD559.ser Binary files differdeleted file mode 100644 index 3b14d4a8f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD559.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD56.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD56.ser Binary files differdeleted file mode 100644 index 373392279..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD56.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD560.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD560.ser Binary files differdeleted file mode 100644 index a91b8512a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD560.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD561.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD561.ser Binary files differdeleted file mode 100644 index 639a7be49..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD561.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD562.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD562.ser Binary files differdeleted file mode 100644 index 68dd4089b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD562.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD563.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD563.ser Binary files differdeleted file mode 100644 index 2908e3f63..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD563.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD564.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD564.ser Binary files differdeleted file mode 100644 index 391e3e14a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD564.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD565.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD565.ser Binary files differdeleted file mode 100644 index 5bd9c1e71..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD565.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD566.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD566.ser Binary files differdeleted file mode 100644 index d4ecb3a88..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD566.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD567.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD567.ser Binary files differdeleted file mode 100644 index d68ca24ac..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD567.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD568.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD568.ser Binary files differdeleted file mode 100644 index 73cd97bf6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD568.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD569.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD569.ser Binary files differdeleted file mode 100644 index a6d766289..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD569.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD57.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD57.ser Binary files differdeleted file mode 100644 index d0af60722..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD57.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD570.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD570.ser Binary files differdeleted file mode 100644 index 231290df6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD570.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD571.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD571.ser Binary files differdeleted file mode 100644 index 21e85e747..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD571.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD572.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD572.ser Binary files differdeleted file mode 100644 index e99365766..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD572.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD573.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD573.ser Binary files differdeleted file mode 100644 index 4f844be2e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD573.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD574.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD574.ser Binary files differdeleted file mode 100644 index ccb6d70f1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD574.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD575.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD575.ser Binary files differdeleted file mode 100644 index aa3909601..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD575.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD576.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD576.ser Binary files differdeleted file mode 100644 index 5d1bb4981..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD576.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD577.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD577.ser Binary files differdeleted file mode 100644 index 64823ec47..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD577.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD578.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD578.ser Binary files differdeleted file mode 100644 index 09d6843e8..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD578.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD579.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD579.ser Binary files differdeleted file mode 100644 index 59f2572ad..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD579.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD58.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD58.ser Binary files differdeleted file mode 100644 index cb600cfca..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD58.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD580.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD580.ser Binary files differdeleted file mode 100644 index b1faa848b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD580.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD581.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD581.ser Binary files differdeleted file mode 100644 index 1e057fdf4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD581.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD582.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD582.ser Binary files differdeleted file mode 100644 index cdd3cbec1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD582.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD583.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD583.ser Binary files differdeleted file mode 100644 index 84eed41fe..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD583.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD584.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD584.ser Binary files differdeleted file mode 100644 index 7b91077fc..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD584.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD585.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD585.ser Binary files differdeleted file mode 100644 index 259194e4e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD585.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD586.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD586.ser Binary files differdeleted file mode 100644 index 0616c3c12..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD586.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD587.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD587.ser Binary files differdeleted file mode 100644 index 22430bd97..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD587.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD588.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD588.ser Binary files differdeleted file mode 100644 index b583a1a1b..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD588.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD589.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD589.ser Binary files differdeleted file mode 100644 index 841747bdf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD589.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD59.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD59.ser Binary files differdeleted file mode 100644 index 23521f3cd..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD59.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD590.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD590.ser Binary files differdeleted file mode 100644 index 168552d3c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD590.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD591.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD591.ser Binary files differdeleted file mode 100644 index c0da95a76..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD591.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD592.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD592.ser Binary files differdeleted file mode 100644 index 276e0ffed..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD592.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD593.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD593.ser Binary files differdeleted file mode 100644 index 363f4f695..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD593.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD594.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD594.ser Binary files differdeleted file mode 100644 index a0f6639ba..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD594.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD595.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD595.ser Binary files differdeleted file mode 100644 index cdc9eb94a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD595.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD596.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD596.ser Binary files differdeleted file mode 100644 index c6223a7ce..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD596.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD597.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD597.ser Binary files differdeleted file mode 100644 index 74f023e83..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD597.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD598.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD598.ser Binary files differdeleted file mode 100644 index 9755e4a3c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD598.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD599.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD599.ser Binary files differdeleted file mode 100644 index 986a332f3..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD599.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD6.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD6.ser Binary files differdeleted file mode 100644 index edc35abdc..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD6.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD60.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD60.ser Binary files differdeleted file mode 100644 index 6ed639c5e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD60.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD600.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD600.ser Binary files differdeleted file mode 100644 index d2c52eba1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD600.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD601.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD601.ser Binary files differdeleted file mode 100644 index f34830970..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD601.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD602.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD602.ser Binary files differdeleted file mode 100644 index 7cea4a6c6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD602.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD603.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD603.ser Binary files differdeleted file mode 100644 index e2c08df91..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD603.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD604.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD604.ser Binary files differdeleted file mode 100644 index 7a37cd019..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD604.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD605.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD605.ser Binary files differdeleted file mode 100644 index 85f679da2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD605.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD606.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD606.ser Binary files differdeleted file mode 100644 index 8f1d6966d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD606.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD607.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD607.ser Binary files differdeleted file mode 100644 index f82e37287..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD607.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD608.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD608.ser Binary files differdeleted file mode 100644 index f22902dd5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD608.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD609.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD609.ser Binary files differdeleted file mode 100644 index bb7f98e41..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD609.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD61.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD61.ser Binary files differdeleted file mode 100644 index d25cb04c7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD61.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD610.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD610.ser Binary files differdeleted file mode 100644 index 8ddaeb744..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD610.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD611.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD611.ser Binary files differdeleted file mode 100644 index b11de6c32..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD611.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD612.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD612.ser Binary files differdeleted file mode 100644 index 2b1ea8898..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD612.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD613.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD613.ser Binary files differdeleted file mode 100644 index 1d2ea017c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD613.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD614.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD614.ser Binary files differdeleted file mode 100644 index ae74ca063..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD614.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD615.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD615.ser Binary files differdeleted file mode 100644 index fed68df6e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD615.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD616.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD616.ser Binary files differdeleted file mode 100644 index 94b09c1e1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD616.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD617.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD617.ser Binary files differdeleted file mode 100644 index 0af062be1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD617.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD618.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD618.ser Binary files differdeleted file mode 100644 index bd93b288c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD618.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD619.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD619.ser Binary files differdeleted file mode 100644 index ea7a544bf..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD619.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD62.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD62.ser Binary files differdeleted file mode 100644 index c3510ec9e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD62.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD620.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD620.ser Binary files differdeleted file mode 100644 index c02164344..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD620.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD621.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD621.ser Binary files differdeleted file mode 100644 index 16cf973f2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD621.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD63.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD63.ser Binary files differdeleted file mode 100644 index f827db274..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD63.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD64.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD64.ser Binary files differdeleted file mode 100644 index c079752d6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD64.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD65.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD65.ser Binary files differdeleted file mode 100644 index 18d091c4a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD65.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD66.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD66.ser Binary files differdeleted file mode 100644 index 2628ac645..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD66.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD67.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD67.ser Binary files differdeleted file mode 100644 index e0a656874..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD67.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD68.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD68.ser Binary files differdeleted file mode 100644 index cd908264a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD68.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD69.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD69.ser Binary files differdeleted file mode 100644 index da9a56794..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD69.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD7.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD7.ser Binary files differdeleted file mode 100644 index 1eec94eeb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD7.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD70.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD70.ser Binary files differdeleted file mode 100644 index 1458485b6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD70.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD71.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD71.ser Binary files differdeleted file mode 100644 index 0bb894af9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD71.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD72.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD72.ser Binary files differdeleted file mode 100644 index 596af011c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD72.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD73.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD73.ser Binary files differdeleted file mode 100644 index adac3305c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD73.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD74.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD74.ser Binary files differdeleted file mode 100644 index 1440bb78a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD74.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD75.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD75.ser Binary files differdeleted file mode 100644 index 2a1091e9c..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD75.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD76.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD76.ser Binary files differdeleted file mode 100644 index a519dc078..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD76.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD77.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD77.ser Binary files differdeleted file mode 100644 index 533579a8f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD77.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD78.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD78.ser Binary files differdeleted file mode 100644 index cd8bea1c7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD78.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD79.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD79.ser Binary files differdeleted file mode 100644 index 16635b605..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD79.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD8.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD8.ser Binary files differdeleted file mode 100644 index 05616a937..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD8.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD80.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD80.ser Binary files differdeleted file mode 100644 index 44ce6375e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD80.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD81.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD81.ser Binary files differdeleted file mode 100644 index cfd698d7d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD81.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD82.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD82.ser Binary files differdeleted file mode 100644 index 415f1bf8e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD82.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD83.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD83.ser Binary files differdeleted file mode 100644 index 2fc94de93..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD83.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD84.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD84.ser Binary files differdeleted file mode 100644 index a7e226ec1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD84.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD85.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD85.ser Binary files differdeleted file mode 100644 index 573c8ce87..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD85.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD86.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD86.ser Binary files differdeleted file mode 100644 index e8df233a5..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD86.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD87.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD87.ser Binary files differdeleted file mode 100644 index abcad78d0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD87.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD88.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD88.ser Binary files differdeleted file mode 100644 index e702881e7..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD88.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD89.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD89.ser Binary files differdeleted file mode 100644 index 1b76a8499..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD89.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD9.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD9.ser Binary files differdeleted file mode 100644 index 13edb5406..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD9.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD90.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD90.ser Binary files differdeleted file mode 100644 index da2ee39ec..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD90.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD91.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD91.ser Binary files differdeleted file mode 100644 index 7f9f0a3fd..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD91.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD92.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD92.ser Binary files differdeleted file mode 100644 index 6cbe89840..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD92.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD93.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD93.ser Binary files differdeleted file mode 100644 index 423f92310..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD93.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD94.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD94.ser Binary files differdeleted file mode 100644 index 331ba261f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD94.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD95.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD95.ser Binary files differdeleted file mode 100644 index 0c4e54135..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD95.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD96.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD96.ser Binary files differdeleted file mode 100644 index 20afc295a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD96.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD97.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD97.ser Binary files differdeleted file mode 100644 index e801916f4..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD97.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD98.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD98.ser Binary files differdeleted file mode 100644 index 7fc398de9..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD98.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD99.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD99.ser Binary files differdeleted file mode 100644 index 5c7a0de21..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$LD99.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD0.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD0.ser Binary files differdeleted file mode 100644 index f7b1fbed1..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD0.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD1.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD1.ser Binary files differdeleted file mode 100644 index dc3634dec..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD1.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD10.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD10.ser Binary files differdeleted file mode 100644 index a3108b43e..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD10.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD11.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD11.ser Binary files differdeleted file mode 100644 index f561c2d2f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD11.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD12.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD12.ser Binary files differdeleted file mode 100644 index 1dc99e434..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD12.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD13.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD13.ser Binary files differdeleted file mode 100644 index e1b97d053..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD13.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD14.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD14.ser Binary files differdeleted file mode 100644 index 5600cbfa2..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD14.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD15.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD15.ser Binary files differdeleted file mode 100644 index fe4068c42..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD15.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD16.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD16.ser Binary files differdeleted file mode 100644 index 59ad5e462..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD16.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD17.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD17.ser Binary files differdeleted file mode 100644 index b11600cd0..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD17.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD18.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD18.ser Binary files differdeleted file mode 100644 index 5abc2b1b6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD18.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD2.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD2.ser Binary files differdeleted file mode 100644 index 37814223f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD2.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD3.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD3.ser Binary files differdeleted file mode 100644 index 58bb75a7f..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD3.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD4.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD4.ser Binary files differdeleted file mode 100644 index f905fc364..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD4.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD5.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD5.ser Binary files differdeleted file mode 100644 index 0c1e74beb..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD5.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD6.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD6.ser Binary files differdeleted file mode 100644 index 1032043be..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD6.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD7.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD7.ser Binary files differdeleted file mode 100644 index d0e34603a..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD7.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD8.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD8.ser Binary files differdeleted file mode 100644 index 4d47ada2d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD8.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD9.ser b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD9.ser Binary files differdeleted file mode 100644 index eb522634d..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData$TD9.ser +++ /dev/null diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java b/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java deleted file mode 100644 index 49a5c9455..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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: License.java 1039179 2010-11-25 21:04:09Z vhennebert $ */ - -package org.apache.fop.complexscripts.bidi; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; - - -/* - * !!! THIS IS A GENERATED FILE !!! - * If updates to the source are needed, then: - * - apply the necessary modifications to - * 'src/codegen/unicode/java/org/apache/fop/text/bidi/GenerateBidiTestData.java' - * - run 'ant codegen-unicode', which will generate a new BidiTestData.java - * in 'test/java/org/apache/fop/complexscripts/bidi' - * - commit BOTH changed files - */ - -/** Bidirectional test data. */ -public final class BidiTestData { - - private BidiTestData() { - } - - public static final String TD_PFX = "TD"; - public static final int TD_CNT = 19; - - public static final String LD_PFX = "LD"; - public static final int LD_CNT = 622; - - public static final int NUM_TEST_SEQUENCES = 216357; - - public static int[] readTestData(String prefix, int index) { - int[] data = null; - InputStream is = null; - Class btc = BidiTestData.class; - String name = btc.getSimpleName() + "$" + prefix + index + ".ser"; - try { - if ((is = btc.getResourceAsStream(name)) != null) { - ObjectInputStream ois = new ObjectInputStream(is); - data = (int[]) ois.readObject(); - ois.close(); - } - } catch (IOException e) { - data = null; - } catch (ClassNotFoundException e) { - data = null; - } finally { - if (is != null) { - try { is.close(); } catch (Exception e) { /* NOP */ } - } - } - return data; - } -} diff --git a/test/java/org/apache/fop/complexscripts/bidi/BidiTestSuite.java b/test/java/org/apache/fop/complexscripts/bidi/BidiTestSuite.java deleted file mode 100644 index 7a6a095c6..000000000 --- a/test/java/org/apache/fop/complexscripts/bidi/BidiTestSuite.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.complexscripts.bidi; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for bidirectional functionality. - */ -@RunWith(Suite.class) -@SuiteClasses({ - BidiClassTestCase.class, - BidiAlgorithmTestCase.class -}) -public class BidiTestSuite { -} diff --git a/test/java/org/apache/fop/complexscripts/fonts/FontsTestSuite.java b/test/java/org/apache/fop/complexscripts/fonts/FontsTestSuite.java deleted file mode 100644 index a7e4b0615..000000000 --- a/test/java/org/apache/fop/complexscripts/fonts/FontsTestSuite.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.complexscripts.fonts; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.apache.fop.complexscripts.fonts.ttx.TTXFileTestCase; - -/** - * Test suite for fonts functionality related to complex scripts. - */ -@RunWith(Suite.class) -@SuiteClasses({ - TTXFileTestCase.class, - GDEFTestCase.class, - GSUBTestCase.class, - GPOSTestCase.class -}) -public class FontsTestSuite { -} diff --git a/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java deleted file mode 100644 index f1512903c..000000000 --- a/test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java +++ /dev/null @@ -1,3170 +0,0 @@ -/* - * 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.complexscripts.fonts; - -import java.io.File; - -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"; - - private static String[][] ttxFonts = { - { "f0", "arab/ttx/arab-001.ttx" }, // simplified arabic - { "f1", "arab/ttx/arab-002.ttx" }, // traditional arabic - { "f2", "arab/ttx/arab-003.ttx" }, // lateef - { "f3", "arab/ttx/arab-004.ttx" }, // scheherazade - }; - - private static Object[][] ltGlyphClass = { - { GlyphDefinitionTable.GDEF_LOOKUP_TYPE_GLYPH_CLASS }, - // arab-001.ttx - { "f0", "lu0", - new String[][] { - { "a", "1" }, - { "aacute", "1" }, - { "acircumflex", "1" }, - { "acute", "1" }, - { "adieresis", "1" }, - { "ae", "1" }, - { "agrave", "1" }, - { "ain", "1" }, - { "ainfinal", "1" }, - { "aininitial", "1" }, - { "ainisolated", "1" }, - { "ainmedial", "1" }, - { "aleffinal", "1" }, - { "alefisolated", "1" }, - { "alefmaksura", "1" }, - { "alefmaksurafinal", "1" }, - { "alefmaksuraisolated", "1" }, - { "alefwasla", "1" }, - { "alefwaslafinal", "1" }, - { "alefwaslaisolated", "1" }, - { "alefwithfathatanfinal", "1" }, - { "alefwithfathatanisolated", "1" }, - { "alefwithhamzaabove", "1" }, - { "alefwithhamzaabovefinal", "1" }, - { "alefwithhamzaaboveisolated", "1" }, - { "alefwithhamzabelow", "1" }, - { "alefwithhamzabelowfinal", "1" }, - { "alefwithhamzabelowisolated", "1" }, - { "alefwithmaddaabove", "1" }, - { "alefwithmaddaabovefinal", "1" }, - { "alefwithmaddaaboveisolated", "1" }, - { "allahisolated", "2" }, - { "ampersand", "1" }, - { "arabicae", "1" }, - { "arabicalef", "1" }, - { "arabiccomma", "1" }, - { "arabicfivepointedstar", "1" }, - { "arabicindicdigiteight", "1" }, - { "arabicindicdigitfive", "1" }, - { "arabicindicdigitfour", "1" }, - { "arabicindicdigitnine", "1" }, - { "arabicindicdigitone", "1" }, - { "arabicindicdigitseven", "1" }, - { "arabicindicdigitsix", "1" }, - { "arabicindicdigitthree", "1" }, - { "arabicindicdigittwo", "1" }, - { "arabicindicdigitzero", "1" }, - { "arabickaf", "1" }, - { "arabicpercentsign", "1" }, - { "arabicquestionmark", "1" }, - { "arabicsemicolon", "1" }, - { "aring", "1" }, - { "asciicircum", "1" }, - { "asciitilde", "1" }, - { "asterisk", "1" }, - { "at", "1" }, - { "atilde", "1" }, - { "b", "1" }, - { "backslash", "1" }, - { "bar", "1" }, - { "beh", "1" }, - { "behisolated", "1" }, - { "behmedial", "1" }, - { "braceleft", "1" }, - { "braceright", "1" }, - { "bracketleft", "1" }, - { "bracketright", "1" }, - { "brokenbar", "1" }, - { "bullet", "1" }, - { "c", "1" }, - { "caron", "1" }, - { "ccedilla", "1" }, - { "cedilla", "1" }, - { "cent", "1" }, - { "circumflex", "1" }, - { "colon", "1" }, - { "comma", "1" }, - { "copyright", "1" }, - { "currency", "1" }, - { "d", "1" }, - { "dad", "1" }, - { "dadisolated", "1" }, - { "dadmedial", "1" }, - { "dagger", "1" }, - { "daggerdbl", "1" }, - { "dal", "1" }, - { "dalisolated", "1" }, - { "damma", "3" }, - { "dammahontatweel", "3" }, - { "dammaisolated", "3" }, - { "dammalow", "1" }, - { "dammaonhamza", "3" }, - { "dammatan", "3" }, - { "dammatanisolated", "3" }, - { "dammatanlow", "1" }, - { "dammatanonhamza", "3" }, - { "degree", "1" }, - { "delete", "1" }, - { "dieresis", "1" }, - { "divide", "1" }, - { "dollar", "1" }, - { "dotlessi", "1" }, - { "e", "1" }, - { "eacute", "1" }, - { "ecircumflex", "1" }, - { "edieresis", "1" }, - { "egrave", "1" }, - { "eight", "1" }, - { "ellipsis", "1" }, - { "endash", "1" }, - { "equal", "1" }, - { "eth", "1" }, - { "exclam", "1" }, - { "exclamdown", "1" }, - { "extendedarabicindicdigiteight", "1" }, - { "extendedarabicindicdigitfive", "1" }, - { "extendedarabicindicdigitfour", "1" }, - { "extendedarabicindicdigitnine", "1" }, - { "extendedarabicindicdigitone", "1" }, - { "extendedarabicindicdigitseven", "1" }, - { "extendedarabicindicdigitsix", "1" }, - { "extendedarabicindicdigitthree", "1" }, - { "extendedarabicindicdigittwo", "1" }, - { "extendedarabicindicdigitzero", "1" }, - { "f", "1" }, - { "farsiyeh", "1" }, - { "farsiyehfinal", "1" }, - { "farsiyehisolated", "1" }, - { "fatha", "3" }, - { "fathahontatweel", "3" }, - { "fathaisolated", "3" }, - { "fathalow", "1" }, - { "fathaonhamza", "3" }, - { "fathatan", "3" }, - { "fathatanisolated", "3" }, - { "fathatanlow", "1" }, - { "fathatanonhamza", "3" }, - { "fathatanontatweel", "1" }, - { "feh", "1" }, - { "fehinitial", "1" }, - { "fehisolated", "1" }, - { "fehmedial", "1" }, - { "five", "1" }, - { "florin", "1" }, - { "four", "1" }, - { "g", "1" }, - { "gaf", "1" }, - { "gaffinal", "1" }, - { "gafinitial", "1" }, - { "gafisolated", "1" }, - { "gafmedial", "1" }, - { "germandbls", "1" }, - { "ghain", "1" }, - { "ghainfinal", "1" }, - { "ghaininitial", "1" }, - { "ghainisolated", "1" }, - { "ghainmedial", "1" }, - { "glyph1", "1" }, - { "glyph2", "1" }, - { "glyph99", "1" }, - { "grave", "1" }, - { "greater", "1" }, - { "guillemotleft", "1" }, - { "guillemotright", "1" }, - { "guilsinglleft", "1" }, - { "guilsinglright", "1" }, - { "h", "1" }, - { "hah", "1" }, - { "hahfinal", "1" }, - { "hahisolated", "1" }, - { "hahmedial", "1" }, - { "hamza", "1" }, - { "hamzaisolated", "3" }, - { "heh", "1" }, - { "hehfinal", "1" }, - { "hehinitial", "1" }, - { "hehisolated", "1" }, - { "hehmedial", "1" }, - { "highhamza", "1" }, - { "hyphenminus", "1" }, - { "i", "1" }, - { "iacute", "1" }, - { "icircumflex", "1" }, - { "idieresis", "1" }, - { "igrave", "1" }, - { "j", "1" }, - { "jeem", "1" }, - { "jeemfinal", "1" }, - { "jeemisolated", "1" }, - { "jeemmedial", "1" }, - { "jeh", "1" }, - { "jehisolated", "1" }, - { "k", "1" }, - { "kafisolated", "1" }, - { "kafmedial", "1" }, - { "kasra", "3" }, - { "kasrahontatweel", "3" }, - { "kasraisolated", "3" }, - { "kasralow", "1" }, - { "kasratan", "3" }, - { "kasratanisolated", "3" }, - { "kasratanlow", "1" }, - { "keheh", "1" }, - { "kehehfinal", "1" }, - { "kehehinitial", "1" }, - { "kehehisolated", "1" }, - { "kehehmedial", "1" }, - { "khah", "1" }, - { "khahfinal", "1" }, - { "khahisolated", "1" }, - { "khahmedial", "1" }, - { "l", "1" }, - { "lam", "1" }, - { "lamisolated", "1" }, - { "lammedial", "1" }, - { "lamwithaleffinal", "2" }, - { "lamwithalefhamzaabovefinal", "2" }, - { "lamwithalefhamzaaboveisolatedd", "2" }, - { "lamwithalefhamzabelowfinal", "2" }, - { "lamwithalefhamzabelowisolated", "2" }, - { "lamwithalefisolated", "2" }, - { "lamwithalefmaddaabovefinal", "2" }, - { "lamwithalefmaddaaboveisolatedd", "2" }, - { "lamwithmeemwithjeeminitial", "1" }, - { "lefttoright", "1" }, - { "less", "1" }, - { "logicalnot", "1" }, - { "m", "1" }, - { "macron", "1" }, - { "meem", "1" }, - { "meemisolated", "1" }, - { "meemmedial", "1" }, - { "micro", "1" }, - { "multiply", "1" }, - { "n", "1" }, - { "nbspace", "1" }, - { "nine", "1" }, - { "noon", "1" }, - { "noonisolated", "1" }, - { "noonmedial", "1" }, - { "ntilde", "1" }, - { "numbersign", "1" }, - { "o", "1" }, - { "oacute", "1" }, - { "ocircumflex", "1" }, - { "odieresis", "1" }, - { "oe", "1" }, - { "ograve", "1" }, - { "one", "1" }, - { "onehalf", "1" }, - { "onequarter", "1" }, - { "onesuperior", "1" }, - { "ordfeminine", "1" }, - { "ordmasculine", "1" }, - { "ornateleftparenthesis", "1" }, - { "ornaterightparenthesis", "1" }, - { "oslash", "1" }, - { "otilde", "1" }, - { "p", "1" }, - { "paragraph", "1" }, - { "parenleft", "1" }, - { "parenright", "1" }, - { "peh", "1" }, - { "pehisolated", "1" }, - { "pehmedial", "1" }, - { "percent", "1" }, - { "period", "1" }, - { "periodcentered", "1" }, - { "perthousand", "1" }, - { "plus", "1" }, - { "plusminus", "1" }, - { "q", "1" }, - { "qaf", "1" }, - { "qafinitial", "1" }, - { "qafisolated", "1" }, - { "qafmedial", "1" }, - { "question", "1" }, - { "questiondown", "1" }, - { "quotedash", "1" }, - { "quotedbl", "1" }, - { "quotedblbase", "1" }, - { "quotedblleft", "1" }, - { "quotedblright", "1" }, - { "quoteleft", "1" }, - { "quoteright", "1" }, - { "quotesinglbase", "1" }, - { "quotesingle", "1" }, - { "r", "1" }, - { "rayaleflam", "2" }, - { "registered", "1" }, - { "reh", "1" }, - { "rehisolated", "1" }, - { "righttoleft", "1" }, - { "s", "1" }, - { "sad", "1" }, - { "sadisolated", "1" }, - { "sadmedial", "1" }, - { "scaron", "1" }, - { "section", "1" }, - { "seen", "1" }, - { "seenisolated", "1" }, - { "seenmedial", "1" }, - { "semicolon", "1" }, - { "seven", "1" }, - { "sfthyphen", "1" }, - { "shadda", "3" }, - { "shaddahontatweel", "3" }, - { "shaddaisolated", "3" }, - { "shaddalow", "1" }, - { "shaddawithdammaisolated", "3" }, - { "shaddawithdammalow", "3" }, - { "shaddawithdammamedial", "1" }, - { "shaddawithdammatanisolated", "1" }, - { "shaddawithdammatanlow", "3" }, - { "shaddawithfathaisolated", "3" }, - { "shaddawithfathalow", "3" }, - { "shaddawithfathamedial", "1" }, - { "shaddawithfathatanisolated", "1" }, - { "shaddawithfathatanlow", "3" }, - { "shaddawithkasraisolated", "3" }, - { "shaddawithkasralow", "3" }, - { "shaddawithkasramedial", "1" }, - { "shaddawithkasratanisolated", "1" }, - { "shaddawithkasratanlow", "3" }, - { "sheen", "1" }, - { "sheenisolated", "1" }, - { "sheenmedial", "1" }, - { "six", "1" }, - { "slash", "1" }, - { "smallhighmadda", "3" }, - { "space", "1" }, - { "sterling", "1" }, - { "sukun", "3" }, - { "sukunisolated", "3" }, - { "sukunlow", "1" }, - { "sukunonhamza", "3" }, - { "sukunontatweel", "3" }, - { "superscriptalef", "3" }, - { "t", "1" }, - { "tah", "1" }, - { "tahisolated", "1" }, - { "tatweel", "1" }, - { "tcheh", "1" }, - { "tchehfinal", "1" }, - { "tchehisolated", "1" }, - { "tchehmedial", "1" }, - { "teh", "1" }, - { "tehisolated", "1" }, - { "tehmarbuta", "1" }, - { "tehmarbutafinal", "1" }, - { "tehmarbutaisolated", "1" }, - { "tehmedial", "1" }, - { "thal", "1" }, - { "thalisolated", "1" }, - { "theh", "1" }, - { "thehisolated", "1" }, - { "thehmedial", "1" }, - { "thorn", "1" }, - { "three", "1" }, - { "threequarters", "1" }, - { "threesuperior", "1" }, - { "tilde", "1" }, - { "trademark", "1" }, - { "two", "1" }, - { "twosuperior", "1" }, - { "u", "1" }, - { "uacute", "1" }, - { "ucircumflex", "1" }, - { "udieresis", "1" }, - { "ugrave", "1" }, - { "underscore", "1" }, - { "uni000D", "1" }, - { "uni0649.init", "1" }, - { "uni0654", "3" }, - { "uni0655", "3" }, - { "uni0655064D", "3" }, - { "uni06550650", "3" }, - { "uni06A5.init", "1" }, - { "uni25CC", "1" }, - { "v", "1" }, - { "veh", "1" }, - { "vehisolated", "1" }, - { "vehmedial", "1" }, - { "w", "1" }, - { "waw", "1" }, - { "wawisolated", "1" }, - { "wawwithhamzaabove", "1" }, - { "wawwithhamzaaboveisolated", "1" }, - { "x", "1" }, - { "y", "1" }, - { "yacute", "1" }, - { "ydieresis", "1" }, - { "yeh", "1" }, - { "yehfinal", "1" }, - { "yehisolated", "1" }, - { "yehmedial", "1" }, - { "yehwithhamzaabove", "1" }, - { "yehwithhamzaabovefinal", "1" }, - { "yehwithhamzaaboveisolated", "1" }, - { "yehwithhamzaabovemedial", "1" }, - { "yen", "1" }, - { "z", "1" }, - { "zah", "1" }, - { "zahisolated", "1" }, - { "zain", "1" }, - { "zainisolated", "1" }, - { "zcaron", "1" }, - { "zero", "1" }, - { "zerojoin", "1" }, - { "zeronojoin", "1" }, - { "zerowidthnobreakspace", "1" }, - }, - }, - // arab-002.ttx - { "f1", "lu0", - new String[][] { - { "a", "1" }, - { "aacute", "1" }, - { "acircumflex", "1" }, - { "acute", "1" }, - { "adieresis", "1" }, - { "ae", "1" }, - { "agrave", "1" }, - { "ain", "1" }, - { "ainfinal", "1" }, - { "aininitial", "1" }, - { "ainisolated", "1" }, - { "ainmedial", "1" }, - { "aleffinal", "1" }, - { "alefisolated", "1" }, - { "alefmaksura", "1" }, - { "alefmaksurafinal", "1" }, - { "alefmaksuraisolated", "1" }, - { "alefwasla", "1" }, - { "alefwaslafinal", "1" }, - { "alefwaslaisolated", "1" }, - { "alefwithfathatanfinal", "1" }, - { "alefwithfathatanisolated", "1" }, - { "alefwithhamzaabove", "1" }, - { "alefwithhamzaabovefinal", "1" }, - { "alefwithhamzaaboveisolated", "1" }, - { "alefwithhamzabelow", "1" }, - { "alefwithhamzabelowfinal", "1" }, - { "alefwithhamzabelowisolated", "1" }, - { "alefwithmaddaabove", "1" }, - { "alefwithmaddaabovefinal", "1" }, - { "alefwithmaddaaboveisolated", "1" }, - { "allahisolated", "2" }, - { "ampersand", "1" }, - { "arabicae", "1" }, - { "arabicalef", "1" }, - { "arabiccomma", "1" }, - { "arabicfivepointedstar", "3" }, - { "arabicindicdigiteight", "1" }, - { "arabicindicdigitfive", "1" }, - { "arabicindicdigitfour", "1" }, - { "arabicindicdigitnine", "1" }, - { "arabicindicdigitone", "1" }, - { "arabicindicdigitseven", "1" }, - { "arabicindicdigitsix", "1" }, - { "arabicindicdigitthree", "1" }, - { "arabicindicdigittwo", "1" }, - { "arabicindicdigitzero", "1" }, - { "arabickaf", "1" }, - { "arabickaffinal", "1" }, - { "arabicpercentsign", "1" }, - { "arabicquestionmark", "1" }, - { "arabicsemicolon", "1" }, - { "aring", "1" }, - { "asciicircum", "1" }, - { "asciitilde", "1" }, - { "asterisk", "1" }, - { "at", "1" }, - { "atilde", "1" }, - { "b", "1" }, - { "backslash", "1" }, - { "bar", "1" }, - { "beh", "1" }, - { "behfinal", "1" }, - { "behinitial", "1" }, - { "behisolated", "1" }, - { "behmedial", "1" }, - { "behwithalefmaksurafinal", "2" }, - { "behwithalefmaksuraisolated", "2" }, - { "behwithhahinitial", "2" }, - { "behwithhehinitial", "2" }, - { "behwithjeeminitial", "2" }, - { "behwithkhahinitial", "2" }, - { "behwithmeeminitial", "2" }, - { "behwithmeemisolated", "2" }, - { "behwithnoonfinal", "2" }, - { "behwithrehfinal", "2" }, - { "behwithyehfinal", "2" }, - { "behwithyehisolated", "2" }, - { "braceleft", "1" }, - { "braceright", "1" }, - { "bracketleft", "1" }, - { "bracketright", "1" }, - { "brokenbar", "1" }, - { "bullet", "1" }, - { "c", "1" }, - { "caron", "1" }, - { "ccedilla", "1" }, - { "cedilla", "1" }, - { "cent", "1" }, - { "circumflex", "1" }, - { "colon", "1" }, - { "comma", "1" }, - { "copyright", "1" }, - { "currency", "1" }, - { "d", "1" }, - { "dad", "1" }, - { "dadfinal", "1" }, - { "dadinitial", "1" }, - { "dadisolated", "1" }, - { "dadmedial", "1" }, - { "dagger", "1" }, - { "daggerdbl", "1" }, - { "dal", "1" }, - { "dalfinal", "1" }, - { "dalisolated", "1" }, - { "damma", "3" }, - { "dammahontatweel", "1" }, - { "dammaisolated", "1" }, - { "dammalow", "1" }, - { "dammaonhamza", "3" }, - { "dammatan", "3" }, - { "dammatanisolated", "1" }, - { "dammatanlow", "1" }, - { "dammatanonhamza", "3" }, - { "degree", "1" }, - { "delete", "1" }, - { "dieresis", "1" }, - { "divide", "1" }, - { "dollar", "1" }, - { "dotlessi", "1" }, - { "e", "1" }, - { "eacute", "1" }, - { "ecircumflex", "1" }, - { "edieresis", "1" }, - { "egrave", "1" }, - { "eight", "1" }, - { "ellipsis", "1" }, - { "endash", "1" }, - { "equal", "1" }, - { "eth", "1" }, - { "exclam", "1" }, - { "exclamdown", "1" }, - { "extendedarabicindicdigiteight", "1" }, - { "extendedarabicindicdigitfive", "1" }, - { "extendedarabicindicdigitfour", "1" }, - { "extendedarabicindicdigitnine", "1" }, - { "extendedarabicindicdigitone", "1" }, - { "extendedarabicindicdigitseven", "1" }, - { "extendedarabicindicdigitsix", "1" }, - { "extendedarabicindicdigitthree", "1" }, - { "extendedarabicindicdigittwo", "1" }, - { "extendedarabicindicdigitzero", "1" }, - { "f", "1" }, - { "farsiyeh", "1" }, - { "farsiyehfinal", "1" }, - { "farsiyehisolated", "1" }, - { "fatha", "3" }, - { "fathahontatweel", "1" }, - { "fathaisolated", "1" }, - { "fathalow", "1" }, - { "fathaonhamza", "3" }, - { "fathatan", "3" }, - { "fathatanisolated", "1" }, - { "fathatanlow", "1" }, - { "fathatanonhamza", "3" }, - { "fathatanontatweel", "1" }, - { "feh", "1" }, - { "fehfinal", "1" }, - { "fehinitial", "1" }, - { "fehisolated", "1" }, - { "fehmedial", "1" }, - { "fehwithalefmaksuraisolated", "2" }, - { "fehwithyehisolated", "2" }, - { "five", "1" }, - { "florin", "1" }, - { "four", "1" }, - { "g", "1" }, - { "gaf", "1" }, - { "gaffinal", "1" }, - { "gafinitial", "1" }, - { "gafisolated", "1" }, - { "gafmedial", "1" }, - { "germandbls", "1" }, - { "ghain", "1" }, - { "ghainfinal", "1" }, - { "ghaininitial", "1" }, - { "ghainisolated", "1" }, - { "ghainmedial", "1" }, - { "grave", "1" }, - { "greater", "1" }, - { "guillemotleft", "1" }, - { "guillemotright", "1" }, - { "guilsinglleft", "1" }, - { "guilsinglright", "1" }, - { "h", "1" }, - { "hah", "1" }, - { "hahfinal", "1" }, - { "hahinitial", "1" }, - { "hahisolated", "1" }, - { "hahmedial", "1" }, - { "hahwithmeeminitial", "2" }, - { "hamza", "1" }, - { "hamzaisolated", "1" }, - { "heh", "1" }, - { "hehfinal", "1" }, - { "hehinitial", "1" }, - { "hehisolated", "1" }, - { "hehmedial", "1" }, - { "hehwithmeeminitial", "2" }, - { "highhamza", "1" }, - { "hyphenminus", "1" }, - { "i", "1" }, - { "iacute", "1" }, - { "icircumflex", "1" }, - { "idieresis", "1" }, - { "igrave", "1" }, - { "j", "1" }, - { "jeem", "1" }, - { "jeemfinal", "1" }, - { "jeeminitial", "1" }, - { "jeemisolated", "1" }, - { "jeemmedial", "1" }, - { "jeemwithmeeminitial", "2" }, - { "jeh", "1" }, - { "jehfinal", "1" }, - { "jehisolated", "1" }, - { "k", "1" }, - { "kafinitial", "1" }, - { "kafisolated", "1" }, - { "kafmedial", "1" }, - { "kasra", "3" }, - { "kasrahontatweel", "1" }, - { "kasraisolated", "1" }, - { "kasralow", "1" }, - { "kasratan", "3" }, - { "kasratanisolated", "1" }, - { "kasratanlow", "1" }, - { "keheh", "1" }, - { "kehehfinal", "1" }, - { "kehehinitial", "1" }, - { "kehehisolated", "1" }, - { "kehehmedial", "1" }, - { "khah", "1" }, - { "khahfinal", "1" }, - { "khahinitial", "1" }, - { "khahisolated", "1" }, - { "khahmedial", "1" }, - { "khahwithmeeminitial", "2" }, - { "l", "1" }, - { "lam", "1" }, - { "lamfinal", "1" }, - { "laminitial", "1" }, - { "lamisolated", "1" }, - { "lammedial", "1" }, - { "lamwithaleffinal", "2" }, - { "lamwithalefhamzaabovefinal", "2" }, - { "lamwithalefhamzaaboveisolatedd", "2" }, - { "lamwithalefhamzabelowfinal", "2" }, - { "lamwithalefhamzabelowisolated", "2" }, - { "lamwithalefisolated", "2" }, - { "lamwithalefmaddaabovefinal", "2" }, - { "lamwithalefmaddaaboveisolatedd", "2" }, - { "lamwithalefmaksuraisolated", "2" }, - { "lamwithhahinitial", "2" }, - { "lamwithhahisolated", "2" }, - { "lamwithhehinitial", "2" }, - { "lamwithjeeminitial", "2" }, - { "lamwithjeemisolated", "2" }, - { "lamwithkhahinitial", "2" }, - { "lamwithkhahisolated", "2" }, - { "lamwithmeeminitial", "2" }, - { "lamwithmeemisolated", "2" }, - { "lamwithmeemwithhahinitial", "2" }, - { "lamwithmeemwithjeeminitial", "2" }, - { "lamwithyehisolated", "2" }, - { "lefttoright", "1" }, - { "less", "1" }, - { "logicalnot", "1" }, - { "m", "1" }, - { "macron", "1" }, - { "meem", "1" }, - { "meemfinal", "1" }, - { "meeminitial", "1" }, - { "meemisolated", "1" }, - { "meemmedial", "1" }, - { "meemwithhahinitial", "2" }, - { "meemwithjeeminitial", "2" }, - { "meemwithkhahinitial", "2" }, - { "meemwithmeeminitial", "2" }, - { "micro", "1" }, - { "multiply", "1" }, - { "n", "1" }, - { "nine", "1" }, - { "nonbreakingspace", "1" }, - { "nonmarkingreturn", "1" }, - { "noon", "1" }, - { "noonfinal", "1" }, - { "nooninitial", "1" }, - { "noonisolated", "1" }, - { "noonmedial", "1" }, - { "noonwithalefmaksurafinal", "2" }, - { "noonwithalefmaksuraisolated", "2" }, - { "noonwithhahinitial", "2" }, - { "noonwithhehinitial", "2" }, - { "noonwithjeeminitial", "2" }, - { "noonwithkhahinitial", "2" }, - { "noonwithmeeminitial", "2" }, - { "noonwithmeemisolated", "2" }, - { "noonwithyehfinal", "2" }, - { "noonwithyehisolated", "2" }, - { "noonwithzainfinal", "2" }, - { "ntilde", "1" }, - { "numbersign", "1" }, - { "o", "1" }, - { "oacute", "1" }, - { "ocircumflex", "1" }, - { "odieresis", "1" }, - { "oe", "1" }, - { "ograve", "1" }, - { "one", "1" }, - { "onehalf", "1" }, - { "onequarter", "1" }, - { "onesuperior", "1" }, - { "ordfeminine", "1" }, - { "ordmasculine", "1" }, - { "ornateleftparenthesis", "1" }, - { "ornaterightparenthesis", "1" }, - { "oslash", "1" }, - { "otilde", "1" }, - { "p", "1" }, - { "paragraph", "1" }, - { "parenleft", "1" }, - { "parenright", "1" }, - { "peh", "1" }, - { "pehfinal", "1" }, - { "pehinitial", "1" }, - { "pehisolated", "1" }, - { "pehmedial", "1" }, - { "pehwithhehinitial", "2" }, - { "percent", "1" }, - { "period", "1" }, - { "periodcentered", "1" }, - { "perthousand", "1" }, - { "plus", "1" }, - { "plusminus", "1" }, - { "q", "1" }, - { "qaf", "1" }, - { "qaffinal", "1" }, - { "qafinitial", "1" }, - { "qafisolated", "1" }, - { "qafmedial", "1" }, - { "question", "1" }, - { "questiondown", "1" }, - { "quotedash", "1" }, - { "quotedbl", "1" }, - { "quotedblbase", "1" }, - { "quotedblleft", "1" }, - { "quotedblright", "1" }, - { "quoteleft", "1" }, - { "quoteright", "1" }, - { "quotesinglbase", "1" }, - { "quotesingle", "1" }, - { "r", "1" }, - { "rayaleflam", "2" }, - { "registered", "1" }, - { "reh", "1" }, - { "rehfinal", "1" }, - { "rehisolated", "1" }, - { "righttoleft", "1" }, - { "s", "1" }, - { "sad", "1" }, - { "sadfinal", "1" }, - { "sadinitial", "1" }, - { "sadisolated", "1" }, - { "sadmedial", "1" }, - { "scaron", "1" }, - { "section", "1" }, - { "seen", "1" }, - { "seenfinal", "1" }, - { "seeninitial", "1" }, - { "seenisolated", "1" }, - { "seenmedial", "1" }, - { "seenwithmeeminitial", "2" }, - { "semicolon", "1" }, - { "seven", "1" }, - { "sfthyphen", "1" }, - { "shadda", "3" }, - { "shaddahontatweel", "1" }, - { "shaddaisolated", "1" }, - { "shaddalow", "1" }, - { "shaddawithdammaisolated", "1" }, - { "shaddawithdammaisolatedlow", "3" }, - { "shaddawithdammamedial", "1" }, - { "shaddawithdammatanisolated", "1" }, - { "shaddawithdammatanisolatedlow", "3" }, - { "shaddawithfathaisolated", "1" }, - { "shaddawithfathaisolatedlow", "3" }, - { "shaddawithfathamedial", "1" }, - { "shaddawithfathatanisolated", "3" }, - { "shaddawithfathatanisolatedlow", "3" }, - { "shaddawithkasraisolated", "1" }, - { "shaddawithkasraisolatedlow", "3" }, - { "shaddawithkasramedial", "1" }, - { "shaddawithkasratanisolated", "1" }, - { "shaddawithkasratanisolatedlow", "3" }, - { "sheen", "1" }, - { "sheenfinal", "1" }, - { "sheeninitial", "1" }, - { "sheenisolated", "1" }, - { "sheenmedial", "1" }, - { "sheenwithmeeminitial", "2" }, - { "six", "1" }, - { "slash", "1" }, - { "smallhighmadda", "3" }, - { "space", "1" }, - { "sterling", "1" }, - { "sukun", "3" }, - { "sukunisolated", "1" }, - { "sukunlow", "1" }, - { "sukunonhamza", "3" }, - { "sukunontatweel", "1" }, - { "superscriptalef", "3" }, - { "t", "1" }, - { "tah", "1" }, - { "tahfinal", "1" }, - { "tahinitial", "1" }, - { "tahisolated", "1" }, - { "tahmedial", "1" }, - { "tatweel", "1" }, - { "tcheh", "1" }, - { "tchehfinal", "1" }, - { "tchehinitial", "1" }, - { "tchehisolated", "1" }, - { "tchehmedial", "1" }, - { "teh", "1" }, - { "tehfinal", "1" }, - { "tehinitial", "1" }, - { "tehisolated", "1" }, - { "tehmarbuta", "1" }, - { "tehmarbutafinal", "1" }, - { "tehmarbutaisolated", "1" }, - { "tehmedial", "1" }, - { "tehwithalefmaksurafinal", "2" }, - { "tehwithhahinitial", "2" }, - { "tehwithhehinitial", "2" }, - { "tehwithjeeminitial", "2" }, - { "tehwithkhahinitial", "2" }, - { "tehwithmeeminitial", "2" }, - { "tehwithmeemisolated", "2" }, - { "tehwithnoonfinal", "2" }, - { "tehwithyehfinal", "2" }, - { "tehwithyehisolated", "2" }, - { "thal", "1" }, - { "thalfinal", "1" }, - { "thalisolated", "1" }, - { "theh", "1" }, - { "thehfinal", "1" }, - { "thehinitial", "1" }, - { "thehisolated", "1" }, - { "thehmedial", "1" }, - { "thehwithmeeminitial", "2" }, - { "thehwithmeemisolated", "2" }, - { "thorn", "1" }, - { "three", "1" }, - { "threequarters", "1" }, - { "threesuperior", "1" }, - { "tilde", "1" }, - { "trademark", "1" }, - { "two", "1" }, - { "twosuperior", "1" }, - { "u", "1" }, - { "uacute", "1" }, - { "ucircumflex", "1" }, - { "udieresis", "1" }, - { "ugrave", "1" }, - { "underscore", "1" }, - { "uni000D", "1" }, - { "uni0649.init", "1" }, - { "uni0649.medi", "1" }, - { "uni0654", "3" }, - { "uni0655", "3" }, - { "uni0655064D", "3" }, - { "uni06550650", "3" }, - { "uni25CC", "1" }, - { "uniE817", "2" }, - { "v", "1" }, - { "veh", "1" }, - { "vehfinal", "1" }, - { "vehinitial", "1" }, - { "vehisolated", "1" }, - { "vehmedial", "1" }, - { "w", "1" }, - { "waw", "1" }, - { "wawfinal", "1" }, - { "wawisolated", "1" }, - { "wawwithhamzaabove", "1" }, - { "wawwithhamzaabovefinal", "1" }, - { "wawwithhamzaaboveisolated", "1" }, - { "x", "1" }, - { "y", "1" }, - { "yacute", "1" }, - { "ydieresis", "1" }, - { "yeh", "1" }, - { "yehfinal", "1" }, - { "yehinitial", "1" }, - { "yehisolated", "1" }, - { "yehmedial", "1" }, - { "yehwithalefmaksurafinal", "2" }, - { "yehwithalefmaksuraisolated", "2" }, - { "yehwithhahinitial", "2" }, - { "yehwithhamzaabove", "1" }, - { "yehwithhamzaabovefinal", "1" }, - { "yehwithhamzaaboveinitial", "1" }, - { "yehwithhamzaaboveisolated", "1" }, - { "yehwithhamzaabovemedial", "1" }, - { "yehwithjeeminitial", "2" }, - { "yehwithkhahinitial", "2" }, - { "yehwithmeeminitial", "2" }, - { "yehwithmeemisolated", "2" }, - { "yehwithnoonfinal", "2" }, - { "yehwithrehfinal", "2" }, - { "yen", "1" }, - { "z", "1" }, - { "zah", "1" }, - { "zahfinal", "1" }, - { "zahinitial", "1" }, - { "zahisolated", "1" }, - { "zahmedial", "1" }, - { "zain", "1" }, - { "zainfinal", "1" }, - { "zainisolated", "1" }, - { "zcaron", "1" }, - { "zero", "1" }, - { "zerojoin", "1" }, - { "zeronojoin", "1" }, - { "zerowidthnobreakspace", "1" }, - }, - }, - // arab-003.ttx - { "f2", "lu0", - new String[][] { - { "_bar", "1" }, - { "_damma", "1" }, - { "_dot1", "1" }, - { "_dot1_hat", "1" }, - { "_dot1_smallV", "1" }, - { "_dot1_tah", "1" }, - { "_dot2h", "1" }, - { "_dot2h_tah", "1" }, - { "_dot2v", "1" }, - { "_dot3d", "1" }, - { "_dot3h", "1" }, - { "_dot3u", "1" }, - { "_dot3u_tah", "1" }, - { "_dot4", "1" }, - { "_gafBar", "1" }, - { "_gafBar_dot2h", "1" }, - { "_gafBar_dot3u", "1" }, - { "_hamza", "1" }, - { "_hamzaDamma", "1" }, - { "_hat", "1" }, - { "_highHamza", "1" }, - { "_hook", "1" }, - { "_invSmallV", "1" }, - { "_lines", "1" }, - { "_madda", "1" }, - { "_ring", "1" }, - { "_smallV", "1" }, - { "_tah", "1" }, - { "_vline", "1" }, - { "_wasla", "1" }, - { "_wavyHamza", "1" }, - { "_wavyHamza.b", "1" }, - { "a", "1" }, - { "absAutoKashida", "1" }, - { "absJeemRetro1", "1" }, - { "absJeemRetro1Fin", "1" }, - { "absJeemRetro1Ini", "1" }, - { "absJeemRetro1Med", "1" }, - { "absJeemRetro2", "1" }, - { "absJeemRetro2Fin", "1" }, - { "absJeemRetro2Ini", "1" }, - { "absJeemRetro2Med", "1" }, - { "absJeemRetro3", "1" }, - { "absJeemRetro3Fin", "1" }, - { "absJeemRetro3Ini", "1" }, - { "absJeemRetro3Med", "1" }, - { "absJehRetro1", "1" }, - { "absJehRetro1Fin", "1" }, - { "absJehRetro2", "1" }, - { "absJehRetro2Fin", "1" }, - { "absLamRetro", "1" }, - { "absLamRetroAlef", "2" }, - { "absLamRetroAlefFin", "2" }, - { "absLamRetroFin", "1" }, - { "absLamRetroIni", "1" }, - { "absLamRetroIni.preAlef", "1" }, - { "absLamRetroMed", "1" }, - { "absLamRetroMed.preAlef", "1" }, - { "absShaddaAlef", "3" }, - { "absSheenRetro1", "1" }, - { "absSheenRetro1Fin", "1" }, - { "absSheenRetro1Ini", "1" }, - { "absSheenRetro1Med", "1" }, - { "absSheenRetro2", "1" }, - { "absSheenRetro2Fin", "1" }, - { "absSheenRetro2Ini", "1" }, - { "absSheenRetro2Med", "1" }, - { "absTchehRetro1", "1" }, - { "absTchehRetro1Fin", "1" }, - { "absTchehRetro1Ini", "1" }, - { "absTchehRetro1Med", "1" }, - { "absTchehRetro2", "1" }, - { "absTchehRetro2Fin", "1" }, - { "absTchehRetro2Ini", "1" }, - { "absTchehRetro2Med", "1" }, - { "absWawDotBelow", "1" }, - { "absWawDotBelowFin", "1" }, - { "ampersand", "1" }, - { "asciicircum", "1" }, - { "asciitilde", "1" }, - { "asterisk", "1" }, - { "asterisk.arab", "1" }, - { "at", "1" }, - { "b", "1" }, - { "backslash", "1" }, - { "bar", "1" }, - { "braceleft", "1" }, - { "braceright", "1" }, - { "bracketleft", "1" }, - { "bracketright", "1" }, - { "c", "1" }, - { "colon", "1" }, - { "colon.arab", "1" }, - { "comma", "1" }, - { "d", "1" }, - { "dollar", "1" }, - { "e", "1" }, - { "eight", "1" }, - { "eightMedium", "3" }, - { "eightSmall", "3" }, - { "equal", "1" }, - { "exclam", "1" }, - { "exclam.arab", "1" }, - { "f", "1" }, - { "five", "1" }, - { "fiveMedium", "3" }, - { "fiveSmall", "3" }, - { "four", "1" }, - { "fourMedium", "3" }, - { "fourSmall", "3" }, - { "g", "1" }, - { "grave", "1" }, - { "greater", "1" }, - { "h", "1" }, - { "hyphen", "1" }, - { "i", "1" }, - { "j", "1" }, - { "k", "1" }, - { "l", "1" }, - { "less", "1" }, - { "m", "1" }, - { "n", "1" }, - { "nine", "1" }, - { "nineMedium", "3" }, - { "nineSmall", "3" }, - { "nonmarkingreturn", "1" }, - { "numbersign", "1" }, - { "o", "1" }, - { "one", "1" }, - { "oneMedium", "3" }, - { "oneSmall", "3" }, - { "p", "1" }, - { "parenleft", "1" }, - { "parenleft.arab", "1" }, - { "parenright", "1" }, - { "parenright.arab", "1" }, - { "percent", "1" }, - { "period", "1" }, - { "plus", "1" }, - { "q", "1" }, - { "question", "1" }, - { "quotedbl", "1" }, - { "quotedblleft.arab", "1" }, - { "quotedblright.arab", "1" }, - { "quoteleft.arab", "1" }, - { "quoteright.arab", "1" }, - { "quotesingle", "1" }, - { "r", "1" }, - { "s", "1" }, - { "semicolon", "1" }, - { "seven", "1" }, - { "sevenMedium", "3" }, - { "sevenSmall", "3" }, - { "six", "1" }, - { "sixMedium", "3" }, - { "sixSmall", "3" }, - { "slash", "1" }, - { "space", "1" }, - { "t", "1" }, - { "three", "1" }, - { "threeMedium", "3" }, - { "threeSmall", "3" }, - { "two", "1" }, - { "twoMedium", "3" }, - { "twoSmall", "3" }, - { "u", "1" }, - { "underscore", "1" }, - { "uni060C", "1" }, - { "uni060C.downward", "1" }, - { "uni0614", "3" }, - { "uni061B", "1" }, - { "uni061B.downward", "1" }, - { "uni061E", "1" }, - { "uni061F", "1" }, - { "uni0621", "1" }, - { "uni0622", "1" }, - { "uni0622.fina", "1" }, - { "uni0622.fina.postLamIni", "1" }, - { "uni0622.fina.postLamMed", "1" }, - { "uni0623", "1" }, - { "uni0623.fina", "1" }, - { "uni0623.fina.postLamIni", "1" }, - { "uni0623.fina.postLamMed", "1" }, - { "uni0624", "1" }, - { "uni0624.fina", "1" }, - { "uni0625", "1" }, - { "uni0625.fina", "1" }, - { "uni0625.fina.postLamIni", "1" }, - { "uni0625.fina.postLamMed", "1" }, - { "uni0626", "1" }, - { "uni0626.fina", "1" }, - { "uni0626.init", "1" }, - { "uni0626.medi", "1" }, - { "uni0627", "1" }, - { "uni0627.fina", "1" }, - { "uni0627.fina.postLamIni", "1" }, - { "uni0627.fina.postLamMed", "1" }, - { "uni0628", "1" }, - { "uni0628.fina", "1" }, - { "uni0628.init", "1" }, - { "uni0628.medi", "1" }, - { "uni0629", "1" }, - { "uni0629.fina", "1" }, - { "uni062A", "1" }, - { "uni062A.fina", "1" }, - { "uni062A.init", "1" }, - { "uni062A.medi", "1" }, - { "uni062B", "1" }, - { "uni062B.fina", "1" }, - { "uni062B.init", "1" }, - { "uni062B.medi", "1" }, - { "uni062C", "1" }, - { "uni062C.fina", "1" }, - { "uni062C.init", "1" }, - { "uni062C.medi", "1" }, - { "uni062D", "1" }, - { "uni062D.fina", "1" }, - { "uni062D.init", "1" }, - { "uni062D.medi", "1" }, - { "uni062E", "1" }, - { "uni062E.fina", "1" }, - { "uni062E.init", "1" }, - { "uni062E.medi", "1" }, - { "uni062F", "1" }, - { "uni062F.fina", "1" }, - { "uni0630", "1" }, - { "uni0630.fina", "1" }, - { "uni0631", "1" }, - { "uni0631.fina", "1" }, - { "uni0632", "1" }, - { "uni0632.fina", "1" }, - { "uni0633", "1" }, - { "uni0633.fina", "1" }, - { "uni0633.init", "1" }, - { "uni0633.medi", "1" }, - { "uni0634", "1" }, - { "uni0634.fina", "1" }, - { "uni0634.init", "1" }, - { "uni0634.medi", "1" }, - { "uni0635", "1" }, - { "uni0635.fina", "1" }, - { "uni0635.init", "1" }, - { "uni0635.medi", "1" }, - { "uni0636", "1" }, - { "uni0636.fina", "1" }, - { "uni0636.init", "1" }, - { "uni0636.medi", "1" }, - { "uni0637", "1" }, - { "uni0637.fina", "1" }, - { "uni0637.init", "1" }, - { "uni0637.medi", "1" }, - { "uni0638", "1" }, - { "uni0638.fina", "1" }, - { "uni0638.init", "1" }, - { "uni0638.medi", "1" }, - { "uni0639", "1" }, - { "uni0639.fina", "1" }, - { "uni0639.init", "1" }, - { "uni0639.medi", "1" }, - { "uni063A", "1" }, - { "uni063A.fina", "1" }, - { "uni063A.init", "1" }, - { "uni063A.medi", "1" }, - { "uni0640", "1" }, - { "uni0641", "1" }, - { "uni0641.fina", "1" }, - { "uni0641.init", "1" }, - { "uni0641.medi", "1" }, - { "uni0642", "1" }, - { "uni0642.fina", "1" }, - { "uni0642.init", "1" }, - { "uni0642.medi", "1" }, - { "uni0643", "1" }, - { "uni0643.fina", "1" }, - { "uni0643.init", "1" }, - { "uni0643.medi", "1" }, - { "uni0644", "1" }, - { "uni0644.fina", "1" }, - { "uni0644.init", "1" }, - { "uni0644.init.preAlef", "1" }, - { "uni0644.medi", "1" }, - { "uni0644.medi.preAlef", "1" }, - { "uni06440627", "2" }, - { "uni06440627.fina", "2" }, - { "uni0645", "1" }, - { "uni0645.fina", "1" }, - { "uni0645.fina.sindhi", "1" }, - { "uni0645.init", "1" }, - { "uni0645.medi", "1" }, - { "uni0645.sindhi", "1" }, - { "uni0646", "1" }, - { "uni0646.fina", "1" }, - { "uni0646.init", "1" }, - { "uni0646.medi", "1" }, - { "uni0647", "1" }, - { "uni0647.fina", "1" }, - { "uni0647.fina.hooked", "1" }, - { "uni0647.fina.knottedFlat", "1" }, - { "uni0647.fina.knottedHigh", "1" }, - { "uni0647.init", "1" }, - { "uni0647.init.hooked", "1" }, - { "uni0647.knotted", "1" }, - { "uni0647.medi", "1" }, - { "uni0647.medi.hooked", "1" }, - { "uni0647.medi.knottedHigh", "1" }, - { "uni0648", "1" }, - { "uni0648.fina", "1" }, - { "uni0649", "1" }, - { "uni0649.fina", "1" }, - { "uni0649.init", "1" }, - { "uni0649.medi", "1" }, - { "uni064A", "1" }, - { "uni064A.fina", "1" }, - { "uni064A.fina.noDots", "1" }, - { "uni064A.init", "1" }, - { "uni064A.init.noDots", "1" }, - { "uni064A.medi", "1" }, - { "uni064A.medi.noDots", "1" }, - { "uni064A.noDots", "1" }, - { "uni064B", "3" }, - { "uni064C", "3" }, - { "uni064C.sixNine", "3" }, - { "uni064D", "3" }, - { "uni064E", "3" }, - { "uni064F", "3" }, - { "uni0650", "3" }, - { "uni0651", "3" }, - { "uni0651064B", "3" }, - { "uni0651064C", "3" }, - { "uni0651064D", "3" }, - { "uni0651064E", "3" }, - { "uni0651064F", "3" }, - { "uni06510650", "3" }, - { "uni0652", "3" }, - { "uni0652.downOpen", "3" }, - { "uni0652.leftOpen", "3" }, - { "uni0653", "3" }, - { "uni0654", "3" }, - { "uni0654064E", "3" }, - { "uni0654064F", "3" }, - { "uni0655", "3" }, - { "uni0656", "3" }, - { "uni0657", "3" }, - { "uni0658", "3" }, - { "uni0659", "3" }, - { "uni065A", "3" }, - { "uni065B", "3" }, - { "uni065C", "3" }, - { "uni065D", "3" }, - { "uni065E", "3" }, - { "uni0660", "1" }, - { "uni0660.Medium", "3" }, - { "uni0660.Small", "3" }, - { "uni0661", "1" }, - { "uni0661.Medium", "3" }, - { "uni0661.Small", "3" }, - { "uni0662", "1" }, - { "uni0662.Medium", "3" }, - { "uni0662.Small", "3" }, - { "uni0663", "1" }, - { "uni0663.Medium", "3" }, - { "uni0663.Small", "3" }, - { "uni0664", "1" }, - { "uni0664.Medium", "3" }, - { "uni0664.Small", "3" }, - { "uni0665", "1" }, - { "uni0665.Medium", "3" }, - { "uni0665.Small", "3" }, - { "uni0666", "1" }, - { "uni0666.Medium", "3" }, - { "uni0666.Small", "3" }, - { "uni0667", "1" }, - { "uni0667.Medium", "3" }, - { "uni0667.Small", "3" }, - { "uni0668", "1" }, - { "uni0668.Medium", "3" }, - { "uni0668.Small", "3" }, - { "uni0669", "1" }, - { "uni0669.Medium", "3" }, - { "uni0669.Small", "3" }, - { "uni066A", "1" }, - { "uni066B", "1" }, - { "uni066C", "1" }, - { "uni066D", "1" }, - { "uni066E", "1" }, - { "uni066E.fina", "1" }, - { "uni066E.init", "1" }, - { "uni066E.medi", "1" }, - { "uni066F", "1" }, - { "uni066F.fina", "1" }, - { "uni066F.init", "1" }, - { "uni066F.medi", "1" }, - { "uni0670", "3" }, - { "uni0670.large", "3" }, - { "uni0671", "1" }, - { "uni0671.fina", "1" }, - { "uni0671.fina.postLamIni", "1" }, - { "uni0671.fina.postLamMed", "1" }, - { "uni0672", "1" }, - { "uni0672.fina", "1" }, - { "uni0672.fina.postLamIni", "1" }, - { "uni0672.fina.postLamMed", "1" }, - { "uni0673", "1" }, - { "uni0673.fina", "1" }, - { "uni0673.fina.postLamIni", "1" }, - { "uni0673.fina.postLamMed", "1" }, - { "uni0674", "3" }, - { "uni0675", "1" }, - { "uni0675.fina", "1" }, - { "uni0675.fina.postLamIni", "1" }, - { "uni0675.fina.postLamMed", "1" }, - { "uni0676", "1" }, - { "uni0676.fina", "1" }, - { "uni0677", "1" }, - { "uni0677.fina", "1" }, - { "uni0678", "1" }, - { "uni0678.fina", "1" }, - { "uni0678.init", "1" }, - { "uni0678.medi", "1" }, - { "uni0679", "1" }, - { "uni0679.fina", "1" }, - { "uni0679.init", "1" }, - { "uni0679.medi", "1" }, - { "uni067A", "1" }, - { "uni067A.fina", "1" }, - { "uni067A.init", "1" }, - { "uni067A.medi", "1" }, - { "uni067B", "1" }, - { "uni067B.fina", "1" }, - { "uni067B.init", "1" }, - { "uni067B.medi", "1" }, - { "uni067C", "1" }, - { "uni067C.fina", "1" }, - { "uni067C.init", "1" }, - { "uni067C.medi", "1" }, - { "uni067D", "1" }, - { "uni067D.fina", "1" }, - { "uni067D.init", "1" }, - { "uni067D.medi", "1" }, - { "uni067E", "1" }, - { "uni067E.fina", "1" }, - { "uni067E.init", "1" }, - { "uni067E.medi", "1" }, - { "uni067F", "1" }, - { "uni067F.fina", "1" }, - { "uni067F.init", "1" }, - { "uni067F.medi", "1" }, - { "uni0680", "1" }, - { "uni0680.fina", "1" }, - { "uni0680.init", "1" }, - { "uni0680.medi", "1" }, - { "uni0681", "1" }, - { "uni0681.fina", "1" }, - { "uni0681.init", "1" }, - { "uni0681.medi", "1" }, - { "uni0682", "1" }, - { "uni0682.fina", "1" }, - { "uni0682.init", "1" }, - { "uni0682.medi", "1" }, - { "uni0683", "1" }, - { "uni0683.fina", "1" }, - { "uni0683.init", "1" }, - { "uni0683.medi", "1" }, - { "uni0684", "1" }, - { "uni0684.fina", "1" }, - { "uni0684.init", "1" }, - { "uni0684.medi", "1" }, - { "uni0685", "1" }, - { "uni0685.fina", "1" }, - { "uni0685.init", "1" }, - { "uni0685.medi", "1" }, - { "uni0686", "1" }, - { "uni0686.fina", "1" }, - { "uni0686.init", "1" }, - { "uni0686.medi", "1" }, - { "uni0687", "1" }, - { "uni0687.fina", "1" }, - { "uni0687.init", "1" }, - { "uni0687.medi", "1" }, - { "uni0688", "1" }, - { "uni0688.fina", "1" }, - { "uni0689", "1" }, - { "uni0689.fina", "1" }, - { "uni068A", "1" }, - { "uni068A.fina", "1" }, - { "uni068B", "1" }, - { "uni068B.fina", "1" }, - { "uni068C", "1" }, - { "uni068C.fina", "1" }, - { "uni068D", "1" }, - { "uni068D.fina", "1" }, - { "uni068E", "1" }, - { "uni068E.fina", "1" }, - { "uni068F", "1" }, - { "uni068F.fina", "1" }, - { "uni0690", "1" }, - { "uni0690.fina", "1" }, - { "uni0691", "1" }, - { "uni0691.fina", "1" }, - { "uni0692", "1" }, - { "uni0692.fina", "1" }, - { "uni0693", "1" }, - { "uni0693.fina", "1" }, - { "uni0694", "1" }, - { "uni0694.fina", "1" }, - { "uni0695", "1" }, - { "uni0695.fina", "1" }, - { "uni0696", "1" }, - { "uni0696.fina", "1" }, - { "uni0697", "1" }, - { "uni0697.fina", "1" }, - { "uni0698", "1" }, - { "uni0698.dotHat", "1" }, - { "uni0698.fina", "1" }, - { "uni0698.fina.dotHat", "1" }, - { "uni0699", "1" }, - { "uni0699.fina", "1" }, - { "uni069A", "1" }, - { "uni069A.fina", "1" }, - { "uni069A.init", "1" }, - { "uni069A.medi", "1" }, - { "uni069B", "1" }, - { "uni069B.fina", "1" }, - { "uni069B.init", "1" }, - { "uni069B.medi", "1" }, - { "uni069C", "1" }, - { "uni069C.fina", "1" }, - { "uni069C.init", "1" }, - { "uni069C.medi", "1" }, - { "uni069D", "1" }, - { "uni069D.fina", "1" }, - { "uni069D.init", "1" }, - { "uni069D.medi", "1" }, - { "uni069E", "1" }, - { "uni069E.fina", "1" }, - { "uni069E.init", "1" }, - { "uni069E.medi", "1" }, - { "uni069F", "1" }, - { "uni069F.fina", "1" }, - { "uni069F.init", "1" }, - { "uni069F.medi", "1" }, - { "uni06A0", "1" }, - { "uni06A0.fina", "1" }, - { "uni06A0.init", "1" }, - { "uni06A0.medi", "1" }, - { "uni06A1", "1" }, - { "uni06A1.fina", "1" }, - { "uni06A1.init", "1" }, - { "uni06A1.medi", "1" }, - { "uni06A2", "1" }, - { "uni06A2.fina", "1" }, - { "uni06A2.init", "1" }, - { "uni06A2.medi", "1" }, - { "uni06A3", "1" }, - { "uni06A3.fina", "1" }, - { "uni06A3.init", "1" }, - { "uni06A3.medi", "1" }, - { "uni06A4", "1" }, - { "uni06A4.fina", "1" }, - { "uni06A4.init", "1" }, - { "uni06A4.medi", "1" }, - { "uni06A5", "1" }, - { "uni06A5.fina", "1" }, - { "uni06A5.init", "1" }, - { "uni06A5.medi", "1" }, - { "uni06A6", "1" }, - { "uni06A6.fina", "1" }, - { "uni06A6.init", "1" }, - { "uni06A6.medi", "1" }, - { "uni06A7", "1" }, - { "uni06A7.fina", "1" }, - { "uni06A7.init", "1" }, - { "uni06A7.medi", "1" }, - { "uni06A8", "1" }, - { "uni06A8.fina", "1" }, - { "uni06A8.init", "1" }, - { "uni06A8.medi", "1" }, - { "uni06A9", "1" }, - { "uni06A9.fina", "1" }, - { "uni06A9.init", "1" }, - { "uni06A9.medi", "1" }, - { "uni06AA", "1" }, - { "uni06AA.fina", "1" }, - { "uni06AA.init", "1" }, - { "uni06AA.medi", "1" }, - { "uni06AB", "1" }, - { "uni06AB.fina", "1" }, - { "uni06AB.init", "1" }, - { "uni06AB.medi", "1" }, - { "uni06AC", "1" }, - { "uni06AC.fina", "1" }, - { "uni06AC.init", "1" }, - { "uni06AC.medi", "1" }, - { "uni06AD", "1" }, - { "uni06AD.fina", "1" }, - { "uni06AD.init", "1" }, - { "uni06AD.medi", "1" }, - { "uni06AE", "1" }, - { "uni06AE.fina", "1" }, - { "uni06AE.init", "1" }, - { "uni06AE.medi", "1" }, - { "uni06AF", "1" }, - { "uni06AF.fina", "1" }, - { "uni06AF.init", "1" }, - { "uni06AF.medi", "1" }, - { "uni06B0", "1" }, - { "uni06B0.fina", "1" }, - { "uni06B0.init", "1" }, - { "uni06B0.medi", "1" }, - { "uni06B1", "1" }, - { "uni06B1.fina", "1" }, - { "uni06B1.init", "1" }, - { "uni06B1.medi", "1" }, - { "uni06B2", "1" }, - { "uni06B2.fina", "1" }, - { "uni06B2.init", "1" }, - { "uni06B2.medi", "1" }, - { "uni06B3", "1" }, - { "uni06B3.fina", "1" }, - { "uni06B3.init", "1" }, - { "uni06B3.medi", "1" }, - { "uni06B4", "1" }, - { "uni06B4.fina", "1" }, - { "uni06B4.init", "1" }, - { "uni06B4.medi", "1" }, - { "uni06B5", "1" }, - { "uni06B5.fina", "1" }, - { "uni06B5.init", "1" }, - { "uni06B5.init.preAlef", "1" }, - { "uni06B5.medi", "1" }, - { "uni06B5.medi.preAlef", "1" }, - { "uni06B50627", "2" }, - { "uni06B50627.fina", "2" }, - { "uni06B6", "1" }, - { "uni06B6.fina", "1" }, - { "uni06B6.init", "1" }, - { "uni06B6.init.preAlef", "1" }, - { "uni06B6.medi", "1" }, - { "uni06B6.medi.preAlef", "1" }, - { "uni06B60627", "2" }, - { "uni06B60627.fina", "2" }, - { "uni06B7", "1" }, - { "uni06B7.fina", "1" }, - { "uni06B7.init", "1" }, - { "uni06B7.init.preAlef", "1" }, - { "uni06B7.medi", "1" }, - { "uni06B7.medi.preAlef", "1" }, - { "uni06B70627", "2" }, - { "uni06B70627.fina", "2" }, - { "uni06B8", "1" }, - { "uni06B8.fina", "1" }, - { "uni06B8.init", "1" }, - { "uni06B8.init.preAlef", "1" }, - { "uni06B8.medi", "1" }, - { "uni06B8.medi.preAlef", "1" }, - { "uni06B80627", "2" }, - { "uni06B80627.fina", "2" }, - { "uni06B9", "1" }, - { "uni06B9.fina", "1" }, - { "uni06B9.init", "1" }, - { "uni06B9.medi", "1" }, - { "uni06BA", "1" }, - { "uni06BA.fina", "1" }, - { "uni06BA.init", "1" }, - { "uni06BA.medi", "1" }, - { "uni06BB", "1" }, - { "uni06BB.fina", "1" }, - { "uni06BB.init", "1" }, - { "uni06BB.medi", "1" }, - { "uni06BC", "1" }, - { "uni06BC.fina", "1" }, - { "uni06BC.init", "1" }, - { "uni06BC.medi", "1" }, - { "uni06BD", "1" }, - { "uni06BD.fina", "1" }, - { "uni06BD.init", "1" }, - { "uni06BD.medi", "1" }, - { "uni06BE", "1" }, - { "uni06BE.fina", "1" }, - { "uni06BE.init", "1" }, - { "uni06BE.medi", "1" }, - { "uni06BF", "1" }, - { "uni06BF.fina", "1" }, - { "uni06BF.init", "1" }, - { "uni06BF.medi", "1" }, - { "uni06C0", "1" }, - { "uni06C0.fina", "1" }, - { "uni06C0.init", "1" }, - { "uni06C0.medi", "1" }, - { "uni06C1", "1" }, - { "uni06C1.fina", "1" }, - { "uni06C1.init", "1" }, - { "uni06C1.medi", "1" }, - { "uni06C2", "1" }, - { "uni06C2.fina", "1" }, - { "uni06C2.init", "1" }, - { "uni06C2.medi", "1" }, - { "uni06C3", "1" }, - { "uni06C3.fina", "1" }, - { "uni06C4", "1" }, - { "uni06C4.fina", "1" }, - { "uni06C5", "1" }, - { "uni06C5.fina", "1" }, - { "uni06C6", "1" }, - { "uni06C6.fina", "1" }, - { "uni06C7", "1" }, - { "uni06C7.fina", "1" }, - { "uni06C8", "1" }, - { "uni06C8.fina", "1" }, - { "uni06C9", "1" }, - { "uni06C9.fina", "1" }, - { "uni06CA", "1" }, - { "uni06CA.fina", "1" }, - { "uni06CB", "1" }, - { "uni06CB.fina", "1" }, - { "uni06CC", "1" }, - { "uni06CC.fina", "1" }, - { "uni06CC.init", "1" }, - { "uni06CC.medi", "1" }, - { "uni06CD", "1" }, - { "uni06CD.fina", "1" }, - { "uni06CE", "1" }, - { "uni06CE.fina", "1" }, - { "uni06CE.init", "1" }, - { "uni06CE.medi", "1" }, - { "uni06CF", "1" }, - { "uni06CF.fina", "1" }, - { "uni06D0", "1" }, - { "uni06D0.fina", "1" }, - { "uni06D0.init", "1" }, - { "uni06D0.medi", "1" }, - { "uni06D1", "1" }, - { "uni06D1.fina", "1" }, - { "uni06D1.init", "1" }, - { "uni06D1.medi", "1" }, - { "uni06D2", "1" }, - { "uni06D2.fina", "1" }, - { "uni06D3", "1" }, - { "uni06D3.fina", "1" }, - { "uni06D4", "1" }, - { "uni06D5", "1" }, - { "uni06D6", "3" }, - { "uni06D7", "3" }, - { "uni06D8", "3" }, - { "uni06D9", "3" }, - { "uni06DA", "3" }, - { "uni06DB", "3" }, - { "uni06DC", "3" }, - { "uni06DD", "1" }, - { "uni06DD.2", "1" }, - { "uni06DD.3", "1" }, - { "uni06DD.aat1", "1" }, - { "uni06DD.aat2", "1" }, - { "uni06DD.aat3", "1" }, - { "uni06DD.sp1", "1" }, - { "uni06DD.sp2", "1" }, - { "uni06DD.sp3", "1" }, - { "uni06DE", "1" }, - { "uni06DF", "3" }, - { "uni06E0", "3" }, - { "uni06E1", "3" }, - { "uni06E2", "3" }, - { "uni06E3", "3" }, - { "uni06E4", "3" }, - { "uni06E5", "3" }, - { "uni06E6", "3" }, - { "uni06E7", "3" }, - { "uni06E8", "3" }, - { "uni06E9", "1" }, - { "uni06EA", "3" }, - { "uni06EB", "3" }, - { "uni06EC", "3" }, - { "uni06ED", "3" }, - { "uni06EE", "1" }, - { "uni06EE.fina", "1" }, - { "uni06EF", "1" }, - { "uni06EF.fina", "1" }, - { "uni06F0", "1" }, - { "uni06F0.Medium", "3" }, - { "uni06F0.Small", "3" }, - { "uni06F1", "1" }, - { "uni06F1.Medium", "3" }, - { "uni06F1.Small", "3" }, - { "uni06F2", "1" }, - { "uni06F2.Medium", "3" }, - { "uni06F2.Small", "3" }, - { "uni06F3", "1" }, - { "uni06F3.Medium", "3" }, - { "uni06F3.Small", "3" }, - { "uni06F4", "1" }, - { "uni06F4.Medium", "3" }, - { "uni06F4.Medium.urdu", "3" }, - { "uni06F4.Small", "3" }, - { "uni06F4.Small.urdu", "3" }, - { "uni06F4.urdu", "1" }, - { "uni06F5", "1" }, - { "uni06F5.Medium", "3" }, - { "uni06F5.Small", "3" }, - { "uni06F6", "1" }, - { "uni06F6.Medium", "3" }, - { "uni06F6.Medium.urdu", "3" }, - { "uni06F6.Small", "3" }, - { "uni06F6.Small.urdu", "3" }, - { "uni06F6.urdu", "1" }, - { "uni06F7", "1" }, - { "uni06F7.Medium", "3" }, - { "uni06F7.Medium.urdu", "3" }, - { "uni06F7.Small", "3" }, - { "uni06F7.Small.urdu", "3" }, - { "uni06F7.urdu", "1" }, - { "uni06F8", "1" }, - { "uni06F8.Medium", "3" }, - { "uni06F8.Small", "3" }, - { "uni06F9", "1" }, - { "uni06F9.Medium", "3" }, - { "uni06F9.Small", "3" }, - { "uni06FA", "1" }, - { "uni06FA.fina", "1" }, - { "uni06FA.init", "1" }, - { "uni06FA.medi", "1" }, - { "uni06FB", "1" }, - { "uni06FB.fina", "1" }, - { "uni06FB.init", "1" }, - { "uni06FB.medi", "1" }, - { "uni06FC", "1" }, - { "uni06FC.fina", "1" }, - { "uni06FC.init", "1" }, - { "uni06FC.medi", "1" }, - { "uni06FD", "1" }, - { "uni06FE", "1" }, - { "uni06FF", "1" }, - { "uni06FF.fina", "1" }, - { "uni06FF.init", "1" }, - { "uni06FF.medi", "1" }, - { "uni0750", "1" }, - { "uni0750.fina", "1" }, - { "uni0750.init", "1" }, - { "uni0750.medi", "1" }, - { "uni0751", "1" }, - { "uni0751.fina", "1" }, - { "uni0751.init", "1" }, - { "uni0751.medi", "1" }, - { "uni0752", "1" }, - { "uni0752.fina", "1" }, - { "uni0752.init", "1" }, - { "uni0752.medi", "1" }, - { "uni0753", "1" }, - { "uni0753.fina", "1" }, - { "uni0753.init", "1" }, - { "uni0753.medi", "1" }, - { "uni0754", "1" }, - { "uni0754.fina", "1" }, - { "uni0754.init", "1" }, - { "uni0754.medi", "1" }, - { "uni0755", "1" }, - { "uni0755.fina", "1" }, - { "uni0755.init", "1" }, - { "uni0755.medi", "1" }, - { "uni0756", "1" }, - { "uni0756.fina", "1" }, - { "uni0756.init", "1" }, - { "uni0756.medi", "1" }, - { "uni0757", "1" }, - { "uni0757.fina", "1" }, - { "uni0757.init", "1" }, - { "uni0757.medi", "1" }, - { "uni0758", "1" }, - { "uni0758.fina", "1" }, - { "uni0758.init", "1" }, - { "uni0758.medi", "1" }, - { "uni0759", "1" }, - { "uni0759.fina", "1" }, - { "uni075A", "1" }, - { "uni075A.fina", "1" }, - { "uni075B", "1" }, - { "uni075B.fina", "1" }, - { "uni075C", "1" }, - { "uni075C.fina", "1" }, - { "uni075C.init", "1" }, - { "uni075C.medi", "1" }, - { "uni075D", "1" }, - { "uni075D.fina", "1" }, - { "uni075D.init", "1" }, - { "uni075D.medi", "1" }, - { "uni075E", "1" }, - { "uni075E.fina", "1" }, - { "uni075E.init", "1" }, - { "uni075E.medi", "1" }, - { "uni075F", "1" }, - { "uni075F.fina", "1" }, - { "uni075F.init", "1" }, - { "uni075F.medi", "1" }, - { "uni0760", "1" }, - { "uni0760.fina", "1" }, - { "uni0760.init", "1" }, - { "uni0760.medi", "1" }, - { "uni0761", "1" }, - { "uni0761.fina", "1" }, - { "uni0761.init", "1" }, - { "uni0761.medi", "1" }, - { "uni0762", "1" }, - { "uni0762.fina", "1" }, - { "uni0762.init", "1" }, - { "uni0762.medi", "1" }, - { "uni0763", "1" }, - { "uni0763.fina", "1" }, - { "uni0763.init", "1" }, - { "uni0763.medi", "1" }, - { "uni0764", "1" }, - { "uni0764.fina", "1" }, - { "uni0764.init", "1" }, - { "uni0764.medi", "1" }, - { "uni0765", "1" }, - { "uni0765.fina", "1" }, - { "uni0765.init", "1" }, - { "uni0765.medi", "1" }, - { "uni0766", "1" }, - { "uni0766.fina", "1" }, - { "uni0766.init", "1" }, - { "uni0766.medi", "1" }, - { "uni0767", "1" }, - { "uni0767.fina", "1" }, - { "uni0767.init", "1" }, - { "uni0767.medi", "1" }, - { "uni0768", "1" }, - { "uni0768.fina", "1" }, - { "uni0768.init", "1" }, - { "uni0768.medi", "1" }, - { "uni0769", "1" }, - { "uni0769.fina", "1" }, - { "uni0769.init", "1" }, - { "uni0769.medi", "1" }, - { "uni076A", "1" }, - { "uni076A.fina", "1" }, - { "uni076A.init", "1" }, - { "uni076A.init.preAlef", "1" }, - { "uni076A.medi", "1" }, - { "uni076A.medi.preAlef", "1" }, - { "uni076A0627", "2" }, - { "uni076A0627.fina", "2" }, - { "uni076B", "1" }, - { "uni076B.fina", "1" }, - { "uni076C", "1" }, - { "uni076C.fina", "1" }, - { "uni076D", "1" }, - { "uni076D.fina", "1" }, - { "uni076D.init", "1" }, - { "uni076D.medi", "1" }, - { "uni2000", "1" }, - { "uni2001", "1" }, - { "uni2002", "1" }, - { "uni2003", "1" }, - { "uni2004", "1" }, - { "uni2005", "1" }, - { "uni2006", "1" }, - { "uni2007", "1" }, - { "uni2008", "1" }, - { "uni2009", "1" }, - { "uni200A", "1" }, - { "uni200B", "1" }, - { "uni200C", "1" }, - { "uni200D", "1" }, - { "uni200E", "1" }, - { "uni200F", "1" }, - { "uni202A", "1" }, - { "uni202B", "1" }, - { "uni202C", "1" }, - { "uni202D", "1" }, - { "uni202E", "1" }, - { "uni2060", "1" }, - { "uni206C", "1" }, - { "uni206D", "1" }, - { "uni25CC", "1" }, - { "uniFD3E", "1" }, - { "uniFD3F", "1" }, - { "uniFDF2", "1" }, - { "uniFDFC", "1" }, - { "uniFEFF", "1" }, - { "v", "1" }, - { "w", "1" }, - { "x", "1" }, - { "y", "1" }, - { "z", "1" }, - { "zero", "1" }, - { "zeroMedium", "3" }, - { "zeroSmall", "3" }, - }, - }, - // arab-004.ttx - { "f3", "lu0", - new String[][] { - { "_bar", "1" }, - { "_damma", "1" }, - { "_dot1", "1" }, - { "_dot1_hat", "1" }, - { "_dot1_smallV", "1" }, - { "_dot1_tah", "1" }, - { "_dot2h", "1" }, - { "_dot2h_tah", "1" }, - { "_dot2v", "1" }, - { "_dot3d", "1" }, - { "_dot3h", "1" }, - { "_dot3u", "1" }, - { "_dot3u_tah", "1" }, - { "_dot4", "1" }, - { "_gafBar", "1" }, - { "_gafBarShort", "1" }, - { "_gafBarShort_dot2h", "1" }, - { "_gafBarShort_dot3u", "1" }, - { "_gafBar_dot2h", "1" }, - { "_gafBar_dot3u", "1" }, - { "_hamza", "1" }, - { "_hamzaDamma", "1" }, - { "_hat", "1" }, - { "_highHamza", "1" }, - { "_invSmallV", "1" }, - { "_lines", "1" }, - { "_madda", "1" }, - { "_ring", "1" }, - { "_smallV", "1" }, - { "_tah", "1" }, - { "_vline", "1" }, - { "_wasla", "1" }, - { "_wavyHamza", "1" }, - { "_wavyHamza.b", "1" }, - { "a", "1" }, - { "absAutoKashida", "1" }, - { "absJeemRetro1", "1" }, - { "absJeemRetro1Fin", "1" }, - { "absJeemRetro1Ini", "1" }, - { "absJeemRetro1Med", "1" }, - { "absJeemRetro2", "1" }, - { "absJeemRetro2Fin", "1" }, - { "absJeemRetro2Ini", "1" }, - { "absJeemRetro2Med", "1" }, - { "absJeemRetro3", "1" }, - { "absJeemRetro3Fin", "1" }, - { "absJeemRetro3Ini", "1" }, - { "absJeemRetro3Med", "1" }, - { "absJehRetro1", "1" }, - { "absJehRetro1Fin", "1" }, - { "absJehRetro2", "1" }, - { "absJehRetro2Fin", "1" }, - { "absLamRetro", "1" }, - { "absLamRetroAlef", "2" }, - { "absLamRetroAlefFin", "2" }, - { "absLamRetroFin", "1" }, - { "absLamRetroIni", "1" }, - { "absLamRetroIni.preAlef", "1" }, - { "absLamRetroMed", "1" }, - { "absLamRetroMed.preAlef", "1" }, - { "absShaddaAlef", "3" }, - { "absSheenRetro1", "1" }, - { "absSheenRetro1Fin", "1" }, - { "absSheenRetro1Ini", "1" }, - { "absSheenRetro1Med", "1" }, - { "absSheenRetro2", "1" }, - { "absSheenRetro2Fin", "1" }, - { "absSheenRetro2Ini", "1" }, - { "absSheenRetro2Med", "1" }, - { "absTchehRetro1", "1" }, - { "absTchehRetro1Fin", "1" }, - { "absTchehRetro1Ini", "1" }, - { "absTchehRetro1Med", "1" }, - { "absTchehRetro2", "1" }, - { "absTchehRetro2Fin", "1" }, - { "absTchehRetro2Ini", "1" }, - { "absTchehRetro2Med", "1" }, - { "absWawDotBelow", "1" }, - { "absWawDotBelowFin", "1" }, - { "ampersand", "1" }, - { "asciicircum", "1" }, - { "asciitilde", "1" }, - { "asterisk", "1" }, - { "at", "1" }, - { "b", "1" }, - { "backslash", "1" }, - { "bar", "1" }, - { "braceleft", "1" }, - { "braceright", "1" }, - { "bracketleft", "1" }, - { "bracketright", "1" }, - { "c", "1" }, - { "colon", "1" }, - { "comma", "1" }, - { "d", "1" }, - { "dollar", "1" }, - { "e", "1" }, - { "eight", "1" }, - { "eightMedium", "3" }, - { "eightSmall", "3" }, - { "equal", "1" }, - { "exclam", "1" }, - { "f", "1" }, - { "five", "1" }, - { "fiveMedium", "3" }, - { "fiveSmall", "3" }, - { "four", "1" }, - { "fourMedium", "3" }, - { "fourSmall", "3" }, - { "g", "1" }, - { "grave", "1" }, - { "greater", "1" }, - { "h", "1" }, - { "hyphen", "1" }, - { "i", "1" }, - { "j", "1" }, - { "k", "1" }, - { "l", "1" }, - { "less", "1" }, - { "m", "1" }, - { "n", "1" }, - { "nine", "1" }, - { "nineMedium", "3" }, - { "nineSmall", "3" }, - { "nonmarkingreturn", "1" }, - { "numbersign", "1" }, - { "o", "1" }, - { "one", "1" }, - { "oneMedium", "3" }, - { "oneSmall", "3" }, - { "p", "1" }, - { "parenleft", "1" }, - { "parenright", "1" }, - { "percent", "1" }, - { "period", "1" }, - { "plus", "1" }, - { "q", "1" }, - { "question", "1" }, - { "quotedbl", "1" }, - { "quotesingle", "1" }, - { "r", "1" }, - { "s", "1" }, - { "semicolon", "1" }, - { "seven", "1" }, - { "sevenMedium", "3" }, - { "sevenSmall", "3" }, - { "six", "1" }, - { "sixMedium", "3" }, - { "sixSmall", "3" }, - { "slash", "1" }, - { "space", "1" }, - { "t", "1" }, - { "three", "1" }, - { "threeMedium", "3" }, - { "threeSmall", "3" }, - { "two", "1" }, - { "twoMedium", "3" }, - { "twoSmall", "3" }, - { "u", "1" }, - { "underscore", "1" }, - { "uni0600", "1" }, - { "uni0600.2", "1" }, - { "uni0600.3", "1" }, - { "uni0600.aat1", "1" }, - { "uni0600.aat2", "1" }, - { "uni0600.aat3", "1" }, - { "uni0600.sp1", "1" }, - { "uni0600.sp2", "1" }, - { "uni0600.sp3", "1" }, - { "uni0601", "1" }, - { "uni0601.2", "1" }, - { "uni0601.3", "1" }, - { "uni0601.4", "1" }, - { "uni0601.aat1", "1" }, - { "uni0601.aat2", "1" }, - { "uni0601.aat3", "1" }, - { "uni0601.aat4", "1" }, - { "uni0601.sp1", "1" }, - { "uni0601.sp2", "1" }, - { "uni0601.sp3", "1" }, - { "uni0601.sp4", "1" }, - { "uni0602", "1" }, - { "uni0602.2", "1" }, - { "uni0602.aat1", "1" }, - { "uni0602.aat2", "1" }, - { "uni0602.sp1", "1" }, - { "uni0602.sp2", "1" }, - { "uni0603", "1" }, - { "uni0603.2", "1" }, - { "uni0603.3", "1" }, - { "uni0603.aat1", "1" }, - { "uni0603.aat2", "1" }, - { "uni0603.aat3", "1" }, - { "uni0603.sp1", "1" }, - { "uni0603.sp2", "1" }, - { "uni0603.sp3", "1" }, - { "uni060B", "1" }, - { "uni060C", "1" }, - { "uni060C.downward", "1" }, - { "uni060D", "1" }, - { "uni060E", "1" }, - { "uni060F", "1" }, - { "uni0610", "3" }, - { "uni0611", "3" }, - { "uni0612", "3" }, - { "uni0613", "3" }, - { "uni0614", "3" }, - { "uni0615", "3" }, - { "uni061B", "1" }, - { "uni061B.downward", "1" }, - { "uni061E", "1" }, - { "uni061F", "1" }, - { "uni0621", "1" }, - { "uni0622", "1" }, - { "uni0622.fina", "1" }, - { "uni0622.fina.postLamIni", "1" }, - { "uni0622.fina.postLamMed", "1" }, - { "uni0623", "1" }, - { "uni0623.fina", "1" }, - { "uni0623.fina.postLamIni", "1" }, - { "uni0623.fina.postLamMed", "1" }, - { "uni0624", "1" }, - { "uni0624.fina", "1" }, - { "uni0625", "1" }, - { "uni0625.fina", "1" }, - { "uni0625.fina.postLamIni", "1" }, - { "uni0625.fina.postLamMed", "1" }, - { "uni0626", "1" }, - { "uni0626.fina", "1" }, - { "uni0626.init", "1" }, - { "uni0626.medi", "1" }, - { "uni0627", "1" }, - { "uni0627.fina", "1" }, - { "uni0627.fina.postLamIni", "1" }, - { "uni0627.fina.postLamMed", "1" }, - { "uni0628", "1" }, - { "uni0628.fina", "1" }, - { "uni0628.init", "1" }, - { "uni0628.medi", "1" }, - { "uni0629", "1" }, - { "uni0629.fina", "1" }, - { "uni062A", "1" }, - { "uni062A.fina", "1" }, - { "uni062A.init", "1" }, - { "uni062A.medi", "1" }, - { "uni062B", "1" }, - { "uni062B.fina", "1" }, - { "uni062B.init", "1" }, - { "uni062B.medi", "1" }, - { "uni062C", "1" }, - { "uni062C.fina", "1" }, - { "uni062C.init", "1" }, - { "uni062C.medi", "1" }, - { "uni062D", "1" }, - { "uni062D.fina", "1" }, - { "uni062D.init", "1" }, - { "uni062D.medi", "1" }, - { "uni062E", "1" }, - { "uni062E.fina", "1" }, - { "uni062E.init", "1" }, - { "uni062E.medi", "1" }, - { "uni062F", "1" }, - { "uni062F.fina", "1" }, - { "uni0630", "1" }, - { "uni0630.fina", "1" }, - { "uni0631", "1" }, - { "uni0631.fina", "1" }, - { "uni0632", "1" }, - { "uni0632.fina", "1" }, - { "uni0633", "1" }, - { "uni0633.fina", "1" }, - { "uni0633.init", "1" }, - { "uni0633.medi", "1" }, - { "uni0634", "1" }, - { "uni0634.fina", "1" }, - { "uni0634.init", "1" }, - { "uni0634.medi", "1" }, - { "uni0635", "1" }, - { "uni0635.fina", "1" }, - { "uni0635.init", "1" }, - { "uni0635.medi", "1" }, - { "uni0636", "1" }, - { "uni0636.fina", "1" }, - { "uni0636.init", "1" }, - { "uni0636.medi", "1" }, - { "uni0637", "1" }, - { "uni0637.fina", "1" }, - { "uni0637.init", "1" }, - { "uni0637.medi", "1" }, - { "uni0638", "1" }, - { "uni0638.fina", "1" }, - { "uni0638.init", "1" }, - { "uni0638.medi", "1" }, - { "uni0639", "1" }, - { "uni0639.fina", "1" }, - { "uni0639.init", "1" }, - { "uni0639.medi", "1" }, - { "uni063A", "1" }, - { "uni063A.fina", "1" }, - { "uni063A.init", "1" }, - { "uni063A.medi", "1" }, - { "uni0640", "1" }, - { "uni0641", "1" }, - { "uni0641.fina", "1" }, - { "uni0641.init", "1" }, - { "uni0641.medi", "1" }, - { "uni0642", "1" }, - { "uni0642.fina", "1" }, - { "uni0642.init", "1" }, - { "uni0642.medi", "1" }, - { "uni0643", "1" }, - { "uni0643.fina", "1" }, - { "uni0643.init", "1" }, - { "uni0643.medi", "1" }, - { "uni0644", "1" }, - { "uni0644.fina", "1" }, - { "uni0644.init", "1" }, - { "uni0644.init.preAlef", "1" }, - { "uni0644.medi", "1" }, - { "uni0644.medi.preAlef", "1" }, - { "uni06440627", "2" }, - { "uni06440627.fina", "2" }, - { "uni0645", "1" }, - { "uni0645.fina", "1" }, - { "uni0645.fina.sindhi", "1" }, - { "uni0645.init", "1" }, - { "uni0645.medi", "1" }, - { "uni0645.sindhi", "1" }, - { "uni0646", "1" }, - { "uni0646.fina", "1" }, - { "uni0646.init", "1" }, - { "uni0646.medi", "1" }, - { "uni0647", "1" }, - { "uni0647.fina", "1" }, - { "uni0647.fina.hooked", "1" }, - { "uni0647.fina.knottedFlat", "1" }, - { "uni0647.fina.knottedHigh", "1" }, - { "uni0647.init", "1" }, - { "uni0647.init.hooked", "1" }, - { "uni0647.knotted", "1" }, - { "uni0647.medi", "1" }, - { "uni0647.medi.hooked", "1" }, - { "uni0647.medi.knottedHigh", "1" }, - { "uni0648", "1" }, - { "uni0648.fina", "1" }, - { "uni0649", "1" }, - { "uni0649.fina", "1" }, - { "uni0649.init", "1" }, - { "uni0649.medi", "1" }, - { "uni064A", "1" }, - { "uni064A.fina", "1" }, - { "uni064A.fina.noDots", "1" }, - { "uni064A.init", "1" }, - { "uni064A.init.noDots", "1" }, - { "uni064A.medi", "1" }, - { "uni064A.medi.noDots", "1" }, - { "uni064A.noDots", "1" }, - { "uni064B", "3" }, - { "uni064C", "3" }, - { "uni064C.sixNine", "3" }, - { "uni064D", "3" }, - { "uni064E", "3" }, - { "uni064F", "3" }, - { "uni0650", "3" }, - { "uni0651", "3" }, - { "uni0651064B", "3" }, - { "uni0651064C", "3" }, - { "uni0651064D", "3" }, - { "uni0651064E", "3" }, - { "uni0651064F", "3" }, - { "uni06510650", "3" }, - { "uni0652", "3" }, - { "uni0652.downOpen", "3" }, - { "uni0652.leftOpen", "3" }, - { "uni0653", "3" }, - { "uni0654", "3" }, - { "uni0654064E", "3" }, - { "uni0654064F", "3" }, - { "uni0655", "3" }, - { "uni0656", "3" }, - { "uni0657", "3" }, - { "uni0658", "3" }, - { "uni0659", "3" }, - { "uni065A", "3" }, - { "uni065B", "3" }, - { "uni065C", "3" }, - { "uni065D", "3" }, - { "uni065E", "3" }, - { "uni0660", "1" }, - { "uni0660.Medium", "3" }, - { "uni0660.Small", "3" }, - { "uni0661", "1" }, - { "uni0661.Medium", "3" }, - { "uni0661.Small", "3" }, - { "uni0662", "1" }, - { "uni0662.Medium", "3" }, - { "uni0662.Small", "3" }, - { "uni0663", "1" }, - { "uni0663.Medium", "3" }, - { "uni0663.Small", "3" }, - { "uni0664", "1" }, - { "uni0664.Medium", "3" }, - { "uni0664.Small", "3" }, - { "uni0665", "1" }, - { "uni0665.Medium", "3" }, - { "uni0665.Small", "3" }, - { "uni0666", "1" }, - { "uni0666.Medium", "3" }, - { "uni0666.Small", "3" }, - { "uni0667", "1" }, - { "uni0667.Medium", "3" }, - { "uni0667.Small", "3" }, - { "uni0668", "1" }, - { "uni0668.Medium", "3" }, - { "uni0668.Small", "3" }, - { "uni0669", "1" }, - { "uni0669.Medium", "3" }, - { "uni0669.Small", "3" }, - { "uni066A", "1" }, - { "uni066B", "1" }, - { "uni066C", "1" }, - { "uni066D", "1" }, - { "uni066E", "1" }, - { "uni066E.fina", "1" }, - { "uni066E.init", "1" }, - { "uni066E.medi", "1" }, - { "uni066F", "1" }, - { "uni066F.fina", "1" }, - { "uni066F.init", "1" }, - { "uni066F.medi", "1" }, - { "uni0670", "3" }, - { "uni0670.large", "3" }, - { "uni0671", "1" }, - { "uni0671.fina", "1" }, - { "uni0671.fina.postLamIni", "1" }, - { "uni0671.fina.postLamMed", "1" }, - { "uni0672", "1" }, - { "uni0672.fina", "1" }, - { "uni0672.fina.postLamIni", "1" }, - { "uni0672.fina.postLamMed", "1" }, - { "uni0673", "1" }, - { "uni0673.fina", "1" }, - { "uni0673.fina.postLamIni", "1" }, - { "uni0673.fina.postLamMed", "1" }, - { "uni0674", "3" }, - { "uni0675", "1" }, - { "uni0675.fina", "1" }, - { "uni0675.fina.postLamIni", "1" }, - { "uni0675.fina.postLamMed", "1" }, - { "uni0676", "1" }, - { "uni0676.fina", "1" }, - { "uni0677", "1" }, - { "uni0677.fina", "1" }, - { "uni0678", "1" }, - { "uni0678.fina", "1" }, - { "uni0678.init", "1" }, - { "uni0678.medi", "1" }, - { "uni0679", "1" }, - { "uni0679.fina", "1" }, - { "uni0679.init", "1" }, - { "uni0679.medi", "1" }, - { "uni067A", "1" }, - { "uni067A.fina", "1" }, - { "uni067A.init", "1" }, - { "uni067A.medi", "1" }, - { "uni067B", "1" }, - { "uni067B.fina", "1" }, - { "uni067B.init", "1" }, - { "uni067B.medi", "1" }, - { "uni067C", "1" }, - { "uni067C.fina", "1" }, - { "uni067C.init", "1" }, - { "uni067C.medi", "1" }, - { "uni067D", "1" }, - { "uni067D.fina", "1" }, - { "uni067D.init", "1" }, - { "uni067D.medi", "1" }, - { "uni067E", "1" }, - { "uni067E.fina", "1" }, - { "uni067E.init", "1" }, - { "uni067E.medi", "1" }, - { "uni067F", "1" }, - { "uni067F.fina", "1" }, - { "uni067F.init", "1" }, - { "uni067F.medi", "1" }, - { "uni0680", "1" }, - { "uni0680.fina", "1" }, - { "uni0680.init", "1" }, - { "uni0680.medi", "1" }, - { "uni0681", "1" }, - { "uni0681.fina", "1" }, - { "uni0681.init", "1" }, - { "uni0681.medi", "1" }, - { "uni0682", "1" }, - { "uni0682.fina", "1" }, - { "uni0682.init", "1" }, - { "uni0682.medi", "1" }, - { "uni0683", "1" }, - { "uni0683.fina", "1" }, - { "uni0683.init", "1" }, - { "uni0683.medi", "1" }, - { "uni0684", "1" }, - { "uni0684.fina", "1" }, - { "uni0684.init", "1" }, - { "uni0684.medi", "1" }, - { "uni0685", "1" }, - { "uni0685.fina", "1" }, - { "uni0685.init", "1" }, - { "uni0685.medi", "1" }, - { "uni0686", "1" }, - { "uni0686.fina", "1" }, - { "uni0686.init", "1" }, - { "uni0686.medi", "1" }, - { "uni0687", "1" }, - { "uni0687.fina", "1" }, - { "uni0687.init", "1" }, - { "uni0687.medi", "1" }, - { "uni0688", "1" }, - { "uni0688.fina", "1" }, - { "uni0689", "1" }, - { "uni0689.fina", "1" }, - { "uni068A", "1" }, - { "uni068A.fina", "1" }, - { "uni068B", "1" }, - { "uni068B.fina", "1" }, - { "uni068C", "1" }, - { "uni068C.fina", "1" }, - { "uni068D", "1" }, - { "uni068D.fina", "1" }, - { "uni068E", "1" }, - { "uni068E.fina", "1" }, - { "uni068F", "1" }, - { "uni068F.fina", "1" }, - { "uni0690", "1" }, - { "uni0690.fina", "1" }, - { "uni0691", "1" }, - { "uni0691.fina", "1" }, - { "uni0692", "1" }, - { "uni0692.fina", "1" }, - { "uni0693", "1" }, - { "uni0693.fina", "1" }, - { "uni0694", "1" }, - { "uni0694.fina", "1" }, - { "uni0695", "1" }, - { "uni0695.fina", "1" }, - { "uni0696", "1" }, - { "uni0696.fina", "1" }, - { "uni0697", "1" }, - { "uni0697.fina", "1" }, - { "uni0698", "1" }, - { "uni0698.dotHat", "1" }, - { "uni0698.fina", "1" }, - { "uni0698.fina.dotHat", "1" }, - { "uni0699", "1" }, - { "uni0699.fina", "1" }, - { "uni069A", "1" }, - { "uni069A.fina", "1" }, - { "uni069A.init", "1" }, - { "uni069A.medi", "1" }, - { "uni069B", "1" }, - { "uni069B.fina", "1" }, - { "uni069B.init", "1" }, - { "uni069B.medi", "1" }, - { "uni069C", "1" }, - { "uni069C.fina", "1" }, - { "uni069C.init", "1" }, - { "uni069C.medi", "1" }, - { "uni069D", "1" }, - { "uni069D.fina", "1" }, - { "uni069D.init", "1" }, - { "uni069D.medi", "1" }, - { "uni069E", "1" }, - { "uni069E.fina", "1" }, - { "uni069E.init", "1" }, - { "uni069E.medi", "1" }, - { "uni069F", "1" }, - { "uni069F.fina", "1" }, - { "uni069F.init", "1" }, - { "uni069F.medi", "1" }, - { "uni06A0", "1" }, - { "uni06A0.fina", "1" }, - { "uni06A0.init", "1" }, - { "uni06A0.medi", "1" }, - { "uni06A1", "1" }, - { "uni06A1.fina", "1" }, - { "uni06A1.init", "1" }, - { "uni06A1.medi", "1" }, - { "uni06A2", "1" }, - { "uni06A2.fina", "1" }, - { "uni06A2.init", "1" }, - { "uni06A2.medi", "1" }, - { "uni06A3", "1" }, - { "uni06A3.fina", "1" }, - { "uni06A3.init", "1" }, - { "uni06A3.medi", "1" }, - { "uni06A4", "1" }, - { "uni06A4.fina", "1" }, - { "uni06A4.init", "1" }, - { "uni06A4.medi", "1" }, - { "uni06A5", "1" }, - { "uni06A5.fina", "1" }, - { "uni06A5.init", "1" }, - { "uni06A5.medi", "1" }, - { "uni06A6", "1" }, - { "uni06A6.fina", "1" }, - { "uni06A6.init", "1" }, - { "uni06A6.medi", "1" }, - { "uni06A7", "1" }, - { "uni06A7.fina", "1" }, - { "uni06A7.init", "1" }, - { "uni06A7.medi", "1" }, - { "uni06A8", "1" }, - { "uni06A8.fina", "1" }, - { "uni06A8.init", "1" }, - { "uni06A8.medi", "1" }, - { "uni06A9", "1" }, - { "uni06A9.fina", "1" }, - { "uni06A9.init", "1" }, - { "uni06A9.medi", "1" }, - { "uni06AA", "1" }, - { "uni06AA.fina", "1" }, - { "uni06AA.init", "1" }, - { "uni06AA.medi", "1" }, - { "uni06AB", "1" }, - { "uni06AB.fina", "1" }, - { "uni06AB.init", "1" }, - { "uni06AB.medi", "1" }, - { "uni06AC", "1" }, - { "uni06AC.fina", "1" }, - { "uni06AC.init", "1" }, - { "uni06AC.medi", "1" }, - { "uni06AD", "1" }, - { "uni06AD.fina", "1" }, - { "uni06AD.init", "1" }, - { "uni06AD.medi", "1" }, - { "uni06AE", "1" }, - { "uni06AE.fina", "1" }, - { "uni06AE.init", "1" }, - { "uni06AE.medi", "1" }, - { "uni06AF", "1" }, - { "uni06AF.fina", "1" }, - { "uni06AF.init", "1" }, - { "uni06AF.medi", "1" }, - { "uni06B0", "1" }, - { "uni06B0.fina", "1" }, - { "uni06B0.init", "1" }, - { "uni06B0.medi", "1" }, - { "uni06B1", "1" }, - { "uni06B1.fina", "1" }, - { "uni06B1.init", "1" }, - { "uni06B1.medi", "1" }, - { "uni06B2", "1" }, - { "uni06B2.fina", "1" }, - { "uni06B2.init", "1" }, - { "uni06B2.medi", "1" }, - { "uni06B3", "1" }, - { "uni06B3.fina", "1" }, - { "uni06B3.init", "1" }, - { "uni06B3.medi", "1" }, - { "uni06B4", "1" }, - { "uni06B4.fina", "1" }, - { "uni06B4.init", "1" }, - { "uni06B4.medi", "1" }, - { "uni06B5", "1" }, - { "uni06B5.fina", "1" }, - { "uni06B5.init", "1" }, - { "uni06B5.init.preAlef", "1" }, - { "uni06B5.medi", "1" }, - { "uni06B5.medi.preAlef", "1" }, - { "uni06B50627", "2" }, - { "uni06B50627.fina", "2" }, - { "uni06B6", "1" }, - { "uni06B6.fina", "1" }, - { "uni06B6.init", "1" }, - { "uni06B6.init.preAlef", "1" }, - { "uni06B6.medi", "1" }, - { "uni06B6.medi.preAlef", "1" }, - { "uni06B60627", "2" }, - { "uni06B60627.fina", "2" }, - { "uni06B7", "1" }, - { "uni06B7.fina", "1" }, - { "uni06B7.init", "1" }, - { "uni06B7.init.preAlef", "1" }, - { "uni06B7.medi", "1" }, - { "uni06B7.medi.preAlef", "1" }, - { "uni06B70627", "2" }, - { "uni06B70627.fina", "2" }, - { "uni06B8", "1" }, - { "uni06B8.fina", "1" }, - { "uni06B8.init", "1" }, - { "uni06B8.init.preAlef", "1" }, - { "uni06B8.medi", "1" }, - { "uni06B8.medi.preAlef", "1" }, - { "uni06B80627", "2" }, - { "uni06B80627.fina", "2" }, - { "uni06B9", "1" }, - { "uni06B9.fina", "1" }, - { "uni06B9.init", "1" }, - { "uni06B9.medi", "1" }, - { "uni06BA", "1" }, - { "uni06BA.fina", "1" }, - { "uni06BA.init", "1" }, - { "uni06BA.medi", "1" }, - { "uni06BB", "1" }, - { "uni06BB.fina", "1" }, - { "uni06BB.init", "1" }, - { "uni06BB.medi", "1" }, - { "uni06BC", "1" }, - { "uni06BC.fina", "1" }, - { "uni06BC.init", "1" }, - { "uni06BC.medi", "1" }, - { "uni06BD", "1" }, - { "uni06BD.fina", "1" }, - { "uni06BD.init", "1" }, - { "uni06BD.medi", "1" }, - { "uni06BE", "1" }, - { "uni06BE.fina", "1" }, - { "uni06BE.init", "1" }, - { "uni06BE.medi", "1" }, - { "uni06BF", "1" }, - { "uni06BF.fina", "1" }, - { "uni06BF.init", "1" }, - { "uni06BF.medi", "1" }, - { "uni06C0", "1" }, - { "uni06C0.fina", "1" }, - { "uni06C0.init", "1" }, - { "uni06C0.medi", "1" }, - { "uni06C1", "1" }, - { "uni06C1.fina", "1" }, - { "uni06C1.init", "1" }, - { "uni06C1.medi", "1" }, - { "uni06C2", "1" }, - { "uni06C2.fina", "1" }, - { "uni06C2.init", "1" }, - { "uni06C2.medi", "1" }, - { "uni06C3", "1" }, - { "uni06C3.fina", "1" }, - { "uni06C4", "1" }, - { "uni06C4.fina", "1" }, - { "uni06C5", "1" }, - { "uni06C5.fina", "1" }, - { "uni06C6", "1" }, - { "uni06C6.fina", "1" }, - { "uni06C7", "1" }, - { "uni06C7.fina", "1" }, - { "uni06C8", "1" }, - { "uni06C8.fina", "1" }, - { "uni06C9", "1" }, - { "uni06C9.fina", "1" }, - { "uni06CA", "1" }, - { "uni06CA.fina", "1" }, - { "uni06CB", "1" }, - { "uni06CB.fina", "1" }, - { "uni06CC", "1" }, - { "uni06CC.fina", "1" }, - { "uni06CC.init", "1" }, - { "uni06CC.medi", "1" }, - { "uni06CD", "1" }, - { "uni06CD.fina", "1" }, - { "uni06CE", "1" }, - { "uni06CE.fina", "1" }, - { "uni06CE.init", "1" }, - { "uni06CE.medi", "1" }, - { "uni06CF", "1" }, - { "uni06CF.fina", "1" }, - { "uni06D0", "1" }, - { "uni06D0.fina", "1" }, - { "uni06D0.init", "1" }, - { "uni06D0.medi", "1" }, - { "uni06D1", "1" }, - { "uni06D1.fina", "1" }, - { "uni06D1.init", "1" }, - { "uni06D1.medi", "1" }, - { "uni06D2", "1" }, - { "uni06D2.fina", "1" }, - { "uni06D3", "1" }, - { "uni06D3.fina", "1" }, - { "uni06D4", "1" }, - { "uni06D5", "1" }, - { "uni06D6", "3" }, - { "uni06D7", "3" }, - { "uni06D8", "3" }, - { "uni06D9", "3" }, - { "uni06DA", "3" }, - { "uni06DB", "3" }, - { "uni06DC", "3" }, - { "uni06DD", "1" }, - { "uni06DD.2", "1" }, - { "uni06DD.3", "1" }, - { "uni06DD.aat1", "1" }, - { "uni06DD.aat2", "1" }, - { "uni06DD.aat3", "1" }, - { "uni06DD.alt", "1" }, - { "uni06DD.alt.2", "1" }, - { "uni06DD.alt.3", "1" }, - { "uni06DD.alt.aat1", "1" }, - { "uni06DD.alt.aat2", "1" }, - { "uni06DD.alt.aat3", "1" }, - { "uni06DD.altB", "1" }, - { "uni06DD.altB.2", "1" }, - { "uni06DD.altB.3", "1" }, - { "uni06DD.altB.aat1", "1" }, - { "uni06DD.altB.aat2", "1" }, - { "uni06DD.altB.aat3", "1" }, - { "uni06DD.sp1", "1" }, - { "uni06DD.sp2", "1" }, - { "uni06DD.sp3", "1" }, - { "uni06DE", "1" }, - { "uni06DF", "3" }, - { "uni06E0", "3" }, - { "uni06E1", "3" }, - { "uni06E2", "3" }, - { "uni06E3", "3" }, - { "uni06E4", "3" }, - { "uni06E5", "3" }, - { "uni06E6", "3" }, - { "uni06E7", "3" }, - { "uni06E8", "3" }, - { "uni06E9", "1" }, - { "uni06EA", "3" }, - { "uni06EB", "3" }, - { "uni06EC", "3" }, - { "uni06ED", "3" }, - { "uni06EE", "1" }, - { "uni06EE.fina", "1" }, - { "uni06EF", "1" }, - { "uni06EF.fina", "1" }, - { "uni06F0", "1" }, - { "uni06F0.Medium", "3" }, - { "uni06F0.Small", "3" }, - { "uni06F1", "1" }, - { "uni06F1.Medium", "3" }, - { "uni06F1.Small", "3" }, - { "uni06F2", "1" }, - { "uni06F2.Medium", "3" }, - { "uni06F2.Small", "3" }, - { "uni06F3", "1" }, - { "uni06F3.Medium", "3" }, - { "uni06F3.Small", "3" }, - { "uni06F4", "1" }, - { "uni06F4.Medium", "3" }, - { "uni06F4.Medium.urdu", "3" }, - { "uni06F4.Small", "3" }, - { "uni06F4.Small.urdu", "3" }, - { "uni06F4.urdu", "1" }, - { "uni06F5", "1" }, - { "uni06F5.Medium", "3" }, - { "uni06F5.Small", "3" }, - { "uni06F6", "1" }, - { "uni06F6.Medium", "3" }, - { "uni06F6.Medium.urdu", "3" }, - { "uni06F6.Small", "3" }, - { "uni06F6.Small.urdu", "3" }, - { "uni06F6.urdu", "1" }, - { "uni06F7", "1" }, - { "uni06F7.Medium", "3" }, - { "uni06F7.Medium.urdu", "3" }, - { "uni06F7.Small", "3" }, - { "uni06F7.Small.urdu", "3" }, - { "uni06F7.urdu", "1" }, - { "uni06F8", "1" }, - { "uni06F8.Medium", "3" }, - { "uni06F8.Small", "3" }, - { "uni06F9", "1" }, - { "uni06F9.Medium", "3" }, - { "uni06F9.Small", "3" }, - { "uni06FA", "1" }, - { "uni06FA.fina", "1" }, - { "uni06FA.init", "1" }, - { "uni06FA.medi", "1" }, - { "uni06FB", "1" }, - { "uni06FB.fina", "1" }, - { "uni06FB.init", "1" }, - { "uni06FB.medi", "1" }, - { "uni06FC", "1" }, - { "uni06FC.fina", "1" }, - { "uni06FC.init", "1" }, - { "uni06FC.medi", "1" }, - { "uni06FD", "1" }, - { "uni06FE", "1" }, - { "uni06FF", "1" }, - { "uni06FF.fina", "1" }, - { "uni06FF.init", "1" }, - { "uni06FF.medi", "1" }, - { "uni0750", "1" }, - { "uni0750.fina", "1" }, - { "uni0750.init", "1" }, - { "uni0750.medi", "1" }, - { "uni0751", "1" }, - { "uni0751.fina", "1" }, - { "uni0751.init", "1" }, - { "uni0751.medi", "1" }, - { "uni0752", "1" }, - { "uni0752.fina", "1" }, - { "uni0752.init", "1" }, - { "uni0752.medi", "1" }, - { "uni0753", "1" }, - { "uni0753.fina", "1" }, - { "uni0753.init", "1" }, - { "uni0753.medi", "1" }, - { "uni0754", "1" }, - { "uni0754.fina", "1" }, - { "uni0754.init", "1" }, - { "uni0754.medi", "1" }, - { "uni0755", "1" }, - { "uni0755.fina", "1" }, - { "uni0755.init", "1" }, - { "uni0755.medi", "1" }, - { "uni0756", "1" }, - { "uni0756.fina", "1" }, - { "uni0756.init", "1" }, - { "uni0756.medi", "1" }, - { "uni0757", "1" }, - { "uni0757.fina", "1" }, - { "uni0757.init", "1" }, - { "uni0757.medi", "1" }, - { "uni0758", "1" }, - { "uni0758.fina", "1" }, - { "uni0758.init", "1" }, - { "uni0758.medi", "1" }, - { "uni0759", "1" }, - { "uni0759.fina", "1" }, - { "uni075A", "1" }, - { "uni075A.fina", "1" }, - { "uni075B", "1" }, - { "uni075B.fina", "1" }, - { "uni075C", "1" }, - { "uni075C.fina", "1" }, - { "uni075C.init", "1" }, - { "uni075C.medi", "1" }, - { "uni075D", "1" }, - { "uni075D.fina", "1" }, - { "uni075D.init", "1" }, - { "uni075D.medi", "1" }, - { "uni075E", "1" }, - { "uni075E.fina", "1" }, - { "uni075E.init", "1" }, - { "uni075E.medi", "1" }, - { "uni075F", "1" }, - { "uni075F.fina", "1" }, - { "uni075F.init", "1" }, - { "uni075F.medi", "1" }, - { "uni0760", "1" }, - { "uni0760.fina", "1" }, - { "uni0760.init", "1" }, - { "uni0760.medi", "1" }, - { "uni0761", "1" }, - { "uni0761.fina", "1" }, - { "uni0761.init", "1" }, - { "uni0761.medi", "1" }, - { "uni0762", "1" }, - { "uni0762.fina", "1" }, - { "uni0762.init", "1" }, - { "uni0762.medi", "1" }, - { "uni0763", "1" }, - { "uni0763.fina", "1" }, - { "uni0763.init", "1" }, - { "uni0763.medi", "1" }, - { "uni0764", "1" }, - { "uni0764.fina", "1" }, - { "uni0764.init", "1" }, - { "uni0764.medi", "1" }, - { "uni0765", "1" }, - { "uni0765.fina", "1" }, - { "uni0765.init", "1" }, - { "uni0765.medi", "1" }, - { "uni0766", "1" }, - { "uni0766.fina", "1" }, - { "uni0766.init", "1" }, - { "uni0766.medi", "1" }, - { "uni0767", "1" }, - { "uni0767.fina", "1" }, - { "uni0767.init", "1" }, - { "uni0767.medi", "1" }, - { "uni0768", "1" }, - { "uni0768.fina", "1" }, - { "uni0768.init", "1" }, - { "uni0768.medi", "1" }, - { "uni0769", "1" }, - { "uni0769.fina", "1" }, - { "uni0769.init", "1" }, - { "uni0769.medi", "1" }, - { "uni076A", "1" }, - { "uni076A.fina", "1" }, - { "uni076A.init", "1" }, - { "uni076A.init.preAlef", "1" }, - { "uni076A.medi", "1" }, - { "uni076A.medi.preAlef", "1" }, - { "uni076A0627", "2" }, - { "uni076A0627.fina", "2" }, - { "uni076B", "1" }, - { "uni076B.fina", "1" }, - { "uni076C", "1" }, - { "uni076C.fina", "1" }, - { "uni076D", "1" }, - { "uni076D.fina", "1" }, - { "uni076D.init", "1" }, - { "uni076D.medi", "1" }, - { "uni2000", "1" }, - { "uni2001", "1" }, - { "uni2002", "1" }, - { "uni2003", "1" }, - { "uni2004", "1" }, - { "uni2005", "1" }, - { "uni2006", "1" }, - { "uni2007", "1" }, - { "uni2008", "1" }, - { "uni2009", "1" }, - { "uni200A", "1" }, - { "uni200B", "1" }, - { "uni200C", "1" }, - { "uni200D", "1" }, - { "uni200E", "1" }, - { "uni200F", "1" }, - { "uni202A", "1" }, - { "uni202B", "1" }, - { "uni202C", "1" }, - { "uni202D", "1" }, - { "uni202E", "1" }, - { "uni2060", "1" }, - { "uni206C", "1" }, - { "uni206D", "1" }, - { "uni25CC", "1" }, - { "uniFD3E", "1" }, - { "uniFD3F", "1" }, - { "uniFDF2", "1" }, - { "uniFDFC", "1" }, - { "uniFEFF", "1" }, - { "v", "1" }, - { "w", "1" }, - { "x", "1" }, - { "y", "1" }, - { "z", "1" }, - { "zero", "1" }, - { "zeroMedium", "3" }, - { "zeroSmall", "3" }, - }, - }, - }; - - private static Object[][] ltAttachmentPoint = { - { GlyphDefinitionTable.GDEF_LOOKUP_TYPE_ATTACHMENT_POINT }, - // arab-001.ttx - not present - // arab-002.ttx - maybe add tests - // arab-003.ttx - maybe add tests - // arab-004.ttx - maybe add tests - }; - - private static Object[][] ltLigatureCaret = { - { GlyphDefinitionTable.GDEF_LOOKUP_TYPE_LIGATURE_CARET }, - // arab-001.ttx - not present - // arab-002.ttx - maybe add tests - // arab-003.ttx - maybe add tests - // arab-004.ttx - maybe add tests - }; - - private static Object[][] ltMarkAttachment = { - { GlyphDefinitionTable.GDEF_LOOKUP_TYPE_MARK_ATTACHMENT }, - // arab-001.ttx - not present - // arab-002.ttx - maybe add tests - // arab-003.ttx - maybe add tests - // arab-004.ttx - maybe add tests - }; - - @Test - public void testGDEFGlyphClass() throws Exception { - performLookups(ltGlyphClass); - } - - @Test - public void testGDEFAttachmentPoint() throws Exception { - performLookups(ltAttachmentPoint); - } - - @Test - public void testGDEFLigatureCaret() throws Exception { - performLookups(ltLigatureCaret); - } - - @Test - public void testGDEFMarkAttachment() throws Exception { - performLookups(ltMarkAttachment); - } - - /** - * Perform lookups on all test data in test specification TS. - * @param ts test specification - */ - private void performLookups(Object[][] ts) { - assert ts.length > 0; - Object[] tp = ts[0]; - for (int i = 1; i < ts.length; i++) { - performLookups(tp, ts[i]); - } - } - - /** - * Perform lookups on all test data TD using test parameters TP. - * @param tp test parameters - * @param td test data - */ - private void performLookups(Object[] tp, Object[] td) { - assert tp.length > 0; - if (td.length > 1) { - String fid = (String) td[0]; - String lid = (String) td[1]; - TTXFile tf = findTTX(fid); - assertTrue(tf != null); - GlyphDefinitionTable gdef = tf.getGDEF(); - assertTrue(gdef != null); - String[][] tia = (String[][]) td[2]; - switch ((int) ((Integer) tp[0])) { - case GlyphDefinitionTable.GDEF_LOOKUP_TYPE_GLYPH_CLASS: - performGlyphClassLookups(tf, lid, tia); - break; - case GlyphDefinitionTable.GDEF_LOOKUP_TYPE_ATTACHMENT_POINT: - performAttachmentPointLookups(tf, lid, tia); - break; - case GlyphDefinitionTable.GDEF_LOOKUP_TYPE_LIGATURE_CARET: - performLigatureCaretLookups(tf, lid, tia); - break; - case GlyphDefinitionTable.GDEF_LOOKUP_TYPE_MARK_ATTACHMENT: - performMarkAttachmentLookups(tf, lid, tia); - break; - default: - assertTrue("bad lookup type", false); - break; - } - } - } - - private void performGlyphClassLookups(TTXFile tf, String lid, String[][] tia) { - GlyphDefinitionTable gdef = tf.getGDEF(); - assert gdef != null; - for (String[] ti : tia) { - assert ti != null; - assert ti.length > 1; - String gn = ti[0]; - assert gn != null; - String cn = ti[1]; - assert cn != null; - int g = tf.getGlyph(gn); - assertTrue(g >= 0); - int oc = Integer.parseInt(cn); - int tc = gdef.getGlyphClass(g); - assertEquals("bad glyph class for glyph \'" + gn + "\', gid(" + g + ")", oc, tc); - } - } - - private void performAttachmentPointLookups(TTXFile tf, String lid, String[][] tia) { - // not yet supported by GDEF or test TTX files - } - - private void performLigatureCaretLookups(TTXFile tf, String lid, String[][] tia) { - // not yet supported by GDEF or test TTX files - } - - private void performMarkAttachmentLookups(TTXFile tf, String lid, String[][] tia) { - // not yet supported by GDEF or test TTX files - } - - private String findTTXPath(String fid) { - for (String[] fs : ttxFonts) { - if ((fs != null) && (fs.length > 1)) { - if (fs[0].equals(fid)) { - return ttxFilesRoot + File.separator + fs[1]; - } - } - } - return null; - } - - private TTXFile findTTX(String fid) { - String pn = findTTXPath(fid); - assertTrue(pn != null); - try { - TTXFile tf = TTXFile.getFromCache(pn); - return tf; - } catch (Exception e) { - fail(e.getMessage()); - return null; - } - } - -} diff --git a/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java deleted file mode 100644 index cf63b4eff..000000000 --- a/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java +++ /dev/null @@ -1,469 +0,0 @@ -/* - * 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.complexscripts.fonts; - -import java.io.File; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -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"; - - private static String[][] ttxFonts = { - { "f0", "arab/ttx/arab-001.ttx" }, // simplified arabic - { "f1", "arab/ttx/arab-002.ttx" }, // traditional arabic - { "f2", "arab/ttx/arab-003.ttx" }, // lateef - { "f3", "arab/ttx/arab-004.ttx" }, // scheherazade - }; - - private static Object[][] ltSingle = { - { GlyphPositioningTable.GPOS_LOOKUP_TYPE_SINGLE }, - // arab-001.ttx - { "f0", "lu1", "arab", "dflt", "mark", - new Object[][] { - { - new String[] { "fathatan" }, - new int[][] { - { 0, 0, -412, 0 } - } - }, - { - new String[] { "fatha" }, - new int[][] { - { 0, 0, -410, 0 } - } - }, - }, - }, - { "f0", "lu9", "arab", "*", "*", - new Object[][] { - { - new String[] { "fathatan" }, - new int[][] { - { 50, 0, 0, 0 } - } - }, - { - new String[] { "fatha" }, - new int[][] { - { 50, 0, 0, 0 } - } - }, - }, - }, - { "f0", "lu10", "arab", "*", "*", - new Object[][] { - { - new String[] { "kasratan" }, - new int[][] { - { 0, -200, 0, 0 } - } - }, - { - new String[] { "kasra" }, - new int[][] { - { 0, -200, 0, 0 } - } - }, - }, - }, - { "f0", "lu11", "arab", "*", "*", - new Object[][] { - { - new String[] { "kasratan" }, - new int[][] { - { 0, -300, 0, 0 } - } - }, - { - new String[] { "kasra" }, - new int[][] { - { 0, -300, 0, 0 } - } - }, - { - new String[] { "uni0655" }, - new int[][] { - { 0, -250, 0, 0 } - } - }, - }, - }, - // arab-002.ttx - maybe add tests - // arab-003.ttx - maybe add tests - // arab-004.ttx - maybe add tests - }; - - private static Object[][] ltPair = { - { GlyphPositioningTable.GPOS_LOOKUP_TYPE_PAIR }, - // arab-001.ttx - { "f0", "lu0", "arab", "dflt", "kern", - new Object[][] { - { - new String[] { "wawwithhamzaabove", "hamza" }, - new int[][] { - { -300, 0, -300, 0 }, { 0, 0, 0, 0 } - } - }, - { - new String[] { "reh", "alefwithmaddaabove" }, - new int[][] { - { -500, 0, -500, 0 }, { 0, 0, 0, 0 } - } - }, - { - new String[] { "zain", "zain" }, - new int[][] { - { -190, 0, -190, 0 }, { 0, 0, 0, 0 } - } - }, - { - new String[] { "waw", "uni0649.init" }, - new int[][] { - { -145, 0, -145, 0 }, { 0, 0, 0, 0 } - } - }, - { - new String[] { "jeh", "uni06A5.init" }, - new int[][] { - { -345, 0, -345, 0 }, { 0, 0, 0, 0 } - } - }, - }, - }, - // arab-002.ttx - maybe add tests - // arab-003.ttx - maybe add tests - // arab-004.ttx - maybe add tests - }; - - private static Object[][] ltCursive = { - { GlyphPositioningTable.GPOS_LOOKUP_TYPE_CURSIVE }, - // arab-001.ttx - none used - // arab-002.ttx - none used - // arab-003.ttx - maybe add tests - { "f2", "lu0", "arab", "dflt", "curs", - new Object[][] { - { - new String[] { "uni0644.init.preAlef", "uni0622.fina.postLamIni" }, - new int[][] { - // { 576, 0, 0, 0 }, { 0, 0, 0, 0 } - with zero widths - { 295, 0, 0, 0 }, { 0, 0, 0, 0 } - } - }, - { - new String[] { "uni0644.medi.preAlef", "uni0622.fina.postLamMed" }, - new int[][] { - // { 550, 0, 0, 0 }, { 0, 0, 0, 0 } - with zero widths - { 282, 0, 0, 0 }, { 0, 0, 0, 0 } - } - }, - }, - }, - // arab-004.ttx - none used - }; - - private static Object[][] ltMarkToBase = { - { GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_BASE }, - // arab-001.ttx - maybe add tests - // arab-002.ttx - { "f1", "lu4", "arab", "dflt", "mark", - new Object[][] { - { - new String[] { "beh", "fatha" }, - new int[][] { - // { 0, 0, 0, 0 }, { 266, -672, 0, 0 } - with zero widths - { 0, 0, 0, 0 }, { 266, -672, -199, 0 } - } - }, - { - new String[] { "alefwithhamzabelow", "kasra" }, - new int[][] { - // { 0, 0, 0, 0 }, { -48, 344, 0, 0 } - with zero widths - { 0, 0, 0, 0 }, { -48, 344, -199, 0 } - } - }, - }, - }, - // arab-003.ttx - maybe add tests - // arab-004.ttx - maybe add tests - }; - - private static Object[][] ltMarkToLigature = { - { GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_LIGATURE }, - // arab-001.ttx - { "f0", "lu4", "arab", "dflt", "mark", - new Object[][] { - { - new String[] { "rayaleflam", "fatha", "fatha", "fatha", "fatha" }, - new int[][] { - { 0, 0, 0, 0 }, { 1260, -1150, 0, 0 }, { 910, -1020, 0, 0 }, { 590, -630, 0, 0 }, { 110, -720, 0, 0 } - } - }, - { - new String[] { "rayaleflam", "kasra", "kasra", "kasra", "kasra" }, - new int[][] { - { 0, 0, 0, 0 }, { 1110 , 225, 0, 0 }, { 760, 275, 0, 0 }, { 520, 475, 0, 0 }, { 110, 425, 0, 0 } - } - }, - }, - }, - // arab-002.ttx - maybe add tests - // arab-003.ttx - maybe add tests - // arab-004.ttx - maybe add tests - }; - - private static Object[][] ltMarkToMark = { - { GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_MARK }, - // arab-001.ttx - maybe add tests - // arab-002.ttx - maybe add tests - // arab-003.ttx - maybe add tests - // arab-004.ttx - { "f3", "lu3", "arab", "dflt", "mkmk", - new Object[][] { - { - new String[] { "uni064F", "uni064E" }, - new int[][] { - { 0, 0, 0, 0 }, { -15, 495, 0, 0 } - } - }, - { - new String[] { "uni0651", "uni0670" }, - new int[][] { - { 0, 0, 0, 0 }, { -30, 705, 0, 0 } - } - }, - }, - }, - }; - - private static Object[][] ltContextual = { - { GlyphPositioningTable.GPOS_LOOKUP_TYPE_CONTEXTUAL }, - // arab-001.ttx - none used - // arab-002.ttx - none used - // arab-003.ttx - none used - // arab-004.ttx - none used - }; - - private static Object[][] ltChainedContextual = { - { GlyphPositioningTable.GPOS_LOOKUP_TYPE_CHAINED_CONTEXTUAL }, - // arab-001.ttx - { "f0", "lu3", "arab", "dflt", "mark", - new Object[][] { - { - new String[] { "behmedial", "fatha", "lam" }, - new int[][] { - { 0, 0, 0, 0 }, { 50, 0, 0, 0 }, { 0, 0, 0, 0 } - } - }, - }, - }, - // arab-002.ttx - { "f1", "lu6", "arab", "dflt", "mark", - new Object[][] { - { - new String[] { "zain", "fatha", "kafinitial" }, - new int[][] { - { 0, 250, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } - } - }, - }, - }, - // arab-003.ttx - none used - // arab-004.ttx - { "f3", "lu5", "arab", "dflt", "mark", - new Object[][] { - { - new String[] { "uni064D", "uni0622.fina.postLamIni", "uni0650" }, - new int[][] { - { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 55, 424, 0, 0 } - } - }, - }, - }, - }; - - @Test - public void testGPOSSingle() throws Exception { - performPositioning(ltSingle); - } - - @Test - public void testGPOSPair() throws Exception { - performPositioning(ltPair); - } - - @Test - public void testGPOSCursive() throws Exception { - performPositioning(ltCursive); - } - - @Test - public void testGPOSMarkToBase() throws Exception { - performPositioning(ltMarkToBase); - } - - @Test - public void testGPOSMarkToLigature() throws Exception { - performPositioning(ltMarkToLigature); - } - - @Test - public void testGPOSMarkToMark() throws Exception { - performPositioning(ltMarkToMark); - } - - @Test - public void testGPOSContextual() throws Exception { - performPositioning(ltContextual); - } - - @Test - public void testGPOSChainedContextual() throws Exception { - performPositioning(ltChainedContextual); - } - - /** - * Perform positioning on all test data in test specification TS. - * @param ts test specification - */ - private void performPositioning(Object[][] ts) { - assert ts.length > 0; - Object[] tp = ts[0]; - for (int i = 1; i < ts.length; i++) { - performPositioning(tp, ts[i]); - } - } - - /** - * Perform positioning on all test data TD using test parameters TP. - * @param tp test parameters - * @param td test data - */ - private void performPositioning(Object[] tp, Object[] td) { - assert tp.length > 0; - if (td.length > 5) { - String fid = (String) td[0]; - String lid = (String) td[1]; - String script = (String) td[2]; - String language = (String) td[3]; - String feature = (String) td[4]; - TTXFile tf = findTTX(fid); - assertTrue(tf != null); - GlyphPositioningTable gpos = tf.getGPOS(); - assertTrue(gpos != null); - GlyphPositioningSubtable[] sta = findGPOSSubtables(gpos, script, language, feature, lid); - assertTrue(sta != null); - assertTrue(sta.length > 0); - ScriptContextTester sct = findScriptContextTester(script, language, feature); - Object[][] tia = (Object[][]) td[5]; // test instance array - for (Object[] ti : tia) { // test instance - if (ti != null) { - if (ti.length > 0) { // must have at least input glyphs - String[] igia = (String[]) ti[0]; // input glyph id array - int[][] ogpa = (int[][]) ti[1]; // output glyph positioning array - GlyphSequence igs = tf.getGlyphSequence(igia); - int[] widths = tf.getWidths(); - int[][] tgpa = new int [ igia.length ] [ 4 ]; - boolean adjusted = GlyphPositioningSubtable.position(igs, script, language, feature, 1000, sta, widths, tgpa, sct); - assertTrue(adjusted); - assertSamePositions(ogpa, tgpa); - } - } - } - } - } - - private String findTTXPath(String fid) { - for (String[] fs : ttxFonts) { - if ((fs != null) && (fs.length > 1)) { - if (fs[0].equals(fid)) { - return ttxFilesRoot + File.separator + fs[1]; - } - } - } - return null; - } - - private TTXFile findTTX(String fid) { - String pn = findTTXPath(fid); - assertTrue(pn != null); - try { - TTXFile tf = TTXFile.getFromCache(pn); - return tf; - } catch (Exception e) { - fail(e.getMessage()); - return null; - } - } - - private GlyphPositioningSubtable[] findGPOSSubtables(GlyphPositioningTable gpos, String script, String language, String feature, String lid) { - LookupTable lt = gpos.getLookupTable(lid); - if (lt != null) { - return (GlyphPositioningSubtable[]) lt.getSubtables(); - } else { - return null; - } - } - - private ScriptContextTester findScriptContextTester(String script, String language, String feature) { - return this; - } - - public GlyphContextTester getTester(String feature) { - return this; - } - - public boolean test(String script, String language, String feature, GlyphSequence gs, int index, int flags) { - return true; - } - - private void assertSamePositions(int[][] pa1, int[][] pa2) { - assertNotNull(pa1); - assertNotNull(pa2); - assertEquals("unequal adjustment count", pa1.length, pa2.length); - for (int i = 0; i < pa1.length; i++) { - int[] a1 = pa1 [ i ]; - int[] a2 = pa2 [ i ]; - assertNotNull(a1); - assertNotNull(a2); - assertEquals("bad adjustment array length", 4, a1.length); - assertEquals("bad adjustment array length", 4, a2.length); - for (int k = 0; k < a1.length; k++) { - int p1 = a1[k]; - int p2 = a2[k]; - assertEquals("bad adjustment", p1, p2); - } - } - } -} diff --git a/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java deleted file mode 100644 index 3f23d9ab3..000000000 --- a/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java +++ /dev/null @@ -1,2262 +0,0 @@ -/* - * 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.complexscripts.fonts; - -import java.io.File; -import java.nio.IntBuffer; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -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"; - - private static String[][] ttxFonts = { - { "f0", "arab/ttx/arab-001.ttx" }, // simplified arabic - { "f1", "arab/ttx/arab-002.ttx" }, // traditional arabic - { "f2", "arab/ttx/arab-003.ttx" }, // lateef - { "f3", "arab/ttx/arab-004.ttx" }, // scheherazade - }; - - private static Object[][] ltSingle = { - { GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_SINGLE }, - // arab-001.ttx - { "f0", "lu2", "arab", "dflt", "isol", - new String[][][] { - { { "ainisolated" }, { "ain" } }, - { { "alefmaksuraisolated" }, { "alefmaksura" } }, - { { "behisolated" }, { "beh" } }, - { { "dadisolated" }, { "dad" } }, - { { "dalisolated" }, { "dal" } }, - { { "farsiyehisolated" }, { "farsiyeh" } }, - { { "fehisolated" }, { "feh" } }, - { { "gafisolated" }, { "gaf" } }, - { { "ghainisolated" }, { "ghain" } }, - { { "hahisolated" }, { "hah" } }, - { { "jeemisolated" }, { "jeem" } }, - { { "jehisolated" }, { "jeh" } }, - { { "kafisolated" }, { "arabickaf" } }, - { { "kehehisolated" }, { "keheh" } }, - { { "khahisolated" }, { "khah" } }, - { { "meemisolated" }, { "meem" } }, - { { "noonisolated" }, { "noon" } }, - { { "pehisolated" }, { "peh" } }, - { { "qafisolated" }, { "qaf" } }, - { { "rehisolated" }, { "reh" } }, - { { "sadisolated" }, { "sad" } }, - { { "seenisolated" }, { "seen" } }, - { { "sheenisolated" }, { "sheen" } }, - { { "tahisolated" }, { "tah" } }, - { { "tchehisolated" }, { "tcheh" } }, - { { "tehisolated" }, { "teh" } }, - { { "tehmarbutaisolated" }, { "tehmarbuta" } }, - { { "thalisolated" }, { "thal" } }, - { { "thehisolated" }, { "theh" } }, - { { "vehisolated" }, { "veh" } }, - { { "wawisolated" }, { "waw" } }, - { { "yehisolated" }, { "yeh" } }, - { { "yehwithhamzaaboveisolated" }, { "yehwithhamzaabove" } }, - { { "zahisolated" }, { "zah" } }, - { { "zainisolated" }, { "zain" } }, - }, - }, - { "f0", "lu4", "arab", "dflt", "fina", - new String[][][] { - { { "ain" }, { "ainfinal" } }, - { { "alefmaksura" }, { "alefmaksurafinal" } }, - { { "alefwasla" }, { "alefwaslafinal" } }, - { { "alefwithhamzaabove" }, { "alefwithhamzaabovefinal" } }, - { { "alefwithhamzabelow" }, { "alefwithhamzabelowfinal" } }, - { { "alefwithmaddaabove" }, { "alefwithmaddaabovefinal" } }, - { { "arabicae" }, { "hehfinal" } }, - { { "arabicalef" }, { "aleffinal" } }, - { { "arabickaf" }, { "arabickaf" } }, - { { "beh" }, { "beh" } }, - { { "dad" }, { "dad" } }, - { { "dal" }, { "dal" } }, - { { "farsiyeh" }, { "farsiyehfinal" } }, - { { "feh" }, { "feh" } }, - { { "gaf" }, { "gaffinal" } }, - { { "ghain" }, { "ghainfinal" } }, - { { "hah" }, { "hahfinal" } }, - { { "heh" }, { "hehfinal" } }, - { { "jeem" }, { "jeemfinal" } }, - { { "jeh" }, { "jeh" } }, - { { "keheh" }, { "kehehfinal" } }, - { { "khah" }, { "khahfinal" } }, - { { "lam" }, { "lam" } }, - { { "meem" }, { "meem" } }, - { { "noon" }, { "noon" } }, - { { "peh" }, { "peh" } }, - { { "qaf" }, { "qaf" } }, - { { "reh" }, { "reh" } }, - { { "sad" }, { "sad" } }, - { { "seen" }, { "seen" } }, - { { "sheen" }, { "sheen" } }, - { { "tah" }, { "tah" } }, - { { "tcheh" }, { "tchehfinal" } }, - { { "teh" }, { "teh" } }, - { { "tehmarbuta" }, { "tehmarbutafinal" } }, - { { "thal" }, { "thal" } }, - { { "theh" }, { "theh" } }, - { { "veh" }, { "veh" } }, - { { "waw" }, { "waw" } }, - { { "wawwithhamzaabove" }, { "wawwithhamzaabove" } }, - { { "yeh" }, { "yehfinal" } }, - { { "yehwithhamzaabove" }, { "yehwithhamzaabovefinal" } }, - { { "zah" }, { "zah" } }, - { { "zain" }, { "zain" } }, - } - }, - { "f0", "lu5", "arab", "dflt", "init", - new String[][][] { - { { "ain" }, { "aininitial" } }, - { { "alefmaksura" }, { "uni0649.init" } }, - { { "arabickaf" }, { "kafmedial" } }, - { { "beh" }, { "behmedial" } }, - { { "dad" }, { "dadmedial" } }, - { { "farsiyeh" }, { "yehmedial" } }, - { { "feh" }, { "fehinitial" } }, - { { "gaf" }, { "gafinitial" } }, - { { "ghain" }, { "ghaininitial" } }, - { { "hah" }, { "hahmedial" } }, - { { "heh" }, { "hehinitial" } }, - { { "jeem" }, { "jeemmedial" } }, - { { "keheh" }, { "kehehinitial" } }, - { { "khah" }, { "khahmedial" } }, - { { "lam" }, { "lamisolated" } }, - { { "meem" }, { "meemmedial" } }, - { { "noon" }, { "noonmedial" } }, - { { "peh" }, { "pehmedial" } }, - { { "qaf" }, { "qafinitial" } }, - { { "sad" }, { "sadmedial" } }, - { { "seen" }, { "seenmedial" } }, - { { "sheen" }, { "sheenmedial" } }, - { { "tah" }, { "tah" } }, - { { "tcheh" }, { "tchehmedial" } }, - { { "teh" }, { "tehmedial" } }, - { { "theh" }, { "thehmedial" } }, - { { "veh" }, { "uni06A5.init" } }, - { { "yeh" }, { "yehmedial" } }, - { { "yehwithhamzaabove" }, { "yehwithhamzaabovemedial" } }, - { { "zah" }, { "zah" } }, - } - }, - { "f0", "lu6", "arab", "dflt", "medi", - new String[][][] { - { { "ain" }, { "ainmedial" } }, - { { "alefmaksura" }, { "uni0649.init" } }, - { { "arabickaf" }, { "kafmedial" } }, - { { "beh" }, { "behmedial" } }, - { { "dad" }, { "dadmedial" } }, - { { "farsiyeh" }, { "yehmedial" } }, - { { "feh" }, { "fehmedial" } }, - { { "gaf" }, { "gafmedial" } }, - { { "ghain" }, { "ghainmedial" } }, - { { "hah" }, { "hahmedial" } }, - { { "heh" }, { "hehmedial" } }, - { { "jeem" }, { "jeemmedial" } }, - { { "keheh" }, { "kehehmedial" } }, - { { "khah" }, { "khahmedial" } }, - { { "lam" }, { "lammedial" } }, - { { "meem" }, { "meemmedial" } }, - { { "noon" }, { "noonmedial" } }, - { { "peh" }, { "pehmedial" } }, - { { "qaf" }, { "qafmedial" } }, - { { "sad" }, { "sadmedial" } }, - { { "seen" }, { "seenmedial" } }, - { { "sheen" }, { "sheenmedial" } }, - { { "tah" }, { "tah" } }, - { { "tcheh" }, { "tchehmedial" } }, - { { "teh" }, { "tehmedial" } }, - { { "theh" }, { "thehmedial" } }, - { { "veh" }, { "vehmedial" } }, - { { "yeh" }, { "yehmedial" } }, - { { "yehwithhamzaabove" }, { "yehwithhamzaabovemedial" } }, - { { "zah" }, { "zah" } }, - } - }, - // arab-002.ttx - { "f1", "lu1", "arab", "*", "isol", - new String[][][] { - { { "ainisolated" }, { "ain" } }, - { { "alefmaksuraisolated" }, { "alefmaksura" } }, - { { "behisolated" }, { "beh" } }, - { { "dadisolated" }, { "dad" } }, - { { "dalisolated" }, { "dal" } }, - { { "farsiyehisolated" }, { "farsiyeh" } }, - { { "fehisolated" }, { "feh" } }, - { { "gafisolated" }, { "gaf" } }, - { { "ghainisolated" }, { "ghain" } }, - { { "hahisolated" }, { "hah" } }, - { { "jeemisolated" }, { "jeem" } }, - { { "jehisolated" }, { "jeh" } }, - { { "kafisolated" }, { "arabickaf" } }, - { { "kehehisolated" }, { "keheh" } }, - { { "khahisolated" }, { "khah" } }, - { { "meemisolated" }, { "meem" } }, - { { "noonisolated" }, { "noon" } }, - { { "pehisolated" }, { "peh" } }, - { { "qafisolated" }, { "qaf" } }, - { { "rehisolated" }, { "reh" } }, - { { "sadisolated" }, { "sad" } }, - { { "seenisolated" }, { "seen" } }, - { { "sheenisolated" }, { "sheen" } }, - { { "tahisolated" }, { "tah" } }, - { { "tchehisolated" }, { "tcheh" } }, - { { "tehisolated" }, { "teh" } }, - { { "tehmarbutaisolated" }, { "tehmarbuta" } }, - { { "thalisolated" }, { "thal" } }, - { { "thehisolated" }, { "theh" } }, - { { "vehisolated" }, { "veh" } }, - { { "wawisolated" }, { "waw" } }, - { { "yehisolated" }, { "yeh" } }, - { { "yehwithhamzaaboveisolated" }, { "yehwithhamzaabove" } }, - { { "zahisolated" }, { "zah" } }, - { { "zainisolated" }, { "zain" } }, - } - }, - { "f1", "lu3", "arab", "*", "fina", - new String[][][] { - { { "ain" }, { "ainfinal" } }, - { { "alefmaksura" }, { "alefmaksurafinal" } }, - { { "alefwasla" }, { "alefwaslafinal" } }, - { { "alefwithhamzaabove" }, { "alefwithhamzaabovefinal" } }, - { { "alefwithhamzabelow" }, { "alefwithhamzabelowfinal" } }, - { { "alefwithmaddaabove" }, { "alefwithmaddaabovefinal" } }, - { { "arabicae" }, { "hehfinal" } }, - { { "arabicalef" }, { "aleffinal" } }, - { { "arabickaf" }, { "arabickaffinal" } }, - { { "beh" }, { "behfinal" } }, - { { "dad" }, { "dadfinal" } }, - { { "dal" }, { "dalfinal" } }, - { { "farsiyeh" }, { "farsiyehfinal" } }, - { { "feh" }, { "fehfinal" } }, - { { "gaf" }, { "gaffinal" } }, - { { "ghain" }, { "ghainfinal" } }, - { { "hah" }, { "hahfinal" } }, - { { "heh" }, { "hehfinal" } }, - { { "jeem" }, { "jeemfinal" } }, - { { "jeh" }, { "jehfinal" } }, - { { "keheh" }, { "kehehfinal" } }, - { { "khah" }, { "khahfinal" } }, - { { "lam" }, { "lamfinal" } }, - { { "meem" }, { "meemfinal" } }, - { { "noon" }, { "noonfinal" } }, - { { "peh" }, { "pehfinal" } }, - { { "qaf" }, { "qaffinal" } }, - { { "reh" }, { "rehfinal" } }, - { { "sad" }, { "sadfinal" } }, - { { "seen" }, { "seenfinal" } }, - { { "sheen" }, { "sheenfinal" } }, - { { "tah" }, { "tahfinal" } }, - { { "tcheh" }, { "tchehfinal" } }, - { { "teh" }, { "tehfinal" } }, - { { "tehmarbuta" }, { "tehmarbutafinal" } }, - { { "thal" }, { "thalfinal" } }, - { { "theh" }, { "thehfinal" } }, - { { "veh" }, { "vehfinal" } }, - { { "waw" }, { "wawfinal" } }, - { { "wawwithhamzaabove" }, { "wawwithhamzaabovefinal" } }, - { { "yeh" }, { "yehfinal" } }, - { { "yehwithhamzaabove" }, { "yehwithhamzaabovefinal" } }, - { { "zah" }, { "zahfinal" } }, - { { "zain" }, { "zainfinal" } }, - } - }, - { "f1", "lu4", "arab", "*", "init", - new String[][][] { - { { "ain" }, { "aininitial" } }, - { { "alefmaksura" }, { "uni0649.init" } }, - { { "arabickaf" }, { "kafinitial" } }, - { { "beh" }, { "behinitial" } }, - { { "dad" }, { "dadinitial" } }, - { { "farsiyeh" }, { "yehinitial" } }, - { { "feh" }, { "fehinitial" } }, - { { "gaf" }, { "gafinitial" } }, - { { "ghain" }, { "ghaininitial" } }, - { { "hah" }, { "hahinitial" } }, - { { "heh" }, { "hehinitial" } }, - { { "jeem" }, { "jeeminitial" } }, - { { "keheh" }, { "kehehinitial" } }, - { { "khah" }, { "khahinitial" } }, - { { "lam" }, { "laminitial" } }, - { { "meem" }, { "meeminitial" } }, - { { "noon" }, { "nooninitial" } }, - { { "peh" }, { "pehinitial" } }, - { { "qaf" }, { "qafinitial" } }, - { { "sad" }, { "sadinitial" } }, - { { "seen" }, { "seeninitial" } }, - { { "sheen" }, { "sheeninitial" } }, - { { "tah" }, { "tahinitial" } }, - { { "tcheh" }, { "tchehinitial" } }, - { { "teh" }, { "tehinitial" } }, - { { "theh" }, { "thehinitial" } }, - { { "veh" }, { "vehinitial" } }, - { { "yeh" }, { "yehinitial" } }, - { { "yehwithhamzaabove" }, { "yehwithhamzaaboveinitial" } }, - { { "zah" }, { "zahinitial" } }, - } - }, - { "f1", "lu5", "arab", "*", "medi", - new String[][][] { - { { "ain" }, { "ainmedial" } }, - { { "alefmaksura" }, { "uni0649.medi" } }, - { { "arabickaf" }, { "kafmedial" } }, - { { "beh" }, { "behmedial" } }, - { { "dad" }, { "dadmedial" } }, - { { "farsiyeh" }, { "yehmedial" } }, - { { "feh" }, { "fehmedial" } }, - { { "gaf" }, { "gafmedial" } }, - { { "ghain" }, { "ghainmedial" } }, - { { "hah" }, { "hahmedial" } }, - { { "heh" }, { "hehmedial" } }, - { { "jeem" }, { "jeemmedial" } }, - { { "keheh" }, { "kehehmedial" } }, - { { "khah" }, { "khahmedial" } }, - { { "lam" }, { "lammedial" } }, - { { "meem" }, { "meemmedial" } }, - { { "noon" }, { "noonmedial" } }, - { { "peh" }, { "pehmedial" } }, - { { "qaf" }, { "qafmedial" } }, - { { "sad" }, { "sadmedial" } }, - { { "seen" }, { "seenmedial" } }, - { { "sheen" }, { "sheenmedial" } }, - { { "tah" }, { "tahmedial" } }, - { { "tcheh" }, { "tchehmedial" } }, - { { "teh" }, { "tehmedial" } }, - { { "theh" }, { "thehmedial" } }, - { { "veh" }, { "vehmedial" } }, - { { "yeh" }, { "yehmedial" } }, - { { "yehwithhamzaabove" }, { "yehwithhamzaabovemedial" } }, - { { "zah" }, { "zahmedial" } }, - } - }, - { "f1", "lu13", "arab", "*", "*", - new String[][][] { - { { "heh" }, { "hehisolated" } }, - } - }, - // arab-003.ttx - { "f2", "lu1", "arab", "dflt", "init", - new String[][][] { - { { "absJeemRetro1" }, { "absJeemRetro1Ini" } }, - { { "absJeemRetro2" }, { "absJeemRetro2Ini" } }, - { { "absJeemRetro3" }, { "absJeemRetro3Ini" } }, - { { "absLamRetro" }, { "absLamRetroIni" } }, - { { "absSheenRetro1" }, { "absSheenRetro1Ini" } }, - { { "absSheenRetro2" }, { "absSheenRetro2Ini" } }, - { { "absTchehRetro1" }, { "absTchehRetro1Ini" } }, - { { "absTchehRetro2" }, { "absTchehRetro2Ini" } }, - { { "uni0626" }, { "uni0626.init" } }, - { { "uni0628" }, { "uni0628.init" } }, - { { "uni062A" }, { "uni062A.init" } }, - { { "uni062B" }, { "uni062B.init" } }, - { { "uni062C" }, { "uni062C.init" } }, - { { "uni062D" }, { "uni062D.init" } }, - { { "uni062E" }, { "uni062E.init" } }, - { { "uni0633" }, { "uni0633.init" } }, - { { "uni0634" }, { "uni0634.init" } }, - { { "uni0635" }, { "uni0635.init" } }, - { { "uni0636" }, { "uni0636.init" } }, - { { "uni0637" }, { "uni0637.init" } }, - { { "uni0638" }, { "uni0638.init" } }, - { { "uni0639" }, { "uni0639.init" } }, - { { "uni063A" }, { "uni063A.init" } }, - { { "uni0641" }, { "uni0641.init" } }, - { { "uni0642" }, { "uni0642.init" } }, - { { "uni0643" }, { "uni0643.init" } }, - { { "uni0644" }, { "uni0644.init" } }, - { { "uni0645" }, { "uni0645.init" } }, - { { "uni0646" }, { "uni0646.init" } }, - { { "uni0647" }, { "uni0647.init" } }, - { { "uni0649" }, { "uni0649.init" } }, - { { "uni064A" }, { "uni064A.init" } }, - { { "uni064A.noDots" }, { "uni064A.init.noDots" } }, - { { "uni066E" }, { "uni066E.init" } }, - { { "uni066F" }, { "uni066F.init" } }, - { { "uni0678" }, { "uni0678.init" } }, - { { "uni0679" }, { "uni0679.init" } }, - { { "uni067A" }, { "uni067A.init" } }, - { { "uni067B" }, { "uni067B.init" } }, - { { "uni067C" }, { "uni067C.init" } }, - { { "uni067D" }, { "uni067D.init" } }, - { { "uni067E" }, { "uni067E.init" } }, - { { "uni067F" }, { "uni067F.init" } }, - { { "uni0680" }, { "uni0680.init" } }, - { { "uni0681" }, { "uni0681.init" } }, - { { "uni0682" }, { "uni0682.init" } }, - { { "uni0683" }, { "uni0683.init" } }, - { { "uni0684" }, { "uni0684.init" } }, - { { "uni0685" }, { "uni0685.init" } }, - { { "uni0686" }, { "uni0686.init" } }, - { { "uni0687" }, { "uni0687.init" } }, - { { "uni069A" }, { "uni069A.init" } }, - { { "uni069B" }, { "uni069B.init" } }, - { { "uni069C" }, { "uni069C.init" } }, - { { "uni069D" }, { "uni069D.init" } }, - { { "uni069E" }, { "uni069E.init" } }, - { { "uni069F" }, { "uni069F.init" } }, - { { "uni06A0" }, { "uni06A0.init" } }, - { { "uni06A1" }, { "uni06A1.init" } }, - { { "uni06A2" }, { "uni06A2.init" } }, - { { "uni06A3" }, { "uni06A3.init" } }, - { { "uni06A4" }, { "uni06A4.init" } }, - { { "uni06A5" }, { "uni06A5.init" } }, - { { "uni06A6" }, { "uni06A6.init" } }, - { { "uni06A7" }, { "uni06A7.init" } }, - { { "uni06A8" }, { "uni06A8.init" } }, - { { "uni06A9" }, { "uni06A9.init" } }, - { { "uni06AA" }, { "uni06AA.init" } }, - { { "uni06AB" }, { "uni06AB.init" } }, - { { "uni06AC" }, { "uni06AC.init" } }, - { { "uni06AD" }, { "uni06AD.init" } }, - { { "uni06AE" }, { "uni06AE.init" } }, - { { "uni06AF" }, { "uni06AF.init" } }, - { { "uni06B0" }, { "uni06B0.init" } }, - { { "uni06B1" }, { "uni06B1.init" } }, - { { "uni06B2" }, { "uni06B2.init" } }, - { { "uni06B3" }, { "uni06B3.init" } }, - { { "uni06B4" }, { "uni06B4.init" } }, - { { "uni06B5" }, { "uni06B5.init" } }, - { { "uni06B6" }, { "uni06B6.init" } }, - { { "uni06B7" }, { "uni06B7.init" } }, - { { "uni06B8" }, { "uni06B8.init" } }, - { { "uni06B9" }, { "uni06B9.init" } }, - { { "uni06BA" }, { "uni06BA.init" } }, - { { "uni06BB" }, { "uni06BB.init" } }, - { { "uni06BC" }, { "uni06BC.init" } }, - { { "uni06BD" }, { "uni06BD.init" } }, - { { "uni06BE" }, { "uni06BE.init" } }, - { { "uni06BF" }, { "uni06BF.init" } }, - { { "uni06C1" }, { "uni06C1.init" } }, - { { "uni06C2" }, { "uni06C2.init" } }, - { { "uni06CC" }, { "uni06CC.init" } }, - { { "uni06CE" }, { "uni06CE.init" } }, - { { "uni06D0" }, { "uni06D0.init" } }, - { { "uni06D1" }, { "uni06D1.init" } }, - { { "uni06FA" }, { "uni06FA.init" } }, - { { "uni06FB" }, { "uni06FB.init" } }, - { { "uni06FC" }, { "uni06FC.init" } }, - { { "uni06FF" }, { "uni06FF.init" } }, - { { "uni0750" }, { "uni0750.init" } }, - { { "uni0751" }, { "uni0751.init" } }, - { { "uni0752" }, { "uni0752.init" } }, - { { "uni0753" }, { "uni0753.init" } }, - { { "uni0754" }, { "uni0754.init" } }, - { { "uni0755" }, { "uni0755.init" } }, - { { "uni0756" }, { "uni0756.init" } }, - { { "uni0757" }, { "uni0757.init" } }, - { { "uni0758" }, { "uni0758.init" } }, - { { "uni075C" }, { "uni075C.init" } }, - { { "uni075D" }, { "uni075D.init" } }, - { { "uni075E" }, { "uni075E.init" } }, - { { "uni075F" }, { "uni075F.init" } }, - { { "uni0760" }, { "uni0760.init" } }, - { { "uni0761" }, { "uni0761.init" } }, - { { "uni0762" }, { "uni0762.init" } }, - { { "uni0763" }, { "uni0763.init" } }, - { { "uni0764" }, { "uni0764.init" } }, - { { "uni0765" }, { "uni0765.init" } }, - { { "uni0766" }, { "uni0766.init" } }, - { { "uni0767" }, { "uni0767.init" } }, - { { "uni0768" }, { "uni0768.init" } }, - { { "uni0769" }, { "uni0769.init" } }, - { { "uni076A" }, { "uni076A.init" } }, - { { "uni076D" }, { "uni076D.init" } }, - } - }, - { "f2", "lu2", "arab", "dflt", "fina", - new String[][][] { - { { "absJeemRetro1" }, { "absJeemRetro1Fin" } }, - { { "absJeemRetro2" }, { "absJeemRetro2Fin" } }, - { { "absJeemRetro3" }, { "absJeemRetro3Fin" } }, - { { "absJehRetro1" }, { "absJehRetro1Fin" } }, - { { "absJehRetro2" }, { "absJehRetro2Fin" } }, - { { "absLamRetro" }, { "absLamRetroFin" } }, - { { "absSheenRetro1" }, { "absSheenRetro1Fin" } }, - { { "absSheenRetro2" }, { "absSheenRetro2Fin" } }, - { { "absTchehRetro1" }, { "absTchehRetro1Fin" } }, - { { "absTchehRetro2" }, { "absTchehRetro2Fin" } }, - { { "absWawDotBelow" }, { "absWawDotBelowFin" } }, - { { "uni0622" }, { "uni0622.fina" } }, - { { "uni0623" }, { "uni0623.fina" } }, - { { "uni0624" }, { "uni0624.fina" } }, - { { "uni0625" }, { "uni0625.fina" } }, - { { "uni0626" }, { "uni0626.fina" } }, - { { "uni0627" }, { "uni0627.fina" } }, - { { "uni0628" }, { "uni0628.fina" } }, - { { "uni0629" }, { "uni0629.fina" } }, - { { "uni062A" }, { "uni062A.fina" } }, - { { "uni062B" }, { "uni062B.fina" } }, - { { "uni062C" }, { "uni062C.fina" } }, - { { "uni062D" }, { "uni062D.fina" } }, - { { "uni062E" }, { "uni062E.fina" } }, - { { "uni062F" }, { "uni062F.fina" } }, - { { "uni0630" }, { "uni0630.fina" } }, - { { "uni0631" }, { "uni0631.fina" } }, - { { "uni0632" }, { "uni0632.fina" } }, - { { "uni0633" }, { "uni0633.fina" } }, - { { "uni0634" }, { "uni0634.fina" } }, - { { "uni0635" }, { "uni0635.fina" } }, - { { "uni0636" }, { "uni0636.fina" } }, - { { "uni0637" }, { "uni0637.fina" } }, - { { "uni0638" }, { "uni0638.fina" } }, - { { "uni0639" }, { "uni0639.fina" } }, - { { "uni063A" }, { "uni063A.fina" } }, - { { "uni0641" }, { "uni0641.fina" } }, - { { "uni0642" }, { "uni0642.fina" } }, - { { "uni0643" }, { "uni0643.fina" } }, - { { "uni0644" }, { "uni0644.fina" } }, - { { "uni0645" }, { "uni0645.fina" } }, - { { "uni0646" }, { "uni0646.fina" } }, - { { "uni0647" }, { "uni0647.fina" } }, - { { "uni0648" }, { "uni0648.fina" } }, - { { "uni0649" }, { "uni0649.fina" } }, - { { "uni064A" }, { "uni064A.fina" } }, - { { "uni064A.noDots" }, { "uni064A.fina.noDots" } }, - { { "uni066E" }, { "uni066E.fina" } }, - { { "uni066F" }, { "uni066F.fina" } }, - { { "uni0671" }, { "uni0671.fina" } }, - { { "uni0672" }, { "uni0672.fina" } }, - { { "uni0673" }, { "uni0673.fina" } }, - { { "uni0675" }, { "uni0675.fina" } }, - { { "uni0676" }, { "uni0676.fina" } }, - { { "uni0677" }, { "uni0677.fina" } }, - { { "uni0678" }, { "uni0678.fina" } }, - { { "uni0679" }, { "uni0679.fina" } }, - { { "uni067A" }, { "uni067A.fina" } }, - { { "uni067B" }, { "uni067B.fina" } }, - { { "uni067C" }, { "uni067C.fina" } }, - { { "uni067D" }, { "uni067D.fina" } }, - { { "uni067E" }, { "uni067E.fina" } }, - { { "uni067F" }, { "uni067F.fina" } }, - { { "uni0680" }, { "uni0680.fina" } }, - { { "uni0681" }, { "uni0681.fina" } }, - { { "uni0682" }, { "uni0682.fina" } }, - { { "uni0683" }, { "uni0683.fina" } }, - { { "uni0684" }, { "uni0684.fina" } }, - { { "uni0685" }, { "uni0685.fina" } }, - { { "uni0686" }, { "uni0686.fina" } }, - { { "uni0687" }, { "uni0687.fina" } }, - { { "uni0688" }, { "uni0688.fina" } }, - { { "uni0689" }, { "uni0689.fina" } }, - { { "uni068A" }, { "uni068A.fina" } }, - { { "uni068B" }, { "uni068B.fina" } }, - { { "uni068C" }, { "uni068C.fina" } }, - { { "uni068D" }, { "uni068D.fina" } }, - { { "uni068E" }, { "uni068E.fina" } }, - { { "uni068F" }, { "uni068F.fina" } }, - { { "uni0690" }, { "uni0690.fina" } }, - { { "uni0691" }, { "uni0691.fina" } }, - { { "uni0692" }, { "uni0692.fina" } }, - { { "uni0693" }, { "uni0693.fina" } }, - { { "uni0694" }, { "uni0694.fina" } }, - { { "uni0695" }, { "uni0695.fina" } }, - { { "uni0696" }, { "uni0696.fina" } }, - { { "uni0697" }, { "uni0697.fina" } }, - { { "uni0698" }, { "uni0698.fina" } }, - { { "uni0698.dotHat" }, { "uni0698.fina.dotHat" } }, - { { "uni0699" }, { "uni0699.fina" } }, - { { "uni069A" }, { "uni069A.fina" } }, - { { "uni069B" }, { "uni069B.fina" } }, - { { "uni069C" }, { "uni069C.fina" } }, - { { "uni069D" }, { "uni069D.fina" } }, - { { "uni069E" }, { "uni069E.fina" } }, - { { "uni069F" }, { "uni069F.fina" } }, - { { "uni06A0" }, { "uni06A0.fina" } }, - { { "uni06A1" }, { "uni06A1.fina" } }, - { { "uni06A2" }, { "uni06A2.fina" } }, - { { "uni06A3" }, { "uni06A3.fina" } }, - { { "uni06A4" }, { "uni06A4.fina" } }, - { { "uni06A5" }, { "uni06A5.fina" } }, - { { "uni06A6" }, { "uni06A6.fina" } }, - { { "uni06A7" }, { "uni06A7.fina" } }, - { { "uni06A8" }, { "uni06A8.fina" } }, - { { "uni06A9" }, { "uni06A9.fina" } }, - { { "uni06AA" }, { "uni06AA.fina" } }, - { { "uni06AB" }, { "uni06AB.fina" } }, - { { "uni06AC" }, { "uni06AC.fina" } }, - { { "uni06AD" }, { "uni06AD.fina" } }, - { { "uni06AE" }, { "uni06AE.fina" } }, - { { "uni06AF" }, { "uni06AF.fina" } }, - { { "uni06B0" }, { "uni06B0.fina" } }, - { { "uni06B1" }, { "uni06B1.fina" } }, - { { "uni06B2" }, { "uni06B2.fina" } }, - { { "uni06B3" }, { "uni06B3.fina" } }, - { { "uni06B4" }, { "uni06B4.fina" } }, - { { "uni06B5" }, { "uni06B5.fina" } }, - { { "uni06B6" }, { "uni06B6.fina" } }, - { { "uni06B7" }, { "uni06B7.fina" } }, - { { "uni06B8" }, { "uni06B8.fina" } }, - { { "uni06B9" }, { "uni06B9.fina" } }, - { { "uni06BA" }, { "uni06BA.fina" } }, - { { "uni06BB" }, { "uni06BB.fina" } }, - { { "uni06BC" }, { "uni06BC.fina" } }, - { { "uni06BD" }, { "uni06BD.fina" } }, - { { "uni06BE" }, { "uni06BE.fina" } }, - { { "uni06BF" }, { "uni06BF.fina" } }, - { { "uni06C0" }, { "uni06C0.fina" } }, - { { "uni06C1" }, { "uni06C1.fina" } }, - { { "uni06C2" }, { "uni06C2.fina" } }, - { { "uni06C3" }, { "uni06C3.fina" } }, - { { "uni06C4" }, { "uni06C4.fina" } }, - { { "uni06C5" }, { "uni06C5.fina" } }, - { { "uni06C6" }, { "uni06C6.fina" } }, - { { "uni06C7" }, { "uni06C7.fina" } }, - { { "uni06C8" }, { "uni06C8.fina" } }, - { { "uni06C9" }, { "uni06C9.fina" } }, - { { "uni06CA" }, { "uni06CA.fina" } }, - { { "uni06CB" }, { "uni06CB.fina" } }, - { { "uni06CC" }, { "uni06CC.fina" } }, - { { "uni06CD" }, { "uni06CD.fina" } }, - { { "uni06CE" }, { "uni06CE.fina" } }, - { { "uni06CF" }, { "uni06CF.fina" } }, - { { "uni06D0" }, { "uni06D0.fina" } }, - { { "uni06D1" }, { "uni06D1.fina" } }, - { { "uni06D2" }, { "uni06D2.fina" } }, - { { "uni06D3" }, { "uni06D3.fina" } }, - { { "uni06D5" }, { "uni06D5.fina" } }, - { { "uni06EE" }, { "uni06EE.fina" } }, - { { "uni06EF" }, { "uni06EF.fina" } }, - { { "uni06FA" }, { "uni06FA.fina" } }, - { { "uni06FB" }, { "uni06FB.fina" } }, - { { "uni06FC" }, { "uni06FC.fina" } }, - { { "uni06FF" }, { "uni06FF.fina" } }, - { { "uni0750" }, { "uni0750.fina" } }, - { { "uni0751" }, { "uni0751.fina" } }, - { { "uni0752" }, { "uni0752.fina" } }, - { { "uni0753" }, { "uni0753.fina" } }, - { { "uni0754" }, { "uni0754.fina" } }, - { { "uni0755" }, { "uni0755.fina" } }, - { { "uni0756" }, { "uni0756.fina" } }, - { { "uni0757" }, { "uni0757.fina" } }, - { { "uni0758" }, { "uni0758.fina" } }, - { { "uni0759" }, { "uni0759.fina" } }, - { { "uni075A" }, { "uni075A.fina" } }, - { { "uni075B" }, { "uni075B.fina" } }, - { { "uni075C" }, { "uni075C.fina" } }, - { { "uni075D" }, { "uni075D.fina" } }, - { { "uni075E" }, { "uni075E.fina" } }, - { { "uni075F" }, { "uni075F.fina" } }, - { { "uni0760" }, { "uni0760.fina" } }, - { { "uni0761" }, { "uni0761.fina" } }, - { { "uni0762" }, { "uni0762.fina" } }, - { { "uni0763" }, { "uni0763.fina" } }, - { { "uni0764" }, { "uni0764.fina" } }, - { { "uni0765" }, { "uni0765.fina" } }, - { { "uni0766" }, { "uni0766.fina" } }, - { { "uni0767" }, { "uni0767.fina" } }, - { { "uni0768" }, { "uni0768.fina" } }, - { { "uni0769" }, { "uni0769.fina" } }, - { { "uni076A" }, { "uni076A.fina" } }, - { { "uni076B" }, { "uni076B.fina" } }, - { { "uni076C" }, { "uni076C.fina" } }, - { { "uni076D" }, { "uni076D.fina" } }, - } - }, - { "f2", "lu3", "arab", "dflt", "medi", - new String[][][] { - { { "absJeemRetro1" }, { "absJeemRetro1Med" } }, - { { "absJeemRetro2" }, { "absJeemRetro2Med" } }, - { { "absJeemRetro3" }, { "absJeemRetro3Med" } }, - { { "absLamRetro" }, { "absLamRetroMed" } }, - { { "absSheenRetro1" }, { "absSheenRetro1Med" } }, - { { "absSheenRetro2" }, { "absSheenRetro2Med" } }, - { { "absTchehRetro1" }, { "absTchehRetro1Med" } }, - { { "absTchehRetro2" }, { "absTchehRetro2Med" } }, - { { "uni0626" }, { "uni0626.medi" } }, - { { "uni0628" }, { "uni0628.medi" } }, - { { "uni062A" }, { "uni062A.medi" } }, - { { "uni062B" }, { "uni062B.medi" } }, - { { "uni062C" }, { "uni062C.medi" } }, - { { "uni062D" }, { "uni062D.medi" } }, - { { "uni062E" }, { "uni062E.medi" } }, - { { "uni0633" }, { "uni0633.medi" } }, - { { "uni0634" }, { "uni0634.medi" } }, - { { "uni0635" }, { "uni0635.medi" } }, - { { "uni0636" }, { "uni0636.medi" } }, - { { "uni0637" }, { "uni0637.medi" } }, - { { "uni0638" }, { "uni0638.medi" } }, - { { "uni0639" }, { "uni0639.medi" } }, - { { "uni063A" }, { "uni063A.medi" } }, - { { "uni0641" }, { "uni0641.medi" } }, - { { "uni0642" }, { "uni0642.medi" } }, - { { "uni0643" }, { "uni0643.medi" } }, - { { "uni0644" }, { "uni0644.medi" } }, - { { "uni0645" }, { "uni0645.medi" } }, - { { "uni0646" }, { "uni0646.medi" } }, - { { "uni0647" }, { "uni0647.medi" } }, - { { "uni0649" }, { "uni0649.medi" } }, - { { "uni064A" }, { "uni064A.medi" } }, - { { "uni064A.noDots" }, { "uni064A.medi.noDots" } }, - { { "uni066E" }, { "uni066E.medi" } }, - { { "uni066F" }, { "uni066F.medi" } }, - { { "uni0678" }, { "uni0678.medi" } }, - { { "uni0679" }, { "uni0679.medi" } }, - { { "uni067A" }, { "uni067A.medi" } }, - { { "uni067B" }, { "uni067B.medi" } }, - { { "uni067C" }, { "uni067C.medi" } }, - { { "uni067D" }, { "uni067D.medi" } }, - { { "uni067E" }, { "uni067E.medi" } }, - { { "uni067F" }, { "uni067F.medi" } }, - { { "uni0680" }, { "uni0680.medi" } }, - { { "uni0681" }, { "uni0681.medi" } }, - { { "uni0682" }, { "uni0682.medi" } }, - { { "uni0683" }, { "uni0683.medi" } }, - { { "uni0684" }, { "uni0684.medi" } }, - { { "uni0685" }, { "uni0685.medi" } }, - { { "uni0686" }, { "uni0686.medi" } }, - { { "uni0687" }, { "uni0687.medi" } }, - { { "uni069A" }, { "uni069A.medi" } }, - { { "uni069B" }, { "uni069B.medi" } }, - { { "uni069C" }, { "uni069C.medi" } }, - { { "uni069D" }, { "uni069D.medi" } }, - { { "uni069E" }, { "uni069E.medi" } }, - { { "uni069F" }, { "uni069F.medi" } }, - { { "uni06A0" }, { "uni06A0.medi" } }, - { { "uni06A1" }, { "uni06A1.medi" } }, - { { "uni06A2" }, { "uni06A2.medi" } }, - { { "uni06A3" }, { "uni06A3.medi" } }, - { { "uni06A4" }, { "uni06A4.medi" } }, - { { "uni06A5" }, { "uni06A5.medi" } }, - { { "uni06A6" }, { "uni06A6.medi" } }, - { { "uni06A7" }, { "uni06A7.medi" } }, - { { "uni06A8" }, { "uni06A8.medi" } }, - { { "uni06A9" }, { "uni06A9.medi" } }, - { { "uni06AA" }, { "uni06AA.medi" } }, - { { "uni06AB" }, { "uni06AB.medi" } }, - { { "uni06AC" }, { "uni06AC.medi" } }, - { { "uni06AD" }, { "uni06AD.medi" } }, - { { "uni06AE" }, { "uni06AE.medi" } }, - { { "uni06AF" }, { "uni06AF.medi" } }, - { { "uni06B0" }, { "uni06B0.medi" } }, - { { "uni06B1" }, { "uni06B1.medi" } }, - { { "uni06B2" }, { "uni06B2.medi" } }, - { { "uni06B3" }, { "uni06B3.medi" } }, - { { "uni06B4" }, { "uni06B4.medi" } }, - { { "uni06B5" }, { "uni06B5.medi" } }, - { { "uni06B6" }, { "uni06B6.medi" } }, - { { "uni06B7" }, { "uni06B7.medi" } }, - { { "uni06B8" }, { "uni06B8.medi" } }, - { { "uni06B9" }, { "uni06B9.medi" } }, - { { "uni06BA" }, { "uni06BA.medi" } }, - { { "uni06BB" }, { "uni06BB.medi" } }, - { { "uni06BC" }, { "uni06BC.medi" } }, - { { "uni06BD" }, { "uni06BD.medi" } }, - { { "uni06BE" }, { "uni06BE.medi" } }, - { { "uni06BF" }, { "uni06BF.medi" } }, - { { "uni06C1" }, { "uni06C1.medi" } }, - { { "uni06C2" }, { "uni06C2.medi" } }, - { { "uni06CC" }, { "uni06CC.medi" } }, - { { "uni06CE" }, { "uni06CE.medi" } }, - { { "uni06D0" }, { "uni06D0.medi" } }, - { { "uni06D1" }, { "uni06D1.medi" } }, - { { "uni06FA" }, { "uni06FA.medi" } }, - { { "uni06FB" }, { "uni06FB.medi" } }, - { { "uni06FC" }, { "uni06FC.medi" } }, - { { "uni06FF" }, { "uni06FF.medi" } }, - { { "uni0750" }, { "uni0750.medi" } }, - { { "uni0751" }, { "uni0751.medi" } }, - { { "uni0752" }, { "uni0752.medi" } }, - { { "uni0753" }, { "uni0753.medi" } }, - { { "uni0754" }, { "uni0754.medi" } }, - { { "uni0755" }, { "uni0755.medi" } }, - { { "uni0756" }, { "uni0756.medi" } }, - { { "uni0757" }, { "uni0757.medi" } }, - { { "uni0758" }, { "uni0758.medi" } }, - { { "uni075C" }, { "uni075C.medi" } }, - { { "uni075D" }, { "uni075D.medi" } }, - { { "uni075E" }, { "uni075E.medi" } }, - { { "uni075F" }, { "uni075F.medi" } }, - { { "uni0760" }, { "uni0760.medi" } }, - { { "uni0761" }, { "uni0761.medi" } }, - { { "uni0762" }, { "uni0762.medi" } }, - { { "uni0763" }, { "uni0763.medi" } }, - { { "uni0764" }, { "uni0764.medi" } }, - { { "uni0765" }, { "uni0765.medi" } }, - { { "uni0766" }, { "uni0766.medi" } }, - { { "uni0767" }, { "uni0767.medi" } }, - { { "uni0768" }, { "uni0768.medi" } }, - { { "uni0769" }, { "uni0769.medi" } }, - { { "uni076A" }, { "uni076A.medi" } }, - { { "uni076D" }, { "uni076D.medi" } }, - } - }, - { "f2", "lu9", "arab", "SND ", "calt", - new String[][][] { - { { "uni060C" }, { "uni060C.downward" } }, - { { "uni061B" }, { "uni061B.downward" } }, - { { "uni0645" }, { "uni0645.sindhi" } }, - { { "uni0645.fina" }, { "uni0645.fina.sindhi" } }, - { { "uni0647" }, { "uni0647.knotted" } }, - { { "uni0647.fina" }, { "uni0647.fina.knottedHigh" } }, - { { "uni0647.medi" }, { "uni0647.medi.knottedHigh" } }, - { { "uni064C" }, { "uni064C.sixNine" } }, - { { "uni06F6" }, { "uni06F6.urdu" } }, - { { "uni06F7" }, { "uni06F7.urdu" } }, - } - }, - { "f2", "lu10", "arab", "URD ", "calt", - new String[][][] { - { { "uni0647.fina" }, { "uni0647.fina.hooked" } }, - { { "uni0647.init" }, { "uni0647.init.hooked" } }, - { { "uni0647.medi" }, { "uni0647.medi.hooked" } }, - { { "uni06F4" }, { "uni06F4.urdu" } }, - { { "uni06F6" }, { "uni06F6.urdu" } }, - { { "uni06F7" }, { "uni06F7.urdu" } }, - } - }, - { "f2", "lu11", "arab", "KUR ", "calt", - new String[][][] { - { { "uni0647" }, { "uni0647.knotted" } }, - { { "uni0647.fina" }, { "uni0647.fina.knottedHigh" } }, - } - }, - { "f2", "lu12", "latn", "dflt", "ccmp", - new String[][][] { - { { "asterisk.arab" }, { "asterisk" } }, - { { "colon.arab" }, { "colon" } }, - { { "exclam.arab" }, { "exclam" } }, - { { "parenleft.arab" }, { "parenleft" } }, - { { "parenright.arab" }, { "parenright" } }, - { { "quotedblleft.arab" }, { "quotedblleft" } }, - { { "quotedblright.arab" }, { "quotedblright" } }, - { { "quoteleft.arab" }, { "quoteleft" } }, - { { "quoteright.arab" }, { "quoteright" } }, - } - }, - { "f2", "lu14", "arab", "*", "*", - new String[][][] { - { { "absLamRetroIni" }, { "absLamRetroIni.preAlef" } }, - { { "absLamRetroMed" }, { "absLamRetroMed.preAlef" } }, - { { "uni0644.init" }, { "uni0644.init.preAlef" } }, - { { "uni0644.medi" }, { "uni0644.medi.preAlef" } }, - { { "uni06B5.init" }, { "uni06B5.init.preAlef" } }, - { { "uni06B5.medi" }, { "uni06B5.medi.preAlef" } }, - { { "uni06B6.init" }, { "uni06B6.init.preAlef" } }, - { { "uni06B6.medi" }, { "uni06B6.medi.preAlef" } }, - { { "uni06B7.init" }, { "uni06B7.init.preAlef" } }, - { { "uni06B7.medi" }, { "uni06B7.medi.preAlef" } }, - { { "uni06B8.init" }, { "uni06B8.init.preAlef" } }, - { { "uni06B8.medi" }, { "uni06B8.medi.preAlef" } }, - { { "uni076A.init" }, { "uni076A.init.preAlef" } }, - { { "uni076A.medi" }, { "uni076A.medi.preAlef" } }, - } - }, - { "f2", "lu15", "arab", "*", "*", - new String[][][] { - { { "uni0622.fina" }, { "uni0622.fina.postLamIni" } }, - { { "uni0623.fina" }, { "uni0623.fina.postLamIni" } }, - { { "uni0625.fina" }, { "uni0625.fina.postLamIni" } }, - { { "uni0627.fina" }, { "uni0627.fina.postLamIni" } }, - { { "uni0671.fina" }, { "uni0671.fina.postLamIni" } }, - { { "uni0672.fina" }, { "uni0672.fina.postLamIni" } }, - { { "uni0673.fina" }, { "uni0673.fina.postLamIni" } }, - { { "uni0675.fina" }, { "uni0675.fina.postLamIni" } }, - } - }, - { "f2", "lu16", "arab", "*", "*", - new String[][][] { - { { "uni0622.fina" }, { "uni0622.fina.postLamMed" } }, - { { "uni0623.fina" }, { "uni0623.fina.postLamMed" } }, - { { "uni0625.fina" }, { "uni0625.fina.postLamMed" } }, - { { "uni0627.fina" }, { "uni0627.fina.postLamMed" } }, - { { "uni0671.fina" }, { "uni0671.fina.postLamMed" } }, - { { "uni0672.fina" }, { "uni0672.fina.postLamMed" } }, - { { "uni0673.fina" }, { "uni0673.fina.postLamMed" } }, - { { "uni0675.fina" }, { "uni0675.fina.postLamMed" } }, - } - }, - { "f2", "lu17", "arab", "*", "*", - new String[][][] { - { { "uni0670" }, { "uni0670.large" } }, - } - }, - { "f2", "lu18", "arab", "*", "*", - new String[][][] { - { { "uni06DD" }, { "uni06DD.3" } }, - } - }, - { "f2", "lu19", "arab", "*", "*", - new String[][][] { - { { "uni06DD" }, { "uni06DD.2" } }, - } - }, - { "f2", "lu20", "arab", "*", "*", - new String[][][] { - { { "eight" }, { "eightMedium" } }, - { { "five" }, { "fiveMedium" } }, - { { "four" }, { "fourMedium" } }, - { { "nine" }, { "nineMedium" } }, - { { "one" }, { "oneMedium" } }, - { { "seven" }, { "sevenMedium" } }, - { { "six" }, { "sixMedium" } }, - { { "three" }, { "threeMedium" } }, - { { "two" }, { "twoMedium" } }, - { { "uni0660" }, { "uni0660.Medium" } }, - { { "uni0661" }, { "uni0661.Medium" } }, - { { "uni0662" }, { "uni0662.Medium" } }, - { { "uni0663" }, { "uni0663.Medium" } }, - { { "uni0664" }, { "uni0664.Medium" } }, - { { "uni0665" }, { "uni0665.Medium" } }, - { { "uni0666" }, { "uni0666.Medium" } }, - { { "uni0667" }, { "uni0667.Medium" } }, - { { "uni0668" }, { "uni0668.Medium" } }, - { { "uni0669" }, { "uni0669.Medium" } }, - { { "uni06F0" }, { "uni06F0.Medium" } }, - { { "uni06F1" }, { "uni06F1.Medium" } }, - { { "uni06F2" }, { "uni06F2.Medium" } }, - { { "uni06F3" }, { "uni06F3.Medium" } }, - { { "uni06F4" }, { "uni06F4.Medium" } }, - { { "uni06F4.urdu" }, { "uni06F4.Medium.urdu" } }, - { { "uni06F5" }, { "uni06F5.Medium" } }, - { { "uni06F6" }, { "uni06F6.Medium" } }, - { { "uni06F6.urdu" }, { "uni06F6.Medium.urdu" } }, - { { "uni06F7" }, { "uni06F7.Medium" } }, - { { "uni06F7.urdu" }, { "uni06F7.Medium.urdu" } }, - { { "uni06F8" }, { "uni06F8.Medium" } }, - { { "uni06F9" }, { "uni06F9.Medium" } }, - { { "zero" }, { "zeroMedium" } }, - } - }, - { "f2", "lu21", "arab", "*", "*", - new String[][][] { - { { "eight" }, { "eightSmall" } }, - { { "five" }, { "fiveSmall" } }, - { { "four" }, { "fourSmall" } }, - { { "nine" }, { "nineSmall" } }, - { { "one" }, { "oneSmall" } }, - { { "seven" }, { "sevenSmall" } }, - { { "six" }, { "sixSmall" } }, - { { "three" }, { "threeSmall" } }, - { { "two" }, { "twoSmall" } }, - { { "uni0660" }, { "uni0660.Small" } }, - { { "uni0661" }, { "uni0661.Small" } }, - { { "uni0662" }, { "uni0662.Small" } }, - { { "uni0663" }, { "uni0663.Small" } }, - { { "uni0664" }, { "uni0664.Small" } }, - { { "uni0665" }, { "uni0665.Small" } }, - { { "uni0666" }, { "uni0666.Small" } }, - { { "uni0667" }, { "uni0667.Small" } }, - { { "uni0668" }, { "uni0668.Small" } }, - { { "uni0669" }, { "uni0669.Small" } }, - { { "uni06F0" }, { "uni06F0.Small" } }, - { { "uni06F1" }, { "uni06F1.Small" } }, - { { "uni06F2" }, { "uni06F2.Small" } }, - { { "uni06F3" }, { "uni06F3.Small" } }, - { { "uni06F4" }, { "uni06F4.Small" } }, - { { "uni06F4.urdu" }, { "uni06F4.Small.urdu" } }, - { { "uni06F5" }, { "uni06F5.Small" } }, - { { "uni06F6" }, { "uni06F6.Small" } }, - { { "uni06F6.urdu" }, { "uni06F6.Small.urdu" } }, - { { "uni06F7" }, { "uni06F7.Small" } }, - { { "uni06F7.urdu" }, { "uni06F7.Small.urdu" } }, - { { "uni06F8" }, { "uni06F8.Small" } }, - { { "uni06F9" }, { "uni06F9.Small" } }, - { { "zero" }, { "zeroSmall" } }, - } - }, - // arab-004.ttx - { "f3", "lu1", "arab", "dflt", "init", - new String[][][] { - { { "absJeemRetro1" }, { "absJeemRetro1Ini" } }, - { { "absJeemRetro2" }, { "absJeemRetro2Ini" } }, - { { "absJeemRetro3" }, { "absJeemRetro3Ini" } }, - { { "absLamRetro" }, { "absLamRetroIni" } }, - { { "absSheenRetro1" }, { "absSheenRetro1Ini" } }, - { { "absSheenRetro2" }, { "absSheenRetro2Ini" } }, - { { "absTchehRetro1" }, { "absTchehRetro1Ini" } }, - { { "absTchehRetro2" }, { "absTchehRetro2Ini" } }, - { { "uni0626" }, { "uni0626.init" } }, - { { "uni0628" }, { "uni0628.init" } }, - { { "uni062A" }, { "uni062A.init" } }, - { { "uni062B" }, { "uni062B.init" } }, - { { "uni062C" }, { "uni062C.init" } }, - { { "uni062D" }, { "uni062D.init" } }, - { { "uni062E" }, { "uni062E.init" } }, - { { "uni0633" }, { "uni0633.init" } }, - { { "uni0634" }, { "uni0634.init" } }, - { { "uni0635" }, { "uni0635.init" } }, - { { "uni0636" }, { "uni0636.init" } }, - { { "uni0637" }, { "uni0637.init" } }, - { { "uni0638" }, { "uni0638.init" } }, - { { "uni0639" }, { "uni0639.init" } }, - { { "uni063A" }, { "uni063A.init" } }, - { { "uni0641" }, { "uni0641.init" } }, - { { "uni0642" }, { "uni0642.init" } }, - { { "uni0643" }, { "uni0643.init" } }, - { { "uni0644" }, { "uni0644.init" } }, - { { "uni0645" }, { "uni0645.init" } }, - { { "uni0646" }, { "uni0646.init" } }, - { { "uni0647" }, { "uni0647.init" } }, - { { "uni0649" }, { "uni0649.init" } }, - { { "uni064A" }, { "uni064A.init" } }, - { { "uni064A.noDots" }, { "uni064A.init.noDots" } }, - { { "uni066E" }, { "uni066E.init" } }, - { { "uni066F" }, { "uni066F.init" } }, - { { "uni0678" }, { "uni0678.init" } }, - { { "uni0679" }, { "uni0679.init" } }, - { { "uni067A" }, { "uni067A.init" } }, - { { "uni067B" }, { "uni067B.init" } }, - { { "uni067C" }, { "uni067C.init" } }, - { { "uni067D" }, { "uni067D.init" } }, - { { "uni067E" }, { "uni067E.init" } }, - { { "uni067F" }, { "uni067F.init" } }, - { { "uni0680" }, { "uni0680.init" } }, - { { "uni0681" }, { "uni0681.init" } }, - { { "uni0682" }, { "uni0682.init" } }, - { { "uni0683" }, { "uni0683.init" } }, - { { "uni0684" }, { "uni0684.init" } }, - { { "uni0685" }, { "uni0685.init" } }, - { { "uni0686" }, { "uni0686.init" } }, - { { "uni0687" }, { "uni0687.init" } }, - { { "uni069A" }, { "uni069A.init" } }, - { { "uni069B" }, { "uni069B.init" } }, - { { "uni069C" }, { "uni069C.init" } }, - { { "uni069D" }, { "uni069D.init" } }, - { { "uni069E" }, { "uni069E.init" } }, - { { "uni069F" }, { "uni069F.init" } }, - { { "uni06A0" }, { "uni06A0.init" } }, - { { "uni06A1" }, { "uni06A1.init" } }, - { { "uni06A2" }, { "uni06A2.init" } }, - { { "uni06A3" }, { "uni06A3.init" } }, - { { "uni06A4" }, { "uni06A4.init" } }, - { { "uni06A5" }, { "uni06A5.init" } }, - { { "uni06A6" }, { "uni06A6.init" } }, - { { "uni06A7" }, { "uni06A7.init" } }, - { { "uni06A8" }, { "uni06A8.init" } }, - { { "uni06A9" }, { "uni06A9.init" } }, - { { "uni06AA" }, { "uni06AA.init" } }, - { { "uni06AB" }, { "uni06AB.init" } }, - { { "uni06AC" }, { "uni06AC.init" } }, - { { "uni06AD" }, { "uni06AD.init" } }, - { { "uni06AE" }, { "uni06AE.init" } }, - { { "uni06AF" }, { "uni06AF.init" } }, - { { "uni06B0" }, { "uni06B0.init" } }, - { { "uni06B1" }, { "uni06B1.init" } }, - { { "uni06B2" }, { "uni06B2.init" } }, - { { "uni06B3" }, { "uni06B3.init" } }, - { { "uni06B4" }, { "uni06B4.init" } }, - { { "uni06B5" }, { "uni06B5.init" } }, - { { "uni06B6" }, { "uni06B6.init" } }, - { { "uni06B7" }, { "uni06B7.init" } }, - { { "uni06B8" }, { "uni06B8.init" } }, - { { "uni06B9" }, { "uni06B9.init" } }, - { { "uni06BA" }, { "uni06BA.init" } }, - { { "uni06BB" }, { "uni06BB.init" } }, - { { "uni06BC" }, { "uni06BC.init" } }, - { { "uni06BD" }, { "uni06BD.init" } }, - { { "uni06BE" }, { "uni06BE.init" } }, - { { "uni06BF" }, { "uni06BF.init" } }, - { { "uni06C1" }, { "uni06C1.init" } }, - { { "uni06CC" }, { "uni06CC.init" } }, - { { "uni06CE" }, { "uni06CE.init" } }, - { { "uni06D0" }, { "uni06D0.init" } }, - { { "uni06D1" }, { "uni06D1.init" } }, - { { "uni06FA" }, { "uni06FA.init" } }, - { { "uni06FB" }, { "uni06FB.init" } }, - { { "uni06FC" }, { "uni06FC.init" } }, - { { "uni06FF" }, { "uni06FF.init" } }, - { { "uni0750" }, { "uni0750.init" } }, - { { "uni0751" }, { "uni0751.init" } }, - { { "uni0752" }, { "uni0752.init" } }, - { { "uni0753" }, { "uni0753.init" } }, - { { "uni0754" }, { "uni0754.init" } }, - { { "uni0755" }, { "uni0755.init" } }, - { { "uni0756" }, { "uni0756.init" } }, - { { "uni0757" }, { "uni0757.init" } }, - { { "uni0758" }, { "uni0758.init" } }, - { { "uni075C" }, { "uni075C.init" } }, - { { "uni075D" }, { "uni075D.init" } }, - { { "uni075E" }, { "uni075E.init" } }, - { { "uni075F" }, { "uni075F.init" } }, - { { "uni0760" }, { "uni0760.init" } }, - { { "uni0761" }, { "uni0761.init" } }, - { { "uni0762" }, { "uni0762.init" } }, - { { "uni0763" }, { "uni0763.init" } }, - { { "uni0764" }, { "uni0764.init" } }, - { { "uni0765" }, { "uni0765.init" } }, - { { "uni0766" }, { "uni0766.init" } }, - { { "uni0767" }, { "uni0767.init" } }, - { { "uni0768" }, { "uni0768.init" } }, - { { "uni0769" }, { "uni0769.init" } }, - { { "uni076A" }, { "uni076A.init" } }, - { { "uni076D" }, { "uni076D.init" } }, - } - }, - { "f3", "lu2", "arab", "dflt", "fina", - new String[][][] { - { { "absJeemRetro1" }, { "absJeemRetro1Fin" } }, - { { "absJeemRetro2" }, { "absJeemRetro2Fin" } }, - { { "absJeemRetro3" }, { "absJeemRetro3Fin" } }, - { { "absJehRetro1" }, { "absJehRetro1Fin" } }, - { { "absJehRetro2" }, { "absJehRetro2Fin" } }, - { { "absLamRetro" }, { "absLamRetroFin" } }, - { { "absSheenRetro1" }, { "absSheenRetro1Fin" } }, - { { "absSheenRetro2" }, { "absSheenRetro2Fin" } }, - { { "absTchehRetro1" }, { "absTchehRetro1Fin" } }, - { { "absTchehRetro2" }, { "absTchehRetro2Fin" } }, - { { "absWawDotBelow" }, { "absWawDotBelowFin" } }, - { { "uni0622" }, { "uni0622.fina" } }, - { { "uni0623" }, { "uni0623.fina" } }, - { { "uni0624" }, { "uni0624.fina" } }, - { { "uni0625" }, { "uni0625.fina" } }, - { { "uni0626" }, { "uni0626.fina" } }, - { { "uni0627" }, { "uni0627.fina" } }, - { { "uni0628" }, { "uni0628.fina" } }, - { { "uni0629" }, { "uni0629.fina" } }, - { { "uni062A" }, { "uni062A.fina" } }, - { { "uni062B" }, { "uni062B.fina" } }, - { { "uni062C" }, { "uni062C.fina" } }, - { { "uni062D" }, { "uni062D.fina" } }, - { { "uni062E" }, { "uni062E.fina" } }, - { { "uni062F" }, { "uni062F.fina" } }, - { { "uni0630" }, { "uni0630.fina" } }, - { { "uni0631" }, { "uni0631.fina" } }, - { { "uni0632" }, { "uni0632.fina" } }, - { { "uni0633" }, { "uni0633.fina" } }, - { { "uni0634" }, { "uni0634.fina" } }, - { { "uni0635" }, { "uni0635.fina" } }, - { { "uni0636" }, { "uni0636.fina" } }, - { { "uni0637" }, { "uni0637.fina" } }, - { { "uni0638" }, { "uni0638.fina" } }, - { { "uni0639" }, { "uni0639.fina" } }, - { { "uni063A" }, { "uni063A.fina" } }, - { { "uni0641" }, { "uni0641.fina" } }, - { { "uni0642" }, { "uni0642.fina" } }, - { { "uni0643" }, { "uni0643.fina" } }, - { { "uni0644" }, { "uni0644.fina" } }, - { { "uni0645" }, { "uni0645.fina" } }, - { { "uni0646" }, { "uni0646.fina" } }, - { { "uni0647" }, { "uni0647.fina" } }, - { { "uni0648" }, { "uni0648.fina" } }, - { { "uni0649" }, { "uni0649.fina" } }, - { { "uni064A" }, { "uni064A.fina" } }, - { { "uni064A.noDots" }, { "uni064A.fina.noDots" } }, - { { "uni066E" }, { "uni066E.fina" } }, - { { "uni066F" }, { "uni066F.fina" } }, - { { "uni0671" }, { "uni0671.fina" } }, - { { "uni0672" }, { "uni0672.fina" } }, - { { "uni0673" }, { "uni0673.fina" } }, - { { "uni0675" }, { "uni0675.fina" } }, - { { "uni0676" }, { "uni0676.fina" } }, - { { "uni0677" }, { "uni0677.fina" } }, - { { "uni0678" }, { "uni0678.fina" } }, - { { "uni0679" }, { "uni0679.fina" } }, - { { "uni067A" }, { "uni067A.fina" } }, - { { "uni067B" }, { "uni067B.fina" } }, - { { "uni067C" }, { "uni067C.fina" } }, - { { "uni067D" }, { "uni067D.fina" } }, - { { "uni067E" }, { "uni067E.fina" } }, - { { "uni067F" }, { "uni067F.fina" } }, - { { "uni0680" }, { "uni0680.fina" } }, - { { "uni0681" }, { "uni0681.fina" } }, - { { "uni0682" }, { "uni0682.fina" } }, - { { "uni0683" }, { "uni0683.fina" } }, - { { "uni0684" }, { "uni0684.fina" } }, - { { "uni0685" }, { "uni0685.fina" } }, - { { "uni0686" }, { "uni0686.fina" } }, - { { "uni0687" }, { "uni0687.fina" } }, - { { "uni0688" }, { "uni0688.fina" } }, - { { "uni0689" }, { "uni0689.fina" } }, - { { "uni068A" }, { "uni068A.fina" } }, - { { "uni068B" }, { "uni068B.fina" } }, - { { "uni068C" }, { "uni068C.fina" } }, - { { "uni068D" }, { "uni068D.fina" } }, - { { "uni068E" }, { "uni068E.fina" } }, - { { "uni068F" }, { "uni068F.fina" } }, - { { "uni0690" }, { "uni0690.fina" } }, - { { "uni0691" }, { "uni0691.fina" } }, - { { "uni0692" }, { "uni0692.fina" } }, - { { "uni0693" }, { "uni0693.fina" } }, - { { "uni0694" }, { "uni0694.fina" } }, - { { "uni0695" }, { "uni0695.fina" } }, - { { "uni0696" }, { "uni0696.fina" } }, - { { "uni0697" }, { "uni0697.fina" } }, - { { "uni0698" }, { "uni0698.fina" } }, - { { "uni0698.dotHat" }, { "uni0698.fina.dotHat" } }, - { { "uni0699" }, { "uni0699.fina" } }, - { { "uni069A" }, { "uni069A.fina" } }, - { { "uni069B" }, { "uni069B.fina" } }, - { { "uni069C" }, { "uni069C.fina" } }, - { { "uni069D" }, { "uni069D.fina" } }, - { { "uni069E" }, { "uni069E.fina" } }, - { { "uni069F" }, { "uni069F.fina" } }, - { { "uni06A0" }, { "uni06A0.fina" } }, - { { "uni06A1" }, { "uni06A1.fina" } }, - { { "uni06A2" }, { "uni06A2.fina" } }, - { { "uni06A3" }, { "uni06A3.fina" } }, - { { "uni06A4" }, { "uni06A4.fina" } }, - { { "uni06A5" }, { "uni06A5.fina" } }, - { { "uni06A6" }, { "uni06A6.fina" } }, - { { "uni06A7" }, { "uni06A7.fina" } }, - { { "uni06A8" }, { "uni06A8.fina" } }, - { { "uni06A9" }, { "uni06A9.fina" } }, - { { "uni06AA" }, { "uni06AA.fina" } }, - { { "uni06AB" }, { "uni06AB.fina" } }, - { { "uni06AC" }, { "uni06AC.fina" } }, - { { "uni06AD" }, { "uni06AD.fina" } }, - { { "uni06AE" }, { "uni06AE.fina" } }, - { { "uni06AF" }, { "uni06AF.fina" } }, - { { "uni06B0" }, { "uni06B0.fina" } }, - { { "uni06B1" }, { "uni06B1.fina" } }, - { { "uni06B2" }, { "uni06B2.fina" } }, - { { "uni06B3" }, { "uni06B3.fina" } }, - { { "uni06B4" }, { "uni06B4.fina" } }, - { { "uni06B5" }, { "uni06B5.fina" } }, - { { "uni06B6" }, { "uni06B6.fina" } }, - { { "uni06B7" }, { "uni06B7.fina" } }, - { { "uni06B8" }, { "uni06B8.fina" } }, - { { "uni06B9" }, { "uni06B9.fina" } }, - { { "uni06BA" }, { "uni06BA.fina" } }, - { { "uni06BB" }, { "uni06BB.fina" } }, - { { "uni06BC" }, { "uni06BC.fina" } }, - { { "uni06BD" }, { "uni06BD.fina" } }, - { { "uni06BE" }, { "uni06BE.fina" } }, - { { "uni06BF" }, { "uni06BF.fina" } }, - { { "uni06C0" }, { "uni06C0.fina" } }, - { { "uni06C1" }, { "uni06C1.fina" } }, - { { "uni06C2" }, { "uni06C2.fina" } }, - { { "uni06C3" }, { "uni06C3.fina" } }, - { { "uni06C4" }, { "uni06C4.fina" } }, - { { "uni06C5" }, { "uni06C5.fina" } }, - { { "uni06C6" }, { "uni06C6.fina" } }, - { { "uni06C7" }, { "uni06C7.fina" } }, - { { "uni06C8" }, { "uni06C8.fina" } }, - { { "uni06C9" }, { "uni06C9.fina" } }, - { { "uni06CA" }, { "uni06CA.fina" } }, - { { "uni06CB" }, { "uni06CB.fina" } }, - { { "uni06CC" }, { "uni06CC.fina" } }, - { { "uni06CD" }, { "uni06CD.fina" } }, - { { "uni06CE" }, { "uni06CE.fina" } }, - { { "uni06CF" }, { "uni06CF.fina" } }, - { { "uni06D0" }, { "uni06D0.fina" } }, - { { "uni06D1" }, { "uni06D1.fina" } }, - { { "uni06D2" }, { "uni06D2.fina" } }, - { { "uni06D3" }, { "uni06D3.fina" } }, - { { "uni06D5" }, { "uni06D5.fina" } }, - { { "uni06EE" }, { "uni06EE.fina" } }, - { { "uni06EF" }, { "uni06EF.fina" } }, - { { "uni06FA" }, { "uni06FA.fina" } }, - { { "uni06FB" }, { "uni06FB.fina" } }, - { { "uni06FC" }, { "uni06FC.fina" } }, - { { "uni06FF" }, { "uni06FF.fina" } }, - { { "uni0750" }, { "uni0750.fina" } }, - { { "uni0751" }, { "uni0751.fina" } }, - { { "uni0752" }, { "uni0752.fina" } }, - { { "uni0753" }, { "uni0753.fina" } }, - { { "uni0754" }, { "uni0754.fina" } }, - { { "uni0755" }, { "uni0755.fina" } }, - { { "uni0756" }, { "uni0756.fina" } }, - { { "uni0757" }, { "uni0757.fina" } }, - { { "uni0758" }, { "uni0758.fina" } }, - { { "uni0759" }, { "uni0759.fina" } }, - { { "uni075A" }, { "uni075A.fina" } }, - { { "uni075B" }, { "uni075B.fina" } }, - { { "uni075C" }, { "uni075C.fina" } }, - { { "uni075D" }, { "uni075D.fina" } }, - { { "uni075E" }, { "uni075E.fina" } }, - { { "uni075F" }, { "uni075F.fina" } }, - { { "uni0760" }, { "uni0760.fina" } }, - { { "uni0761" }, { "uni0761.fina" } }, - { { "uni0762" }, { "uni0762.fina" } }, - { { "uni0763" }, { "uni0763.fina" } }, - { { "uni0764" }, { "uni0764.fina" } }, - { { "uni0765" }, { "uni0765.fina" } }, - { { "uni0766" }, { "uni0766.fina" } }, - { { "uni0767" }, { "uni0767.fina" } }, - { { "uni0768" }, { "uni0768.fina" } }, - { { "uni0769" }, { "uni0769.fina" } }, - { { "uni076A" }, { "uni076A.fina" } }, - { { "uni076B" }, { "uni076B.fina" } }, - { { "uni076C" }, { "uni076C.fina" } }, - { { "uni076D" }, { "uni076D.fina" } }, - } - }, - { "f3", "lu3", "arab", "dflt", "medi", - new String[][][] { - { { "absJeemRetro1" }, { "absJeemRetro1Med" } }, - { { "absJeemRetro2" }, { "absJeemRetro2Med" } }, - { { "absJeemRetro3" }, { "absJeemRetro3Med" } }, - { { "absLamRetro" }, { "absLamRetroMed" } }, - { { "absSheenRetro1" }, { "absSheenRetro1Med" } }, - { { "absSheenRetro2" }, { "absSheenRetro2Med" } }, - { { "absTchehRetro1" }, { "absTchehRetro1Med" } }, - { { "absTchehRetro2" }, { "absTchehRetro2Med" } }, - { { "uni0626" }, { "uni0626.medi" } }, - { { "uni0628" }, { "uni0628.medi" } }, - { { "uni062A" }, { "uni062A.medi" } }, - { { "uni062B" }, { "uni062B.medi" } }, - { { "uni062C" }, { "uni062C.medi" } }, - { { "uni062D" }, { "uni062D.medi" } }, - { { "uni062E" }, { "uni062E.medi" } }, - { { "uni0633" }, { "uni0633.medi" } }, - { { "uni0634" }, { "uni0634.medi" } }, - { { "uni0635" }, { "uni0635.medi" } }, - { { "uni0636" }, { "uni0636.medi" } }, - { { "uni0637" }, { "uni0637.medi" } }, - { { "uni0638" }, { "uni0638.medi" } }, - { { "uni0639" }, { "uni0639.medi" } }, - { { "uni063A" }, { "uni063A.medi" } }, - { { "uni0641" }, { "uni0641.medi" } }, - { { "uni0642" }, { "uni0642.medi" } }, - { { "uni0643" }, { "uni0643.medi" } }, - { { "uni0644" }, { "uni0644.medi" } }, - { { "uni0645" }, { "uni0645.medi" } }, - { { "uni0646" }, { "uni0646.medi" } }, - { { "uni0647" }, { "uni0647.medi" } }, - { { "uni0649" }, { "uni0649.medi" } }, - { { "uni064A" }, { "uni064A.medi" } }, - { { "uni064A.noDots" }, { "uni064A.medi.noDots" } }, - { { "uni066E" }, { "uni066E.medi" } }, - { { "uni066F" }, { "uni066F.medi" } }, - { { "uni0678" }, { "uni0678.medi" } }, - { { "uni0679" }, { "uni0679.medi" } }, - { { "uni067A" }, { "uni067A.medi" } }, - { { "uni067B" }, { "uni067B.medi" } }, - { { "uni067C" }, { "uni067C.medi" } }, - { { "uni067D" }, { "uni067D.medi" } }, - { { "uni067E" }, { "uni067E.medi" } }, - { { "uni067F" }, { "uni067F.medi" } }, - { { "uni0680" }, { "uni0680.medi" } }, - { { "uni0681" }, { "uni0681.medi" } }, - { { "uni0682" }, { "uni0682.medi" } }, - { { "uni0683" }, { "uni0683.medi" } }, - { { "uni0684" }, { "uni0684.medi" } }, - { { "uni0685" }, { "uni0685.medi" } }, - { { "uni0686" }, { "uni0686.medi" } }, - { { "uni0687" }, { "uni0687.medi" } }, - { { "uni069A" }, { "uni069A.medi" } }, - { { "uni069B" }, { "uni069B.medi" } }, - { { "uni069C" }, { "uni069C.medi" } }, - { { "uni069D" }, { "uni069D.medi" } }, - { { "uni069E" }, { "uni069E.medi" } }, - { { "uni069F" }, { "uni069F.medi" } }, - { { "uni06A0" }, { "uni06A0.medi" } }, - { { "uni06A1" }, { "uni06A1.medi" } }, - { { "uni06A2" }, { "uni06A2.medi" } }, - { { "uni06A3" }, { "uni06A3.medi" } }, - { { "uni06A4" }, { "uni06A4.medi" } }, - { { "uni06A5" }, { "uni06A5.medi" } }, - { { "uni06A6" }, { "uni06A6.medi" } }, - { { "uni06A7" }, { "uni06A7.medi" } }, - { { "uni06A8" }, { "uni06A8.medi" } }, - { { "uni06A9" }, { "uni06A9.medi" } }, - { { "uni06AA" }, { "uni06AA.medi" } }, - { { "uni06AB" }, { "uni06AB.medi" } }, - { { "uni06AC" }, { "uni06AC.medi" } }, - { { "uni06AD" }, { "uni06AD.medi" } }, - { { "uni06AE" }, { "uni06AE.medi" } }, - { { "uni06AF" }, { "uni06AF.medi" } }, - { { "uni06B0" }, { "uni06B0.medi" } }, - { { "uni06B1" }, { "uni06B1.medi" } }, - { { "uni06B2" }, { "uni06B2.medi" } }, - { { "uni06B3" }, { "uni06B3.medi" } }, - { { "uni06B4" }, { "uni06B4.medi" } }, - { { "uni06B5" }, { "uni06B5.medi" } }, - { { "uni06B6" }, { "uni06B6.medi" } }, - { { "uni06B7" }, { "uni06B7.medi" } }, - { { "uni06B8" }, { "uni06B8.medi" } }, - { { "uni06B9" }, { "uni06B9.medi" } }, - { { "uni06BA" }, { "uni06BA.medi" } }, - { { "uni06BB" }, { "uni06BB.medi" } }, - { { "uni06BC" }, { "uni06BC.medi" } }, - { { "uni06BD" }, { "uni06BD.medi" } }, - { { "uni06BE" }, { "uni06BE.medi" } }, - { { "uni06BF" }, { "uni06BF.medi" } }, - { { "uni06C1" }, { "uni06C1.medi" } }, - { { "uni06CC" }, { "uni06CC.medi" } }, - { { "uni06CE" }, { "uni06CE.medi" } }, - { { "uni06D0" }, { "uni06D0.medi" } }, - { { "uni06D1" }, { "uni06D1.medi" } }, - { { "uni06FA" }, { "uni06FA.medi" } }, - { { "uni06FB" }, { "uni06FB.medi" } }, - { { "uni06FC" }, { "uni06FC.medi" } }, - { { "uni06FF" }, { "uni06FF.medi" } }, - { { "uni0750" }, { "uni0750.medi" } }, - { { "uni0751" }, { "uni0751.medi" } }, - { { "uni0752" }, { "uni0752.medi" } }, - { { "uni0753" }, { "uni0753.medi" } }, - { { "uni0754" }, { "uni0754.medi" } }, - { { "uni0755" }, { "uni0755.medi" } }, - { { "uni0756" }, { "uni0756.medi" } }, - { { "uni0757" }, { "uni0757.medi" } }, - { { "uni0758" }, { "uni0758.medi" } }, - { { "uni075C" }, { "uni075C.medi" } }, - { { "uni075D" }, { "uni075D.medi" } }, - { { "uni075E" }, { "uni075E.medi" } }, - { { "uni075F" }, { "uni075F.medi" } }, - { { "uni0760" }, { "uni0760.medi" } }, - { { "uni0761" }, { "uni0761.medi" } }, - { { "uni0762" }, { "uni0762.medi" } }, - { { "uni0763" }, { "uni0763.medi" } }, - { { "uni0764" }, { "uni0764.medi" } }, - { { "uni0765" }, { "uni0765.medi" } }, - { { "uni0766" }, { "uni0766.medi" } }, - { { "uni0767" }, { "uni0767.medi" } }, - { { "uni0768" }, { "uni0768.medi" } }, - { { "uni0769" }, { "uni0769.medi" } }, - { { "uni076A" }, { "uni076A.medi" } }, - { { "uni076D" }, { "uni076D.medi" } }, - } - }, - { "f3", "lu11", "arab", "SND ", "calt", - new String[][][] { - { { "uni0645" }, { "uni0645.sindhi" } }, - { { "uni0645.fina" }, { "uni0645.fina.sindhi" } }, - { { "uni0647" }, { "uni0647.knotted" } }, - { { "uni0647.fina" }, { "uni0647.fina.knottedHigh" } }, - { { "uni0647.medi" }, { "uni0647.medi.knottedHigh" } }, - { { "uni06F6" }, { "uni06F6.urdu" } }, - { { "uni06F7" }, { "uni06F7.urdu" } }, - } - }, - { "f3", "lu12", "arab", "KUR ", "calt", - new String[][][] { - { { "uni0647" }, { "uni0647.knotted" } }, - { { "uni0647.fina" }, { "uni0647.fina.knottedHigh" } }, - } - }, - { "f3", "lu13", "arab", "URD ", "calt", - new String[][][] { - { { "uni0647.fina" }, { "uni0647.fina.hooked" } }, - { { "uni0647.init" }, { "uni0647.init.hooked" } }, - { { "uni0647.medi" }, { "uni0647.medi.hooked" } }, - { { "uni06F4" }, { "uni06F4.urdu" } }, - { { "uni06F6" }, { "uni06F6.urdu" } }, - { { "uni06F7" }, { "uni06F7.urdu" } }, - } - }, - { "f3", "lu15", "arab", "*", "*", - new String[][][] { - { { "absLamRetroIni" }, { "absLamRetroIni.preAlef" } }, - { { "absLamRetroMed" }, { "absLamRetroMed.preAlef" } }, - { { "uni0644.init" }, { "uni0644.init.preAlef" } }, - { { "uni0644.medi" }, { "uni0644.medi.preAlef" } }, - { { "uni06B5.init" }, { "uni06B5.init.preAlef" } }, - { { "uni06B5.medi" }, { "uni06B5.medi.preAlef" } }, - { { "uni06B6.init" }, { "uni06B6.init.preAlef" } }, - { { "uni06B6.medi" }, { "uni06B6.medi.preAlef" } }, - { { "uni06B7.init" }, { "uni06B7.init.preAlef" } }, - { { "uni06B7.medi" }, { "uni06B7.medi.preAlef" } }, - { { "uni06B8.init" }, { "uni06B8.init.preAlef" } }, - { { "uni06B8.medi" }, { "uni06B8.medi.preAlef" } }, - { { "uni076A.init" }, { "uni076A.init.preAlef" } }, - { { "uni076A.medi" }, { "uni076A.medi.preAlef" } }, - } - }, - { "f3", "lu16", "arab", "*", "*", - new String[][][] { - { { "uni0622.fina" }, { "uni0622.fina.postLamIni" } }, - { { "uni0623.fina" }, { "uni0623.fina.postLamIni" } }, - { { "uni0625.fina" }, { "uni0625.fina.postLamIni" } }, - { { "uni0627.fina" }, { "uni0627.fina.postLamIni" } }, - { { "uni0671.fina" }, { "uni0671.fina.postLamIni" } }, - { { "uni0672.fina" }, { "uni0672.fina.postLamIni" } }, - { { "uni0673.fina" }, { "uni0673.fina.postLamIni" } }, - { { "uni0675.fina" }, { "uni0675.fina.postLamIni" } }, - } - }, - { "f3", "lu17", "arab", "*", "*", - new String[][][] { - { { "uni0622.fina" }, { "uni0622.fina.postLamMed" } }, - { { "uni0623.fina" }, { "uni0623.fina.postLamMed" } }, - { { "uni0625.fina" }, { "uni0625.fina.postLamMed" } }, - { { "uni0627.fina" }, { "uni0627.fina.postLamMed" } }, - { { "uni0671.fina" }, { "uni0671.fina.postLamMed" } }, - { { "uni0672.fina" }, { "uni0672.fina.postLamMed" } }, - { { "uni0673.fina" }, { "uni0673.fina.postLamMed" } }, - { { "uni0675.fina" }, { "uni0675.fina.postLamMed" } }, - } - }, - { "f3", "lu18", "arab", "*", "*", - new String[][][] { - { { "uni0601" }, { "uni0601.4" } }, - } - }, - { "f3", "lu19", "arab", "*", "*", - new String[][][] { - { { "uni0600" }, { "uni0600.3" } }, - { { "uni0601" }, { "uni0601.3" } }, - { { "uni0603" }, { "uni0603.3" } }, - { { "uni06DD" }, { "uni06DD.3" } }, - { { "uni06DD.alt" }, { "uni06DD.alt.3" } }, - { { "uni06DD.altB" }, { "uni06DD.altB.3" } }, - } - }, - { "f3", "lu20", "arab", "*", "*", - new String[][][] { - { { "uni0600" }, { "uni0600.2" } }, - { { "uni0601" }, { "uni0601.2" } }, - { { "uni0602" }, { "uni0602.2" } }, - { { "uni0603" }, { "uni0603.2" } }, - { { "uni06DD" }, { "uni06DD.2" } }, - { { "uni06DD.alt" }, { "uni06DD.alt.2" } }, - { { "uni06DD.altB" }, { "uni06DD.altB.2" } }, - } - }, - { "f3", "lu21", "arab", "*", "*", - new String[][][] { - { { "eight" }, { "eightMedium" } }, - { { "five" }, { "fiveMedium" } }, - { { "four" }, { "fourMedium" } }, - { { "nine" }, { "nineMedium" } }, - { { "one" }, { "oneMedium" } }, - { { "seven" }, { "sevenMedium" } }, - { { "six" }, { "sixMedium" } }, - { { "three" }, { "threeMedium" } }, - { { "two" }, { "twoMedium" } }, - { { "uni0660" }, { "uni0660.Medium" } }, - { { "uni0661" }, { "uni0661.Medium" } }, - { { "uni0662" }, { "uni0662.Medium" } }, - { { "uni0663" }, { "uni0663.Medium" } }, - { { "uni0664" }, { "uni0664.Medium" } }, - { { "uni0665" }, { "uni0665.Medium" } }, - { { "uni0666" }, { "uni0666.Medium" } }, - { { "uni0667" }, { "uni0667.Medium" } }, - { { "uni0668" }, { "uni0668.Medium" } }, - { { "uni0669" }, { "uni0669.Medium" } }, - { { "uni06F0" }, { "uni06F0.Medium" } }, - { { "uni06F1" }, { "uni06F1.Medium" } }, - { { "uni06F2" }, { "uni06F2.Medium" } }, - { { "uni06F3" }, { "uni06F3.Medium" } }, - { { "uni06F4" }, { "uni06F4.Medium" } }, - { { "uni06F4.urdu" }, { "uni06F4.Medium.urdu" } }, - { { "uni06F5" }, { "uni06F5.Medium" } }, - { { "uni06F6" }, { "uni06F6.Medium" } }, - { { "uni06F6.urdu" }, { "uni06F6.Medium.urdu" } }, - { { "uni06F7" }, { "uni06F7.Medium" } }, - { { "uni06F7.urdu" }, { "uni06F7.Medium.urdu" } }, - { { "uni06F8" }, { "uni06F8.Medium" } }, - { { "uni06F9" }, { "uni06F9.Medium" } }, - { { "zero" }, { "zeroMedium" } }, - } - }, - { "f3", "lu22", "arab", "*", "*", - new String[][][] { - { { "eight" }, { "eightSmall" } }, - { { "five" }, { "fiveSmall" } }, - { { "four" }, { "fourSmall" } }, - { { "nine" }, { "nineSmall" } }, - { { "one" }, { "oneSmall" } }, - { { "seven" }, { "sevenSmall" } }, - { { "six" }, { "sixSmall" } }, - { { "three" }, { "threeSmall" } }, - { { "two" }, { "twoSmall" } }, - { { "uni0660" }, { "uni0660.Small" } }, - { { "uni0661" }, { "uni0661.Small" } }, - { { "uni0662" }, { "uni0662.Small" } }, - { { "uni0663" }, { "uni0663.Small" } }, - { { "uni0664" }, { "uni0664.Small" } }, - { { "uni0665" }, { "uni0665.Small" } }, - { { "uni0666" }, { "uni0666.Small" } }, - { { "uni0667" }, { "uni0667.Small" } }, - { { "uni0668" }, { "uni0668.Small" } }, - { { "uni0669" }, { "uni0669.Small" } }, - { { "uni06F0" }, { "uni06F0.Small" } }, - { { "uni06F1" }, { "uni06F1.Small" } }, - { { "uni06F2" }, { "uni06F2.Small" } }, - { { "uni06F3" }, { "uni06F3.Small" } }, - { { "uni06F4" }, { "uni06F4.Small" } }, - { { "uni06F4.urdu" }, { "uni06F4.Small.urdu" } }, - { { "uni06F5" }, { "uni06F5.Small" } }, - { { "uni06F6" }, { "uni06F6.Small" } }, - { { "uni06F6.urdu" }, { "uni06F6.Small.urdu" } }, - { { "uni06F7" }, { "uni06F7.Small" } }, - { { "uni06F7.urdu" }, { "uni06F7.Small.urdu" } }, - { { "uni06F8" }, { "uni06F8.Small" } }, - { { "uni06F9" }, { "uni06F9.Small" } }, - { { "zero" }, { "zeroSmall" } }, - } - }, - { "f3", "lu23", "arab", "*", "*", - new String[][][] { - { { "uni0670" }, { "uni0670.large" } }, - } - }, - }; - - private static Object[][] ltMultiple = { - { GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_MULTIPLE }, - // arab-001.ttx - { "f0", "lu9", "arab", "*", "*", - new String[][][] { - { { "alefwithhamzabelow" }, { "arabicalef", "uni0655" } }, - } - }, - // arab-002.ttx - { "f1", "lu14", "arab", "*", "*", - new String[][][] { - { { "pehinitial" }, { "pehinitial", "tatweel" } }, - { { "yehwithhamzaaboveinitial" }, { "yehwithhamzaaboveinitial", "tatweel" } }, - { { "behinitial" }, { "behinitial", "tatweel" } }, - { { "tehinitial" }, { "tehinitial", "tatweel" } }, - { { "thehinitial" }, { "thehinitial", "tatweel" } }, - { { "fehinitial" }, { "fehinitial", "tatweel" } }, - { { "qafinitial" }, { "qafinitial", "tatweel" } }, - { { "nooninitial" }, { "nooninitial", "tatweel" } }, - { { "yehinitial" }, { "yehinitial", "tatweel" } }, - { { "uni0649.init" }, { "uni0649.init", "tatweel" } }, - } - }, - { "f1", "lu15", "arab", "*", "*", - new String[][][] { - { { "pehmedial" }, { "pehmedial", "tatweel" } }, - { { "yehwithhamzaabovemedial" }, { "yehwithhamzaabovemedial", "tatweel" } }, - { { "behmedial" }, { "behmedial", "tatweel" } }, - { { "tehmedial" }, { "tehmedial", "tatweel" } }, - { { "thehmedial" }, { "thehmedial", "tatweel" } }, - { { "noonmedial" }, { "noonmedial", "tatweel" } }, - { { "yehmedial" }, { "yehmedial", "tatweel" } }, - { { "uni0649.medi" }, { "uni0649.medi", "tatweel" } }, - } - }, - // arab-003.ttx - { "f2", "lu0", "arab", "dflt", "ccmp", - new String[][][] { - { { "uni0622" }, { "uni0627", "uni0653" } }, - { { "uni0623" }, { "uni0627", "uni0654" } }, - { { "uni0625" }, { "uni0627", "uni0655" } }, - { { "uni0626" }, { "uni064A", "uni0654" } }, - } - }, - // arab-004.ttx - { "f3", "lu0", "arab", "dflt", "ccmp", - new String[][][] { - { { "uni0622" }, { "uni0627", "uni0653" } }, - { { "uni0623" }, { "uni0627", "uni0654" } }, - { { "uni0625" }, { "uni0627", "uni0655" } }, - } - }, - }; - - private static Object[][] ltAlternate = { - { GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_ALTERNATE }, - // arab-001.ttx - none used - // arab-002.ttx - none used - // arab-003.ttx - none used - // arab-004.ttx - add tests - { "f3", "lu14", "arab", "dflt", "salt" }, - }; - - private static Object[][] ltLigature = { - { GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_LIGATURE }, - // arab-001.ttx - { "f0", "lu0", "arab", "dflt", "ccmp", - new String[][][] { - { { "damma", "shadda" }, { "shaddawithdammalow" } }, - { { "damma", "highhamza" }, { "dammaonhamza" } }, - { { "dammatan", "shadda" }, { "shaddawithdammatanlow" } }, - { { "dammatan", "highhamza" }, { "dammatanonhamza" } }, - { { "fatha", "shadda" }, { "shaddawithfathalow" } }, - { { "fatha", "highhamza" }, { "fathaonhamza" } }, - { { "fathatan", "shadda" }, { "shaddawithfathatanlow" } }, - { { "fathatan", "highhamza" }, { "fathatanonhamza" } }, - { { "highhamza", "fatha" }, { "fathaonhamza" } }, - { { "highhamza", "fathatan" }, { "fathatanonhamza" } }, - { { "highhamza", "sukun" }, { "sukunonhamza" } }, - { { "highhamza", "damma" }, { "dammaonhamza" } }, - { { "highhamza", "dammatan" }, { "dammatanonhamza" } }, - { { "kasra", "shadda" }, { "shaddawithkasralow" } }, - { { "kasra", "uni0655" }, { "uni06550650" } }, - { { "kasratan", "shadda" }, { "shaddawithkasratanlow" } }, - { { "kasratan", "uni0655" }, { "uni0655064D" } }, - { { "shadda", "dammatan" }, { "shaddawithdammatanlow" } }, - { { "shadda", "fatha" }, { "shaddawithfathalow" } }, - { { "shadda", "damma" }, { "shaddawithdammalow" } }, - { { "shadda", "fathatan" }, { "shaddawithfathatanlow" } }, - { { "shadda", "kasratan" }, { "shaddawithkasratanlow" } }, - { { "shadda", "kasra" }, { "shaddawithkasralow" } }, - { { "sukun", "highhamza" }, { "sukunonhamza" } }, - { { "uni0655", "kasratan" }, { "uni0655064D" } }, - { { "uni0655", "kasra" }, { "uni06550650" } }, - } - }, - { "f0", "lu7", "arab", "dflt", "rlig", - new String[][][] { - { { "lamisolated", "alefwithmaddaabovefinal" }, { "lamwithalefmaddaaboveisolatedd" } }, - { { "lamisolated", "alefwithhamzaabovefinal" }, { "lamwithalefhamzaaboveisolatedd" } }, - { { "lamisolated", "alefwithhamzabelowfinal" }, { "lamwithalefhamzabelowisolated" } }, - { { "lamisolated", "aleffinal" }, { "lamwithalefisolated" } }, - { { "lammedial", "alefwithmaddaabovefinal" }, { "lamwithalefmaddaabovefinal" } }, - { { "lammedial", "alefwithhamzaabovefinal" }, { "lamwithalefhamzaabovefinal" } }, - { { "lammedial", "alefwithhamzabelowfinal" }, { "lamwithalefhamzabelowfinal" } }, - { { "lammedial", "aleffinal" }, { "lamwithaleffinal" } }, - } - }, - { "f0", "lu8", "arab", "dflt", "liga", - new String[][][] { - { { "lamisolated", "lammedial", "hehfinal" }, { "allahisolated" } }, - { { "reh", "yehmedial", "aleffinal", "lam" }, { "rayaleflam" } }, - } - }, - // arab-002.ttx - { "f1", "lu0", "arab", "dflt", "ccmp", - new String[][][] { - { { "damma", "shadda" }, { "shaddawithdammaisolatedlow" } }, - { { "damma", "highhamza" }, { "dammaonhamza" } }, - { { "dammatan", "shadda" }, { "shaddawithdammatanisolatedlow" } }, - { { "dammatan", "highhamza" }, { "dammatanonhamza" } }, - { { "fatha", "shadda" }, { "shaddawithfathaisolatedlow" } }, - { { "fatha", "highhamza" }, { "fathaonhamza" } }, - { { "fathatan", "shadda" }, { "shaddawithfathatanisolatedlow" } }, - { { "fathatan", "highhamza" }, { "fathatanonhamza" } }, - { { "highhamza", "fatha" }, { "fathaonhamza" } }, - { { "highhamza", "fathatan" }, { "fathatanonhamza" } }, - { { "highhamza", "sukun" }, { "sukunonhamza" } }, - { { "highhamza", "damma" }, { "dammaonhamza" } }, - { { "highhamza", "dammatan" }, { "dammatanonhamza" } }, - { { "kasra", "shadda" }, { "shaddawithkasraisolatedlow" } }, - { { "kasra", "uni0655" }, { "uni06550650" } }, - { { "kasratan", "shadda" }, { "shaddawithkasratanisolatedlow" } }, - { { "kasratan", "uni0655" }, { "uni0655064D" } }, - { { "shadda", "dammatan" }, { "shaddawithdammatanisolatedlow" } }, - { { "shadda", "fatha" }, { "shaddawithfathaisolatedlow" } }, - { { "shadda", "damma" }, { "shaddawithdammaisolatedlow" } }, - { { "shadda", "fathatan" }, { "shaddawithfathatanisolatedlow" } }, - { { "shadda", "kasratan" }, { "shaddawithkasratanisolatedlow" } }, - { { "shadda", "kasra" }, { "shaddawithkasraisolatedlow" } }, - { { "sukun", "highhamza" }, { "sukunonhamza" } }, - { { "uni0655", "kasratan" }, { "uni0655064D" } }, - { { "uni0655", "kasra" }, { "uni06550650" } }, - } - }, - { "f1", "lu6", "arab", "dflt", "liga", - new String[][][] { - { { "behinitial", "hehmedial" }, { "behwithhehinitial" } }, - { { "behinitial", "meemfinal" }, { "behwithmeemisolated" } }, - { { "behinitial", "meemmedial" }, { "behwithmeeminitial" } }, - { { "behinitial", "alefmaksurafinal" }, { "behwithalefmaksuraisolated" } }, - { { "behinitial", "yehfinal" }, { "behwithyehisolated" } }, - { { "behinitial", "jeemmedial" }, { "behwithjeeminitial" } }, - { { "behinitial", "hahmedial" }, { "behwithhahinitial" } }, - { { "behinitial", "khahmedial" }, { "behwithkhahinitial" } }, - { { "behmedial", "alefmaksurafinal" }, { "behwithalefmaksurafinal" } }, - { { "behmedial", "yehfinal" }, { "behwithyehfinal" } }, - { { "behmedial", "rehfinal" }, { "behwithrehfinal" } }, - { { "behmedial", "noonfinal" }, { "behwithnoonfinal" } }, - { { "fehinitial", "alefmaksurafinal" }, { "fehwithalefmaksuraisolated" } }, - { { "fehinitial", "yehfinal" }, { "fehwithyehisolated" } }, - { { "hahinitial", "meemmedial" }, { "hahwithmeeminitial" } }, - { { "hehinitial", "meemmedial" }, { "hehwithmeeminitial" } }, - { { "jeeminitial", "meemmedial" }, { "jeemwithmeeminitial" } }, - { { "khahinitial", "meemmedial" }, { "khahwithmeeminitial" } }, - { { "laminitial", "jeemmedial" }, { "lamwithjeeminitial" } }, - { { "laminitial", "hahmedial" }, { "lamwithhahinitial" } }, - { { "laminitial", "khahmedial" }, { "lamwithkhahinitial" } }, - { { "laminitial", "hehmedial" }, { "lamwithhehinitial" } }, - { { "laminitial", "meemfinal" }, { "lamwithmeemisolated" } }, - { { "laminitial", "alefmaksurafinal" }, { "lamwithalefmaksuraisolated" } }, - { { "laminitial", "yehfinal" }, { "lamwithyehisolated" } }, - { { "meeminitial", "jeemmedial" }, { "meemwithjeeminitial" } }, - { { "meeminitial", "hahmedial" }, { "meemwithhahinitial" } }, - { { "meeminitial", "khahmedial" }, { "meemwithkhahinitial" } }, - { { "meeminitial", "meemmedial" }, { "meemwithmeeminitial" } }, - { { "nooninitial", "hehmedial" }, { "noonwithhehinitial" } }, - { { "nooninitial", "meemfinal" }, { "noonwithmeemisolated" } }, - { { "nooninitial", "meemmedial" }, { "noonwithmeeminitial" } }, - { { "nooninitial", "alefmaksurafinal" }, { "noonwithalefmaksuraisolated" } }, - { { "nooninitial", "yehfinal" }, { "noonwithyehisolated" } }, - { { "nooninitial", "jeemmedial" }, { "noonwithjeeminitial" } }, - { { "nooninitial", "hahmedial" }, { "noonwithhahinitial" } }, - { { "nooninitial", "khahmedial" }, { "noonwithkhahinitial" } }, - { { "noonmedial", "alefmaksurafinal" }, { "noonwithalefmaksurafinal" } }, - { { "noonmedial", "yehfinal" }, { "noonwithyehfinal" } }, - { { "pehinitial", "hehmedial" }, { "pehwithhehinitial" } }, - { { "seeninitial", "meemmedial" }, { "seenwithmeeminitial" } }, - { { "sheeninitial", "meemmedial" }, { "sheenwithmeeminitial" } }, - { { "tchehinitial", "meemmedial" }, { "uniE817" } }, - { { "tehinitial", "hehmedial" }, { "tehwithhehinitial" } }, - { { "tehinitial", "meemfinal" }, { "tehwithmeemisolated" } }, - { { "tehinitial", "meemmedial" }, { "tehwithmeeminitial" } }, - { { "tehinitial", "yehfinal" }, { "tehwithyehisolated" } }, - { { "tehinitial", "jeemmedial" }, { "tehwithjeeminitial" } }, - { { "tehinitial", "hahmedial" }, { "tehwithhahinitial" } }, - { { "tehinitial", "khahmedial" }, { "tehwithkhahinitial" } }, - { { "tehmedial", "alefmaksurafinal" }, { "tehwithalefmaksurafinal" } }, - { { "tehmedial", "yehfinal" }, { "tehwithyehfinal" } }, - { { "tehmedial", "rehfinal" }, { "noonwithzainfinal" } }, - { { "tehmedial", "noonfinal" }, { "tehwithnoonfinal" } }, - { { "thehinitial", "meemfinal" }, { "thehwithmeemisolated" } }, - { { "thehinitial", "meemmedial" }, { "thehwithmeeminitial" } }, - { { "yehinitial", "meemfinal" }, { "yehwithmeemisolated" } }, - { { "yehinitial", "meemmedial" }, { "yehwithmeeminitial" } }, - { { "yehinitial", "alefmaksurafinal" }, { "yehwithalefmaksuraisolated" } }, - { { "yehinitial", "jeemmedial" }, { "yehwithjeeminitial" } }, - { { "yehinitial", "hahmedial" }, { "yehwithhahinitial" } }, - { { "yehinitial", "khahmedial" }, { "yehwithkhahinitial" } }, - { { "yehmedial", "alefmaksurafinal" }, { "yehwithalefmaksurafinal" } }, - { { "yehmedial", "rehfinal" }, { "yehwithrehfinal" } }, - { { "yehmedial", "noonfinal" }, { "yehwithnoonfinal" } }, - } - }, - { "f1", "lu7", "arab", "dflt", "liga", - new String[][][] { - { { "laminitial", "meemmedial", "jeemmedial" }, { "lamwithmeemwithjeeminitial" } }, - { { "laminitial", "meemmedial", "hahmedial" }, { "lamwithmeemwithhahinitial" } }, - { { "laminitial", "meemmedial" }, { "lamwithmeeminitial" } }, - } - }, - { "f1", "lu8", "arab", "dflt", "liga", - new String[][][] { - { { "laminitial", "jeemfinal" }, { "lamwithjeemisolated" } }, - { { "laminitial", "hahfinal" }, { "lamwithhahisolated" } }, - { { "laminitial", "khahfinal" }, { "lamwithkhahisolated" } }, - } - }, - { "f1", "lu9", "arab", "dflt", "rlig", - new String[][][] { - { { "laminitial", "alefwithmaddaabovefinal" }, { "lamwithalefmaddaaboveisolatedd" } }, - { { "laminitial", "alefwithhamzaabovefinal" }, { "lamwithalefhamzaaboveisolatedd" } }, - { { "laminitial", "alefwithhamzabelowfinal" }, { "lamwithalefhamzabelowisolated" } }, - { { "laminitial", "aleffinal" }, { "lamwithalefisolated" } }, - { { "lammedial", "alefwithmaddaabovefinal" }, { "lamwithalefmaddaabovefinal" } }, - { { "lammedial", "alefwithhamzaabovefinal" }, { "lamwithalefhamzaabovefinal" } }, - { { "lammedial", "alefwithhamzabelowfinal" }, { "lamwithalefhamzabelowfinal" } }, - { { "lammedial", "aleffinal" }, { "lamwithaleffinal" } }, - } - }, - { "f1", "lu10", "arab", "dflt", "liga", - new String[][][] { - { { "laminitial", "lammedial", "hehfinal" }, { "allahisolated" } }, - { { "reh", "yehinitial", "aleffinal", "lam" }, { "rayaleflam" } }, - } - }, - // arab-003.ttx - { "f2", "lu5", "arab", "dflt", "rlig", - new String[][][] { - { { "uni064B", "uni0651" }, { "uni0651064B" } }, - { { "uni064C", "uni0651" }, { "uni0651064C" } }, - { { "uni064E", "uni0651" }, { "uni0651064E" } }, - { { "uni064F", "uni0651" }, { "uni0651064F" } }, - { { "uni0651", "uni064B" }, { "uni0651064B" } }, - { { "uni0651", "uni064C" }, { "uni0651064C" } }, - { { "uni0651", "uni064E" }, { "uni0651064E" } }, - { { "uni0651", "uni064F" }, { "uni0651064F" } }, - { { "uni0651", "uni0670" }, { "absShaddaAlef" } }, - { { "uni0670", "uni0651" }, { "absShaddaAlef" } }, - } - }, - { "f2", "lu6", "arab", "dflt", "rlig", - new String[][][] { - { { "uni064D", "uni0651" }, { "uni0651064D" } }, - { { "uni0650", "uni0651" }, { "uni06510650" } }, - { { "uni0651", "uni0650" }, { "uni06510650" } }, - { { "uni0651", "uni064D" }, { "uni0651064D" } }, - } - }, - { "f2", "lu7", "arab", "dflt", "rlig", - new String[][][] { - { { "uni0647", "uni0654" }, { "uni06C0" } }, - { { "uni0647.fina", "uni0654" }, { "uni06C0.fina" } }, - { { "uni0647.init", "uni0654" }, { "uni06C0.init" } }, - { { "uni0647.medi", "uni0654" }, { "uni06C0.medi" } }, - { { "uni0648", "uni0654" }, { "uni0624" } }, - { { "uni0648.fina", "uni0654" }, { "uni0624.fina" } }, - { { "uni064A", "uni0654" }, { "uni0626" } }, - { { "uni064A.fina", "uni0654" }, { "uni0626.fina" } }, - { { "uni064A.init", "uni0654" }, { "uni0626.init" } }, - { { "uni064A.medi", "uni0654" }, { "uni0626.medi" } }, - { { "uni06C1", "uni0654" }, { "uni06C2" } }, - { { "uni06C1.fina", "uni0654" }, { "uni06C2.fina" } }, - { { "uni06C1.init", "uni0654" }, { "uni06C2.init" } }, - { { "uni06C1.medi", "uni0654" }, { "uni06C2.medi" } }, - } - }, - // arab-004.ttx - { "f3", "lu5", "arab", "dflt", "rlig", - new String[][][] { - { { "uni064B", "uni0651" }, { "uni0651064B" } }, - { { "uni064C", "uni0651" }, { "uni0651064C" } }, - { { "uni064E", "uni0651" }, { "uni0651064E" } }, - { { "uni064F", "uni0651" }, { "uni0651064F" } }, - { { "uni0651", "uni064B" }, { "uni0651064B" } }, - { { "uni0651", "uni064C" }, { "uni0651064C" } }, - { { "uni0651", "uni064E" }, { "uni0651064E" } }, - { { "uni0651", "uni064F" }, { "uni0651064F" } }, - { { "uni0651", "uni0670" }, { "absShaddaAlef" } }, - { { "uni0670", "uni0651" }, { "absShaddaAlef" } }, - } - }, - { "f3", "lu6", "arab", "dflt", "rlig", - new String[][][] { - { { "uni064D", "uni0651" }, { "uni0651064D" } }, - { { "uni0650", "uni0651" }, { "uni06510650" } }, - { { "uni0651", "uni0650" }, { "uni06510650" } }, - { { "uni0651", "uni064D" }, { "uni0651064D" } }, - } - }, - { "f3", "lu7", "arab", "dflt", "rlig", - new String[][][] { - { { "uni0647", "uni0654" }, { "uni06C0" } }, - { { "uni0647.fina", "uni0654" }, { "uni06C0.fina" } }, - { { "uni0647.init", "uni0654" }, { "uni06C0.init" } }, - { { "uni0647.medi", "uni0654" }, { "uni06C0.medi" } }, - { { "uni0648", "uni0654" }, { "uni0624" } }, - { { "uni0648.fina", "uni0654" }, { "uni0624.fina" } }, - { { "uni064A", "uni0654" }, { "uni0626" } }, - { { "uni064A.fina", "uni0654" }, { "uni0626.fina" } }, - { { "uni064A.init", "uni0654" }, { "uni0626.init" } }, - { { "uni064A.medi", "uni0654" }, { "uni0626.medi" } }, - { { "uni06C1", "uni0654" }, { "uni06C2" } }, - { { "uni06C1.fina", "uni0654" }, { "uni06C2.fina" } }, - { { "uni06C1.init", "uni0654" }, { "uni06C2.init" } }, - { { "uni06C1.medi", "uni0654" }, { "uni06C2.medi" } }, - } - }, - { "f3", "lu8", "arab", "dflt", "rlig", - new String[][][] { - { { "uni064E", "uni0654" }, { "uni0654064E" } }, - { { "uni064F", "uni0654" }, { "uni0654064F" } }, - { { "uni0654", "uni064E" }, { "uni0654064E" } }, - { { "uni0654", "uni064F" }, { "uni0654064F" } }, - } - }, - }; - - private static Object[][] ltContextual = { - { GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_CONTEXTUAL }, - // arab-001.ttx - none used - // arab-002.ttx - none used - // arab-003.ttx - none used - // arab-004.ttx - none used - }; - - private static Object[][] ltChainedContextual = { - { GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_CHAINED_CONTEXTUAL }, - // arab-001.ttx - { "f0", "lu1", "arab", "dflt", "ccmp", - new String[][][] { - { { "wawwithhamzaabove", "alefwithhamzabelow" }, { "wawwithhamzaabove", "arabicalef", "uni0655" } }, - { { "reh", "alefwithhamzabelow" }, { "reh", "arabicalef", "uni0655" } }, - { { "zain", "alefwithhamzabelow" }, { "zain", "arabicalef", "uni0655" } }, - { { "waw", "alefwithhamzabelow" }, { "waw", "arabicalef", "uni0655" } }, - { { "jeh", "alefwithhamzabelow" }, { "jeh", "arabicalef", "uni0655" } }, - } - }, - { "f0", "lu3", "arab", "dflt", "isol", - new String[][][] { - { { "hamza", "heh" }, { "hamza", "hehisolated" } }, - { { "alefwithmaddaabove", "heh" }, { "alefwithmaddaabove", "hehisolated" } }, - { { "alefwithhamzaabove", "heh" }, { "alefwithhamzaabove", "hehisolated" } }, - { { "wawwithhamzaabove", "heh" }, { "wawwithhamzaabove", "hehisolated" } }, - { { "alefwithhamzabelow", "heh" }, { "alefwithhamzabelow", "hehisolated" } }, - { { "arabicalef", "heh" }, { "arabicalef", "hehisolated" } }, - { { "tehmarbuta", "heh" }, { "tehmarbuta", "hehisolated" } }, - { { "dal", "heh" }, { "dal", "hehisolated" } }, - { { "thal", "heh" }, { "thal", "hehisolated" } }, - { { "reh", "heh" }, { "reh", "hehisolated" } }, - { { "zain", "heh" }, { "zain", "hehisolated" } }, - { { "waw", "heh" }, { "waw", "hehisolated" } }, - { { "alefwasla", "heh" }, { "alefwasla", "hehisolated" } }, - { { "jeh", "heh" }, { "jeh", "hehisolated" } }, - { { "arabicae", "heh" }, { "arabicae", "hehisolated" } }, - { { "alefwaslafinal", "heh" }, { "alefwaslafinal", "hehisolated" } }, - { { "alefwithmaddaabovefinal", "heh" }, { "alefwithmaddaabovefinal", "hehisolated" } }, - { { "alefwithhamzaabovefinal", "heh" }, { "alefwithhamzaabovefinal", "hehisolated" } }, - { { "alefwithhamzabelowfinal", "heh" }, { "alefwithhamzabelowfinal", "hehisolated" } }, - { { "aleffinal", "heh" }, { "aleffinal", "hehisolated" } }, - { { "tehmarbutafinal", "heh" }, { "tehmarbutafinal", "hehisolated" } }, - { { "lamwithalefmaddaaboveisolatedd", "heh" }, { "lamwithalefmaddaaboveisolatedd", "hehisolated" } }, - { { "lamwithalefmaddaabovefinal", "heh" }, { "lamwithalefmaddaabovefinal", "hehisolated" } }, - { { "lamwithalefhamzaaboveisolatedd", "heh" }, { "lamwithalefhamzaaboveisolatedd", "hehisolated" } }, - { { "lamwithalefhamzaabovefinal", "heh" }, { "lamwithalefhamzaabovefinal", "hehisolated" } }, - { { "lamwithalefhamzabelowisolated", "heh" }, { "lamwithalefhamzabelowisolated", "hehisolated" } }, - { { "lamwithalefhamzabelowfinal", "heh" }, { "lamwithalefhamzabelowfinal", "hehisolated" } }, - { { "lamwithalefisolated", "heh" }, { "lamwithalefisolated", "hehisolated" } }, - { { "lamwithaleffinal", "heh" }, { "lamwithaleffinal", "hehisolated" } }, - } - }, - // arab-002.ttx - { "f1", "lu2", "arab", "dflt", "isol", - new String[][][] { - { { "hamza", "heh" }, { "hamza", "hehisolated" } }, - { { "alefwithmaddaabove", "heh" }, { "alefwithmaddaabove", "hehisolated" } }, - { { "alefwithhamzaabove", "heh" }, { "alefwithhamzaabove", "hehisolated" } }, - { { "wawwithhamzaabove", "heh" }, { "wawwithhamzaabove", "hehisolated" } }, - { { "alefwithhamzabelow", "heh" }, { "alefwithhamzabelow", "hehisolated" } }, - { { "arabicalef", "heh" }, { "arabicalef", "hehisolated" } }, - { { "tehmarbuta", "heh" }, { "tehmarbuta", "hehisolated" } }, - { { "dal", "heh" }, { "dal", "hehisolated" } }, - { { "thal", "heh" }, { "thal", "hehisolated" } }, - { { "reh", "heh" }, { "reh", "hehisolated" } }, - { { "zain", "heh" }, { "zain", "hehisolated" } }, - { { "waw", "heh" }, { "waw", "hehisolated" } }, - { { "alefwasla", "heh" }, { "alefwasla", "hehisolated" } }, - { { "jeh", "heh" }, { "jeh", "hehisolated" } }, - { { "arabicae", "heh" }, { "arabicae", "hehisolated" } }, - { { "alefwaslafinal", "heh" }, { "alefwaslafinal", "hehisolated" } }, - { { "alefwithmaddaabovefinal", "heh" }, { "alefwithmaddaabovefinal", "hehisolated" } }, - { { "alefwithhamzaabovefinal", "heh" }, { "alefwithhamzaabovefinal", "hehisolated" } }, - { { "alefwithhamzabelowfinal", "heh" }, { "alefwithhamzabelowfinal", "hehisolated" } }, - { { "aleffinal", "heh" }, { "aleffinal", "hehisolated" } }, - { { "tehmarbutafinal", "heh" }, { "tehmarbutafinal", "hehisolated" } }, - { { "lamwithalefmaddaaboveisolatedd", "heh" }, { "lamwithalefmaddaaboveisolatedd", "hehisolated" } }, - { { "lamwithalefmaddaabovefinal", "heh" }, { "lamwithalefmaddaabovefinal", "hehisolated" } }, - { { "lamwithalefhamzaaboveisolatedd", "heh" }, { "lamwithalefhamzaaboveisolatedd", "hehisolated" } }, - { { "lamwithalefhamzaabovefinal", "heh" }, { "lamwithalefhamzaabovefinal", "hehisolated" } }, - { { "lamwithalefhamzabelowisolated", "heh" }, { "lamwithalefhamzabelowisolated", "hehisolated" } }, - { { "lamwithalefhamzabelowfinal", "heh" }, { "lamwithalefhamzabelowfinal", "hehisolated" } }, - { { "lamwithalefisolated", "heh" }, { "lamwithalefisolated", "hehisolated" } }, - { { "lamwithaleffinal", "heh" }, { "lamwithaleffinal", "hehisolated" } }, - } - }, - { "f1", "lu11", "arab", "dflt", "calt", - new String[][][] { - { { "pehinitial", "fatha", "pehmedial", "fatha" }, { "pehinitial", "tatweel", "fatha", "pehmedial", "fatha" } }, - { { "yehwithhamzaaboveinitial", "damma", "vehmedial", "damma" }, { "yehwithhamzaaboveinitial", "tatweel", "damma", "vehmedial", "damma" } }, - { { "behinitial", "shadda", "jehfinal", "shadda" }, { "behinitial", "tatweel", "shadda", "jehfinal", "shadda" } }, - { { "tehinitial", "sukun", "behmedial", "sukun" }, { "tehinitial", "tatweel", "sukun", "behmedial", "sukun" } }, - { { "thehinitial", "smallhighmadda", "tehmedial", "smallhighmadda" }, { "thehinitial", "tatweel", "smallhighmadda", "tehmedial", "smallhighmadda" } }, - { { "fehinitial", "fathaonhamza", "ainmedial", "fathaonhamza" }, { "fehinitial", "tatweel", "fathaonhamza", "ainmedial", "fathaonhamza" } }, - { { "qafinitial", "dammaonhamza", "qafmedial", "dammaonhamza" }, { "qafinitial", "tatweel", "dammaonhamza", "qafmedial", "dammaonhamza" } }, - { { "nooninitial", "superscriptalef", "wawfinal", "superscriptalef" }, { "nooninitial", "tatweel", "superscriptalef", "wawfinal", "superscriptalef" } }, - { { "yehinitial", "dammatanonhamza", "rehfinal", "dammatanonhamza" }, { "yehinitial", "tatweel", "dammatanonhamza", "rehfinal", "dammatanonhamza" } }, - { { "uni0649.init", "uni0654", "wawwithhamzaabovefinal", "uni0654" }, { "uni0649.init", "tatweel", "uni0654", "wawwithhamzaabovefinal", "uni0654" } }, - } - }, - { "f1", "lu12", "arab", "dflt", "calt", - new String[][][] { - { { "pehmedial", "fatha", "pehmedial", "fatha" }, { "pehmedial", "tatweel", "fatha", "pehmedial", "fatha" } }, - { { "yehwithhamzaabovemedial", "damma", "vehmedial", "damma" }, { "yehwithhamzaabovemedial", "tatweel", "damma", "vehmedial", "damma" } }, - { { "behmedial", "shadda", "wawwithhamzaabovefinal", "shadda" }, { "behmedial", "tatweel", "shadda", "wawwithhamzaabovefinal", "shadda" } }, - { { "tehmedial", "sukun", "rehfinal", "sukun" }, { "tehmedial", "tatweel", "sukun", "rehfinal", "sukun" } }, - { { "thehmedial", "smallhighmadda", "zainfinal", "smallhighmadda" }, { "thehmedial", "tatweel", "smallhighmadda", "zainfinal", "smallhighmadda" } }, - { { "noonmedial", "superscriptalef", "ainmedial", "superscriptalef" }, { "noonmedial", "tatweel", "superscriptalef", "ainmedial", "superscriptalef" } }, - { { "yehmedial", "dammatanonhamza", "wawfinal", "dammatanonhamza" }, { "yehmedial", "tatweel", "dammatanonhamza", "wawfinal", "dammatanonhamza" } }, - { { "uni0649.medi", "uni0654", "yehmedial", "uni0654" }, { "uni0649.medi", "tatweel", "uni0654", "yehmedial", "uni0654" } }, - } - }, - // arab-003.ttx - { "f2", "lu4", "arab", "dflt", "rlig", - new String[][][] { - { { "uni0644.medi", "uni0622.fina" }, { "uni0644.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni06B5.medi", "uni0622.fina" }, { "uni06B5.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni06B6.medi", "uni0622.fina" }, { "uni06B6.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni06B7.medi", "uni0622.fina" }, { "uni06B7.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni06B8.medi", "uni0622.fina" }, { "uni06B8.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "absLamRetroMed", "uni0622.fina" }, { "absLamRetroMed.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni076A.medi", "uni0622.fina" }, { "uni076A.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni0644.init", "uni0622.fina" }, { "uni0644.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni06B5.init", "uni0622.fina" }, { "uni06B5.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni06B6.init", "uni0622.fina" }, { "uni06B6.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni06B7.init", "uni0622.fina" }, { "uni06B7.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni06B8.init", "uni0622.fina" }, { "uni06B8.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "absLamRetroIni", "uni0622.fina" }, { "absLamRetroIni.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni076A.init", "uni0622.fina" }, { "uni076A.init.preAlef", "uni0622.fina.postLamIni" } }, - } - }, - { "f2", "lu8", "arab", "dflt", "calt", - new String[][][] { - { { "uni064A", "uni0670" }, { "uni064A", "uni0670.large" } }, - } - }, - { "f2", "lu13", "arab", "dflt", "calt", - new String[][][] { - { { "uni06DD", "one" }, { "uni06DD", "oneMedium" } }, - { { "uni06DD", "one", "two" }, { "uni06DD.2", "oneMedium", "twoMedium" } }, - { { "uni06DD", "one", "two", "three" }, { "uni06DD.3", "oneSmall", "twoSmall", "threeSmall" } }, - } - }, - // arab-004.ttx - { "f3", "lu4", "arab", "dflt", "rlig", - new String[][][] { - { { "uni0644.medi", "uni0622.fina" }, { "uni0644.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni06B5.medi", "uni0622.fina" }, { "uni06B5.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni06B6.medi", "uni0622.fina" }, { "uni06B6.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni06B7.medi", "uni0622.fina" }, { "uni06B7.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni06B8.medi", "uni0622.fina" }, { "uni06B8.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "absLamRetroMed", "uni0622.fina" }, { "absLamRetroMed.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni076A.medi", "uni0622.fina" }, { "uni076A.medi.preAlef", "uni0622.fina.postLamMed" } }, - { { "uni0644.init", "uni0622.fina" }, { "uni0644.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni06B5.init", "uni0622.fina" }, { "uni06B5.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni06B6.init", "uni0622.fina" }, { "uni06B6.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni06B7.init", "uni0622.fina" }, { "uni06B7.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni06B8.init", "uni0622.fina" }, { "uni06B8.init.preAlef", "uni0622.fina.postLamIni" } }, - { { "absLamRetroIni", "uni0622.fina" }, { "absLamRetroIni.preAlef", "uni0622.fina.postLamIni" } }, - { { "uni076A.init", "uni0622.fina" }, { "uni076A.init.preAlef", "uni0622.fina.postLamIni" } }, - } - }, - { "f3", "lu9", "arab", "dflt", "calt", - new String[][][] { - { { "uni0601", "uni0661" }, { "uni0601", "uni0661.Medium" } }, - { { "uni0601", "uni0661", "uni0662" }, { "uni0601.2", "uni0661.Medium", "uni0662.Medium" } }, - { { "uni0601", "uni0661", "uni0662", "uni0663" }, { "uni0601.3", "uni0661.Medium", "uni0662.Medium", "uni0663.Medium", } }, - { { "uni0601", "uni0661", "uni0662", "uni0663", "uni0664" }, { "uni0601.4", "uni0661.Medium", "uni0662.Medium", "uni0663.Medium", "uni0664.Medium" } }, - } - }, - { "f3", "lu10", "arab", "dflt", "calt", - new String[][][] { - { { "uni064A", "uni0670" }, { "uni064A", "uni0670.large" } }, - } - }, - }; - - @Test - public void testGSUBSingle() throws Exception { - performSubstitutions(ltSingle); - } - - @Test - public void testGSUBMultiple() throws Exception { - performSubstitutions(ltMultiple); - } - - @Test - public void testGSUBAlternate() throws Exception { - performSubstitutions(ltAlternate); - } - - @Test - public void testGSUBLigature() throws Exception { - performSubstitutions(ltLigature); - } - - @Test - public void testGSUBContextual() throws Exception { - performSubstitutions(ltContextual); - } - - @Test - public void testGSUBChainedContextual() throws Exception { - performSubstitutions(ltChainedContextual); - } - - /** - * Perform substitutions on all test data in test specification TS. - * @param ts test specification - */ - private void performSubstitutions(Object[][] ts) { - assert ts.length > 0; - Object[] tp = ts[0]; - for (int i = 1; i < ts.length; i++) { - performSubstitutions(tp, ts[i]); - } - } - - /** - * Perform substitutions on all test data TD using test parameters TP. - * @param tp test parameters - * @param td test data - */ - private void performSubstitutions(Object[] tp, Object[] td) { - assert tp.length > 0; - if (td.length > 5) { - String fid = (String) td[0]; - String lid = (String) td[1]; - String script = (String) td[2]; - String language = (String) td[3]; - String feature = (String) td[4]; - TTXFile tf = findTTX(fid); - assertTrue(tf != null); - GlyphSubstitutionTable gsub = tf.getGSUB(); - assertTrue(gsub != null); - GlyphSubstitutionSubtable[] sta = findGSUBSubtables(gsub, script, language, feature, lid); - assertTrue(sta != null); - assertTrue(sta.length > 0); - ScriptContextTester sct = findScriptContextTester(script, language, feature); - String[][][] tia = (String[][][]) td[5]; // test instance array - for (String[][] ti : tia) { // test instance - if (ti != null) { - if (ti.length > 1) { // must have at least input and output glyph id arrays - String[] igia = ti[0]; // input glyph id array - String[] ogia = ti[1]; // output glyph id array - GlyphSequence igs = tf.getGlyphSequence(igia); - GlyphSequence ogs = tf.getGlyphSequence(ogia); - GlyphSequence tgs = GlyphSubstitutionSubtable.substitute(igs, script, language, feature, sta, sct); - assertSameGlyphs(ogs, tgs); - } - } - } - } - } - - private String findTTXPath(String fid) { - for (String[] fs : ttxFonts) { - if ((fs != null) && (fs.length > 1)) { - if (fs[0].equals(fid)) { - return ttxFilesRoot + File.separator + fs[1]; - } - } - } - return null; - } - - private TTXFile findTTX(String fid) { - String pn = findTTXPath(fid); - assertTrue(pn != null); - try { - TTXFile tf = TTXFile.getFromCache(pn); - return tf; - } catch (Exception e) { - fail(e.getMessage()); - return null; - } - } - - private GlyphSubstitutionSubtable[] findGSUBSubtables(GlyphSubstitutionTable gsub, String script, String language, String feature, String lid) { - LookupTable lt = gsub.getLookupTable(lid); - if (lt != null) { - return (GlyphSubstitutionSubtable[]) lt.getSubtables(); - } else { - return null; - } - } - - private ScriptContextTester findScriptContextTester(String script, String language, String feature) { - return this; - } - - public GlyphContextTester getTester(String feature) { - return this; - } - - public boolean test(String script, String language, String feature, GlyphSequence gs, int index, int flags) { - return true; - } - - private void assertSameGlyphs(GlyphSequence gs1, GlyphSequence gs2) { - assertNotNull(gs1); - assertNotNull(gs2); - IntBuffer gb1 = gs1.getGlyphs(); - IntBuffer gb2 = gs2.getGlyphs(); - assertEquals("unequal glyph count", gb1.limit(), gb2.limit()); - for (int i = 0; i < gb1.limit(); i++) { - int g1 = gb1.get(i); - int g2 = gb2.get(i); - assertEquals("unequal glyph code", g1, g2); - } - } - -} diff --git a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java b/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java deleted file mode 100644 index 178203ff6..000000000 --- a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java +++ /dev/null @@ -1,3438 +0,0 @@ -/* - * 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.complexscripts.fonts.ttx; - -import java.io.File; -import java.io.IOException; -import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.TreeMap; -import java.util.Vector; - -import javax.xml.parsers.FactoryConfigurationError; -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.GlyphDefinitionTable; -import org.apache.fop.complexscripts.fonts.GlyphMappingTable; -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.GlyphSubstitutionTable; -import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable.Ligature; -import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable.LigatureSet; -import org.apache.fop.complexscripts.fonts.GlyphSubtable; -import org.apache.fop.complexscripts.fonts.GlyphTable; -import org.apache.fop.complexscripts.fonts.GlyphTable.RuleLookup; -import org.apache.fop.complexscripts.util.GlyphSequence; -import org.apache.fop.complexscripts.util.UTF32; -import org.apache.fop.util.CharUtilities; - - -// CSOFF: LineLengthCheck - -/** - * This class supports a subset of the <code>TTX</code> file as produced by the Adobe FLEX - * SDK (AFDKO). In particular, it is used to parse a <code>TTX</code> file in order to - * extract character to glyph code mapping data, glyph definition data, glyph substitution - * data, and glyph positioning data. - * - * <code>TTX</code> files are used in FOP for testing and debugging purposes only. Such - * files are used to represent font data employed by complex script processing, and - * normally extracted directly from an opentype (or truetype) file. However, due to - * copyright restrictions, it is not possible to include most opentype (or truetype) font - * 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. - */ -public class TTXFile { - - /** logging instance */ - private static final Log log = LogFactory.getLog(TTXFile.class); // CSOK: ConstantNameCheck - /** default script tag */ - private static final String DEFAULT_SCRIPT_TAG = "dflt"; - /** default language tag */ - private static final String DEFAULT_LANGUAGE_TAG = "dflt"; - - /** ttxfile cache */ - 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 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 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 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 - private List<Ligature> ligatures; // list of ligatures in ligature set being constructed - private List<Integer> substitutes; // list of substitutes in (multiple substitution) sequence being constructed - private List<PairValues> pairs; // list of pair value records being constructed - private List<PairValues[]> pairSets; // list of pair value sets (as arrays) being constructed - private List<Anchor> anchors; // list of anchors of base|mark|component record being constructed - private List<Anchor[]> components; // list of ligature component anchors being constructed - private List<MarkAnchor> markAnchors; // list of mark anchors being constructed - private List<Anchor[]> baseOrMarkAnchors; // list of base|mark2 anchors being constructed - private List<Anchor[][]> ligatureAnchors; // list of ligature anchors being constructed - private List<Anchor[]> attachmentAnchors; // list of entry|exit attachment anchors being constructed - private List<RuleLookup> ruleLookups; // list of rule lookups being constructed - private int glyphIdMax; // maximum glyph id - private int cmPlatform; // plaform id of cmap being constructed - private int cmEncoding; // plaform id of cmap being constructed - private int cmLanguage; // plaform id of cmap being constructed - private int flIndex; // index of feature being constructed - private int flSequence; // feature sequence within feature list - private int ltIndex; // index of lookup table being constructed - private int ltSequence; // lookup sequence within table - private int ltFlags; // flags of current lookup being constructed - private int stSequence; // subtable sequence number within lookup - private int stFormat; // format of current subtable being constructed - private int ctFormat; // format of coverage table being constructed - private int ctIndex; // index of coverage table being constructed - private int rlSequence; // rule lookup sequence index - private int rlLookup; // rule lookup lookup index - private int psIndex; // pair set index - private int vf1; // value format 1 (used with pair pos and single pos) - private int vf2; // value format 2 (used with pair pos) - private int g2; // glyph id 2 (used with pair pos) - private int xCoord; // x coordinate of anchor being constructed - private int yCoord; // y coordinate of anchor being constructed - private int markClass; // mark class of mark anchor being constructed - private String defaultScriptTag; // tag of default script - private String scriptTag; // tag of script being constructed - private String defaultLanguageTag; // tag of default language system - private String languageTag; // tag of language system being constructed - private String featureTag; // tag of feature being constructed - private Value v1; // positioining value 1 - private Value v2; // positioining value 2 - - // 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 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 - private GlyphSubstitutionTable gsub; // constructed glyph substitution table - private GlyphPositioningTable gpos; // constructed glyph positioning table - - public TTXFile() { - elements = new Stack<String[]>(); - 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[]>(); - languageFeatures = new ArrayList<String>(); - featureLookups = new ArrayList<String>(); - coverageEntries = new ArrayList<Integer>(); - coverages = new HashMap<String, GlyphCoverageTable>(); - subtableEntries = new ArrayList(); - subtables = new ArrayList<GlyphSubtable>(); - alternates = new ArrayList<Integer>(); - ligatures = new ArrayList<Ligature>(); - substitutes = new ArrayList<Integer>(); - pairs = new ArrayList<PairValues>(); - pairSets = new ArrayList<PairValues[]>(); - anchors = new ArrayList<Anchor>(); - markAnchors = new ArrayList<MarkAnchor>(); - baseOrMarkAnchors = new ArrayList<Anchor[]>(); - ligatureAnchors = new ArrayList<Anchor[][]>(); - components = new ArrayList<Anchor[]>(); - attachmentAnchors = new ArrayList<Anchor[]>(); - ruleLookups = new ArrayList<RuleLookup>(); - glyphIdMax = -1; - cmPlatform = -1; - cmEncoding = -1; - cmLanguage = -1; - flIndex = -1; - flSequence = 0; - ltIndex = -1; - ltSequence = 0; - ltFlags = 0; - stSequence = 0; - stFormat = 0; - ctFormat = -1; - ctIndex = -1; - rlSequence = -1; - rlLookup = -1; - psIndex = -1; - vf1 = -1; - vf2 = -1; - g2 = -1; - xCoord = Integer.MIN_VALUE; - yCoord = Integer.MIN_VALUE; - markClass = -1; - defaultScriptTag = DEFAULT_SCRIPT_TAG; - scriptTag = null; - defaultLanguageTag = DEFAULT_LANGUAGE_TAG; - languageTag = null; - featureTag = null; - v1 = null; - v2 = null; - upem = -1; - } - public void parse(String filename) { - parse(new File(filename)); - } - public void parse(File f) { - assert f != null; - try { - SAXParserFactory spf = SAXParserFactory.newInstance(); - SAXParser sp = spf.newSAXParser(); - sp.parse(f, new Handler()); - } catch (FactoryConfigurationError e) { - throw new RuntimeException(e.getMessage()); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e.getMessage()); - } catch (SAXException e) { - throw new RuntimeException(e.getMessage()); - } catch (IOException e) { - throw new RuntimeException(e.getMessage()); - } - } - public GlyphSequence mapCharsToGlyphs(String s) { - Integer[] ca = UTF32.toUTF32(s, 0, true); - int ng = ca.length; - IntBuffer cb = IntBuffer.allocate(ng); - IntBuffer gb = IntBuffer.allocate(ng); - for (Integer c : ca) { - int g = mapCharToGlyph((int) c); - if (g >= 0) { - cb.put(c); - gb.put(g); - } else { - throw new IllegalArgumentException("character " + CharUtilities.format(c) + " has no corresponding glyph"); - } - } - cb.rewind(); - gb.rewind(); - return new GlyphSequence(cb, gb, null); - } - public int mapCharToGlyph(int c) { - if (cmap != null) { - Integer g = cmap.get(Integer.valueOf(c)); - if (g != null) { - return (int) g; - } else { - return -1; - } - } else { - return -1; - } - } - public int getGlyph(String gid) { - return mapGlyphId0(gid); - } - public GlyphSequence getGlyphSequence(String[] gids) { - assert gids != null; - int ng = gids.length; - IntBuffer cb = IntBuffer.allocate(ng); - IntBuffer gb = IntBuffer.allocate(ng); - for (String gid : gids) { - int g = mapGlyphId0(gid); - if (g >= 0) { - int c = mapGlyphIdToChar(gid); - if (c < 0) { - c = CharUtilities.NOT_A_CHARACTER; - } - cb.put(c); - gb.put(g); - } else { - throw new IllegalArgumentException("unmapped glyph id \"" + gid + "\""); - } - } - cb.rewind(); - gb.rewind(); - return new GlyphSequence(cb, gb, null); - } - public int[] getWidths(String[] gids) { - assert gids != null; - int ng = gids.length; - int[] widths = new int [ ng ]; - int i = 0; - for (String gid : gids) { - int g = mapGlyphId0(gid); - int w = 0; - if (g >= 0) { - if ((hmtx != null) && (g < hmtx.length)) { - int[] mtx = hmtx [ g ]; - assert mtx != null; - assert mtx.length > 0; - w = mtx[0]; - } - } - widths [ i++ ] = w; - } - assert i == ng; - return widths; - } - public int[] getWidths() { - if (this.widths == null) { - if ((hmtx != null) && (upem > 0)) { - int[] widths = new int [ hmtx.length ]; - for (int i = 0, n = widths.length; i < n; i++) { - widths [ i ] = getPDFWidth(hmtx [ i ] [ 0 ], upem); - } - this.widths = widths; - } - } - return this.widths; - } - public static int getPDFWidth(int tw, int upem) { - // N.B. The following is copied (with minor edits) from TTFFile to insure same results - int pw; - if (tw < 0) { - long rest1 = tw % upem; - long storrest = 1000 * rest1; - long ledd2 = (storrest != 0) ? (rest1 / storrest) : 0; - pw = -((-1000 * tw) / upem - (int) ledd2); - } else { - pw = (tw / upem) * 1000 + ((tw % upem) * 1000) / upem; - } - return pw; - } - public GlyphDefinitionTable getGDEF() { - return gdef; - } - public GlyphSubstitutionTable getGSUB() { - return gsub; - } - public GlyphPositioningTable getGPOS() { - return gpos; - } - public static synchronized TTXFile getFromCache(String filename) { - assert cache != null; - TTXFile f; - if ((f = (TTXFile) cache.get(filename)) == null) { - f = new TTXFile(); - f.parse(filename); - cache.put(filename, f); - } - return f; - } - public static synchronized void clearCache() { - cache.clear(); - } - private final class Handler extends DefaultHandler { - private Handler() { - } - @Override - public void startDocument() { - } - @Override - public void endDocument() { - } - @Override - public void setDocumentLocator(Locator locator) { - TTXFile.this.locator = locator; - } - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - String[] en = makeExpandedName(uri, localName, qName); - if (en[0] != null) { - unsupportedElement(en); - } else if (en[1].equals("Alternate")) { - String[] pn = new String[] { null, "AlternateSet" }; - if (isParent(pn)) { - String glyph = attrs.getValue("glyph"); - if (glyph == null) { - missingRequiredAttribute(en, "glyph"); - } - int gid = mapGlyphId(glyph, en); - alternates.add(Integer.valueOf(gid)); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("AlternateSet")) { - String[] pn = new String[] { null, "AlternateSubst" }; - if (isParent(pn)) { - String glyph = attrs.getValue("glyph"); - if (glyph == null) { - missingRequiredAttribute(en, "glyph"); - } - int gid = mapGlyphId(glyph, en); - coverageEntries.add(Integer.valueOf(gid)); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("AlternateSubst")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = 1; - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("BacktrackCoverage")) { - String[] pn1 = new String[] { null, "ChainContextSubst" }; - String[] pn2 = new String[] { null, "ChainContextPos" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String index = attrs.getValue("index"); - int ci = -1; - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - ci = Integer.parseInt(index); - } - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = ci; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("BaseAnchor")) { - String[] pn = new String[] { null, "BaseRecord" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - if (format == null) { - missingRequiredAttribute(en, "Format"); - } - assert xCoord == Integer.MIN_VALUE; - assert yCoord == Integer.MIN_VALUE; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("BaseArray")) { - String[] pn = new String[] { null, "MarkBasePos" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("BaseCoverage")) { - String[] pn = new String[] { null, "MarkBasePos" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("BaseRecord")) { - String[] pn = new String[] { null, "BaseArray" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("ChainContextPos") || en[1].equals("ChainContextSubst")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - case 2: - case 3: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Class")) { - String[] pn = new String[] { null, "MarkRecord" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - int v = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - v = Integer.parseInt(value); - } - assert markClass == -1; - markClass = v; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("ClassDef")) { - String[] pn1 = new String[] { null, "GlyphClassDef" }; - String[] pn2 = new String[] { null, "MarkAttachClassDef" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String glyph = attrs.getValue("glyph"); - if (glyph == null) { - missingRequiredAttribute(en, "glyph"); - } - String glyphClass = attrs.getValue("class"); - if (glyphClass == null) { - missingRequiredAttribute(en, "class"); - } - if (!glyphIds.containsKey(glyph)) { - unsupportedGlyph(en, glyph); - } else if (isParent(pn1)) { - if (glyphClasses.containsKey(glyph)) { - duplicateGlyphClass(en, glyph, glyphClass); - } else { - glyphClasses.put(glyph, Integer.parseInt(glyphClass)); - } - } else if (isParent(pn2)) { - if (glyphClasses.containsKey(glyph)) { - duplicateGlyphClass(en, glyph, glyphClass); - } else { - glyphClasses.put(glyph, Integer.parseInt(glyphClass)); - } - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("ComponentRecord")) { - String[] pn = new String[] { null, "LigatureAttach" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - assert anchors.size() == 0; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Coverage")) { - String[] pn1 = new String[] { null, "CursivePos" }; - String[] pn2 = new String[] { null, "LigCaretList" }; - String[] pn3 = new String[] { null, "MultipleSubst" }; - String[] pn4 = new String[] { null, "PairPos" }; - String[] pn5 = new String[] { null, "SinglePos" }; - String[][] pnx = new String[][] { pn1, pn2, pn3, pn4, pn5 }; - if (isParent(pnx)) { - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("CursivePos")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - assert attachmentAnchors.size() == 0; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("DefaultLangSys")) { - String[] pn = new String[] { null, "Script" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } else { - assertLanguageFeaturesClear(); - assert languageTag == null; - languageTag = defaultLanguageTag; - } - } else if (en[1].equals("EntryAnchor")) { - String[] pn = new String[] { null, "EntryExitRecord" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - if (format == null) { - missingRequiredAttribute(en, "Format"); - } - assert xCoord == Integer.MIN_VALUE; - assert yCoord == Integer.MIN_VALUE; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("EntryExitRecord")) { - String[] pn = new String[] { null, "CursivePos" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("ExitAnchor")) { - String[] pn = new String[] { null, "EntryExitRecord" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - if (format == null) { - missingRequiredAttribute(en, "Format"); - } - assert xCoord == Integer.MIN_VALUE; - assert yCoord == Integer.MIN_VALUE; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Feature")) { - String[] pn = new String[] { null, "FeatureRecord" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } else { - assertFeatureLookupsClear(); - } - } else if (en[1].equals("FeatureIndex")) { - String[] pn1 = new String[] { null, "DefaultLangSys" }; - String[] pn2 = new String[] { null, "LangSys" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String value = attrs.getValue("value"); - int v = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - v = Integer.parseInt(value); - } - if (languageFeatures.size() == 0) { - languageFeatures.add(null); - } - if ((v >= 0) && (v < 65535)) { - languageFeatures.add(makeFeatureId(v)); - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("FeatureList")) { - String[] pn1 = new String[] { null, "GSUB" }; - String[] pn2 = new String[] { null, "GPOS" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (!isParent(pnx)) { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("FeatureRecord")) { - String[] pn = new String[] { null, "FeatureList" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - int fi = -1; - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - fi = Integer.parseInt(index); - } - assertFeatureClear(); - assert flIndex == -1; - flIndex = fi; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("FeatureTag")) { - String[] pn = new String[] { null, "FeatureRecord" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - assert featureTag == null; - featureTag = value; - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("GDEF")) { - String[] pn = new String[] { null, "ttFont" }; - if (isParent(pn)) { - assertSubtablesClear(); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("GPOS")) { - String[] pn = new String[] { null, "ttFont" }; - if (isParent(pn)) { - assertCoveragesClear(); - assertSubtablesClear(); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("GSUB")) { - String[] pn = new String[] { null, "ttFont" }; - if (isParent(pn)) { - assertCoveragesClear(); - assertSubtablesClear(); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Glyph")) { - String[] pn1 = new String[] { null, "Coverage" }; - String[] pn2 = new String[] { null, "InputCoverage" }; - String[] pn3 = new String[] { null, "LookAheadCoverage" }; - String[] pn4 = new String[] { null, "BacktrackCoverage" }; - String[] pn5 = new String[] { null, "MarkCoverage" }; - String[] pn6 = new String[] { null, "Mark1Coverage" }; - String[] pn7 = new String[] { null, "Mark2Coverage" }; - String[] pn8 = new String[] { null, "BaseCoverage" }; - String[] pn9 = new String[] { null, "LigatureCoverage" }; - String[][] pnx = new String[][] { pn1, pn2, pn3, pn4, pn5, pn6, pn7, pn8, pn9 }; - if (isParent(pnx)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - int gid = mapGlyphId(value, en); - coverageEntries.add(Integer.valueOf(gid)); - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("GlyphClassDef")) { - String[] pn = new String[] { null, "GDEF" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - // force format 1 since TTX always writes entries as non-range entries - if (sf != 1) { - sf = 1; - } - stFormat = sf; - assert glyphClasses.isEmpty(); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("GlyphID")) { - String[] pn = new String[] { null, "GlyphOrder" }; - if (isParent(pn)) { - String id = attrs.getValue("id"); - int gid = -1; - if (id == null) { - missingRequiredAttribute(en, "id"); - } else { - gid = Integer.parseInt(id); - } - String name = attrs.getValue("name"); - if (name == null) { - missingRequiredAttribute(en, "name"); - } - if (glyphIds.containsKey(name)) { - duplicateGlyph(en, name, gid); - } else { - if (gid > glyphIdMax) { - glyphIdMax = gid; - } - glyphIds.put(name, gid); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("GlyphOrder")) { - String[] pn = new String[] { null, "ttFont" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("InputCoverage")) { - String[] pn1 = new String[] { null, "ChainContextSubst" }; - String[] pn2 = new String[] { null, "ChainContextPos" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String index = attrs.getValue("index"); - int ci = -1; - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - ci = Integer.parseInt(index); - } - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = ci; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("LangSys")) { - String[] pn = new String[] { null, "LangSysRecord" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } else { - assertLanguageFeaturesClear(); - } - } else if (en[1].equals("LangSysRecord")) { - String[] pn = new String[] { null, "Script" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LangSysTag")) { - String[] pn = new String[] { null, "LangSysRecord" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - assert languageTag == null; - languageTag = value; - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LigCaretList")) { - String[] pn = new String[] { null, "GDEF" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Ligature")) { - String[] pn = new String[] { null, "LigatureSet" }; - if (isParent(pn)) { - String components = attrs.getValue("components"); - if (components == null) { - missingRequiredAttribute(en, "components"); - } - int[] cids = mapGlyphIds(components, en); - String glyph = attrs.getValue("glyph"); - if (glyph == null) { - missingRequiredAttribute(en, "glyph"); - } - int gid = mapGlyphId(glyph, en); - ligatures.add(new Ligature(gid, cids)); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LigatureAnchor")) { - String[] pn = new String[] { null, "ComponentRecord" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - if (format == null) { - missingRequiredAttribute(en, "Format"); - } - assert xCoord == Integer.MIN_VALUE; - assert yCoord == Integer.MIN_VALUE; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LigatureArray")) { - String[] pn = new String[] { null, "MarkLigPos" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LigatureAttach")) { - String[] pn = new String[] { null, "LigatureArray" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - assert components.size() == 0; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LigatureCoverage")) { - String[] pn = new String[] { null, "MarkLigPos" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LigatureSet")) { - String[] pn = new String[] { null, "LigatureSubst" }; - if (isParent(pn)) { - String glyph = attrs.getValue("glyph"); - if (glyph == null) { - missingRequiredAttribute(en, "glyph"); - } - int gid = mapGlyphId(glyph, en); - coverageEntries.add(Integer.valueOf(gid)); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LigatureSubst")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = 1; - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LookAheadCoverage")) { - String[] pn1 = new String[] { null, "ChainContextSubst" }; - String[] pn2 = new String[] { null, "ChainContextPos" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String index = attrs.getValue("index"); - int ci = -1; - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - ci = Integer.parseInt(index); - } - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = ci; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("Lookup")) { - String[] pn = new String[] { null, "LookupList" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - int li = -1; - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - li = Integer.parseInt(index); - } - assertLookupClear(); - assert ltIndex == -1; - ltIndex = li; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LookupFlag")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - int lf = 0; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - lf = Integer.parseInt(value); - } - assert ltFlags == 0; - ltFlags = lf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("LookupList")) { - String[] pn1 = new String[] { null, "GSUB" }; - String[] pn2 = new String[] { null, "GPOS" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (!isParent(pnx)) { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("LookupListIndex")) { - String[] pn1 = new String[] { null, "Feature" }; - String[] pn2 = new String[] { null, "SubstLookupRecord" }; - String[] pn3 = new String[] { null, "PosLookupRecord" }; - String[][] pnx = new String[][] { pn1, pn2, pn3 }; - if (isParent(pnx)) { - String index = attrs.getValue("index"); - String value = attrs.getValue("value"); - int v = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - v = Integer.parseInt(value); - } - String[][] pny = new String[][] { pn2, pn3 }; - if (isParent(pny)) { - assert rlLookup == -1; - assert v != -1; - rlLookup = v; - } else { - featureLookups.add(makeLookupId(v)); - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("LookupType")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Mark1Array")) { - String[] pn = new String[] { null, "MarkMarkPos" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Mark1Coverage")) { - String[] pn = new String[] { null, "MarkMarkPos" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Mark2Anchor")) { - String[] pn = new String[] { null, "Mark2Record" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - if (format == null) { - missingRequiredAttribute(en, "Format"); - } - assert xCoord == Integer.MIN_VALUE; - assert yCoord == Integer.MIN_VALUE; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Mark2Array")) { - String[] pn = new String[] { null, "MarkMarkPos" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Mark2Coverage")) { - String[] pn = new String[] { null, "MarkMarkPos" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Mark2Record")) { - String[] pn = new String[] { null, "Mark2Array" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("MarkAnchor")) { - String[] pn = new String[] { null, "MarkRecord" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - if (format == null) { - missingRequiredAttribute(en, "Format"); - } - assert xCoord == Integer.MIN_VALUE; - assert yCoord == Integer.MIN_VALUE; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("MarkArray")) { - String[] pn1 = new String[] { null, "MarkBasePos" }; - String[] pn2 = new String[] { null, "MarkLigPos" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (!isParent(pnx)) { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("MarkAttachClassDef")) { - String[] pn = new String[] { null, "GDEF" }; - if (isParent(pn)) { - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - // force format 1 since TTX always writes entries as non-range entries - if (sf != 1) { - sf = 1; - } - stFormat = sf; - assert glyphClasses.isEmpty(); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("MarkBasePos")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - assert markAnchors.size() == 0; - assert baseOrMarkAnchors.size() == 0; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("MarkCoverage")) { - String[] pn1 = new String[] { null, "MarkBasePos" }; - String[] pn2 = new String[] { null, "MarkLigPos" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String format = attrs.getValue("Format"); - int cf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - cf = Integer.parseInt(format); - switch (cf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, cf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = cf; - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("MarkLigPos")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - assert markAnchors.size() == 0; - assert ligatureAnchors.size() == 0; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("MarkMarkPos")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - assert markAnchors.size() == 0; - assert baseOrMarkAnchors.size() == 0; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("MarkRecord")) { - String[] pn1 = new String[] { null, "MarkArray" }; - String[] pn2 = new String[] { null, "Mark1Array" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("MultipleSubst")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("PairPos")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("PairSet")) { - String[] pn = new String[] { null, "PairPos" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - int psi = -1; - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - psi = Integer.parseInt(index); - } - assert psIndex == -1; - psIndex = psi; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("PairValueRecord")) { - String[] pn = new String[] { null, "PairSet" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - assertPairClear(); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("PosLookupRecord")) { - String[] pn1 = new String[] { null, "ChainContextSubst" }; - String[] pn2 = new String[] { null, "ChainContextPos" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("ReqFeatureIndex")) { - String[] pn1 = new String[] { null, "DefaultLangSys" }; - String[] pn2 = new String[] { null, "LangSys" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String value = attrs.getValue("value"); - int v = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - v = Integer.parseInt(value); - } - String fid; - if ((v >= 0) && (v < 65535)) { - fid = makeFeatureId(v); - } else { - fid = null; - } - assertLanguageFeaturesClear(); - languageFeatures.add(fid); - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("Script")) { - String[] pn = new String[] { null, "ScriptRecord" }; - 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)) { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("ScriptRecord")) { - String[] pn = new String[] { null, "ScriptList" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("ScriptTag")) { - String[] pn = new String[] { null, "ScriptRecord" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - assert scriptTag == null; - scriptTag = value; - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("SecondGlyph")) { - String[] pn = new String[] { null, "PairValueRecord" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - int gid = mapGlyphId(value, en); - assert g2 == -1; - g2 = gid; - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Sequence")) { - String[] pn = new String[] { null, "MultipleSubst" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - int i = Integer.parseInt(index); - if (i != subtableEntries.size()) { - invalidIndex(en, i, subtableEntries.size()); - } - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("SequenceIndex")) { - String[] pn1 = new String[] { null, "PosLookupRecord" }; - String[] pn2 = new String[] { null, "SubstLookupRecord" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String value = attrs.getValue("value"); - int v = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - v = Integer.parseInt(value); - } - assert rlSequence == -1; - assert v != -1; - rlSequence = v; - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("SinglePos")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("SingleSubst")) { - String[] pn = new String[] { null, "Lookup" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - String format = attrs.getValue("Format"); - int sf = -1; - if (format == null) { - missingRequiredAttribute(en, "Format"); - } else { - sf = Integer.parseInt(format); - switch (sf) { - case 1: - case 2: - break; - default: - unsupportedFormat(en, sf); - break; - } - } - assertCoverageClear(); - ctIndex = 0; - ctFormat = 1; - assertSubtableClear(); - assert sf >= 0; - stFormat = sf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("SubstLookupRecord")) { - String[] pn = new String[] { null, "ChainContextSubst" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Substitute")) { - String[] pn = new String[] { null, "Sequence" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (index == null) { - missingRequiredAttribute(en, "index"); - } else { - int i = Integer.parseInt(index); - if (i != substitutes.size()) { - invalidIndex(en, i, substitutes.size()); - } - } - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - int gid = mapGlyphId(value, en); - substitutes.add(Integer.valueOf(gid)); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Substitution")) { - String[] pn = new String[] { null, "SingleSubst" }; - if (isParent(pn)) { - String in = attrs.getValue("in"); - int igid = -1; - int ogid = -1; - if (in == null) { - missingRequiredAttribute(en, "in"); - } else { - igid = mapGlyphId(in, en); - } - String out = attrs.getValue("out"); - if (out == null) { - missingRequiredAttribute(en, "out"); - } else { - ogid = mapGlyphId(out, en); - } - coverageEntries.add(Integer.valueOf(igid)); - subtableEntries.add(Integer.valueOf(ogid)); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Value")) { - String[] pn = new String[] { null, "SinglePos" }; - if (isParent(pn)) { - String index = attrs.getValue("index"); - if (vf1 < 0) { - missingParameter(en, "value format"); - } else { - subtableEntries.add(parseValue(en, attrs, vf1)); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Value1")) { - String[] pn = new String[] { null, "PairValueRecord" }; - if (isParent(pn)) { - if (vf1 < 0) { - missingParameter(en, "value format 1"); - } else { - assert v1 == null; - v1 = parseValue(en, attrs, vf1); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Value2")) { - String[] pn = new String[] { null, "PairValueRecord" }; - if (isParent(pn)) { - if (vf2 < 0) { - missingParameter(en, "value format 2"); - } else { - assert v2 == null; - v2 = parseValue(en, attrs, vf2); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("ValueFormat")) { - String[] pn = new String[] { null, "SinglePos" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - int vf = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - vf = Integer.parseInt(value); - } - assert vf1 == -1; - vf1 = vf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("ValueFormat1")) { - String[] pn = new String[] { null, "PairPos" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - int vf = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - vf = Integer.parseInt(value); - } - assert vf1 == -1; - vf1 = vf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("ValueFormat2")) { - String[] pn = new String[] { null, "PairPos" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - int vf = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - vf = Integer.parseInt(value); - } - assert vf2 == -1; - vf2 = vf; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("Version")) { - String[] pn1 = new String[] { null, "GDEF" }; - String[] pn2 = new String[] { null, "GPOS" }; - String[] pn3 = new String[] { null, "GSUB" }; - String[][] pnx = new String[][] { pn1, pn2, pn3 }; - if (isParent(pnx)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("XCoordinate")) { - String[] pn1 = new String[] { null, "BaseAnchor" }; - String[] pn2 = new String[] { null, "EntryAnchor" }; - String[] pn3 = new String[] { null, "ExitAnchor" }; - String[] pn4 = new String[] { null, "LigatureAnchor" }; - String[] pn5 = new String[] { null, "MarkAnchor" }; - String[] pn6 = new String[] { null, "Mark2Anchor" }; - String[][] pnx = new String[][] { pn1, pn2, pn3, pn4, pn5, pn6 }; - if (isParent(pnx)) { - String value = attrs.getValue("value"); - int x = 0; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - x = Integer.parseInt(value); - } - assert xCoord == Integer.MIN_VALUE; - xCoord = x; - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("YCoordinate")) { - String[] pn1 = new String[] { null, "BaseAnchor" }; - String[] pn2 = new String[] { null, "EntryAnchor" }; - String[] pn3 = new String[] { null, "ExitAnchor" }; - String[] pn4 = new String[] { null, "LigatureAnchor" }; - String[] pn5 = new String[] { null, "MarkAnchor" }; - String[] pn6 = new String[] { null, "Mark2Anchor" }; - String[][] pnx = new String[][] { pn1, pn2, pn3, pn4, pn5, pn6 }; - if (isParent(pnx)) { - String value = attrs.getValue("value"); - int y = 0; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - y = Integer.parseInt(value); - } - assert yCoord == Integer.MIN_VALUE; - yCoord = y; - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("checkSumAdjustment")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("cmap")) { - String[] pn = new String[] { null, "ttFont" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("cmap_format_0")) { - String[] pn = new String[] { null, "cmap" }; - if (isParent(pn)) { - String platformID = attrs.getValue("platformID"); - if (platformID == null) { - missingRequiredAttribute(en, "platformID"); - } - String platEncID = attrs.getValue("platEncID"); - if (platEncID == null) { - missingRequiredAttribute(en, "platEncID"); - } - String language = attrs.getValue("language"); - if (language == null) { - missingRequiredAttribute(en, "language"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("cmap_format_4")) { - String[] pn = new String[] { null, "cmap" }; - if (isParent(pn)) { - String platformID = attrs.getValue("platformID"); - int pid = -1; - if (platformID == null) { - missingRequiredAttribute(en, "platformID"); - } else { - pid = Integer.parseInt(platformID); - } - String platEncID = attrs.getValue("platEncID"); - int eid = -1; - if (platEncID == null) { - missingRequiredAttribute(en, "platEncID"); - } else { - eid = Integer.parseInt(platEncID); - } - String language = attrs.getValue("language"); - int lid = -1; - if (language == null) { - missingRequiredAttribute(en, "language"); - } else { - lid = Integer.parseInt(language); - } - assert cmapEntries.size() == 0; - assert cmPlatform == -1; - assert cmEncoding == -1; - assert cmLanguage == -1; - cmPlatform = pid; - cmEncoding = eid; - cmLanguage = lid; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("created")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("flags")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("fontDirectionHint")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("fontRevision")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("glyphDataFormat")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("head")) { - String[] pn = new String[] { null, "ttFont" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("hmtx")) { - String[] pn = new String[] { null, "ttFont" }; - if (!isParent(pn)) { - notPermittedInElementContext(en, getParent(), pn); - } else if (glyphIdMax > 0) { - hmtxEntries.setSize(glyphIdMax + 1); - } - } else if (en[1].equals("indexToLocFormat")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("lowestRecPPEM")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("macStyle")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("magicNumber")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("map")) { - String[] pn1 = new String[] { null, "cmap_format_0" }; - String[] pn2 = new String[] { null, "cmap_format_4" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pnx)) { - String code = attrs.getValue("code"); - int cid = -1; - if (code == null) { - missingRequiredAttribute(en, "code"); - } else { - code = code.toLowerCase(); - if (code.startsWith("0x")) { - cid = Integer.parseInt(code.substring(2), 16); - } else { - cid = Integer.parseInt(code, 10); - } - } - String name = attrs.getValue("name"); - int gid = -1; - if (name == null) { - missingRequiredAttribute(en, "name"); - } else { - gid = mapGlyphId(name, en); - } - if ((cmPlatform == 3) && (cmEncoding == 1)) { - cmapEntries.add(new int[] { cid, gid }); - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("modified")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("mtx")) { - String[] pn = new String[] { null, "hmtx" }; - if (isParent(pn)) { - String name = attrs.getValue("name"); - int gid = -1; - if (name == null) { - missingRequiredAttribute(en, "name"); - } else { - gid = mapGlyphId(name, en); - } - String width = attrs.getValue("width"); - int w = -1; - if (width == null) { - missingRequiredAttribute(en, "width"); - } else { - w = Integer.parseInt(width); - } - String lsb = attrs.getValue("lsb"); - int l = -1; - if (lsb == null) { - missingRequiredAttribute(en, "lsb"); - } else { - l = Integer.parseInt(lsb); - } - hmtxEntries.set(gid, new int[] { w, l }); - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("tableVersion")) { - String[] pn1 = new String[] { null, "cmap" }; - String[] pn2 = new String[] { null, "head" }; - String[][] pnx = new String[][] { pn1, pn2 }; - if (isParent(pn1)) { // child of cmap - String version = attrs.getValue("version"); - if (version == null) { - missingRequiredAttribute(en, "version"); - } - } else if (isParent(pn2)) { // child of head - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pnx); - } - } else if (en[1].equals("ttFont")) { - String[] pn = new String[] { null, null }; - if (isParent(pn)) { - String sfntVersion = attrs.getValue("sfntVersion"); - if (sfntVersion == null) { - missingRequiredAttribute(en, "sfntVersion"); - } - String ttLibVersion = attrs.getValue("ttLibVersion"); - if (ttLibVersion == null) { - missingRequiredAttribute(en, "ttLibVersion"); - } - } else { - notPermittedInElementContext(en, getParent(), null); - } - } else if (en[1].equals("unitsPerEm")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - int v = -1; - if (value == null) { - missingRequiredAttribute(en, "value"); - } else { - v = Integer.parseInt(value); - } - assert upem == -1; - upem = v; - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("xMax")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("xMin")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("yMax")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else if (en[1].equals("yMin")) { - String[] pn = new String[] { null, "head" }; - if (isParent(pn)) { - String value = attrs.getValue("value"); - if (value == null) { - missingRequiredAttribute(en, "value"); - } - } else { - notPermittedInElementContext(en, getParent(), pn); - } - } else { - unsupportedElement(en); - } - elements.push(en); - } - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (elements.empty()) { - throw new SAXException("element stack is unbalanced, no elements on stack!"); - } - String[] enParent = elements.peek(); - if (enParent == null) { - throw new SAXException("element stack is empty, elements are not balanced"); - } - String[] en = makeExpandedName(uri, localName, qName); - if (!sameExpandedName(enParent, en)) { - throw new SAXException("element stack is unbalanced, expanded name mismatch"); - } - if (en[0] != null) { - unsupportedElement(en); - } else if (isAnchorElement(en[1])) { - if (xCoord == Integer.MIN_VALUE) { - missingParameter(en, "x coordinate"); - } else if (yCoord == Integer.MIN_VALUE) { - missingParameter(en, "y coordinate"); - } else { - if (en[1].equals("EntryAnchor")) { - if (anchors.size() > 0) { - duplicateParameter(en, "entry anchor"); - } - } else if (en[1].equals("ExitAnchor")) { - if (anchors.size() > 1) { - duplicateParameter(en, "exit anchor"); - } else if (anchors.size() == 0) { - anchors.add(null); - } - } - anchors.add(new GlyphPositioningTable.Anchor(xCoord, yCoord)); - xCoord = yCoord = Integer.MIN_VALUE; - } - } else if (en[1].equals("AlternateSet")) { - subtableEntries.add(extractAlternates()); - } else if (en[1].equals("AlternateSubst")) { - if (!sortEntries(coverageEntries, subtableEntries)) { - mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); - } - addGSUBSubtable(GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_ALTERNATE, extractCoverage()); - } else if (en[1].equals("BacktrackCoverage")) { - String ck = makeCoverageKey("bk", ctIndex); - if (coverages.containsKey(ck)) { - duplicateCoverageIndex(en, ctIndex); - } else { - coverages.put(ck, extractCoverage()); - } - } else if (en[1].equals("BaseCoverage")) { - coverages.put("base", extractCoverage()); - } else if (en[1].equals("BaseRecord")) { - baseOrMarkAnchors.add(extractAnchors()); - } 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"); - if ((igca.length == 0) || hasMissingCoverage(igca)) { - missingCoverage(en, "input", igca.length); - } else if (hasMissingCoverage(bgca)) { - missingCoverage(en, "backtrack", bgca.length); - } else if (hasMissingCoverage(lgca)) { - missingCoverage(en, "lookahead", lgca.length); - } else { - GlyphTable.Rule r = new GlyphTable.ChainedCoverageSequenceRule(extractRuleLookups(), igca.length, igca, bgca, lgca); - GlyphTable.RuleSet rs = new GlyphTable.HomogeneousRuleSet(new GlyphTable.Rule[] {r}); - GlyphTable.RuleSet[] rsa = new GlyphTable.RuleSet[] {rs}; - coverage = igca [ 0 ]; - subtableEntries.add(rsa); - } - } else { - unsupportedFormat(en, stFormat); - } - if (en[1].equals("ChainContextPos")) { - addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_CHAINED_CONTEXTUAL, coverage); - } else if (en[1].equals("ChainContextSubst")) { - addGSUBSubtable(GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_CHAINED_CONTEXTUAL, coverage); - } - } else if (en[1].equals("ComponentRecord")) { - components.add(extractAnchors()); - } else if (en[1].equals("Coverage")) { - coverages.put("main", extractCoverage()); - } else if (en[1].equals("DefaultLangSys") || en[1].equals("LangSysRecord")) { - if (languageTag == null) { - missingTag(en, "language"); - } else if (languages.containsKey(languageTag)) { - duplicateTag(en, "language", languageTag); - } else { - languages.put(languageTag, extractLanguageFeatures()); - languageTag = null; - } - } else if (en[1].equals("CursivePos")) { - GlyphCoverageTable ct = coverages.get("main"); - if (ct == null) { - missingParameter(en, "coverages"); - } else if (stFormat == 1) { - subtableEntries.add(extractAttachmentAnchors()); - } else { - unsupportedFormat(en, stFormat); - } - addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_CURSIVE, ct); - } else if (en[1].equals("EntryExitRecord")) { - int na = anchors.size(); - if (na == 0) { - missingParameter(en, "entry or exit anchor"); - } else if (na == 1) { - anchors.add(null); - } else if (na > 2) { - duplicateParameter(en, "entry or exit anchor"); - } - attachmentAnchors.add(extractAnchors()); - } else if (en[1].equals("BaseRecord")) { - baseOrMarkAnchors.add(extractAnchors()); - } else if (en[1].equals("FeatureRecord")) { - if (flIndex != flSequence) { - mismatchedIndex(en, "feature", flIndex, flSequence); - } else if (featureTag == null) { - missingTag(en, "feature"); - } else { - String fid = makeFeatureId(flIndex); - features.put(fid, extractFeature()); - nextFeature(); - } - } else if (en[1].equals("GDEF")) { - if (subtables.size() > 0) { - gdef = new GlyphDefinitionTable(subtables); - } - clearTable(); - } else if (en[1].equals("GPOS")) { - if (subtables.size() > 0) { - gpos = new GlyphPositioningTable(gdef, extractLookups(), subtables); - } - clearTable(); - } else if (en[1].equals("GSUB")) { - if (subtables.size() > 0) { - gsub = new GlyphSubstitutionTable(gdef, extractLookups(), subtables); - } - clearTable(); - } else if (en[1].equals("GlyphClassDef")) { - GlyphMappingTable mapping = extractClassDefMapping(glyphClasses, stFormat, true); - addGDEFSubtable(GlyphDefinitionTable.GDEF_LOOKUP_TYPE_GLYPH_CLASS, mapping); - } else if (en[1].equals("InputCoverage")) { - String ck = makeCoverageKey("in", ctIndex); - if (coverages.containsKey(ck)) { - duplicateCoverageIndex(en, ctIndex); - } else { - coverages.put(ck, extractCoverage()); - } - } else if (en[1].equals("LigatureAttach")) { - ligatureAnchors.add(extractComponents()); - } else if (en[1].equals("LigatureCoverage")) { - coverages.put("liga", extractCoverage()); - } else if (en[1].equals("LigatureSet")) { - subtableEntries.add(extractLigatures()); - } else if (en[1].equals("LigatureSubst")) { - if (!sortEntries(coverageEntries, subtableEntries)) { - mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); - } - GlyphCoverageTable coverage = extractCoverage(); - addGSUBSubtable(GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_LIGATURE, coverage); - } else if (en[1].equals("LookAheadCoverage")) { - String ck = makeCoverageKey("la", ctIndex); - if (coverages.containsKey(ck)) { - duplicateCoverageIndex(en, ctIndex); - } else { - coverages.put(ck, extractCoverage()); - } - } else if (en[1].equals("Lookup")) { - if (ltIndex != ltSequence) { - mismatchedIndex(en, "lookup", ltIndex, ltSequence); - } else { - nextLookup(); - } - } else if (en[1].equals("MarkAttachClassDef")) { - GlyphMappingTable mapping = extractClassDefMapping(glyphClasses, stFormat, true); - addGDEFSubtable(GlyphDefinitionTable.GDEF_LOOKUP_TYPE_MARK_ATTACHMENT, mapping); - } else if (en[1].equals("MarkCoverage")) { - coverages.put("mark", extractCoverage()); - } else if (en[1].equals("Mark1Coverage")) { - coverages.put("mrk1", extractCoverage()); - } else if (en[1].equals("Mark2Coverage")) { - coverages.put("mrk2", extractCoverage()); - } else if (en[1].equals("MarkBasePos")) { - GlyphCoverageTable mct = coverages.get("mark"); - GlyphCoverageTable bct = coverages.get("base"); - if (mct == null) { - missingParameter(en, "mark coverages"); - } else if (bct == null) { - missingParameter(en, "base coverages"); - } else if (stFormat == 1) { - MarkAnchor[] maa = extractMarkAnchors(); - Anchor[][] bam = extractBaseOrMarkAnchors(); - subtableEntries.add(bct); - subtableEntries.add(computeClassCount(bam)); - subtableEntries.add(maa); - subtableEntries.add(bam); - } else { - unsupportedFormat(en, stFormat); - } - addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_BASE, mct); - } else if (en[1].equals("MarkLigPos")) { - GlyphCoverageTable mct = coverages.get("mark"); - GlyphCoverageTable lct = coverages.get("liga"); - if (mct == null) { - missingParameter(en, "mark coverages"); - } else if (lct == null) { - missingParameter(en, "ligature coverages"); - } else if (stFormat == 1) { - MarkAnchor[] maa = extractMarkAnchors(); - Anchor[][][] lam = extractLigatureAnchors(); - subtableEntries.add(lct); - subtableEntries.add(computeLigaturesClassCount(lam)); - subtableEntries.add(computeLigaturesComponentCount(lam)); - subtableEntries.add(maa); - subtableEntries.add(lam); - } else { - unsupportedFormat(en, stFormat); - } - addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_LIGATURE, mct); - } else if (en[1].equals("MarkMarkPos")) { - GlyphCoverageTable mct1 = coverages.get("mrk1"); - GlyphCoverageTable mct2 = coverages.get("mrk2"); - if (mct1 == null) { - missingParameter(en, "mark coverages 1"); - } else if (mct2 == null) { - missingParameter(en, "mark coverages 2"); - } else if (stFormat == 1) { - MarkAnchor[] maa = extractMarkAnchors(); - Anchor[][] mam = extractBaseOrMarkAnchors(); - subtableEntries.add(mct2); - subtableEntries.add(computeClassCount(mam)); - subtableEntries.add(maa); - subtableEntries.add(mam); - } else { - unsupportedFormat(en, stFormat); - } - addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_MARK_TO_MARK, mct1); - } else if (en[1].equals("MarkRecord")) { - if (markClass == -1) { - missingParameter(en, "mark class"); - } else if (anchors.size() == 0) { - missingParameter(en, "mark anchor"); - } else if (anchors.size() > 1) { - duplicateParameter(en, "mark anchor"); - } else { - markAnchors.add(new GlyphPositioningTable.MarkAnchor(markClass, anchors.get(0))); - markClass = -1; - anchors.clear(); - } - } else if (en[1].equals("Mark2Record")) { - baseOrMarkAnchors.add(extractAnchors()); - } else if (en[1].equals("MultipleSubst")) { - GlyphCoverageTable coverage = coverages.get("main"); - addGSUBSubtable(GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_MULTIPLE, coverage, extractSequenceEntries()); - } else if (en[1].equals("PairPos")) { - assertSubtableEntriesClear(); - if (stFormat == 1) { - if (pairSets.size() == 0) { - missingParameter(en, "pair set"); - } else { - subtableEntries.add(extractPairSets()); - } - } else if (stFormat == 2) { - unsupportedFormat(en, stFormat); - } - GlyphCoverageTable coverage = coverages.get("main"); - addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_PAIR, coverage); - vf1 = vf2 = -1; - psIndex = -1; - } else if (en[1].equals("PairSet")) { - if (psIndex != pairSets.size()) { - invalidIndex(en, psIndex, pairSets.size()); - } else { - pairSets.add(extractPairs()); - } - } else if (en[1].equals("PairValueRecord")) { - if (g2 == -1) { - missingParameter(en, "second glyph"); - } else if ((v1 == null) && (v2 == null)) { - missingParameter(en, "first or second value"); - } else { - pairs.add(new PairValues(g2, v1, v2)); - clearPair(); - } - } else if (en[1].equals("PosLookupRecord") || en[1].equals("SubstLookupRecord")) { - if (rlSequence < 0) { - missingParameter(en, "sequence index"); - } else if (rlLookup < 0) { - missingParameter(en, "lookup index"); - } else { - ruleLookups.add(new GlyphTable.RuleLookup(rlSequence, rlLookup)); - rlSequence = rlLookup = -1; - } - } else if (en[1].equals("Script")) { - if (scriptTag == null) { - missingTag(en, "script"); - } else if (scripts.containsKey(scriptTag)) { - duplicateTag(en, "script", scriptTag); - } else { - scripts.put(scriptTag, extractLanguages()); - scriptTag = null; - } - } else if (en[1].equals("Sequence")) { - subtableEntries.add(extractSubstitutes()); - } else if (en[1].equals("SinglePos")) { - int nv = subtableEntries.size(); - if (stFormat == 1) { - if (nv < 0) { - missingParameter(en, "value"); - } else if (nv > 1) { - duplicateParameter(en, "value"); - } - } else if (stFormat == 2) { - GlyphPositioningTable.Value[] pva = (GlyphPositioningTable.Value[]) subtableEntries.toArray(new GlyphPositioningTable.Value [ nv ]); - subtableEntries.clear(); - subtableEntries.add(pva); - } - GlyphCoverageTable coverage = coverages.get("main"); - addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_SINGLE, coverage); - vf1 = -1; - } else if (en[1].equals("SingleSubst")) { - if (!sortEntries(coverageEntries, subtableEntries)) { - mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); - } - GlyphCoverageTable coverage = extractCoverage(); - addGSUBSubtable(GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_SINGLE, coverage); - } else if (en[1].equals("cmap")) { - cmap = getCMAP(); - gmap = getGMAP(); - cmapEntries.clear(); - } else if (en[1].equals("cmap_format_4")) { - cmPlatform = cmEncoding = cmLanguage = -1; - } else if (en[1].equals("hmtx")) { - hmtx = getHMTX(); - hmtxEntries.clear(); - } else if (en[1].equals("ttFont")) { - if (cmap == null) { - missingParameter(en, "cmap"); - } - if (hmtx == null) { - missingParameter(en, "hmtx"); - } - } - elements.pop(); - } - @Override - public void characters(char[] chars, int start, int length) { - } - private String[] getParent() { - if (!elements.empty()) { - return elements.peek(); - } else { - return new String[] { null, null }; - } - } - private boolean isParent(Object enx) { - if (enx instanceof String[][]) { - for (String[] en : (String[][]) enx) { - if (isParent(en)) { - return true; - } - } - return false; - } else if (enx instanceof String[]) { - String[] en = (String[]) enx; - if (!elements.empty()) { - String[] pn = elements.peek(); - return (pn != null) && sameExpandedName(en, pn); - } else { - return ((en[0] == null) && (en[1] == null)); - } - } else { - return false; - } - } - private boolean isAnchorElement(String ln) { - if (ln.equals("BaseAnchor")) { - return true; - } else if (ln.equals("EntryAnchor")) { - return true; - } else if (ln.equals("ExitAnchor")) { - return true; - } else if (ln.equals("LigatureAnchor")) { - return true; - } else if (ln.equals("MarkAnchor")) { - return true; - } else { - return ln.equals("Mark2Anchor"); - } - } - 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]); - cmap.put(c, g); - } - return cmap; - } - 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]); - gmap.put(g, c); - } - return gmap; - } - private int[][] getHMTX() { - int ne = hmtxEntries.size(); - int[][] hmtx = new int [ ne ] [ 2 ]; - for (int i = 0; i < ne; i++) { - int[] ea = hmtxEntries.get(i); - if (ea != null) { - hmtx [ i ] [ 0 ] = ea[0]; - hmtx [ i ] [ 1 ] = ea[1]; - } - } - return hmtx; - } - private GlyphClassTable extractClassDefMapping(Map<String, Integer> glyphClasses, int format, boolean clearSourceMap) { - GlyphClassTable ct; - if (format == 1) { - ct = extractClassDefMapping1(extractClassMappings(glyphClasses, clearSourceMap)); - } else if (format == 2) { - ct = extractClassDefMapping2(extractClassMappings(glyphClasses, clearSourceMap)); - } else { - ct = null; - } - return ct; - } - private GlyphClassTable extractClassDefMapping1(int[][] cma) { - List entries = new ArrayList<Integer>(); - int s = -1; - int l = -1; - Integer zero = Integer.valueOf(0); - for (int[] m : cma) { - int g = m[0]; - int c = m[1]; - if (s < 0) { - s = g; - l = g - 1; - entries.add(Integer.valueOf(s)); - } - while (g > (l + 1)) { - entries.add(zero); - l++; - } - assert l == (g - 1); - entries.add(Integer.valueOf(c)); - l = g; - } - return GlyphClassTable.createClassTable(entries); - } - private GlyphClassTable extractClassDefMapping2(int[][] cma) { - List entries = new ArrayList<Integer>(); - int s = -1; - int e = s; - int l = -1; - for (int[] m : cma) { - int g = m[0]; - int c = m[1]; - if (c != l) { - if (s >= 0) { - entries.add(new GlyphClassTable.MappingRange(s, e, l)); - } - s = e = g; - } else { - e = g; - } - l = c; - } - return GlyphClassTable.createClassTable(entries); - } - 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()) { - Integer gid = glyphIds.get(e.getKey()); - assert gid != null; - int[] m = cma [ i ]; - m [ 0 ] = (int) gid; - m [ 1 ] = (int) e.getValue(); - i++; - } - if (clearSourceMap) { - glyphClasses.clear(); - } - return sortClassMappings(cma); - } - private int[][] sortClassMappings(int[][] cma) { - Arrays.sort(cma, new Comparator<int[]>() { - public int compare(int[] m1, int[] m2) { - assert m1.length > 0; - assert m2.length > 0; - if (m1[0] < m2[0]) { - return -1; - } else if (m1[0] > m2[0]) { - return 1; - } else { - return 0; - } - } - } - ); - return cma; - } - // sort coverage entries and subtable entries together - private boolean sortEntries(List cel, List sel) { - assert cel != null; - assert sel != null; - if (cel.size() == sel.size()) { - int np = cel.size(); - Object[][] pa = new Object [ np ] [ 2 ]; - for (int i = 0; i < np; i++) { - pa [ i ] [ 0 ] = cel.get(i); - pa [ i ] [ 1 ] = sel.get(i); - } - Arrays.sort(pa, new Comparator<Object[]>() { - public int compare(Object[] p1, Object[] p2) { - assert p1.length == 2; - assert p2.length == 2; - int c1 = (Integer) p1[0]; - int c2 = (Integer) p2[0]; - if (c1 < c2) { - return -1; - } else if (c1 > c2) { - return 1; - } else { - return 0; - } - } - } - ); - cel.clear(); - sel.clear(); - for (int i = 0; i < np; i++) { - cel.add(pa [ i ] [ 0 ]); - sel.add(pa [ i ] [ 1 ]); - } - assert cel.size() == sel.size(); - return true; - } else { - return false; - } - } - private String makeCoverageKey(String prefix, int index) { - assert prefix != null; - assert prefix.length() == 2; - assert index < 100; - return prefix + CharUtilities.padLeft(Integer.toString(index, 10), 2, '0'); - } - private List extractCoverageEntries() { - List entries = new ArrayList<Integer>(coverageEntries); - clearCoverage(); - return entries; - } - private void clearCoverageEntries() { - coverageEntries.clear(); - ctFormat = -1; - ctIndex = -1; - } - private void assertCoverageEntriesClear() { - assert coverageEntries.size() == 0; - } - private GlyphCoverageTable extractCoverage() { - assert (ctFormat == 1) || (ctFormat == 2); - assert ctIndex >= 0; - GlyphCoverageTable coverage = GlyphCoverageTable.createCoverageTable(extractCoverageEntries()); - clearCoverage(); - return coverage; - } - private void clearCoverages() { - coverages.clear(); - } - private void assertCoverageClear() { - assert ctFormat == -1; - assert ctIndex == -1; - assertCoverageEntriesClear(); - } - private void clearCoverage() { - ctFormat = -1; - ctIndex = -1; - clearCoverageEntries(); - } - private void assertCoveragesClear() { - assert coverages.size() == 0; - } - private GlyphCoverageTable[] getCoveragesWithPrefix(String prefix) { - assert prefix != null; - int prefixLength = prefix.length(); - Set<String> keys = coverages.keySet(); - int mi = -1; // maximum coverage table index - for (String k : keys) { - if (k.startsWith(prefix)) { - int i = Integer.parseInt(k.substring(prefixLength)); - if (i > mi) { - mi = i; - } - } - } - GlyphCoverageTable[] gca = new GlyphCoverageTable [ mi + 1 ]; - for (String k : keys) { - if (k.startsWith(prefix)) { - int i = Integer.parseInt(k.substring(prefixLength)); - if (i >= 0) { - gca [ i ] = coverages.get(k); - } - } - } - return gca; - } - private boolean hasMissingCoverage(GlyphCoverageTable[] gca) { - assert gca != null; - int nc = 0; - for (int i = 0, n = gca.length; i < n; i++) { - if (gca [ i ] != null) { - nc++; - } - } - return nc != gca.length; - } - private String makeFeatureId(int fid) { - assert fid >= 0; - return "f" + fid; - } - private String makeLookupId(int lid) { - assert lid >= 0; - return "lu" + lid; - } - private void clearScripts() { - scripts.clear(); - } - private List<String> extractLanguageFeatures() { - List<String> lfl = new ArrayList<String>(languageFeatures); - clearLanguageFeatures(); - return lfl; - } - private void assertLanguageFeaturesClear() { - assert languageFeatures.size() == 0; - } - private void clearLanguageFeatures() { - languageFeatures.clear(); - } - private Map<String, List<String>> extractLanguages() { - Map<String, List<String>> lm = new HashMap(languages); - clearLanguages(); - return lm; - } - private void clearLanguages() { - languages.clear(); - } - private void assertFeatureLookupsClear() { - assert featureLookups.size() == 0; - } - private List extractFeatureLookups() { - List lookups = new ArrayList<String>(featureLookups); - clearFeatureLookups(); - return lookups; - } - private void clearFeatureLookups() { - featureLookups.clear(); - } - private void assertFeatureClear() { - assert flIndex == -1; - assert featureTag == null; - assertFeatureLookupsClear(); - } - private Object[] extractFeature() { - Object[] fa = new Object [ 2 ]; - fa[0] = featureTag; - fa[1] = extractFeatureLookups(); - clearFeature(); - return fa; - } - private void clearFeature() { - flIndex = -1; - featureTag = null; - clearFeatureLookups(); - } - private void nextFeature() { - flSequence++; - } - private void clearFeatures() { - features.clear(); - } - private void clearSubtableInLookup() { - stFormat = 0; - clearCoverages(); - } - private void clearSubtablesInLookup() { - clearSubtableInLookup(); - stSequence = 0; - } - private void clearSubtablesInTable() { - clearSubtablesInLookup(); - subtables.clear(); - } - private void nextSubtableInLookup() { - stSequence++; - clearSubtableInLookup(); - } - private void assertLookupClear() { - assert ltIndex == -1; - assert ltFlags == 0; - } - private void clearLookup() { - ltIndex = -1; - ltFlags = 0; - clearSubtablesInLookup(); - } - 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); - if (lm != null) { - for (String lt : lm.keySet()) { - List<String> fids = lm.get(lt); - if (fids != null) { - for (String fid : fids) { - if (fid != null) { - Object[] fa = features.get(fid); - if (fa != null) { - assert fa.length == 2; - String ft = (String) fa[0]; - List<String> lids = (List<String>) fa[1]; - if ((lids != null) && (lids.size() > 0)) { - GlyphTable.LookupSpec ls = new GlyphTable.LookupSpec(st, lt, ft); - lookups.put(ls, lids); - } - } - } - } - } - } - } - } - clearScripts(); - clearLanguages(); - clearFeatures(); - return lookups; - } - private void clearLookups() { - clearLookup(); - clearSubtablesInTable(); - ltSequence = 0; - flSequence = 0; - } - private void nextLookup() { - ltSequence++; - clearLookup(); - } - private void clearTable() { - clearLookups(); - } - private void assertSubtableClear() { - assert stFormat == 0; - assertCoverageEntriesClear(); - } - private void assertSubtablesClear() { - assertSubtableClear(); - assert subtables.size() == 0; - } - private void clearSubtableEntries() { - subtableEntries.clear(); - } - private void assertSubtableEntriesClear() { - assert subtableEntries.size() == 0; - } - private List extractSubtableEntries() { - List entries = new ArrayList(subtableEntries); - clearSubtableEntries(); - return entries; - } - private int[] extractAlternates() { - int[] aa = new int [ alternates.size() ]; - int i = 0; - for (Integer a : alternates) { - aa[i++] = (int) a; - } - clearAlternates(); - return aa; - } - private void clearAlternates() { - alternates.clear(); - } - private LigatureSet extractLigatures() { - LigatureSet ls = new LigatureSet(ligatures); - clearLigatures(); - return ls; - } - private void clearLigatures() { - ligatures.clear(); - } - private int[] extractSubstitutes() { - int[] aa = new int [ substitutes.size() ]; - int i = 0; - for (Integer a : substitutes) { - aa[i++] = (int) a; - } - clearSubstitutes(); - return aa; - } - private void clearSubstitutes() { - substitutes.clear(); - } - private List extractSequenceEntries() { - List sequences = extractSubtableEntries(); - int[][] sa = new int [ sequences.size() ] []; - int i = 0; - for (Object s : sequences) { - if (s instanceof int[]) { - sa[i++] = (int[]) s; - } - } - List entries = new ArrayList(); - entries.add(sa); - return entries; - } - private RuleLookup[] extractRuleLookups() { - RuleLookup[] lookups = (RuleLookup[]) ruleLookups.toArray(new RuleLookup [ ruleLookups.size() ]); - clearRuleLookups(); - return lookups; - } - private void clearRuleLookups() { - ruleLookups.clear(); - } - private GlyphPositioningTable.Value parseValue(String[] en, Attributes attrs, int format) throws SAXException { - String xPlacement = attrs.getValue("XPlacement"); - int xp = 0; - if (xPlacement != null) { - xp = Integer.parseInt(xPlacement); - } else if ((format & GlyphPositioningTable.Value.X_PLACEMENT) != 0) { - missingParameter(en, "xPlacement"); - } - String yPlacement = attrs.getValue("YPlacement"); - int yp = 0; - if (yPlacement != null) { - yp = Integer.parseInt(yPlacement); - } else if ((format & GlyphPositioningTable.Value.Y_PLACEMENT) != 0) { - missingParameter(en, "yPlacement"); - } - String xAdvance = attrs.getValue("XAdvance"); - int xa = 0; - if (xAdvance != null) { - xa = Integer.parseInt(xAdvance); - } else if ((format & GlyphPositioningTable.Value.X_ADVANCE) != 0) { - missingParameter(en, "xAdvance"); - } - String yAdvance = attrs.getValue("YAdvance"); - int ya = 0; - if (yAdvance != null) { - ya = Integer.parseInt(yAdvance); - } else if ((format & GlyphPositioningTable.Value.Y_ADVANCE) != 0) { - missingParameter(en, "yAdvance"); - } - return new GlyphPositioningTable.Value(xp, yp, xa, ya, null, null, null, null); - } - private void assertPairClear() { - assert g2 == -1; - assert v1 == null; - assert v2 == null; - } - private void clearPair() { - g2 = -1; - v1 = null; - v2 = null; - } - private void assertPairsClear() { - assert pairs.size() == 0; - } - private void clearPairs() { - pairs.clear(); - psIndex = -1; - } - private PairValues[] extractPairs() { - PairValues[] pva = (PairValues[]) pairs.toArray(new PairValues [ pairs.size() ]); - clearPairs(); - return pva; - } - private void assertPairSetsClear() { - assert pairSets.size() == 0; - } - private void clearPairSets() { - pairSets.clear(); - } - private PairValues[][] extractPairSets() { - PairValues[][] pvm = (PairValues[][]) pairSets.toArray(new PairValues [ pairSets.size() ][]); - clearPairSets(); - return pvm; - } - private Anchor[] extractAnchors() { - Anchor[] aa = (Anchor[]) anchors.toArray(new Anchor [ anchors.size() ]); - anchors.clear(); - return aa; - } - private MarkAnchor[] extractMarkAnchors() { - MarkAnchor[] maa = new MarkAnchor [ markAnchors.size() ]; - maa = (MarkAnchor[]) markAnchors.toArray(new MarkAnchor [ maa.length ]); - markAnchors.clear(); - return maa; - } - private Anchor[][] extractBaseOrMarkAnchors() { - int na = baseOrMarkAnchors.size(); - int ncMax = 0; - for (Anchor[] aa : baseOrMarkAnchors) { - if (aa != null) { - int nc = aa.length; - if (nc > ncMax) { - ncMax = nc; - } - } - } - Anchor[][] am = new Anchor [ na ][ ncMax ]; - for (int i = 0; i < na; i++) { - Anchor[] aa = baseOrMarkAnchors.get(i); - if (aa != null) { - for (int j = 0; j < ncMax; j++) { - if (j < aa.length) { - am [ i ] [ j ] = aa [ j ]; - } - } - } - } - baseOrMarkAnchors.clear(); - return am; - } - private Integer computeClassCount(Anchor[][] am) { - int ncMax = 0; - for (int i = 0, n = am.length; i < n; i++) { - Anchor[] aa = am [ i ]; - if (aa != null) { - int nc = aa.length; - if (nc > ncMax) { - ncMax = nc; - } - } - } - return Integer.valueOf(ncMax); - } - private Anchor[][] extractComponents() { - Anchor[][] cam = new Anchor [ components.size() ][]; - cam = (Anchor[][]) components.toArray(new Anchor [ cam.length ][]); - components.clear(); - return cam; - } - private Anchor[][][] extractLigatureAnchors() { - int na = ligatureAnchors.size(); - int ncMax = 0; - int nxMax = 0; - for (Anchor[][] cm : ligatureAnchors) { - if (cm != null) { - int nx = cm.length; - if (nx > nxMax) { - nxMax = nx; - } - for (Anchor[] aa : cm) { - if (aa != null) { - int nc = aa.length; - if (nc > ncMax) { - ncMax = nc; - } - } - } - - } - } - Anchor[][][] lam = new Anchor [ na ] [ nxMax ] [ ncMax ]; - for (int i = 0; i < na; i++) { - Anchor[][] cm = ligatureAnchors.get(i); - if (cm != null) { - for (int j = 0; j < nxMax; j++) { - if (j < cm.length) { - Anchor[] aa = cm [ j ]; - if (aa != null) { - for (int k = 0; k < ncMax; k++) { - if (k < aa.length) { - lam [ i ] [ j ] [ k ] = aa [ k ]; - } - } - } - } - } - } - } - ligatureAnchors.clear(); - return lam; - } - private Integer computeLigaturesClassCount(Anchor[][][] lam) { - int ncMax = 0; - if (lam != null) { - for (Anchor[][] cm : lam) { - if (cm != null) { - for (Anchor[] aa : cm) { - if (aa != null) { - int nc = aa.length; - if (nc > ncMax) { - ncMax = nc; - } - } - } - } - } - } - return Integer.valueOf(ncMax); - } - private Integer computeLigaturesComponentCount(Anchor[][][] lam) { - int nxMax = 0; - if (lam != null) { - for (Anchor[][] cm : lam) { - if (cm != null) { - int nx = cm.length; - if (nx > nxMax) { - nxMax = nx; - } - } - } - } - return Integer.valueOf(nxMax); - } - private Anchor[] extractAttachmentAnchors() { - int na = attachmentAnchors.size(); - Anchor[] aa = new Anchor [ na * 2 ]; - for (int i = 0; i < na; i++) { - Anchor[] ea = attachmentAnchors.get(i); - int ne = ea.length; - if (ne > 0) { - aa [ (i * 2) + 0 ] = ea[0]; - } - if (ne > 1) { - aa [ (i * 2) + 1 ] = ea[1]; - } - } - attachmentAnchors.clear(); - return aa; - } - private void addGDEFSubtable(int stType, GlyphMappingTable mapping) { - subtables.add(GlyphDefinitionTable.createSubtable(stType, makeLookupId(ltSequence), stSequence, ltFlags, stFormat, mapping, extractSubtableEntries())); - nextSubtableInLookup(); - } - private void addGSUBSubtable(int stType, GlyphCoverageTable coverage, List entries) { - subtables.add(GlyphSubstitutionTable.createSubtable(stType, makeLookupId(ltSequence), stSequence, ltFlags, stFormat, coverage, entries)); - nextSubtableInLookup(); - } - private void addGSUBSubtable(int stType, GlyphCoverageTable coverage) { - addGSUBSubtable(stType, coverage, extractSubtableEntries()); - } - private void addGPOSSubtable(int stType, GlyphCoverageTable coverage, List entries) { - subtables.add(GlyphPositioningTable.createSubtable(stType, makeLookupId(ltSequence), stSequence, ltFlags, stFormat, coverage, entries)); - nextSubtableInLookup(); - } - private void addGPOSSubtable(int stType, GlyphCoverageTable coverage) { - addGPOSSubtable(stType, coverage, extractSubtableEntries()); - } - } - private int mapGlyphId0(String glyph) { - assert glyphIds != null; - Integer gid = glyphIds.get(glyph); - if (gid != null) { - return (int) gid; - } else { - return -1; - } - } - private int mapGlyphId(String glyph, String[] currentElement) throws SAXException { - int g = mapGlyphId0(glyph); - if (g < 0) { - unsupportedGlyph(currentElement, glyph); - return -1; - } else { - return g; - } - } - private int[] mapGlyphIds(String glyphs, String[] currentElement) throws SAXException { - String[] ga = glyphs.split(","); - int[] gids = new int [ ga.length ]; - int i = 0; - for (String glyph : ga) { - gids[i++] = mapGlyphId(glyph, currentElement); - } - return gids; - } - private int mapGlyphIdToChar(String glyph) { - assert glyphIds != null; - Integer gid = glyphIds.get(glyph); - if (gid != null) { - if (gmap != null) { - Integer cid = gmap.get(gid); - if (cid != null) { - return cid.intValue(); - } - } - } - return -1; - } - private String formatLocator() { - if (locator == null) { - return "{null}"; - } else { - return "{" + locator.getSystemId() + ":" + locator.getLineNumber() + ":" + locator.getColumnNumber() + "}"; - } - } - private void unsupportedElement(String[] en) throws SAXException { - throw new SAXException(formatLocator() + ": unsupported element " + formatExpandedName(en)); - } - private void notPermittedInElementContext(String[] en, String[] cn, Object xns) throws SAXException { - assert en != null; - assert cn != null; - String s = "element " + formatExpandedName(en) + " not permitted in current element context " + formatExpandedName(cn); - if (xns == null) { - s += ", expected root context"; - } else if (xns instanceof String[][]) { - int nxn = 0; - s += ", expected one of { "; - for (String[] xn : (String[][]) xns) { - if (nxn++ > 0) { - s += ", "; - } - s += formatExpandedName(xn); - } - s += " }"; - } else if (xns instanceof String[]) { - s += ", expected " + formatExpandedName((String[]) xns); - } - throw new SAXException(formatLocator() + ": " + s); - } - private void missingRequiredAttribute(String[] en, String name) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " missing required attribute " + name); - } - private void duplicateGlyph(String[] en, String name, int gid) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate name \"" + name + "\", with identifier value " + gid); - } - private void unsupportedGlyph(String[] en, String name) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " refers to unsupported glyph id \"" + name + "\""); - } - private void duplicateCMAPCharacter(String[] en, int cid) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate cmap character code: " + CharUtilities.format(cid)); - } - private void duplicateCMAPGlyph(String[] en, int gid) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate cmap glyph code: " + gid); - } - private void duplicateGlyphClass(String[] en, String name, String glyphClass) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " contains duplicate glyph class for \"" + name + "\", with class value " + glyphClass); - } - private void unsupportedFormat(String[] en, int format) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " refers to unsupported table format \"" + format + "\""); - } - private void invalidIndex(String[] en, int actual, int expected) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " specifies invalid index " + actual + ", expected " + expected); - } - private void mismatchedIndex(String[] en, String label, int actual, int expected) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " mismatched " + label + " index: got " + actual + ", expected " + expected); - } - private void mismatchedEntries(String[] en, int nce, int nse) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " mismatched coverage and subtable entry counts, # coverages " + nce + ", # entries " + nse); - } - private void missingParameter(String[] en, String label) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " missing " + label + " parameter"); - } - private void duplicateParameter(String[] en, String label) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " duplicate " + label + " parameter"); - } - private void duplicateCoverageIndex(String[] en, int index) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " duplicate coverage table index " + index); - } - private void missingCoverage(String[] en, String type, int expected) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " missing " + type + " coverage table, expected " + ((expected > 0) ? expected : 1) + " table(s)"); - } - private void missingTag(String[] en, String label) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " missing " + label + " tag"); - } - private void duplicateTag(String[] en, String label, String tag) throws SAXException { - throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " duplicate " + label + " tag: " + tag); - } - private static String[] makeExpandedName(String uri, String localName, String qName) { - if ((uri != null) && (uri.length() == 0)) { - uri = null; - } - if ((localName != null) && (localName.length() == 0)) { - localName = null; - } - if ((uri == null) && (localName == null)) { - uri = extractPrefix(qName); - localName = extractLocalName(qName); - } - return new String[] { uri, localName }; - } - private static String extractPrefix(String qName) { - String[] sa = qName.split(":"); - if (sa.length == 2) { - return sa[0]; - } else { - return null; - } - } - private static String extractLocalName(String qName) { - String[] sa = qName.split(":"); - if (sa.length == 2) { - return sa[1]; - } else if (sa.length == 1) { - return sa[0]; - } else { - return null; - } - } - private static boolean sameExpandedName(String[] n1, String[] n2) { - String u1 = n1[0]; - String u2 = n2[0]; - if ((u1 == null) ^ (u2 == null)) { - return false; - } - if ((u1 != null) && (u2 != null)) { - if (!u1.equals(u2)) { - return false; - } - } - String l1 = n1[1]; - String l2 = n2[1]; - if ((l1 == null) ^ (l2 == null)) { - return false; - } - if ((l1 != null) && (l2 != null)) { - if (!l1.equals(l2)) { - return false; - } - } - return true; - } - private static String formatExpandedName(String[] n) { - String u = (n[0] != null) ? n[0] : "null"; - String l = (n[1] != null) ? n[1] : "null"; - return "{" + u + "}" + l; - } -} diff --git a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFileTestCase.java b/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFileTestCase.java deleted file mode 100644 index f4b7d34e8..000000000 --- a/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFileTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.complexscripts.fonts.ttx; - -import java.io.File; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class TTXFileTestCase { - - private static String ttxFilesRoot = "test/resources/complexscripts"; - - private static String[] ttxFiles = { - "arab/ttx/arab-001.ttx", - "arab/ttx/arab-002.ttx", - "arab/ttx/arab-003.ttx", - "arab/ttx/arab-004.ttx", - }; - - @Test - public void testTTXFiles() throws Exception { - for (String tfn : ttxFiles) { - try { - TTXFile tf = TTXFile.getFromCache(ttxFilesRoot + File.separator + tfn); - assertTrue(tf != null); - } catch (Exception e) { - fail(e.getMessage()); - } - } - } - -} diff --git a/test/java/org/apache/fop/complexscripts/layout/ComplexScriptsLayoutTestCase.java b/test/java/org/apache/fop/complexscripts/layout/ComplexScriptsLayoutTestCase.java deleted file mode 100644 index 416cbf8d0..000000000 --- a/test/java/org/apache/fop/complexscripts/layout/ComplexScriptsLayoutTestCase.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * 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.complexscripts.layout; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -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; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.TransformerHandler; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -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.commons.io.FileUtils; -import org.apache.commons.io.filefilter.AndFileFilter; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.NameFileFilter; -import org.apache.commons.io.filefilter.PrefixFileFilter; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.apache.commons.io.filefilter.TrueFileFilter; - -import org.apache.fop.DebugHelper; -import org.apache.fop.apps.EnvironmentProfile; -import org.apache.fop.apps.EnvironmentalProfileFactory; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.FopConfParser; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.FopFactoryBuilder; -import org.apache.fop.apps.FormattingResults; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.apps.PDFRendererConfBuilder; -import org.apache.fop.apps.io.ResourceResolverFactory; -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; -import org.apache.fop.intermediate.TestAssistant; -import org.apache.fop.layoutengine.ElementListCollector; -import org.apache.fop.layoutengine.LayoutEngineCheck; -import org.apache.fop.layoutengine.LayoutEngineChecksFactory; -import org.apache.fop.layoutengine.LayoutResult; -import org.apache.fop.layoutengine.TestFilesConfiguration; -import org.apache.fop.layoutmgr.ElementListObserver; -import org.apache.fop.render.Renderer; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFRenderer; -import org.apache.fop.render.intermediate.IFSerializer; -import org.apache.fop.render.xml.XMLRenderer; -import org.apache.fop.util.ConsoleEventListenerForTests; -import org.apache.fop.util.DelegatingContentHandler; - -// CSOFF: LineLengthCheck - -/** - * Test complex script layout (end-to-end) functionality. - */ -@RunWith(Parameterized.class) -public class ComplexScriptsLayoutTestCase { - - private static final boolean DEBUG = false; - private static final String AREA_TREE_OUTPUT_DIRECTORY = "build/test-results/complexscripts"; - private static File areaTreeOutputDir; - - private TestAssistant testAssistant = new TestAssistant(); - private LayoutEngineChecksFactory layoutEngineChecksFactory = new LayoutEngineChecksFactory(); - private TestFilesConfiguration testConfig; - private File testFile; - private IFTester ifTester; - private TransformerFactory tfactory = TransformerFactory.newInstance(); - - public ComplexScriptsLayoutTestCase(TestFilesConfiguration testConfig, File testFile) { - this.testConfig = testConfig; - this.testFile = testFile; - this.ifTester = new IFTester(tfactory, areaTreeOutputDir); - } - - @Parameters - public static Collection<Object[]> getParameters() throws IOException { - return getTestFiles(); - } - - @BeforeClass - public static void makeDirAndRegisterDebugHelper() throws IOException { - DebugHelper.registerStandardElementListObservers(); - areaTreeOutputDir = new File(AREA_TREE_OUTPUT_DIRECTORY); - if (!areaTreeOutputDir.mkdirs() && !areaTreeOutputDir.exists()) { - throw new IOException("Failed to create the AT output directory at " + AREA_TREE_OUTPUT_DIRECTORY); - } - } - - @Test - public void runTest() throws TransformerException, SAXException, IOException, ParserConfigurationException { - DOMResult domres = new DOMResult(); - ElementListCollector elCollector = new ElementListCollector(); - ElementListObserver.addObserver(elCollector); - Fop fop; - FopFactory effFactory; - EventsChecker eventsChecker = new EventsChecker(new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN)); - try { - Document testDoc = testAssistant.loadTestCase(testFile); - effFactory = getFopFactory(testConfig, testDoc); - // Setup Transformer to convert the testcase XML to XSL-FO - Transformer transformer = testAssistant.getTestcase2FOStylesheet().newTransformer(); - Source src = new DOMSource(testDoc); - // Setup Transformer to convert the area tree to a DOM - TransformerHandler athandler; - athandler = testAssistant.getTransformerFactory().newTransformerHandler(); - athandler.setResult(domres); - // Setup FOP for area tree rendering - FOUserAgent ua = effFactory.newFOUserAgent(); - ua.getEventBroadcaster().addEventListener(eventsChecker); - XMLRenderer atrenderer = new XMLRenderer(ua); - Renderer targetRenderer = ua.getRendererFactory().createRenderer(ua, MimeConstants.MIME_PDF); - atrenderer.mimicRenderer(targetRenderer); - atrenderer.setContentHandler(athandler); - ua.setRendererOverride(atrenderer); - fop = effFactory.newFop(ua); - SAXResult fores = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, fores); - } finally { - ElementListObserver.removeObserver(elCollector); - } - Document doc = (Document)domres.getNode(); - if (areaTreeOutputDir != null) { - testAssistant.saveDOM(doc, new File(areaTreeOutputDir, testFile.getName() + ".at.xml")); - } - FormattingResults results = fop.getResults(); - LayoutResult result = new LayoutResult(doc, elCollector, results); - checkAll(effFactory, testFile, result, eventsChecker); - } - - private FopFactory getFopFactory(TestFilesConfiguration testConfig, Document testDoc) throws SAXException, IOException { - EnvironmentProfile profile = EnvironmentalProfileFactory.createRestrictedIO( - testConfig.getTestDirectory().getParentFile().toURI(), - ResourceResolverFactory.createDefaultResourceResolver()); - InputStream confStream = - new FopConfBuilder().setStrictValidation(true) - .setFontBaseURI("test/resources/fonts/ttf/") - .startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .startFont(null, "DejaVuLGCSerif.ttf") - .addTriplet("DejaVu LGC Serif", "normal", "normal") - .endFont() - .endFontConfig() - .endRendererConfig().build(); - FopFactoryBuilder builder = - new FopConfParser(confStream, new File(".").toURI(), profile).getFopFactoryBuilder(); - // builder.setStrictFOValidation(isStrictValidation(testDoc)); - // builder.getFontManager().setBase14KerningEnabled(isBase14KerningEnabled(testDoc)); - return builder.build(); - } - - private void checkAll(FopFactory fopFactory, File testFile, LayoutResult result, EventsChecker eventsChecker) throws TransformerException { - Element testRoot = testAssistant.getTestRoot(testFile); - NodeList nodes; - nodes = testRoot.getElementsByTagName("at-checks"); - if (nodes.getLength() > 0) { - Element atChecks = (Element)nodes.item(0); - doATChecks(atChecks, result); - } - nodes = testRoot.getElementsByTagName("if-checks"); - if (nodes.getLength() > 0) { - Element ifChecks = (Element)nodes.item(0); - 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) throws TransformerException { - try { - FOUserAgent ua = fopFactory.newFOUserAgent(); - ua.getEventBroadcaster().addEventListener(new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN)); - IFRenderer ifRenderer = new IFRenderer(ua); - IFSerializer serializer = new IFSerializer(new IFContext(ua)); - DOMResult result = new DOMResult(); - serializer.setResult(result); - ifRenderer.setDocumentHandler(serializer); - ua.setRendererOverride(ifRenderer); - FontInfo fontInfo = new FontInfo(); - //Construct the AreaTreeModel that will received the individual pages - final AreaTreeModel treeModel = new RenderPagesModel(ua, null, fontInfo, null); - //Iterate over all intermediate files - AreaTreeParser parser = new AreaTreeParser(); - ContentHandler handler = parser.getContentHandler(treeModel, ua); - DelegatingContentHandler proxy = new DelegatingContentHandler() { - public void endDocument() throws SAXException { - super.endDocument(); - treeModel.endDocument(); - } - }; - proxy.setDelegateContentHandler(handler); - Transformer transformer = tfactory.newTransformer(); - transformer.transform(new DOMSource(areaTreeXML), new SAXResult(proxy)); - return (Document)result.getNode(); - } catch (Exception e) { - throw new TransformerException("Error while generating intermediate format file: " + e.getMessage(), e); - } - } - - private void doATChecks(Element checksRoot, LayoutResult result) { - List<LayoutEngineCheck> checks = layoutEngineChecksFactory.createCheckList(checksRoot); - if (checks.size() == 0) { - throw new RuntimeException("No available area tree check"); - } - for (LayoutEngineCheck check : checks) { - check.check(result); - } - } - - 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); - } - } - - private static Collection<Object[]> getTestFiles(TestFilesConfiguration testConfig) { - File mainDir = testConfig.getTestDirectory(); - IOFileFilter filter; - String single = testConfig.getSingleTest(); - String startsWith = testConfig.getStartsWith(); - if (single != null) { - filter = new NameFileFilter(single); - } else if (startsWith != null) { - filter = new PrefixFileFilter(startsWith); - filter = new AndFileFilter(filter, new SuffixFileFilter(testConfig.getFileSuffix())); - } else { - filter = new SuffixFileFilter(testConfig.getFileSuffix()); - } - String testset = testConfig.getTestSet(); - Collection<File> files = FileUtils.listFiles(new File(mainDir, testset), filter, TrueFileFilter.INSTANCE); - if (testConfig.hasPrivateTests()) { - Collection<File> privateFiles = - FileUtils.listFiles(new File(mainDir, "private-testcases"), filter, TrueFileFilter.INSTANCE); - files.addAll(privateFiles); - } - Collection<Object[]> parametersForJUnit4 = new ArrayList<Object[]>(); - int index = 0; - for (File f : files) { - parametersForJUnit4.add(new Object[] { testConfig, f }); - if (DEBUG) { - System.out.println(String.format("%3d %s", index++, f)); - } - } - return parametersForJUnit4; - } - - private static Collection<Object[]> getTestFiles() { - String testSet = System.getProperty("fop.complexscripts.testset"); - testSet = (testSet != null ? testSet : "standard") + "-testcases"; - return getTestFiles(testSet); - } - - private static Collection<Object[]> getTestFiles(String testSetName) { - TestFilesConfiguration.Builder builder = new TestFilesConfiguration.Builder(); - builder.testDir("test/resources/complexscripts/layout") - .singleProperty("fop.complexscripts.single") - .startsWithProperty("fop.complexscripts.starts-with") - .suffix(".xml") - .testSet(testSetName) - .privateTestsProperty("fop.complexscripts.private"); - return getTestFiles(builder.build()); - } - - private static class EventsChecker implements EventListener { - - private final List<Event> events = new ArrayList<Event>(); - private final EventListener defaultListener; - - 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); - } - } - } - -} diff --git a/test/java/org/apache/fop/complexscripts/layout/ComplexScriptsLayoutTestSuite.java b/test/java/org/apache/fop/complexscripts/layout/ComplexScriptsLayoutTestSuite.java deleted file mode 100644 index e55ead635..000000000 --- a/test/java/org/apache/fop/complexscripts/layout/ComplexScriptsLayoutTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.complexscripts.layout; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for running complex script layout tests under JUnit control. - */ -@RunWith(Suite.class) -@SuiteClasses(ComplexScriptsLayoutTestCase.class) -public class ComplexScriptsLayoutTestSuite { -} diff --git a/test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java b/test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java deleted file mode 100644 index 27914450a..000000000 --- a/test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.complexscripts.scripts; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.apache.fop.complexscripts.scripts.arabic.ArabicJoinersTestCase; -import org.apache.fop.complexscripts.scripts.arabic.ArabicWordFormsTestCase; - -/** - * Test suite for script specific functionality related to complex scripts. - */ -@RunWith(Suite.class) -@SuiteClasses({ - ArabicJoinersTestCase.class, - ArabicWordFormsTestCase.class -}) -public class ScriptsTestSuite { -} diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicJoinersTestCase.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicJoinersTestCase.java deleted file mode 100644 index 092bebd41..000000000 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicJoinersTestCase.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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.complexscripts.scripts.arabic; - -import java.nio.IntBuffer; -import java.util.BitSet; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -import org.apache.fop.complexscripts.scripts.ScriptProcessor; -import org.apache.fop.complexscripts.util.CharScript; -import org.apache.fop.complexscripts.util.GlyphContextTester; -import org.apache.fop.complexscripts.util.GlyphSequence; -import org.apache.fop.complexscripts.util.ScriptContextTester; -import org.apache.fop.complexscripts.util.UTF32; - -// CSOFF: LineLength - -/** - * Tests for joiner (ZWJ, ZWNJ) functionality related to the arabic script. - */ -public class ArabicJoinersTestCase { - - private static final String[][] ZWJ_TESTS_ISOL = new String[][] { - { "\u0643", "1", }, - { "\u0643\u200D", "00", }, - { "\u200D\u0643", "00", }, - { "\u200D\u0643\u200D", "000", }, - }; - - private static final String[][] ZWJ_TESTS_INIT = new String[][] { - { "\u0643", "0", }, - { "\u0643\u200D", "10", }, - { "\u200D\u0643", "00", }, - { "\u200D\u0643\u200D", "000", }, - }; - - private static final String[][] ZWJ_TESTS_MEDI = new String[][] { - { "\u0643", "0", }, - { "\u0643\u200D", "00", }, - { "\u200D\u0643", "00", }, - { "\u200D\u0643\u200D", "010", }, - }; - - private static final String[][] ZWJ_TESTS_FINA = new String[][] { - { "\u0643", "0", }, - { "\u0643\u200D", "00", }, - { "\u200D\u0643", "01", }, - { "\u200D\u0643\u200D", "000", }, - }; - - private static final String[][] ZWJ_TESTS_LIGA = new String[][] { - }; - - @Test - public void testArabicJoiners() { - String script = CharScript.scriptTagFromCode(CharScript.SCRIPT_ARABIC); - ScriptProcessor sp = ScriptProcessor.getInstance(script); - assertTrue(sp != null); - ScriptContextTester sct = sp.getSubstitutionContextTester(); - assertTrue(sct != null); - String language = "dflt"; - int flags = 0; - testZWJ(sct, script, language, "isol", flags, ZWJ_TESTS_ISOL); - testZWJ(sct, script, language, "init", flags, ZWJ_TESTS_INIT); - testZWJ(sct, script, language, "medi", flags, ZWJ_TESTS_MEDI); - testZWJ(sct, script, language, "fina", flags, ZWJ_TESTS_FINA); - testZWJ(sct, script, language, "liga", flags, ZWJ_TESTS_LIGA); - } - - private void testZWJ(ScriptContextTester sct, String script, String language, String feature, int flags, String[][] tests) { - GlyphContextTester gct = sct.getTester(feature); - assertTrue(gct != null); - for (String[] t : tests) { - testZWJ(gct, script, language, feature, flags, t); - } - } - - private void testZWJ(GlyphContextTester gct, String script, String language, String feature, int flags, String[] test) { - assert test.length == 2; - String str = test[0]; - BitSet act = new BitSet(); - GlyphSequence gs = makeGlyphSequence(str); - for (int i = 0, n = str.length(); i < n; ++i) { - if (gct.test(script, language, feature, gs, i, flags)) { - act.set(i); - } - } - BitSet exp = parseBitSet(test[1]); - assertTrue(act.equals(exp)); - } - - private GlyphSequence makeGlyphSequence(String s) { - Integer[] ca = UTF32.toUTF32(s, 0, true); - IntBuffer cb = IntBuffer.allocate(ca.length); - for (Integer c : ca) { - cb.put(c); - } - cb.rewind(); - return new GlyphSequence(cb, null, null); - } - - private BitSet parseBitSet(String s) { - BitSet bits = new BitSet(); - for (int i = 0, n = s.length(); i < n; ++i) { - char c = s.charAt(i); - assert (c == '0') || (c == '1'); - if (c == '1') { - bits.set(i); - } - } - return bits; - } - - @Test - public void testArabicNonJoiners() { - } - -} diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicWordFormsConstants.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicWordFormsConstants.java deleted file mode 100644 index 41094b687..000000000 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicWordFormsConstants.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.complexscripts.scripts.arabic; - -/** - * Constants for test functionality related to the arabic script. - */ -public interface ArabicWordFormsConstants { - - String WF_FILE_SCRIPT = "arab"; - String WF_FILE_LANGUAGE = "dflt"; - - String SRC_FILES_DIR = "test/resources/complexscripts/arab/data"; - String DAT_FILES_DIR = "test/resources/complexscripts/arab/data"; - - String[] SRC_FILES = { - "arab-001", // unpointed word forms - }; - - String WF_FILE_SRC_EXT = "txt"; - String WF_FILE_DAT_EXT = "ser"; - - String TTX_FONTS_DIR = "test/resources/complexscripts/arab/ttx"; - - String[] TTX_FONTS = { - "arab-001.ttx", // simplified arabic - "arab-002.ttx", // traditional arabic - "arab-003.ttx", // lateef - "arab-004.ttx", // scheherazade - }; - -} diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicWordFormsTestCase.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicWordFormsTestCase.java deleted file mode 100644 index abe4f513a..000000000 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicWordFormsTestCase.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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.complexscripts.scripts.arabic; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.nio.IntBuffer; -import java.util.List; - -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. - */ -public class ArabicWordFormsTestCase implements ArabicWordFormsConstants { - - @Test - public void testArabicWordForms() { - for (String sfn : SRC_FILES) { - try { - processWordForms(new File(DAT_FILES_DIR)); - } catch (Exception e) { - fail(e.getMessage()); - } - } - } - - private void processWordForms(File dfd) { - String[] files = listWordFormFiles(dfd); - for (String fn : files) { - File dff = new File(dfd, fn); - processWordForms(dff.getAbsolutePath()); - } - } - - private String[] listWordFormFiles(File dfd) { - return dfd.list(new FilenameFilter() { - public boolean accept(File f, String name) { - return hasPrefixFrom(name, SRC_FILES) && hasExtension(name, WF_FILE_DAT_EXT); - } - private boolean hasPrefixFrom(String name, String[] prefixes) { - for (String p : prefixes) { - if (name.startsWith(p)) { - return true; - } - } - return false; - } - private boolean hasExtension(String name, String extension) { - return name.endsWith("." + extension); - } - }); - } - - private void processWordForms(String dpn) { - FileInputStream fis = null; - try { - fis = new FileInputStream(dpn); - if (fis != null) { - ObjectInputStream ois = new ObjectInputStream(fis); - List<Object[]> data = (List<Object[]>) ois.readObject(); - if (data != null) { - processWordForms(data); - } - ois.close(); - } - } catch (FileNotFoundException e) { - throw new RuntimeException(e.getMessage(), e); - } catch (IOException e) { - throw new RuntimeException(e.getMessage(), e); - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); - } finally { - if (fis != null) { - try { fis.close(); } catch (Exception e) { /* NOP */ } - } - } - } - - private void processWordForms(List<Object[]> data) { - assert data != null; - assert data.size() > 0; - String script = null; - String language = null; - String tfn = null; - TTXFile tf = null; - GlyphSubstitutionTable gsub = null; - GlyphPositioningTable gpos = null; - int[] widths = null; - for (Object[] d : data) { - if (script == null) { - assert d.length >= 4; - script = (String) d[0]; - language = (String) d[1]; - tfn = (String) d[3]; - tf = TTXFile.getFromCache(TTX_FONTS_DIR + File.separator + tfn); - assertTrue(tf != null); - gsub = tf.getGSUB(); - assertTrue(gsub != null); - gpos = tf.getGPOS(); - assertTrue(gpos != null); - widths = tf.getWidths(); - assertTrue(widths != null); - } else { - assert tf != null; - assert gsub != null; - assert gpos != null; - assert tfn != null; - assert d.length >= 4; - String wf = (String) d[0]; - int[] iga = (int[]) d[1]; - int[] oga = (int[]) d[2]; - int[][] paa = (int[][]) d[3]; - GlyphSequence tigs = tf.mapCharsToGlyphs(wf); - assertSameGlyphs(iga, getGlyphs(tigs), "input glyphs", wf, tfn); - GlyphSequence togs = gsub.substitute(tigs, script, language); - assertSameGlyphs(oga, getGlyphs(togs), "output glyphs", wf, tfn); - int[][] tpaa = new int [ togs.getGlyphCount() ] [ 4 ]; - if (gpos.position(togs, script, language, 1000, widths, tpaa)) { - assertSameAdjustments(paa, tpaa, wf, tfn); - } else if (paa != null) { - assertEquals("unequal adjustment count, word form(" + wf + "), font (" + tfn + ")", paa.length, 0); - } - } - } - } - - private void assertSameGlyphs(int[] expected, int[] actual, String label, String wf, String tfn) { - assertEquals(label + ": unequal glyph count, word form(" + wf + "), font (" + tfn + ")", expected.length, actual.length); - for (int i = 0, n = expected.length; i < n; i++) { - int e = expected[i]; - int a = actual[i]; - assertEquals(label + ": unequal glyphs[" + i + "], word form(" + wf + "), font (" + tfn + ")", e, a); - } - } - - private void assertSameAdjustments(int[][] expected, int[][] actual, String wf, String tfn) { - assertEquals("unequal adjustment count, word form(" + wf + "), font (" + tfn + ")", expected.length, actual.length); - for (int i = 0, n = expected.length; i < n; i++) { - int[] ea = expected[i]; - int[] aa = actual[i]; - assertEquals("bad adjustments length, word form(" + wf + "), font (" + tfn + ")", ea.length, aa.length); - for (int k = 0; k < 4; k++) { - int e = ea[k]; - int a = aa[k]; - assertEquals("unequal adjustment[" + i + "][" + k + "], word form(" + wf + "), font (" + tfn + ")", e, a); - } - } - } - - private static int[] getGlyphs(GlyphSequence gs) { - IntBuffer gb = gs.getGlyphs(); - int[] ga = new int [ gb.limit() ]; - gb.rewind(); - gb.get(ga); - return ga; - } - -} diff --git a/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java b/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java deleted file mode 100644 index 35bfb3128..000000000 --- a/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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.complexscripts.scripts.arabic; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.LineNumberReader; -import java.io.ObjectOutputStream; -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; - -/** - * Tests for functionality related to the arabic script. - */ -public final class GenerateArabicTestData implements ArabicWordFormsConstants { - - private GenerateArabicTestData() { - } - - public static void main(String[] args) { - boolean compile = false; - boolean help = false; - for (String a : args) { - if (a.equals("-c")) { - compile = true; - } - if (a.equals("-?")) { - help = true; - } - } - if (help) { - help(); - } else if (compile) { - compile(); - } - } - - private static void help() { - StringBuffer sb = new StringBuffer(); - sb.append("org.apache.fop.complexscripts.arabic.ArabicTestCase"); - sb.append(" [-compile]"); - sb.append(" [-?]"); - System.out.println(sb.toString()); - } - - private static void compile() { - for (String sfn : SRC_FILES) { - try { - 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()); - } - } - } - - private static void compile(String script, String language, String spn) { - int fno = 0; - 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); - } - } - - private static List compile(String script, String language, String spn, String tfn, TTXFile tf) { - List<Object[]> data = new ArrayList<Object[]>(); - data.add(new Object[] { script, language, spn, tfn }); - GlyphSubstitutionTable gsub = tf.getGSUB(); - GlyphPositioningTable gpos = tf.getGPOS(); - int[] widths = tf.getWidths(); - if ((gsub != null) && (gpos != null)) { - FileInputStream fis = null; - try { - fis = new FileInputStream(spn); - if (fis != null) { - LineNumberReader lr = new LineNumberReader(new InputStreamReader(fis, Charset.forName("UTF-8"))); - String wf; - while ((wf = lr.readLine()) != null) { - 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)) { - paa = null; - } - data.add(new Object[] { wf, getGlyphs(igs), getGlyphs(ogs), paa }); - } - lr.close(); - } - } catch (FileNotFoundException e) { - throw new RuntimeException(e.getMessage(), e); - } catch (IOException e) { - throw new RuntimeException(e.getMessage(), e); - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); - } finally { - if (fis != null) { - try { fis.close(); } catch (Exception e) { /* NOP */ } - } - } - } else { - assert gsub != null; - assert gpos != null; - } - System.err.println("compiled " + (data.size() - 1) + " word forms using font " + tfn); - return data; - } - - private static int[] getGlyphs(GlyphSequence gs) { - IntBuffer gb = gs.getGlyphs(); - int[] ga = new int [ gb.limit() ]; - gb.rewind(); - gb.get(ga); - return ga; - } - - private static String makeDataPathName(String spn, int fno) { - File f = new File(spn); - return DAT_FILES_DIR + File.separator + stripExtension(f.getName()) + "-f" + fno + "." + WF_FILE_DAT_EXT; - } - - private static String stripExtension(String s) { - int i = s.lastIndexOf('.'); - if (i >= 0) { - return s.substring(0, i); - } else { - return s; - } - } - - private static void output(String dpn, List<Object[]> data) { - FileOutputStream fos = null; - try { - fos = new FileOutputStream(dpn); - if (fos != null) { - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(data); - oos.close(); - } - } catch (FileNotFoundException e) { - throw new RuntimeException(e.getMessage(), e); - } catch (IOException e) { - throw new RuntimeException(e.getMessage(), e); - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); - } finally { - if (fos != null) { - 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 deleted file mode 100644 index 4e1db5fb3..000000000 --- a/test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java +++ /dev/null @@ -1,1562 +0,0 @@ -/* - * 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.complexscripts.util; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -// CSOFF: LineLengthCheck - -/** - * Test number converter functionality. - */ -public class NumberConverterTestCase { - - private static String[][] formatDecimal = - { - { "1" }, - { "0", "0" }, - { "1", "1" }, - { "1000", "1000" }, - { "1000000", "1000000" }, - { "1000000000", "1000000000" }, - }; - - private static String[][] formatDecimalPadded = - { - { "001" }, - { "0", "000" }, - { "1", "001" }, - { "9", "009" }, - { "10", "010" }, - { "99", "099" }, - { "100", "100" }, - { "999", "999" }, - { "1000", "1000" }, - }; - - private static String[][] formatDecimalGrouped = - { - { "1", ",", "1" }, - { "0", "0" }, - { "1", "1" }, - { "1000", "1,0,0,0" }, - { "1000000", "1,0,0,0,0,0,0" }, - { "1000000000", "1,0,0,0,0,0,0,0,0,0" }, - }; - - private static String[][] formatDecimalGroupedPadded = - { - { "001", ",", "2" }, - { "0", "0,00" }, - { "1", "0,01" }, - { "9", "0,09" }, - { "10", "0,10" }, - { "99", "0,99" }, - { "100", "1,00" }, - { "999", "9,99" }, - { "1000", "10,00" }, - }; - - private static String[][] formatDecimalArabic = - { - { "\u0661" }, - { "0", "\u0660" }, - { "1", "\u0661" }, - { "2", "\u0662" }, - { "3", "\u0663" }, - { "4", "\u0664" }, - { "5", "\u0665" }, - { "6", "\u0666" }, - { "7", "\u0667" }, - { "8", "\u0668" }, - { "9", "\u0669" }, - { "10", "\u0661\u0660" }, - { "1000", "\u0661\u0660\u0660\u0660" }, - { "1000000", "\u0661\u0660\u0660\u0660\u0660\u0660\u0660" }, - { "1000000000", "\u0661\u0660\u0660\u0660\u0660\u0660\u0660\u0660\u0660\u0660" }, - }; - - private static String[][] formatDecimalArabicPadded = - { - { "\u0660\u0660\u0661" }, - { "0", "\u0660\u0660\u0660" }, - { "1", "\u0660\u0660\u0661" }, - { "9", "\u0660\u0660\u0669" }, - { "10", "\u0660\u0661\u0660" }, - { "99", "\u0660\u0669\u0669" }, - { "100", "\u0661\u0660\u0660" }, - { "999", "\u0669\u0669\u0669" }, - { "1000", "\u0661\u0660\u0660\u0660" }, - }; - - private static String[][] formatDecimalArabicGrouped = - { - { "\u0661", "\u066c", "1" }, - { "0", "\u0660" }, - { "1", "\u0661" }, - { "1000", "\u0661\u066c\u0660\u066c\u0660\u066c\u0660" }, - { "1000000", "\u0661\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660" }, - { "1000000000", "\u0661\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660\u066c\u0660" }, - }; - - private static String[][] formatDecimalArabicGroupedPadded = - { - { "\u0660\u0660\u0661", "\u066c", "2" }, - { "0", "\u0660\u066c\u0660\u0660" }, - { "1", "\u0660\u066c\u0660\u0661" }, - { "9", "\u0660\u066c\u0660\u0669" }, - { "10", "\u0660\u066c\u0661\u0660" }, - { "99", "\u0660\u066c\u0669\u0669" }, - { "100", "\u0661\u066c\u0660\u0660" }, - { "999", "\u0669\u066c\u0669\u0669" }, - { "1000", "\u0661\u0660\u066c\u0660\u0660" }, - }; - - private static String[][] formatDecimalThai = - { - { "\u0E51" }, - { "0", "\u0E50" }, - { "1", "\u0E51" }, - { "2", "\u0E52" }, - { "3", "\u0E53" }, - { "4", "\u0E54" }, - { "5", "\u0E55" }, - { "6", "\u0E56" }, - { "7", "\u0E57" }, - { "8", "\u0E58" }, - { "9", "\u0E59" }, - { "10", "\u0E51\u0E50" }, - { "1000", "\u0E51\u0E50\u0E50\u0E50" }, - { "1000000", "\u0E51\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50" }, - { "1000000000", "\u0E51\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50" }, - }; - - private static String[][] formatDecimalThaiPadded = - { - { "\u0E50\u0E50\u0E51" }, - { "0", "\u0E50\u0E50\u0E50" }, - { "1", "\u0E50\u0E50\u0E51" }, - { "9", "\u0E50\u0E50\u0E59" }, - { "10", "\u0E50\u0E51\u0E50" }, - { "99", "\u0E50\u0E59\u0E59" }, - { "100", "\u0E51\u0E50\u0E50" }, - { "999", "\u0E59\u0E59\u0E59" }, - { "1000", "\u0E51\u0E50\u0E50\u0E50" }, - }; - - private static String[][] formatRomanLower = - { - { "i" }, - { "0", "0" }, - { "1", "i" }, - { "2", "ii" }, - { "3", "iii" }, - { "4", "iv" }, - { "5", "v" }, - { "6", "vi" }, - { "7", "vii" }, - { "8", "viii" }, - { "9", "ix" }, - { "10", "x" }, - { "20", "xx" }, - { "30", "xxx" }, - { "40", "xl" }, - { "50", "l" }, - { "60", "lx" }, - { "70", "lxx" }, - { "80", "lxxx" }, - { "90", "xc" }, - { "100", "c" }, - { "200", "cc" }, - { "300", "ccc" }, - { "400", "cd" }, - { "500", "d" }, - { "600", "dc" }, - { "700", "dcc" }, - { "800", "dccc" }, - { "900", "cm" }, - { "1000", "m" }, - { "2000", "mm" }, - { "2011", "mmxi" }, - { "4999", "mmmmcmxcix" }, - { "5000", "5000" }, - }; - - private static String[][] formatRomanUpper = - { - - { "I" }, - { "0", "0" }, - { "1", "I" }, - { "2", "II" }, - { "3", "III" }, - { "4", "IV" }, - { "5", "V" }, - { "6", "VI" }, - { "7", "VII" }, - { "8", "VIII" }, - { "9", "IX" }, - { "10", "X" }, - { "20", "XX" }, - { "30", "XXX" }, - { "40", "XL" }, - { "50", "L" }, - { "60", "LX" }, - { "70", "LXX" }, - { "80", "LXXX" }, - { "90", "XC" }, - { "100", "C" }, - { "200", "CC" }, - { "300", "CCC" }, - { "400", "CD" }, - { "500", "D" }, - { "600", "DC" }, - { "700", "DCC" }, - { "800", "DCCC" }, - { "900", "CM" }, - { "1000", "M" }, - { "2000", "MM" }, - { "2011", "MMXI" }, - { "4999", "MMMMCMXCIX" }, - { "5000", "5000" }, - }; - - private static String[][] formatRomanLargeLower = - { - { "i", null, null, null, "large" }, - { "0", "0" }, - { "1", "i" }, - { "2", "ii" }, - { "3", "iii" }, - { "4", "iv" }, - { "5", "v" }, - { "6", "vi" }, - { "7", "vii" }, - { "8", "viii" }, - { "9", "ix" }, - { "10", "x" }, - { "20", "xx" }, - { "30", "xxx" }, - { "40", "xl" }, - { "50", "l" }, - { "60", "lx" }, - { "70", "lxx" }, - { "80", "lxxx" }, - { "90", "xc" }, - { "100", "c" }, - { "200", "cc" }, - { "300", "ccc" }, - { "400", "cd" }, - { "500", "d" }, - { "600", "dc" }, - { "700", "dcc" }, - { "800", "dccc" }, - { "900", "cm" }, - { "1000", "m" }, - { "2000", "mm" }, - { "2011", "mmxi" }, - { "4999", "\u2180\u2181cmxcix" }, - { "5000", "\u2181" }, - { "5001", "\u2181i" }, - { "9999", "\u2180\u2182cmxcix" }, - { "10000", "\u2182" }, - { "10001", "\u2182i" }, - { "49999", "\u2182\u2187\u2180\u2182cmxcix" }, - { "99999", "\u2182\u2188\u2180\u2182cmxcix" }, - { "100000", "\u2188" }, - { "100001", "\u2188i" }, - { "199999", "\u2188\u2182\u2188\u2180\u2182cmxcix" }, - { "200000", "200000" }, - }; - - private static String[][] formatRomanLargeUpper = - { - { "I", null, null, null, "large" }, - { "0", "0" }, - { "1", "I" }, - { "2", "II" }, - { "3", "III" }, - { "4", "IV" }, - { "5", "V" }, - { "6", "VI" }, - { "7", "VII" }, - { "8", "VIII" }, - { "9", "IX" }, - { "10", "X" }, - { "20", "XX" }, - { "30", "XXX" }, - { "40", "XL" }, - { "50", "L" }, - { "60", "LX" }, - { "70", "LXX" }, - { "80", "LXXX" }, - { "90", "XC" }, - { "100", "C" }, - { "200", "CC" }, - { "300", "CCC" }, - { "400", "CD" }, - { "500", "D" }, - { "600", "DC" }, - { "700", "DCC" }, - { "800", "DCCC" }, - { "900", "CM" }, - { "1000", "M" }, - { "2000", "MM" }, - { "2011", "MMXI" }, - { "4999", "\u2180\u2181CMXCIX" }, - { "5000", "\u2181" }, - { "5001", "\u2181I" }, - { "9999", "\u2180\u2182CMXCIX" }, - { "10000", "\u2182" }, - { "10001", "\u2182I" }, - { "49999", "\u2182\u2187\u2180\u2182CMXCIX" }, - { "99999", "\u2182\u2188\u2180\u2182CMXCIX" }, - { "100000", "\u2188" }, - { "100001", "\u2188I" }, - { "199999", "\u2188\u2182\u2188\u2180\u2182CMXCIX" }, - { "200000", "200000" }, - }; - - private static String[][] formatRomanNumberFormsLower = - { - { "i", null, null, null, "unicode-number-forms" }, - { "0", "0" }, - { "1", "\u2170" }, - { "2", "\u2171" }, - { "3", "\u2172" }, - { "4", "\u2173" }, - { "5", "\u2174" }, - { "6", "\u2175" }, - { "7", "\u2176" }, - { "8", "\u2177" }, - { "9", "\u2178" }, - { "10", "\u2179" }, - { "11", "\u2179\u2170" }, - { "12", "\u2179\u2171" }, - { "13", "\u2179\u2172" }, - { "14", "\u2179\u2173" }, - { "15", "\u2179\u2174" }, - { "16", "\u2179\u2175" }, - { "17", "\u2179\u2176" }, - { "18", "\u2179\u2177" }, - { "19", "\u2179\u2178" }, - { "20", "\u2179\u2179" }, - { "30", "\u2179\u2179\u2179" }, - { "40", "\u2179\u217C" }, - { "50", "\u217C" }, - { "60", "\u217C\u2179" }, - { "70", "\u217C\u2179\u2179" }, - { "80", "\u217C\u2179\u2179\u2179" }, - { "90", "\u2179\u217D" }, - { "100", "\u217D" }, - { "200", "\u217D\u217D" }, - { "300", "\u217D\u217D\u217D" }, - { "400", "\u217D\u217E" }, - { "500", "\u217E" }, - { "600", "\u217E\u217D" }, - { "700", "\u217E\u217D\u217D" }, - { "800", "\u217E\u217D\u217D\u217D" }, - { "900", "\u217D\u217F" }, - { "999", "\u217D\u217F\u2179\u217D\u2178" }, - { "1000", "\u217F" }, - { "2000", "\u217F\u217F" }, - { "2011", "\u217F\u217F\u2179\u2170" }, - { "4999", "\u2180\u2181\u217D\u217F\u2179\u217D\u2178" }, - { "5000", "\u2181" }, - { "5001", "\u2181\u2170" }, - { "9999", "\u2180\u2182\u217D\u217F\u2179\u217D\u2178" }, - { "10000", "\u2182" }, - { "10001", "\u2182\u2170" }, - { "49999", "\u2182\u2187\u2180\u2182\u217D\u217F\u2179\u217D\u2178" }, - { "99999", "\u2182\u2188\u2180\u2182\u217D\u217F\u2179\u217D\u2178" }, - { "100000", "\u2188" }, - { "100001", "\u2188\u2170" }, - { "199999", "\u2188\u2182\u2188\u2180\u2182\u217D\u217F\u2179\u217D\u2178" }, - { "200000", "200000" }, - }; - - private static String[][] formatRomanNumberFormsUpper = - { - { "I", null, null, null, "unicode-number-forms" }, - { "0", "0" }, - { "1", "\u2160" }, - { "2", "\u2161" }, - { "3", "\u2162" }, - { "4", "\u2163" }, - { "5", "\u2164" }, - { "6", "\u2165" }, - { "7", "\u2166" }, - { "8", "\u2167" }, - { "9", "\u2168" }, - { "10", "\u2169" }, - { "11", "\u2169\u2160" }, - { "12", "\u2169\u2161" }, - { "13", "\u2169\u2162" }, - { "14", "\u2169\u2163" }, - { "15", "\u2169\u2164" }, - { "16", "\u2169\u2165" }, - { "17", "\u2169\u2166" }, - { "18", "\u2169\u2167" }, - { "19", "\u2169\u2168" }, - { "20", "\u2169\u2169" }, - { "30", "\u2169\u2169\u2169" }, - { "40", "\u2169\u216C" }, - { "50", "\u216C" }, - { "60", "\u216C\u2169" }, - { "70", "\u216C\u2169\u2169" }, - { "80", "\u216C\u2169\u2169\u2169" }, - { "90", "\u2169\u216D" }, - { "100", "\u216D" }, - { "200", "\u216D\u216D" }, - { "300", "\u216D\u216D\u216D" }, - { "400", "\u216D\u216E" }, - { "500", "\u216E" }, - { "600", "\u216E\u216D" }, - { "700", "\u216E\u216D\u216D" }, - { "800", "\u216E\u216D\u216D\u216D" }, - { "900", "\u216D\u216F" }, - { "999", "\u216D\u216F\u2169\u216D\u2168" }, - { "1000", "\u216F" }, - { "2000", "\u216F\u216F" }, - { "2011", "\u216F\u216F\u2169\u2160" }, - { "4999", "\u2180\u2181\u216D\u216F\u2169\u216D\u2168" }, - { "5000", "\u2181" }, - { "5001", "\u2181\u2160" }, - { "9999", "\u2180\u2182\u216D\u216F\u2169\u216D\u2168" }, - { "10000", "\u2182" }, - { "10001", "\u2182\u2160" }, - { "49999", "\u2182\u2187\u2180\u2182\u216D\u216F\u2169\u216D\u2168" }, - { "99999", "\u2182\u2188\u2180\u2182\u216D\u216F\u2169\u216D\u2168" }, - { "100000", "\u2188" }, - { "100001", "\u2188\u2160" }, - { "199999", "\u2188\u2182\u2188\u2180\u2182\u216D\u216F\u2169\u216D\u2168" }, - { "200000", "200000" }, - }; - - private static String[][] formatAlphabeticLatinLower = - { - { "a" }, - { "0", "0" }, - { "1", "a" }, - { "2", "b" }, - { "3", "c" }, - { "10", "j" }, - { "20", "t" }, - { "26", "z" }, - { "27", "aa" }, - { "28", "ab" }, - { "29", "ac" }, - { "52", "az" }, - { "53", "ba" }, - { "702", "zz" }, - { "703", "aaa" }, - { "999999", "bdwgm" }, - { "1000000", "bdwgn" }, - }; - - private static String[][] formatAlphabeticLatinUpper = - { - { "A" }, - { "0", "0" }, - { "1", "A" }, - { "2", "B" }, - { "3", "C" }, - { "10", "J" }, - { "20", "T" }, - { "26", "Z" }, - { "27", "AA" }, - { "28", "AB" }, - { "29", "AC" }, - { "52", "AZ" }, - { "53", "BA" }, - { "702", "ZZ" }, - { "703", "AAA" }, - { "999999", "BDWGM" }, - { "1000000", "BDWGN" }, - }; - - private static String[][] formatAlphabeticArabicHijai = - { - { "\u0627", null, null, "alphabetic" }, - { "0", "0" }, - { "1", "\u0623" }, - { "2", "\u0628" }, - { "3", "\u062A" }, - { "4", "\u062B" }, - { "5", "\u062C" }, - { "6", "\u062D" }, - { "7", "\u062E" }, - { "8", "\u062F" }, - { "9", "\u0630" }, - { "10", "\u0631" }, - { "11", "\u0632" }, - { "12", "\u0633" }, - { "13", "\u0634" }, - { "14", "\u0635" }, - { "15", "\u0636" }, - { "16", "\u0637" }, - { "17", "\u0638" }, - { "18", "\u0639" }, - { "19", "\u063A" }, - { "20", "\u0641" }, - { "21", "\u0642" }, - { "22", "\u0643" }, - { "23", "\u0644" }, - { "24", "\u0645" }, - { "25", "\u0646" }, - { "26", "\u0647" }, - { "27", "\u0648" }, - { "28", "\u0649" }, - { "29", "\u0623\u0623" }, - { "56", "\u0623\u0649" }, - { "57", "\u0628\u0623" }, - { "812", "\u0649\u0649" }, - { "813", "\u0623\u0623\u0623" }, - { "999999", "\u0623\u0638\u0636\u0635\u062E" }, - { "1000000", "\u0623\u0638\u0636\u0635\u062F" }, - }; - - private static String[][] formatAlphabeticArabicAbjadi = - { - { "\u0627", null, null, "traditional" }, - { "0", "0" }, - { "1", "\u0623" }, - { "2", "\u0628" }, - { "3", "\u062C" }, - { "4", "\u062F" }, - { "5", "\u0647" }, - { "6", "\u0648" }, - { "7", "\u0632" }, - { "8", "\u062D" }, - { "9", "\u0637" }, - { "10", "\u0649" }, - { "11", "\u0643" }, - { "12", "\u0644" }, - { "13", "\u0645" }, - { "14", "\u0646" }, - { "15", "\u0633" }, - { "16", "\u0639" }, - { "17", "\u0641" }, - { "18", "\u0635" }, - { "19", "\u0642" }, - { "20", "\u0631" }, - { "21", "\u0634" }, - { "22", "\u062A" }, - { "23", "\u062B" }, - { "24", "\u062E" }, - { "25", "\u0630" }, - { "26", "\u0636" }, - { "27", "\u0638" }, - { "28", "\u063A" }, - { "29", "\u0623\u0623" }, - { "56", "\u0623\u063A" }, - { "57", "\u0628\u0623" }, - { "812", "\u063A\u063A" }, - { "813", "\u0623\u0623\u0623" }, - { "999999", "\u0623\u0641\u0633\u0646\u0632" }, - { "1000000", "\u0623\u0641\u0633\u0646\u062D" }, - }; - - private static String[][] formatNumeralArabicAbjadi = - { - { "\u0623", null, null, "traditional" }, - { "0", "0" }, - { "1", "\u0623" }, - { "2", "\u0628" }, - { "3", "\u062C" }, - { "4", "\u062F" }, - { "5", "\u0647" }, - { "6", "\u0648" }, - { "7", "\u0632" }, - { "8", "\u062D" }, - { "9", "\u0637" }, - { "10", "\u0649" }, - { "11", "\u0649\u0623" }, - { "12", "\u0649\u0628" }, - { "13", "\u0649\u062C" }, - { "14", "\u0649\u062F" }, - { "15", "\u0649\u0647" }, - { "16", "\u0649\u0648" }, - { "17", "\u0649\u0632" }, - { "18", "\u0649\u062D" }, - { "19", "\u0649\u0637" }, - { "20", "\u0643" }, - { "30", "\u0644" }, - { "40", "\u0645" }, - { "50", "\u0646" }, - { "60", "\u0633" }, - { "70", "\u0639" }, - { "80", "\u0641" }, - { "90", "\u0635" }, - { "99", "\u0635\u0637" }, - { "100", "\u0642" }, - { "101", "\u0642\u0623" }, - { "200", "\u0631" }, - { "300", "\u0634" }, - { "400", "\u062A" }, - { "500", "\u062B" }, - { "600", "\u062E" }, - { "700", "\u0630" }, - { "800", "\u0636" }, - { "900", "\u0638" }, - { "999", "\u0638\u0635\u0637" }, - { "1000", "\u063A" }, - { "1999", "\u063A\u0638\u0635\u0637" }, - { "2000", "2000" }, - }; - - private static String[][] formatAlphabeticHebrew = - { - { "\u05D0", null, null, "alphabetic" }, - { "0", "0" }, - { "1", "\u05D0" }, - { "2", "\u05D1" }, - { "3", "\u05D2" }, - { "4", "\u05D3" }, - { "5", "\u05D4" }, - { "6", "\u05D5" }, - { "7", "\u05D6" }, - { "8", "\u05D7" }, - { "9", "\u05D8" }, - { "10", "\u05D9" }, - { "11", "\u05DB" }, - { "12", "\u05DC" }, - { "13", "\u05DE" }, - { "14", "\u05E0" }, - { "15", "\u05E1" }, - { "16", "\u05E2" }, - { "17", "\u05E4" }, - { "18", "\u05E6" }, - { "19", "\u05E7" }, - { "20", "\u05E8" }, - { "21", "\u05E9" }, - { "22", "\u05EA" }, - { "23", "\u05DA" }, - { "24", "\u05DD" }, - { "25", "\u05DF" }, - { "26", "\u05E3" }, - { "27", "\u05E5" }, - { "28", "\u05D0\u05D0" }, - { "54", "\u05D0\u05E5" }, - { "55", "\u05D1\u05D0" }, - { "756", "\u05E5\u05E5" }, - { "757", "\u05D0\u05D0\u05D0" }, - { "999999", "\u05D0\u05DA\u05E9\u05E7\u05E5" }, - { "1000000", "\u05D0\u05DA\u05E9\u05E8\u05D0" }, - }; - - private static String[][] formatNumeralHebrewGematria = - { - { "\u05D0", null, null, "traditional" }, - { "0", "0" }, - { "1", "\u05D0" }, - { "2", "\u05D1" }, - { "3", "\u05D2" }, - { "4", "\u05D3" }, - { "5", "\u05D4" }, - { "6", "\u05D5" }, - { "7", "\u05D6" }, - { "8", "\u05D7" }, - { "9", "\u05D8" }, - { "10", "\u05D9" }, - { "11", "\u05D9\u05D0" }, - { "12", "\u05D9\u05D1" }, - { "13", "\u05D9\u05D2" }, - { "14", "\u05D9\u05D3" }, - { "15", "\u05D8\u05F4\u05D5" }, - { "16", "\u05D8\u05F4\u05D6" }, - { "17", "\u05D9\u05D6" }, - { "18", "\u05D9\u05D7" }, - { "19", "\u05D9\u05D8" }, - { "20", "\u05DB" }, - { "30", "\u05DC" }, - { "40", "\u05DE" }, - { "50", "\u05E0" }, - { "60", "\u05E1" }, - { "70", "\u05E2" }, - { "80", "\u05E4" }, - { "90", "\u05E6" }, - { "99", "\u05E6\u05D8" }, - { "100", "\u05E7" }, - { "101", "\u05E7\u05D0" }, - { "200", "\u05E8" }, - { "300", "\u05E9" }, - { "400", "\u05EA" }, - { "500", "\u05EA\u05F4\u05E7" }, - { "600", "\u05EA\u05F4\u05E8" }, - { "700", "\u05EA\u05F4\u05E9" }, - { "800", "\u05EA\u05F4\u05EA" }, - { "900", "\u05EA\u05EA\u05F4\u05E7" }, - { "999", "\u05EA\u05EA\u05F4\u05E7\u05E6\u05D8" }, - { "1000", "\u05D0\u05F3" }, - { "1999", "\u05D0\u05F3\u05EA\u05EA\u05F4\u05E7\u05E6\u05D8" }, - { "2000", "2000" }, - }; - - private static String[][] formatAlphabeticThai = - { - { "\u0E01", null, null, "alphabetic" }, - { "0", "0" }, - { "1", "\u0E01" }, - { "2", "\u0E02" }, - { "3", "\u0E03" }, - { "10", "\u0E0A" }, - { "20", "\u0E14" }, - { "30", "\u0E1E" }, - { "40", "\u0E2A" }, - { "44", "\u0E2E" }, - { "45", "\u0E01\u0E01" }, - { "88", "\u0E01\u0E2E" }, - { "89", "\u0E02\u0E01" }, - { "1980", "\u0E2E\u0E2E" }, - { "1981", "\u0E01\u0E01\u0E01" }, - { "999999", "\u0E0B\u0E20\u0E17\u0E0B" }, - { "1000000", "\u0E0B\u0E20\u0E17\u0E0C" }, - }; - - private static String[][] formatWordEnglishLower = - { - { "w", null, null, null, null, "eng" }, - { "0", "zero" }, - { "1", "one" }, - { "2", "two" }, - { "3", "three" }, - { "4", "four" }, - { "5", "five" }, - { "6", "six" }, - { "7", "seven" }, - { "8", "eight" }, - { "9", "nine" }, - { "10", "ten" }, - { "99", "ninety nine" }, - { "100", "one hundred" }, - { "999", "nine hundred ninety nine" }, - { "1000", "one thousand" }, - { "999999", "nine hundred ninety nine thousand nine hundred ninety nine" }, - { "1000000", "one million" }, - { "999999999", "nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine" }, - { "1000000000", "one billion" } - }; - - private static String[][] formatWordEnglishUpper = - { - { "W", null, null, null, null, "eng" }, - { "0", "ZERO" }, - { "1", "ONE" }, - { "2", "TWO" }, - { "3", "THREE" }, - { "4", "FOUR" }, - { "5", "FIVE" }, - { "6", "SIX" }, - { "7", "SEVEN" }, - { "8", "EIGHT" }, - { "9", "NINE" }, - { "10", "TEN" }, - { "99", "NINETY NINE" }, - { "100", "ONE HUNDRED" }, - { "999", "NINE HUNDRED NINETY NINE" }, - { "1000", "ONE THOUSAND" }, - { "999999", "NINE HUNDRED NINETY NINE THOUSAND NINE HUNDRED NINETY NINE" }, - { "1000000", "ONE MILLION" }, - { "999999999", "NINE HUNDRED NINETY NINE MILLION NINE HUNDRED NINETY NINE THOUSAND NINE HUNDRED NINETY NINE" }, - { "1000000000", "ONE BILLION" } - }; - - private static String[][] formatWordEnglishTitle = - { - { "Ww", null, null, null, null, "eng" }, - { "0", "Zero" }, - { "1", "One" }, - { "2", "Two" }, - { "3", "Three" }, - { "4", "Four" }, - { "5", "Five" }, - { "6", "Six" }, - { "7", "Seven" }, - { "8", "Eight" }, - { "9", "Nine" }, - { "10", "Ten" }, - { "99", "Ninety Nine" }, - { "100", "One Hundred" }, - { "999", "Nine Hundred Ninety Nine" }, - { "1000", "One Thousand" }, - { "999999", "Nine Hundred Ninety Nine Thousand Nine Hundred Ninety Nine" }, - { "1000000", "One Million" }, - { "999999999", "Nine Hundred Ninety Nine Million Nine Hundred Ninety Nine Thousand Nine Hundred Ninety Nine" }, - { "1000000000", "One Billion" } - }; - - private static String[][] formatWordSpanishLower = - { - { "w", null, null, null, null, "spa" }, - { "0", "cero" }, - { "1", "uno" }, - { "2", "dos" }, - { "3", "tres" }, - { "4", "cuatro" }, - { "5", "cinco" }, - { "6", "seise" }, - { "7", "siete" }, - { "8", "ocho" }, - { "9", "nueve" }, - { "10", "diez" }, - { "11", "once" }, - { "12", "doce" }, - { "13", "trece" }, - { "14", "catorce" }, - { "15", "quince" }, - { "16", "diecis\u00e9is" }, - { "17", "diecisiete" }, - { "18", "dieciocho" }, - { "19", "diecinueve" }, - { "20", "veinte" }, - { "21", "veintiuno" }, - { "22", "veintid\u00f3s" }, - { "23", "veintitr\u00e9s" }, - { "24", "veinticuatro" }, - { "25", "veinticinco" }, - { "26", "veintis\u00e9is" }, - { "27", "veintisiete" }, - { "28", "veintiocho" }, - { "29", "veintinueve" }, - { "30", "treinta" }, - { "31", "treinta y uno" }, - { "32", "treinta y dos" }, - { "40", "cuarenta" }, - { "41", "cuarenta y uno" }, - { "42", "cuarenta y dos" }, - { "50", "cincuenta" }, - { "51", "cincuenta y uno" }, - { "52", "cincuenta y dos" }, - { "60", "sesenta" }, - { "61", "sesenta y uno" }, - { "62", "sesenta y dos" }, - { "70", "setenta" }, - { "71", "setenta y uno" }, - { "72", "setenta y dos" }, - { "80", "ochenta" }, - { "81", "ochenta y uno" }, - { "82", "ochenta y dos" }, - { "90", "noventa" }, - { "91", "noventa y uno" }, - { "92", "noventa y dos" }, - { "99", "noventa y nueve" }, - { "100", "cien" }, - { "101", "ciento uno" }, - { "102", "ciento dos" }, - { "200", "doscientos" }, - { "300", "trescientos" }, - { "400", "cuatrocientos" }, - { "500", "quinientos" }, - { "600", "seiscientos" }, - { "700", "setecientos" }, - { "800", "ochocientos" }, - { "900", "novecientos" }, - { "999", "novecientos noventa y nueve" }, - { "1000", "mil" }, - { "1001", "mil uno" }, - { "1002", "mil dos" }, - { "2000", "dos mil" }, - { "2001", "dos mil uno" }, - { "100000", "cien mil" }, - { "100001", "cien mil uno" }, - { "999999", "novecientos noventa y nueve mil novecientos noventa y nueve" }, - { "1000000", "un mill\u00f3n" }, - { "999999999", "novecientos noventa y nueve millones novecientos noventa y nueve mil novecientos noventa y nueve" }, - { "1000000000", "mil millones" } - }; - - private static String[][] formatWordSpanishUpper = - { - { "W", null, null, null, null, "spa" }, - { "0", "CERO" }, - { "1", "UNO" }, - { "2", "DOS" }, - { "3", "TRES" }, - { "4", "CUATRO" }, - { "5", "CINCO" }, - { "6", "SEISE" }, - { "7", "SIETE" }, - { "8", "OCHO" }, - { "9", "NUEVE" }, - { "10", "DIEZ" }, - { "11", "ONCE" }, - { "12", "DOCE" }, - { "13", "TRECE" }, - { "14", "CATORCE" }, - { "15", "QUINCE" }, - { "16", "DIECIS\u00c9IS" }, - { "17", "DIECISIETE" }, - { "18", "DIECIOCHO" }, - { "19", "DIECINUEVE" }, - { "20", "VEINTE" }, - { "21", "VEINTIUNO" }, - { "22", "VEINTID\u00d3S" }, - { "23", "VEINTITR\u00c9S" }, - { "24", "VEINTICUATRO" }, - { "25", "VEINTICINCO" }, - { "26", "VEINTIS\u00c9IS" }, - { "27", "VEINTISIETE" }, - { "28", "VEINTIOCHO" }, - { "29", "VEINTINUEVE" }, - { "30", "TREINTA" }, - { "31", "TREINTA Y UNO" }, - { "32", "TREINTA Y DOS" }, - { "40", "CUARENTA" }, - { "41", "CUARENTA Y UNO" }, - { "42", "CUARENTA Y DOS" }, - { "50", "CINCUENTA" }, - { "51", "CINCUENTA Y UNO" }, - { "52", "CINCUENTA Y DOS" }, - { "60", "SESENTA" }, - { "61", "SESENTA Y UNO" }, - { "62", "SESENTA Y DOS" }, - { "70", "SETENTA" }, - { "71", "SETENTA Y UNO" }, - { "72", "SETENTA Y DOS" }, - { "80", "OCHENTA" }, - { "81", "OCHENTA Y UNO" }, - { "82", "OCHENTA Y DOS" }, - { "90", "NOVENTA" }, - { "91", "NOVENTA Y UNO" }, - { "92", "NOVENTA Y DOS" }, - { "99", "NOVENTA Y NUEVE" }, - { "100", "CIEN" }, - { "101", "CIENTO UNO" }, - { "102", "CIENTO DOS" }, - { "200", "DOSCIENTOS" }, - { "300", "TRESCIENTOS" }, - { "400", "CUATROCIENTOS" }, - { "500", "QUINIENTOS" }, - { "600", "SEISCIENTOS" }, - { "700", "SETECIENTOS" }, - { "800", "OCHOCIENTOS" }, - { "900", "NOVECIENTOS" }, - { "999", "NOVECIENTOS NOVENTA Y NUEVE" }, - { "1000", "MIL" }, - { "1001", "MIL UNO" }, - { "1002", "MIL DOS" }, - { "2000", "DOS MIL" }, - { "2001", "DOS MIL UNO" }, - { "100000", "CIEN MIL" }, - { "100001", "CIEN MIL UNO" }, - { "999999", "NOVECIENTOS NOVENTA Y NUEVE MIL NOVECIENTOS NOVENTA Y NUEVE" }, - { "1000000", "UN MILL\u00d3N" }, - { "999999999", "NOVECIENTOS NOVENTA Y NUEVE MILLONES NOVECIENTOS NOVENTA Y NUEVE MIL NOVECIENTOS NOVENTA Y NUEVE" }, - { "1000000000", "MIL MILLONES" } - }; - - private static String[][] formatWordSpanishTitle = - { - { "Ww", null, null, null, null, "spa" }, - { "0", "Cero" }, - { "1", "Uno" }, - { "2", "Dos" }, - { "3", "Tres" }, - { "4", "Cuatro" }, - { "5", "Cinco" }, - { "6", "Seise" }, - { "7", "Siete" }, - { "8", "Ocho" }, - { "9", "Nueve" }, - { "10", "Diez" }, - { "11", "Once" }, - { "12", "Doce" }, - { "13", "Trece" }, - { "14", "Catorce" }, - { "15", "Quince" }, - { "16", "Diecis\u00e9is" }, - { "17", "Diecisiete" }, - { "18", "Dieciocho" }, - { "19", "Diecinueve" }, - { "20", "Veinte" }, - { "21", "Veintiuno" }, - { "22", "Veintid\u00f3s" }, - { "23", "Veintitr\u00e9s" }, - { "24", "Veinticuatro" }, - { "25", "Veinticinco" }, - { "26", "Veintis\u00e9is" }, - { "27", "Veintisiete" }, - { "28", "Veintiocho" }, - { "29", "Veintinueve" }, - { "30", "Treinta" }, - { "31", "Treinta Y Uno" }, - { "32", "Treinta Y Dos" }, - { "40", "Cuarenta" }, - { "41", "Cuarenta Y Uno" }, - { "42", "Cuarenta Y Dos" }, - { "50", "Cincuenta" }, - { "51", "Cincuenta Y Uno" }, - { "52", "Cincuenta Y Dos" }, - { "60", "Sesenta" }, - { "61", "Sesenta Y Uno" }, - { "62", "Sesenta Y Dos" }, - { "70", "Setenta" }, - { "71", "Setenta Y Uno" }, - { "72", "Setenta Y Dos" }, - { "80", "Ochenta" }, - { "81", "Ochenta Y Uno" }, - { "82", "Ochenta Y Dos" }, - { "90", "Noventa" }, - { "91", "Noventa Y Uno" }, - { "92", "Noventa Y Dos" }, - { "99", "Noventa Y Nueve" }, - { "100", "Cien" }, - { "101", "Ciento Uno" }, - { "102", "Ciento Dos" }, - { "200", "Doscientos" }, - { "300", "Trescientos" }, - { "400", "Cuatrocientos" }, - { "500", "Quinientos" }, - { "600", "Seiscientos" }, - { "700", "Setecientos" }, - { "800", "Ochocientos" }, - { "900", "Novecientos" }, - { "999", "Novecientos Noventa Y Nueve" }, - { "1000", "Mil" }, - { "1001", "Mil Uno" }, - { "1002", "Mil Dos" }, - { "2000", "Dos Mil" }, - { "2001", "Dos Mil Uno" }, - { "100000", "Cien Mil" }, - { "100001", "Cien Mil Uno" }, - { "999999", "Novecientos Noventa Y Nueve Mil Novecientos Noventa Y Nueve" }, - { "1000000", "Un Mill\u00f3n" }, - { "999999999", "Novecientos Noventa Y Nueve Millones Novecientos Noventa Y Nueve Mil Novecientos Noventa Y Nueve" }, - { "1000000000", "Mil Millones" } - }; - - private static String[][] formatWordFrenchLower = - { - { "w", null, null, null, null, "fra" }, - { "0", "z\u00e9ro" }, - { "1", "un" }, - { "2", "deux" }, - { "3", "trois" }, - { "4", "quatre" }, - { "5", "cinq" }, - { "6", "six" }, - { "7", "sept" }, - { "8", "huit" }, - { "9", "neuf" }, - { "10", "dix" }, - { "11", "onze" }, - { "12", "douze" }, - { "13", "treize" }, - { "14", "quatorze" }, - { "15", "quinze" }, - { "16", "seize" }, - { "17", "dix-sept" }, - { "18", "dix-huit" }, - { "19", "dix-neuf" }, - { "20", "vingt" }, - { "21", "vingt et un" }, - { "22", "vingt-deux" }, - { "23", "vingt-trois" }, - { "24", "vingt-quatre" }, - { "25", "vingt-cinq" }, - { "26", "vingt-six" }, - { "27", "vingt-sept" }, - { "28", "vingt-huit" }, - { "29", "vingt-neuf" }, - { "30", "trente" }, - { "31", "trente et un" }, - { "32", "trente-deux" }, - { "40", "quarante" }, - { "41", "quarante et un" }, - { "42", "quarante-deux" }, - { "50", "cinquante" }, - { "51", "cinquante et un" }, - { "52", "cinquante-deux" }, - { "60", "soixante" }, - { "61", "soixante et un" }, - { "62", "soixante-deux" }, - { "70", "soixante-dix" }, - { "71", "soixante et onze" }, - { "72", "soixante-douze" }, - { "79", "soixante-dix-neuf" }, - { "80", "quatre-vingts" }, - { "81", "quatre-vingt-un" }, - { "82", "quatre-vingt-deux" }, - { "89", "quatre-vingt-neuf" }, - { "90", "quatre-vingt-dix" }, - { "91", "quatre-vingt-onze" }, - { "92", "quatre-vingt-douze" }, - { "99", "quatre-vingt-dix-neuf" }, - { "100", "cent" }, - { "101", "cent un" }, - { "102", "cent deux" }, - { "200", "deux cents" }, - { "201", "deux cent un" }, - { "202", "deux cent deux" }, - { "300", "trois cents" }, - { "301", "trois cent un" }, - { "400", "quatre cents" }, - { "401", "quatre cent un" }, - { "500", "cinq cents" }, - { "501", "cinq cent un" }, - { "600", "six cents" }, - { "601", "six cent un" }, - { "700", "sept cents" }, - { "701", "sept cent un" }, - { "800", "huit cents" }, - { "801", "huit cent un" }, - { "900", "neuf cents" }, - { "901", "neuf cent un" }, - { "999", "neuf cent quatre-vingt-dix-neuf" }, - { "1000", "mille" }, - { "1001", "mille un" }, - { "1002", "mille deux" }, - { "2000", "deux mille" }, - { "2001", "deux mille un" }, - { "100000", "cent mille" }, - { "100001", "cent mille un" }, - { "999999", "neuf cent quatre-vingt-dix-neuf mille neuf cent quatre-vingt-dix-neuf" }, - { "1000000", "un million" }, - { "999999999", "neuf cent quatre-vingt-dix-neuf millions neuf cent quatre-vingt-dix-neuf mille neuf cent quatre-vingt-dix-neuf" }, - { "1000000000", "un milliard" } - }; - - private static String[][] formatWordFrenchUpper = - { - { "W", null, null, null, null, "fra" }, - { "0", "Z\u00c9RO" }, - { "1", "UN" }, - { "2", "DEUX" }, - { "3", "TROIS" }, - { "4", "QUATRE" }, - { "5", "CINQ" }, - { "6", "SIX" }, - { "7", "SEPT" }, - { "8", "HUIT" }, - { "9", "NEUF" }, - { "10", "DIX" }, - { "11", "ONZE" }, - { "12", "DOUZE" }, - { "13", "TREIZE" }, - { "14", "QUATORZE" }, - { "15", "QUINZE" }, - { "16", "SEIZE" }, - { "17", "DIX-SEPT" }, - { "18", "DIX-HUIT" }, - { "19", "DIX-NEUF" }, - { "20", "VINGT" }, - { "21", "VINGT ET UN" }, - { "22", "VINGT-DEUX" }, - { "23", "VINGT-TROIS" }, - { "24", "VINGT-QUATRE" }, - { "25", "VINGT-CINQ" }, - { "26", "VINGT-SIX" }, - { "27", "VINGT-SEPT" }, - { "28", "VINGT-HUIT" }, - { "29", "VINGT-NEUF" }, - { "30", "TRENTE" }, - { "31", "TRENTE ET UN" }, - { "32", "TRENTE-DEUX" }, - { "40", "QUARANTE" }, - { "41", "QUARANTE ET UN" }, - { "42", "QUARANTE-DEUX" }, - { "50", "CINQUANTE" }, - { "51", "CINQUANTE ET UN" }, - { "52", "CINQUANTE-DEUX" }, - { "60", "SOIXANTE" }, - { "61", "SOIXANTE ET UN" }, - { "62", "SOIXANTE-DEUX" }, - { "70", "SOIXANTE-DIX" }, - { "71", "SOIXANTE ET ONZE" }, - { "72", "SOIXANTE-DOUZE" }, - { "79", "SOIXANTE-DIX-NEUF" }, - { "80", "QUATRE-VINGTS" }, - { "81", "QUATRE-VINGT-UN" }, - { "82", "QUATRE-VINGT-DEUX" }, - { "89", "QUATRE-VINGT-NEUF" }, - { "90", "QUATRE-VINGT-DIX" }, - { "91", "QUATRE-VINGT-ONZE" }, - { "92", "QUATRE-VINGT-DOUZE" }, - { "99", "QUATRE-VINGT-DIX-NEUF" }, - { "100", "CENT" }, - { "101", "CENT UN" }, - { "102", "CENT DEUX" }, - { "200", "DEUX CENTS" }, - { "201", "DEUX CENT UN" }, - { "202", "DEUX CENT DEUX" }, - { "300", "TROIS CENTS" }, - { "301", "TROIS CENT UN" }, - { "400", "QUATRE CENTS" }, - { "401", "QUATRE CENT UN" }, - { "500", "CINQ CENTS" }, - { "501", "CINQ CENT UN" }, - { "600", "SIX CENTS" }, - { "601", "SIX CENT UN" }, - { "700", "SEPT CENTS" }, - { "701", "SEPT CENT UN" }, - { "800", "HUIT CENTS" }, - { "801", "HUIT CENT UN" }, - { "900", "NEUF CENTS" }, - { "901", "NEUF CENT UN" }, - { "999", "NEUF CENT QUATRE-VINGT-DIX-NEUF" }, - { "1000", "MILLE" }, - { "1001", "MILLE UN" }, - { "1002", "MILLE DEUX" }, - { "2000", "DEUX MILLE" }, - { "2001", "DEUX MILLE UN" }, - { "100000", "CENT MILLE" }, - { "100001", "CENT MILLE UN" }, - { "999999", "NEUF CENT QUATRE-VINGT-DIX-NEUF MILLE NEUF CENT QUATRE-VINGT-DIX-NEUF" }, - { "1000000", "UN MILLION" }, - { "999999999", "NEUF CENT QUATRE-VINGT-DIX-NEUF MILLIONS NEUF CENT QUATRE-VINGT-DIX-NEUF MILLE NEUF CENT QUATRE-VINGT-DIX-NEUF" }, - { "1000000000", "UN MILLIARD" } - }; - - private static String[][] formatWordFrenchTitle = - { - { "Ww", null, null, null, null, "fra" }, - { "0", "Z\u00e9ro" }, - { "1", "Un" }, - { "2", "Deux" }, - { "3", "Trois" }, - { "4", "Quatre" }, - { "5", "Cinq" }, - { "6", "Six" }, - { "7", "Sept" }, - { "8", "Huit" }, - { "9", "Neuf" }, - { "10", "Dix" }, - { "11", "Onze" }, - { "12", "Douze" }, - { "13", "Treize" }, - { "14", "Quatorze" }, - { "15", "Quinze" }, - { "16", "Seize" }, - { "17", "Dix-sept" }, - { "18", "Dix-huit" }, - { "19", "Dix-neuf" }, - { "20", "Vingt" }, - { "21", "Vingt Et Un" }, - { "22", "Vingt-deux" }, - { "23", "Vingt-trois" }, - { "24", "Vingt-quatre" }, - { "25", "Vingt-cinq" }, - { "26", "Vingt-six" }, - { "27", "Vingt-sept" }, - { "28", "Vingt-huit" }, - { "29", "Vingt-neuf" }, - { "30", "Trente" }, - { "31", "Trente Et Un" }, - { "32", "Trente-deux" }, - { "40", "Quarante" }, - { "41", "Quarante Et Un" }, - { "42", "Quarante-deux" }, - { "50", "Cinquante" }, - { "51", "Cinquante Et Un" }, - { "52", "Cinquante-deux" }, - { "60", "Soixante" }, - { "61", "Soixante Et Un" }, - { "62", "Soixante-deux" }, - { "70", "Soixante-dix" }, - { "71", "Soixante Et Onze" }, - { "72", "Soixante-douze" }, - { "79", "Soixante-dix-neuf" }, - { "80", "Quatre-vingts" }, - { "81", "Quatre-vingt-un" }, - { "82", "Quatre-vingt-deux" }, - { "89", "Quatre-vingt-neuf" }, - { "90", "Quatre-vingt-dix" }, - { "91", "Quatre-vingt-onze" }, - { "92", "Quatre-vingt-douze" }, - { "99", "Quatre-vingt-dix-neuf" }, - { "100", "Cent" }, - { "101", "Cent Un" }, - { "102", "Cent Deux" }, - { "200", "Deux Cents" }, - { "201", "Deux Cent Un" }, - { "202", "Deux Cent Deux" }, - { "300", "Trois Cents" }, - { "301", "Trois Cent Un" }, - { "400", "Quatre Cents" }, - { "401", "Quatre Cent Un" }, - { "500", "Cinq Cents" }, - { "501", "Cinq Cent Un" }, - { "600", "Six Cents" }, - { "601", "Six Cent Un" }, - { "700", "Sept Cents" }, - { "701", "Sept Cent Un" }, - { "800", "Huit Cents" }, - { "801", "Huit Cent Un" }, - { "900", "Neuf Cents" }, - { "901", "Neuf Cent Un" }, - { "999", "Neuf Cent Quatre-vingt-dix-neuf" }, - { "1000", "Mille" }, - { "1001", "Mille Un" }, - { "1002", "Mille Deux" }, - { "2000", "Deux Mille" }, - { "2001", "Deux Mille Un" }, - { "100000", "Cent Mille" }, - { "100001", "Cent Mille Un" }, - { "999999", "Neuf Cent Quatre-vingt-dix-neuf Mille Neuf Cent Quatre-vingt-dix-neuf" }, - { "1000000", "Un Million" }, - { "999999999", "Neuf Cent Quatre-vingt-dix-neuf Millions Neuf Cent Quatre-vingt-dix-neuf Mille Neuf Cent Quatre-vingt-dix-neuf" }, - { "1000000000", "Un Milliard" } - }; - - /** - * Tests decimal from latin script. - * @throws Exception if the test fails - */ - @Test - public void testFormatDecimal() throws Exception { - performConversions(formatDecimal); - performConversions(formatDecimalPadded); - performConversions(formatDecimalGrouped); - performConversions(formatDecimalGroupedPadded); - } - - /** - * Tests decimal from arabic script. - * @throws Exception if the test fails - */ - @Test - public void testFormatDecimalArabic() throws Exception { - performConversions(formatDecimalArabic); - performConversions(formatDecimalArabicPadded); - performConversions(formatDecimalArabicGrouped); - performConversions(formatDecimalArabicGroupedPadded); - } - - /** - * Tests decimal from thai script. - * @throws Exception if the test fails - */ - @Test - public void testFormatDecimalThai() throws Exception { - performConversions(formatDecimalThai); - performConversions(formatDecimalThaiPadded); - } - - /** - * Tests roman numbers. - * @throws Exception if the test fails - */ - @Test - public void testFormatRoman() throws Exception { - performConversions(formatRomanLower); - performConversions(formatRomanUpper); - performConversions(formatRomanLargeLower); - performConversions(formatRomanLargeUpper); - performConversions(formatRomanNumberFormsLower); - performConversions(formatRomanNumberFormsUpper); - } - - /** - * Tests latin alphabetic sequence numerals. - * @throws Exception if the test fails - */ - @Test - public void testAlphabeticLatin() throws Exception { - performConversions(formatAlphabeticLatinLower); - performConversions(formatAlphabeticLatinUpper); - } - - /** - * Tests arabic alphabetic sequence numerals. - * @throws Exception if the test fails - */ - @Test - public void testAlphabeticArabic() throws Exception { - performConversions(formatAlphabeticArabicHijai); - performConversions(formatAlphabeticArabicAbjadi); - } - - /** - * Tests hebrew alphabetic sequence numerals. - * @throws Exception if the test fails - */ - @Test - public void testAlphabeticHebrew() throws Exception { - performConversions(formatAlphabeticHebrew); - } - - /** - * Tests latin alphabetic sequence numerals. - * @throws Exception if the test fails - */ - @Test - public void testAlphabeticThai() throws Exception { - performConversions(formatAlphabeticThai); - } - - /** - * Tests arabic numerals.. - * @throws Exception if the test fails - */ - @Test - public void testNumeralArabic() throws Exception { - performConversions(formatNumeralArabicAbjadi); - } - - /** - * Tests hebrew numerals. - * @throws Exception if the test fails - */ - @Test - public void testNumeralHebrew() throws Exception { - performConversions(formatNumeralHebrewGematria); - } - - /** - * Tests english word numerals. - * @throws Exception if the test fails - */ - @Test - public void testWordEnglish() throws Exception { - performConversions(formatWordEnglishLower); - performConversions(formatWordEnglishUpper); - performConversions(formatWordEnglishTitle); - } - - /** - * Tests spanish word numerals. - * @throws Exception if the test fails - */ - @Test - public void testWordSpanish() throws Exception { - performConversions(formatWordSpanishLower); - performConversions(formatWordSpanishUpper); - performConversions(formatWordSpanishTitle); - } - - /** - * Tests french word numerals. - * @throws Exception if the test fails - */ - @Test - public void testWordFrench() throws Exception { - performConversions(formatWordFrenchLower); - performConversions(formatWordFrenchUpper); - performConversions(formatWordFrenchTitle); - } - - /** - * Perform conversions according to test specification. - * @param ts test specification - */ - private void performConversions(String[][] ts) { - assert ts != null; - assert ts.length >= 2; - String[] args = ts[0]; - assert args != null; - assert args.length > 0; - String format = args[0]; - assert format.length() > 0; - char groupingSeparator; - if (args.length > 1) { - String s = args[1]; - if ((s != null) && (s.length() > 0)) { - groupingSeparator = s.charAt(0); - } else { - groupingSeparator = 0; - } - } else { - groupingSeparator = 0; - } - int groupingSize; - if (args.length > 2) { - String s = args[2]; - if ((s != null) && (s.length() > 0)) { - groupingSize = Integer.parseInt(s); - } else { - groupingSize = 0; - } - } else { - groupingSize = 0; - } - int letterValue; - if (args.length > 3) { - String s = args[3]; - if ((s != null) && (s.length() > 0)) { - s = s.toLowerCase(); - if (s.equals("alphabetic")) { - letterValue = NumberConverter.LETTER_VALUE_ALPHABETIC; - } else if (s.equals("traditional")) { - letterValue = NumberConverter.LETTER_VALUE_TRADITIONAL; - } else { - letterValue = 0; - } - } else { - letterValue = 0; - } - } else { - letterValue = 0; - } - String features; - if (args.length > 4) { - String s = args[4]; - if ((s != null) && (s.length() > 0)) { - features = s; - } else { - features = null; - } - } else { - features = null; - } - String language; - if (args.length > 5) { - String s = args[5]; - if ((s != null) && (s.length() > 0)) { - language = s; - } else { - language = null; - } - } else { - language = null; - } - String country; - if (args.length > 6) { - String s = args[6]; - if ((s != null) && (s.length() > 0)) { - country = s; - } else { - country = null; - } - } else { - country = null; - } - NumberConverter nc = new NumberConverter(format, groupingSeparator, groupingSize, letterValue, features, language, country); - for (int i = 1, nt = ts.length; i < nt; i++) { - String[] sa = ts[i]; - assert sa != null; - assert sa.length >= 2; - List<Long> numbers = new ArrayList<Long>(); - for (int k = 0, nn = sa.length - 1; k < nn; k++) { - String s = sa[k]; - numbers.add(Long.valueOf(s)); - } - String expected = sa [ sa.length - 1 ]; - String actual = nc.convert(numbers); - assertEquals(expected, actual); - } - } - -} diff --git a/test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java b/test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java deleted file mode 100644 index 4407254a8..000000000 --- a/test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.complexscripts.util; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for bidirectional functionality. - */ -@RunWith(Suite.class) -@SuiteClasses(NumberConverterTestCase.class) -public class UtilTestSuite { -} diff --git a/test/java/org/apache/fop/config/BaseConstructiveUserConfigTest.java b/test/java/org/apache/fop/config/BaseConstructiveUserConfigTest.java deleted file mode 100644 index 7a3cab3bb..000000000 --- a/test/java/org/apache/fop/config/BaseConstructiveUserConfigTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.config; - -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Test; -import org.xml.sax.SAXException; - -import static org.junit.Assert.fail; - -/** - * Super class of several user config cases. - */ -public abstract class BaseConstructiveUserConfigTest extends BaseUserConfigTest { - - public BaseConstructiveUserConfigTest(InputStream confStream) throws SAXException, IOException { - super(confStream); - } - - /** - * Test using a standard FOP font - * @throws Exception checkstyle wants a comment here, even a silly one - */ - @Test - public void testUserConfig() throws Exception { - try { - convertFO(); - } catch (Exception e) { - // this should *not* happen! - e.printStackTrace(); - fail(e.getMessage()); - } - } -} diff --git a/test/java/org/apache/fop/config/BaseDestructiveUserConfigTest.java b/test/java/org/apache/fop/config/BaseDestructiveUserConfigTest.java deleted file mode 100644 index 4050e9b2d..000000000 --- a/test/java/org/apache/fop/config/BaseDestructiveUserConfigTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.config; - -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Test; -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FOPException; - -/** - * Super class for several user configuration failure cases. - */ -public abstract class BaseDestructiveUserConfigTest extends BaseUserConfigTest { - - public BaseDestructiveUserConfigTest(InputStream confStream) throws SAXException, IOException { - super(confStream); - } - - /** - * Test the user configuration failure. - */ - @Test(expected = FOPException.class) - public void testUserConfig() throws Exception { - convertFO(); - } -} diff --git a/test/java/org/apache/fop/config/BaseUserConfigTest.java b/test/java/org/apache/fop/config/BaseUserConfigTest.java deleted file mode 100644 index 1af57d985..000000000 --- a/test/java/org/apache/fop/config/BaseUserConfigTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.config; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -import org.xml.sax.SAXException; - -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.render.pdf.BasePDFTest; - -import static org.apache.fop.FOPTestUtils.getBaseDir; - -/** - * Basic runtime test for FOP's font configuration. It is used to verify that - * nothing obvious is broken after compiling. - */ -public abstract class BaseUserConfigTest extends BasePDFTest { - - protected DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); - - /** logging instance */ - protected Log log = LogFactory.getLog(BaseUserConfigTest.class); - - - public BaseUserConfigTest(InputStream confStream) throws SAXException, IOException { - super(confStream); - } - - /** - * @see org.apache.fop.render.pdf.BasePDFTest#init() - */ - protected void init() { - // do nothing - } - - protected void convertFO() throws Exception { - final File baseDir = getBaseDir(); - final String fontFOFilePath = getFontFOFilePath(); - File foFile = new File(baseDir, fontFOFilePath); - final boolean dumpOutput = false; - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - convertFO(foFile, foUserAgent, dumpOutput); - } - - /** - * get test FOP config File - * @return fo test filepath - */ - protected String getFontFOFilePath() { - return "test/xml/bugtests/font.fo"; - } - - /** get base config directory */ - protected static String getBaseConfigDir() { - return "test/config/"; - } -} diff --git a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java deleted file mode 100644 index fa4babfa2..000000000 --- a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.config; - -import java.io.IOException; - -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.PDFRendererConfBuilder; - -/** - * this font is without a metrics-url or an embed-url - */ -public class FontAttributesMissingTestCase extends BaseDestructiveUserConfigTest { - - public FontAttributesMissingTestCase() throws SAXException, IOException { - super(new FopConfBuilder().setStrictValidation(true) - .startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .startFont(null, null) - .addTriplet("Gladiator", "normal", "normal") - .endFont() - .endFontConfig() - .endRendererConfig().build()); - } -} diff --git a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java deleted file mode 100644 index 591104412..000000000 --- a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.config; - -import java.io.IOException; - -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.PDFRendererConfBuilder; - -/** - * this font has a metrics-url that does not exist on filesystem - */ -public class FontMetricsUrlBadTestCase extends BaseDestructiveUserConfigTest { - - public FontMetricsUrlBadTestCase() throws SAXException, IOException { - super(new FopConfBuilder().setStrictValidation(true) - .startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .startFont("test/doesnotexist.ttf.ansi.xml", null) - .addTriplet("Gladiator-Ansi", "normal", "normal") - .endFont() - .endFontConfig() - .endRendererConfig().build()); - } -} diff --git a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java deleted file mode 100644 index 11538dc33..000000000 --- a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.config; - -import java.io.IOException; - -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.PDFRendererConfBuilder; - -/** - * this font has a malformed metrics-url - */ -public class FontMetricsUrlMalformedTestCase extends BaseDestructiveUserConfigTest { - - public FontMetricsUrlMalformedTestCase() throws SAXException, IOException { - super(new FopConfBuilder().setStrictValidation(true) - .startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .startFont("badprotocol:test/glb12.ttf.xml", null) - .addTriplet("Gladiator", "normal", "normal") - .endFont() - .endFontConfig() - .endRendererConfig().build()); - } -} diff --git a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java deleted file mode 100644 index 4bacc180c..000000000 --- a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.config; - -import java.io.IOException; - -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.PDFRendererConfBuilder; - -/** - * this font has a missing font triplet attribute - */ -public class FontTripletAttributeMissingTestCase extends BaseDestructiveUserConfigTest { - - public FontTripletAttributeMissingTestCase() throws SAXException, IOException { - super(new FopConfBuilder().setStrictValidation(true) - .startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .startFont(null, "test/resources/fonts/ttf/glb12.ttf") - .addTriplet("Gladiator", null, "normal") - .endFont() - .endFontConfig() - .endRendererConfig().build()); - } -} diff --git a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java deleted file mode 100644 index e05e44ab1..000000000 --- a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.config; - -import java.io.IOException; - -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.PDFRendererConfBuilder; - -public class FontsAutoDetectTestCase extends BaseConstructiveUserConfigTest { - - public FontsAutoDetectTestCase() throws SAXException, IOException { - super(new FopConfBuilder().startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .addAutoDetect() - .endFontConfig() - .endRendererConfig().build()); - } -} diff --git a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java deleted file mode 100644 index aab7a2e7c..000000000 --- a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.config; - -import java.io.IOException; - -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.PDFRendererConfBuilder; - -/** - * tests font directory on system - */ -public class FontsDirectoryRecursiveTestCase extends BaseConstructiveUserConfigTest { - - public FontsDirectoryRecursiveTestCase() throws SAXException, IOException { - super(new FopConfBuilder().startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .addDirectory("test/resources/fonts", true) - .endFontConfig() - .endRendererConfig().build()); - } -} diff --git a/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java b/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java deleted file mode 100644 index 1ac79e353..000000000 --- a/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.config; - -import java.io.File; -import java.io.IOException; - -import org.xml.sax.SAXException; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopConfBuilder; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.apps.PDFRendererConfBuilder; -import org.apache.fop.fonts.CustomFontCollection; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontCollection; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontManager; -import org.apache.fop.fonts.FontTriplet; -import org.apache.fop.fonts.base14.Base14FontCollection; -import org.apache.fop.render.PrintRenderer; - -/** - * Tests the font substitution mechanism - */ -public class FontsSubstitutionTestCase extends BaseConstructiveUserConfigTest { - - public FontsSubstitutionTestCase() throws SAXException, IOException { - super(new FopConfBuilder() - .startFontsConfig() - .substituteFonts("Times", "italic", null, "Gladiator", "normal", "bold") - .endFontsConfig() - .startRendererConfig(PDFRendererConfBuilder.class) - .startFontsConfig() - .startFont(null, "resources/fonts/ttf/glb12.ttf") - .addTriplet("Gladiator", "normal", "bold") - .endFont() - .endFontConfig() - .endRendererConfig().build()); - } - - @Override - protected byte[] convertFO(File foFile, FOUserAgent ua, boolean dumpPdfFile) - throws Exception { - PrintRenderer renderer = (PrintRenderer) ua.getRendererFactory() - .createRenderer(ua, MimeConstants.MIME_PDF); - FontInfo fontInfo = new FontInfo(); - renderer.setupFontInfo(fontInfo); - FontManager fontManager = ua.getFontManager(); - FontCollection[] fontCollections = new FontCollection[] { - new Base14FontCollection(fontManager.isBase14KerningEnabled()), - new CustomFontCollection(fontManager.getResourceResolver(), renderer.getFontList(), - ua.isComplexScriptFeaturesEnabled()) - }; - fontManager.setup(fontInfo, fontCollections); - FontTriplet triplet = new FontTriplet("Times", "italic", - Font.WEIGHT_NORMAL); - String internalFontKey = fontInfo.getInternalFontKey(triplet); - // Times italic should now be mapped to the 15th font (custom font) - // not the original base 14 (F6) - if (!"F15".equals(internalFontKey)) { - throw new Exception("font substitution failed :" + triplet); - } - return null; - } -} diff --git a/test/java/org/apache/fop/config/UserConfigTestSuite.java b/test/java/org/apache/fop/config/UserConfigTestSuite.java deleted file mode 100644 index 9cb5c4270..000000000 --- a/test/java/org/apache/fop/config/UserConfigTestSuite.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.config; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for font configuration. - */ -@RunWith(Suite.class) -@SuiteClasses({ - FontAttributesMissingTestCase.class, - FontTripletAttributeMissingTestCase.class, - FontMetricsUrlBadTestCase.class, - FontMetricsUrlMalformedTestCase.class, - FontsDirectoryRecursiveTestCase.class, - FontsAutoDetectTestCase.class, - FontsSubstitutionTestCase.class -}) -public class UserConfigTestSuite { -} diff --git a/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java b/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java deleted file mode 100644 index f6e2b02ba..000000000 --- a/test/java/org/apache/fop/datatypes/URISpecificationTestCase.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.datatypes; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Tests for URISpecification. - */ -public class URISpecificationTestCase { - - @Test - public void testGetURL() throws Exception { - String actual; - - actual = URISpecification.getURL("http://localhost/test"); - assertEquals("http://localhost/test", actual); - - actual = URISpecification.getURL("url(http://localhost/test)"); - assertEquals("http://localhost/test", actual); - - actual = URISpecification.getURL("url('http://localhost/test')"); - assertEquals("http://localhost/test", actual); - - actual = URISpecification.getURL("url(\"http://localhost/test\")"); - assertEquals("http://localhost/test", actual); - } - - @Test - public void testEscapeURI() throws Exception { - String actual; - - actual = URISpecification.escapeURI("http://localhost/test"); - assertEquals("http://localhost/test", actual); - - actual = URISpecification.escapeURI("http://localhost/test%20test"); - assertEquals("http://localhost/test%20test", actual); - - actual = URISpecification.escapeURI("http://localhost/test test"); - assertEquals("http://localhost/test%20test", actual); - - actual = URISpecification.escapeURI("http://localhost/test test.pdf#page=6"); - assertEquals("http://localhost/test%20test.pdf#page=6", actual); - } - -} diff --git a/test/java/org/apache/fop/events/BasicEventTestCase.java b/test/java/org/apache/fop/events/BasicEventTestCase.java deleted file mode 100644 index 39e3fec98..000000000 --- a/test/java/org/apache/fop/events/BasicEventTestCase.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.events; - -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 static org.junit.Assert.fail; - -import org.apache.fop.events.model.EventSeverity; - -public class BasicEventTestCase { - - @Test - public void testBasics() throws Exception { - - MyEventListener listener = new MyEventListener(); - - EventBroadcaster broadcaster = new DefaultEventBroadcaster(); - broadcaster.addEventListener(listener); - assertTrue(broadcaster.hasEventListeners()); - - Event ev = new Event(this, "123", EventSeverity.INFO, - Event.paramsBuilder() - .param("reason", "I'm tired") - .param("blah", new Integer(23)) - .build()); - broadcaster.broadcastEvent(ev); - - ev = listener.event; - assertNotNull(ev); - assertEquals("123", listener.event.getEventID()); - assertEquals(EventSeverity.INFO, listener.event.getSeverity()); - assertEquals("I'm tired", ev.getParam("reason")); - assertEquals(new Integer(23), ev.getParam("blah")); - - broadcaster.removeEventListener(listener); - assertFalse(broadcaster.hasEventListeners()); - - //Just check that there are no NPEs - broadcaster.broadcastEvent(ev); - } - - @Test - public void testEventProducer() throws Exception { - MyEventListener listener = new MyEventListener(); - - EventBroadcaster broadcaster = new DefaultEventBroadcaster(); - broadcaster.addEventListener(listener); - assertTrue(broadcaster.hasEventListeners()); - - - TestEventProducer producer = TestEventProducer.Provider.get(broadcaster); - producer.complain(this, "I'm tired", 23); - - Event ev = listener.event; - assertNotNull(ev); - assertEquals("org.apache.fop.events.TestEventProducer.complain", - listener.event.getEventID()); - assertEquals(EventSeverity.WARN, listener.event.getSeverity()); - assertEquals("I'm tired", ev.getParam("reason")); - assertEquals(new Integer(23), ev.getParam("blah")); - - broadcaster.removeEventListener(listener); - assertFalse(broadcaster.hasEventListeners()); - - //Just check that there are no NPEs - broadcaster.broadcastEvent(ev); - } - - private class MyEventListener implements EventListener { - - private Event event; - - public void processEvent(Event event) { - if (this.event != null) { - fail("Multiple events received"); - } - this.event = event; - } - } - -} diff --git a/test/java/org/apache/fop/events/EventChecker.java b/test/java/org/apache/fop/events/EventChecker.java deleted file mode 100644 index c2d5fcfd6..000000000 --- a/test/java/org/apache/fop/events/EventChecker.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.events; - -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -/** - * Class that checks that an expected event is produced, and only this one. - */ -public class EventChecker implements EventListener { - - private final String expectedEventID; - - private final Map<String, Object> expectedParams; - - private boolean eventReceived; - - public EventChecker(String expectedEventID, Map<String, Object> expectedParams) { - this.expectedEventID = expectedEventID; - this.expectedParams = expectedParams; - } - - public void processEvent(Event event) { - // Always create the message to make sure there is no error in the formatting process - String id = event.getEventID(); - if (id.equals(expectedEventID)) { - eventReceived = true; - for (Map.Entry<String, Object> param : expectedParams.entrySet()) { - assertEquals(param.getValue(), event.getParam(param.getKey())); - } - } - } - - public void end() { - if (!eventReceived) { - fail("Did not receive expected event: " + expectedEventID); - } - } -} diff --git a/test/java/org/apache/fop/events/EventProcessingTestCase.java b/test/java/org/apache/fop/events/EventProcessingTestCase.java deleted file mode 100644 index fb17c9c0c..000000000 --- a/test/java/org/apache/fop/events/EventProcessingTestCase.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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.events; - -import java.io.File; -import java.io.InputStream; -import java.net.URI; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import org.junit.Test; - -import org.apache.commons.io.output.NullOutputStream; - -import org.apache.xmlgraphics.util.MimeConstants; - -import org.apache.fop.ResourceEventProducer; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.area.AreaEventProducer; -import org.apache.fop.fo.FOValidationEventProducer; -import org.apache.fop.fo.flow.table.TableEventProducer; -import org.apache.fop.layoutmgr.BlockLevelEventProducer; -import org.apache.fop.layoutmgr.inline.InlineLevelEventProducer; - -/** - * Tests that the event notification system runs smoothly. - */ -public class EventProcessingTestCase { - - private final TransformerFactory tFactory = TransformerFactory.newInstance(); - private static final URI BASE_DIR; - public static final URI CONFIG_BASE_DIR; - static { - URI base = (new File(".")).toURI(); - BASE_DIR = base.resolve("test/events/"); - - /** The base directory of configuration files */ - CONFIG_BASE_DIR = base.resolve("test/config/"); - - } - - public void doTest(InputStream inStream, URI fopConf, String expectedEventID, String mimeType, - Map<String, Object> expectedParams) throws Exception { - EventChecker eventChecker = new EventChecker(expectedEventID, expectedParams); - FopFactory fopFactory; - if (fopConf != null) { - fopFactory = FopFactory.newInstance(new File(fopConf)); - } else { - fopFactory = FopFactory.newInstance(BASE_DIR); - } - - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - - userAgent.getEventBroadcaster().addEventListener(eventChecker); - Fop fop = fopFactory.newFop(mimeType, userAgent, new NullOutputStream()); - Transformer transformer = tFactory.newTransformer(); - Source src = new StreamSource(inStream); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - eventChecker.end(); - - } - - public void doTest(InputStream inStream, URI fopConf, String expectedEventID, String mimeType) - throws Exception { - Map<String, Object> noParams = Collections.emptyMap(); - doTest(inStream, fopConf, expectedEventID, mimeType, noParams); - } - - public void doTest(String filename, String expectedEventID, Map<String, Object> expectedParams) - throws Exception { - doTest(BASE_DIR.resolve(filename).toURL().openStream(), null, expectedEventID, - MimeConstants.MIME_PDF, expectedParams); - } - - public void doTest(String filename, String expectedEventID) throws Exception { - doTest(BASE_DIR.resolve(filename).toURL().openStream(), null, expectedEventID, - MimeConstants.MIME_PDF); - } - - @Test - public void testArea() throws Exception { - doTest("area.fo", - AreaEventProducer.class.getName() + ".unresolvedIDReferenceOnPage"); - } - - @Test - public void testResource() throws Exception { - doTest("resource.fo", - ResourceEventProducer.class.getName() + ".imageNotFound"); - } - - @Test - public void testValidation() throws Exception { - doTest("validation.fo", - FOValidationEventProducer.class.getName() + ".invalidPropertyValue"); - } - - @Test - public void testTable() throws Exception { - doTest("table.fo", - TableEventProducer.class.getName() + ".noTablePaddingWithCollapsingBorderModel"); - } - - @Test - public void testBlockLevel() throws Exception { - doTest("block-level.fo", - BlockLevelEventProducer.class.getName() + ".overconstrainedAdjustEndIndent"); - } - - @Test - public void testInlineLevel() throws Exception { - doTest("inline-level.fo", - InlineLevelEventProducer.class.getName() + ".lineOverflows"); - } - - @Test - public void testViewportIPDOverflow() throws Exception { - doTest("viewport-overflow.fo", BlockLevelEventProducer.class.getName() + ".viewportIPDOverflow"); - } - - @Test - public void testViewportBPDOverflow() throws Exception { - doTest("viewport-overflow.fo", BlockLevelEventProducer.class.getName() + ".viewportBPDOverflow"); - } - - @Test - public void testPageOverflow() throws Exception { - Map<String, Object> params = new HashMap<String, Object>(); - params.put("page", "1"); - doTest("region-body_overflow.fo", BlockLevelEventProducer.class.getName() + ".regionOverflow", - params); - } -} diff --git a/test/java/org/apache/fop/events/FlowNamedNotMappedTestCase.java b/test/java/org/apache/fop/events/FlowNamedNotMappedTestCase.java deleted file mode 100644 index 802c97450..000000000 --- a/test/java/org/apache/fop/events/FlowNamedNotMappedTestCase.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.events; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Map; - -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.apache.commons.io.output.NullOutputStream; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.fo.FOValidationEventProducer; - -public class FlowNamedNotMappedTestCase { - - - private static class FlowNameNotMappedEventChecker implements EventListener { - private final String personalID = FOValidationEventProducer.class.getName() + ".flowNameNotMapped"; - - public void processEvent(Event event) { - Map<String, Object> t = event.getParams(); - assertEquals("fo:flow", event.getParam("elementName")); - assertEquals("ContentPage_Body", event.getParam("flowName")); - assertEquals(personalID, event.getEventID()); - } - } - - @Test - public void testFlowNamedNotMapped() throws Exception { - FlowNameNotMappedEventChecker flowChecker; - Fop fop; - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - flowChecker = new FlowNameNotMappedEventChecker(); - userAgent.getEventBroadcaster().addEventListener(flowChecker); - fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, new NullOutputStream()); - Source src = new StreamSource(new FileInputStream("test/events/flowNameNotMapped.fo")); - SAXResult res = new SAXResult(fop.getDefaultHandler()); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - String expected = "on fo:flow could not be mapped to a region-name in the layout-master-set."; - String test = ""; - try { - transformer.transform(src, res); - } catch (TransformerException te) { - test = te.getLocalizedMessage(); - } - assertTrue(test.contains(expected)); - } -} diff --git a/test/java/org/apache/fop/events/TestEventProducer.java b/test/java/org/apache/fop/events/TestEventProducer.java deleted file mode 100644 index ff19c7ea6..000000000 --- a/test/java/org/apache/fop/events/TestEventProducer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.events; - -public interface TestEventProducer extends EventProducer { - - /** - * Complain about something. - * @param source the event source - * @param reason the reason for the complaint - * @param blah the complaint - * @event.severity WARN - */ - void complain(Object source, String reason, int blah); - - /** - * Express joy about something. - * @param source the event source - * @param what the cause for the joy - * @event.severity INFO - */ - void enjoy(Object source, String what); - - 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 deleted file mode 100644 index 226c551fb..000000000 --- a/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java +++ /dev/null @@ -1,531 +0,0 @@ -/* - * 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.fo; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -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; -import org.apache.fop.fo.flow.Block; -import org.apache.fop.fo.flow.BlockContainer; -import org.apache.fop.fo.flow.Character; -import org.apache.fop.fo.flow.ExternalGraphic; -import org.apache.fop.fo.flow.Footnote; -import org.apache.fop.fo.flow.FootnoteBody; -import org.apache.fop.fo.flow.Inline; -import org.apache.fop.fo.flow.InstreamForeignObject; -import org.apache.fop.fo.flow.Leader; -import org.apache.fop.fo.flow.ListBlock; -import org.apache.fop.fo.flow.ListItem; -import org.apache.fop.fo.flow.ListItemBody; -import org.apache.fop.fo.flow.ListItemLabel; -import org.apache.fop.fo.flow.PageNumber; -import org.apache.fop.fo.flow.PageNumberCitation; -import org.apache.fop.fo.flow.PageNumberCitationLast; -import org.apache.fop.fo.flow.Wrapper; -import org.apache.fop.fo.flow.table.Table; -import org.apache.fop.fo.flow.table.TableBody; -import org.apache.fop.fo.flow.table.TableCell; -import org.apache.fop.fo.flow.table.TableColumn; -import org.apache.fop.fo.flow.table.TableFooter; -import org.apache.fop.fo.flow.table.TableHeader; -import org.apache.fop.fo.flow.table.TableRow; -import org.apache.fop.fo.pagination.Flow; -import org.apache.fop.fo.pagination.PageSequence; -import org.apache.fop.fo.pagination.Root; -import org.apache.fop.fo.pagination.StaticContent; - -/** - * Tests that {@link DelegatingFOEventHandler} does forward every event to its delegate - * event handler. - */ -public class DelegatingFOEventHandlerTestCase { - - private InputStream document; - - private List<String> expectedEvents; - - private List<String> actualEvents; - - private FODocumentParser documentParser; - - private class DelegatingFOEventHandlerTester extends FOEventHandler { - - DelegatingFOEventHandlerTester(FOUserAgent foUserAgent) { - super(foUserAgent); - } - - private final StringBuilder eventBuilder = new StringBuilder(); - - @Override - public void startDocument() throws SAXException { - actualEvents.add("start document"); - } - - @Override - public void endDocument() throws SAXException { - actualEvents.add("end document"); - } - - @Override - public void startRoot(Root root) { - startElement(root); - } - - @Override - public void endRoot(Root root) { - endElement(root); - } - - @Override - public void startPageSequence(PageSequence pageSeq) { - startElement(pageSeq); - } - - @Override - public void endPageSequence(PageSequence pageSeq) { - endElement(pageSeq); - } - - @Override - public void startPageNumber(PageNumber pagenum) { - startElement(pagenum); - } - - @Override - public void endPageNumber(PageNumber pagenum) { - endElement(pagenum); - } - - @Override - public void startPageNumberCitation(PageNumberCitation pageCite) { - startElement(pageCite); - } - - @Override - public void endPageNumberCitation(PageNumberCitation pageCite) { - endElement(pageCite); - } - - @Override - public void startPageNumberCitationLast(PageNumberCitationLast pageLast) { - startElement(pageLast); - } - - @Override - public void endPageNumberCitationLast(PageNumberCitationLast pageLast) { - endElement(pageLast); - } - - @Override - public void startFlow(Flow fl) { - startElement(fl); - } - - @Override - public void endFlow(Flow fl) { - endElement(fl); - } - - @Override - public void startBlock(Block bl) { - startElement(bl); - } - - @Override - public void endBlock(Block bl) { - endElement(bl); - } - - @Override - public void startBlockContainer(BlockContainer blc) { - startElement(blc); - } - - @Override - public void endBlockContainer(BlockContainer blc) { - endElement(blc); - } - - @Override - public void startInline(Inline inl) { - startElement(inl); - } - - @Override - public void endInline(Inline inl) { - endElement(inl); - } - - @Override - public void startTable(Table tbl) { - startElement(tbl); - } - - @Override - public void endTable(Table tbl) { - endElement(tbl); - } - - @Override - public void startColumn(TableColumn tc) { - startElement(tc); - } - - @Override - public void endColumn(TableColumn tc) { - endElement(tc); - } - - @Override - public void startHeader(TableHeader header) { - startElement(header); - } - - @Override - public void endHeader(TableHeader header) { - endElement(header); - } - - @Override - public void startFooter(TableFooter footer) { - startElement(footer); - } - - @Override - public void endFooter(TableFooter footer) { - endElement(footer); - } - - @Override - public void startBody(TableBody body) { - startElement(body); - } - - @Override - public void endBody(TableBody body) { - endElement(body); - } - - @Override - public void startRow(TableRow tr) { - startElement(tr); - } - - @Override - public void endRow(TableRow tr) { - endElement(tr); - } - - @Override - public void startCell(TableCell tc) { - startElement(tc); - } - - @Override - public void endCell(TableCell tc) { - endElement(tc); - } - - @Override - public void startList(ListBlock lb) { - startElement(lb); - } - - @Override - public void endList(ListBlock lb) { - endElement(lb); - } - - @Override - public void startListItem(ListItem li) { - startElement(li); - } - - @Override - public void endListItem(ListItem li) { - endElement(li); - } - - @Override - public void startListLabel(ListItemLabel listItemLabel) { - startElement(listItemLabel); - } - - @Override - public void endListLabel(ListItemLabel listItemLabel) { - endElement(listItemLabel); - } - - @Override - public void startListBody(ListItemBody listItemBody) { - startElement(listItemBody); - } - - @Override - public void endListBody(ListItemBody listItemBody) { - endElement(listItemBody); - } - - @Override - public void startStatic(StaticContent staticContent) { - startElement(staticContent); - } - - @Override - public void endStatic(StaticContent statisContent) { - endElement(statisContent); - } - - @Override - public void startLink(BasicLink basicLink) { - startElement(basicLink); - } - - @Override - public void endLink(BasicLink basicLink) { - endElement(basicLink); - } - - @Override - public void image(ExternalGraphic eg) { - startElement(eg); - endElement(eg); - } - - @Override - public void startInstreamForeignObject(InstreamForeignObject ifo) { - startElement(ifo); - } - - @Override - public void endInstreamForeignObject(InstreamForeignObject ifo) { - endElement(ifo); - } - - @Override - public void startFootnote(Footnote footnote) { - startElement(footnote); - } - - @Override - public void endFootnote(Footnote footnote) { - endElement(footnote); - } - - @Override - public void startFootnoteBody(FootnoteBody body) { - startElement(body); - } - - @Override - public void endFootnoteBody(FootnoteBody body) { - endElement(body); - } - - @Override - public void startLeader(Leader l) { - startElement(l); - } - - @Override - public void endLeader(Leader l) { - endElement(l); - } - - @Override - public void startWrapper(Wrapper wrapper) { - startElement(wrapper); - } - - @Override - public void endWrapper(Wrapper wrapper) { - endElement(wrapper); - } - - @Override - public void character(Character c) { - startElement(c); - endElement(c); - } - - private void startElement(FObj node) { - addEvent("start ", node); - } - - private void endElement(FObj node) { - addEvent("end ", node); - } - - private void addEvent(String event, FObj node) { - eventBuilder.append(event); - eventBuilder.append(node.getLocalName()); - addID(node); - actualEvents.add(eventBuilder.toString()); - eventBuilder.setLength(0); - } - - private void addID(FObj node) { - String id = node.getId(); - if (id != null && id.length() > 0) { - eventBuilder.append(" id=\""); - eventBuilder.append(id); - eventBuilder.append("\""); - } - } - } - - @Before - public void setUp() throws IOException { - setUpEvents(); - loadDocument(); - createDocumentParser(); - } - - private void setUpEvents() throws IOException { - loadDocument(); - loadExpectedEvents(); - actualEvents = new ArrayList<String>(expectedEvents.size()); - } - - private void loadDocument() { - document = getClass().getResourceAsStream("complete_document.fo"); - } - - private void loadExpectedEvents() throws IOException { - expectedEvents = new ArrayList<String>(); - InputStream xslt = getClass().getResourceAsStream("extract-events.xsl"); - try { - runXSLT(xslt); - } finally { - closeStream(xslt); - closeStream(document); - } - } - - private void runXSLT(InputStream xslt) { - Transformer transformer = createTransformer(xslt); - Source fo = new StreamSource(document); - Result result = createTransformOutputHandler(); - try { - transformer.transform(fo, result); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - } - - private Transformer createTransformer(InputStream xslt) { - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - try { - return transformerFactory.newTransformer(new StreamSource(xslt)); - } catch (TransformerConfigurationException e) { - throw new RuntimeException(e); - } - } - - private Result createTransformOutputHandler() { - return new SAXResult(new DefaultHandler() { - - private final StringBuilder event = new StringBuilder(); - - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - event.setLength(0); - } - - @Override - public void characters(char[] ch, int start, int length) throws SAXException { - event.append(ch, start, length); - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - expectedEvents.add(event.toString()); - } - - }); - } - - private void closeStream(InputStream stream) { - try { - stream.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private void createDocumentParser() { - documentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() { - - public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) { - return new DelegatingFOEventHandler( - new DelegatingFOEventHandlerTester(foUserAgent)) { - }; - } - }); - } - - @Test - public void testFOEventHandler() throws Exception { - documentParser.parse(document); - assertArrayEquals(expectedEvents.toArray(), actualEvents.toArray()); - } - - @After - public void unloadDocument() throws IOException { - document.close(); - } - - /** - * Prints the given list to {@code System.out}, each element on a new line. For - * debugging purpose. - * - * @param list a list - */ - public void printList(List<?> list) { - for (Object element : list) { - System.out.println(element); - } - } - -} diff --git a/test/java/org/apache/fop/fo/FODocumentParser.java b/test/java/org/apache/fop/fo/FODocumentParser.java deleted file mode 100644 index 2e691519b..000000000 --- a/test/java/org/apache/fop/fo/FODocumentParser.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.fo; - -import java.io.File; -import java.io.InputStream; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -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.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.events.EventListener; - -/** - * Parse an FO document and run the corresponding FO events through a given - * {@link FOEventHandler} instance. That instance is created using the helper - * {@link FOEventHandlerFactory}. - * - * <p>An instance of this class may not be used in multiple threads concurrently.<p> - * - * <p>An instance of this class may be used multiple times if the given - * {@link FOEventHandler} implementation can be used multiple times. - */ -public final class FODocumentParser { - - private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance(); - - private static final FopFactory FOP_FACTORY = FopFactory.newInstance(new File(".").toURI()); - - private final FOEventHandlerFactory foEventHandlerFactory; - - private Fop fop; - - private Transformer transformer; - - private EventListener eventListener; - - /** - * A factory to create custom instances of {@link FOEventHandler}. - */ - public interface FOEventHandlerFactory { - - /** - * Creates a new {@code FOEventHandler} instance parameterized with the given FO user agent. - * - * @param foUserAgent an FO user agent - * @return a new {@code FOEventHandler} instance - */ - FOEventHandler newFOEventHandler(FOUserAgent foUserAgent); - } - - private FODocumentParser(FOEventHandlerFactory foeEventHandlerFactory) { - this.foEventHandlerFactory = foeEventHandlerFactory; - } - - /** - * Creates and returns a new FO document parser. The given factory will be used to - * customize the handler that will receive FO events, using the - * {@link FOUserAgent#setFOEventHandlerOverride(FOEventHandler)} method. - * - * @param foEventHandlerFactory the factory to be used to create {@code - * FOEventHandler} instances - * @return a new parser - */ - public static FODocumentParser newInstance(FOEventHandlerFactory foEventHandlerFactory) { - return new FODocumentParser(foEventHandlerFactory); - } - - /** - * Sets the event listener to be used if events occurs when parsing the document. - * - * @param eventListener an event listener - */ - public void setEventListener(EventListener eventListener) { - this.eventListener = eventListener; - } - - /** - * Runs FOP on the given document. - * - * @param document XSL-FO document to parse - * @throws FOPException if an error occurs when initializing FOP - * @throws LoadingException if an error occurs when parsing the document - */ - public void parse(InputStream document) throws FOPException, LoadingException { - parse(document, createFOUserAgent()); - } - - /** - * Runs FOP on the given document with the supplied {@link FOUserAgent}. - * - * @param document XSL-FO document to parse - * @param foUserAgent The user agent - * @throws FOPException if an error occurs when initializing FOP - * @throws LoadingException if an error occurs when parsing the document - */ - public void parse(InputStream document, FOUserAgent foUserAgent) - throws FOPException, LoadingException { - fop = FOP_FACTORY.newFop(foUserAgent); - createTransformer(); - runTransformer(document); - } - - /** - * Creates a new {@link FOUserAgent}. - * @return It - */ - public FOUserAgent createFOUserAgent() { - FOUserAgent userAgent = FOP_FACTORY.newFOUserAgent(); - FOEventHandler foEventHandler = foEventHandlerFactory.newFOEventHandler(userAgent); - userAgent.setFOEventHandlerOverride(foEventHandler); - if (eventListener != null) { - userAgent.getEventBroadcaster().addEventListener(eventListener); - } - return userAgent; - } - - private void createTransformer() { - try { - transformer = TRANSFORMER_FACTORY.newTransformer(); - } catch (TransformerConfigurationException e) { - throw new RuntimeException(e); - } - } - - private void runTransformer(InputStream input) throws LoadingException, FOPException { - Source source = new StreamSource(input); - Result result = new SAXResult(fop.getDefaultHandler()); - try { - transformer.transform(source, result); - } catch (TransformerException e) { - Throwable cause = e.getCause(); - throw new LoadingException(cause == null ? e : cause); - } - } -} diff --git a/test/java/org/apache/fop/fo/FONodeMocks.java b/test/java/org/apache/fop/fo/FONodeMocks.java deleted file mode 100644 index 97889c177..000000000 --- a/test/java/org/apache/fop/fo/FONodeMocks.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.fo; - -import java.io.IOException; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.xmlgraphics.image.loader.ImageException; -import org.apache.xmlgraphics.image.loader.ImageManager; -import org.apache.xmlgraphics.image.loader.ImageSessionContext; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.events.EventBroadcaster; -import org.apache.fop.fo.flow.table.ColumnNumberManager; -import org.apache.fop.fo.flow.table.ColumnNumberManagerHolder; - -/** - * A helper class for creating mocks of {@link FONode} and its descendants. - */ -public final class FONodeMocks { - - private 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 org.apache.fop.apps.FopFactory}, which returns a mock - * {@link ImageManager}. - * - * @return a mock FO node - */ - public static FONode mockFONode() { - FONode mockFONode = mock(FONode.class); - mockGetFOEventHandler(mockFONode); - mockGetImageManager(mockFONode.getFOEventHandler().getUserAgent()); - return mockFONode; - } - - public static FOEventHandler mockGetFOEventHandler(FONode mockFONode) { - FOEventHandler mockFOEventHandler = mock(FOEventHandler.class); - mockGetUserAgent(mockFOEventHandler); - when(mockFONode.getFOEventHandler()).thenReturn(mockFOEventHandler); - return mockFOEventHandler; - } - - public static FOUserAgent mockGetUserAgent(FOEventHandler mockFOEventHandler) { - FOUserAgent mockFOUserAgent = mock(FOUserAgent.class); - when(mockFOEventHandler.getUserAgent()).thenReturn(mockFOUserAgent); - return mockFOUserAgent; - } - - public static EventBroadcaster mockGetEventBroadcaster(FOUserAgent mockFOUserAgent) { - EventBroadcaster mockBroadcaster = mock(EventBroadcaster.class); - when(mockFOUserAgent.getEventBroadcaster()).thenReturn(mockBroadcaster); - return mockBroadcaster; - } - - public static ImageManager mockGetImageManager(FOUserAgent mockFOUserAgent) { - try { - ImageManager mockImageManager = mock(ImageManager.class); - when(mockImageManager.getImageInfo(anyString(), any(ImageSessionContext.class))) - .thenReturn(null); - when(mockFOUserAgent.getImageManager()).thenReturn(mockImageManager); - return mockImageManager; - } catch (ImageException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static ColumnNumberManager mockGetColumnNumberManager(ColumnNumberManagerHolder mock) { - ColumnNumberManager mockColumnNumberManager = mock(ColumnNumberManager.class); - when(mock.getColumnNumberManager()).thenReturn(mockColumnNumberManager); - return mockColumnNumberManager; - } - -} diff --git a/test/java/org/apache/fop/fo/LoadingException.java b/test/java/org/apache/fop/fo/LoadingException.java deleted file mode 100644 index a5d509209..000000000 --- a/test/java/org/apache/fop/fo/LoadingException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.fo; - -/** - * This class specifies an exceptional condition that occurred while an XSL-FO document - * was being parsed. - */ -public class LoadingException extends Exception { - - private static final long serialVersionUID = 7529029475875542916L; - - LoadingException(Throwable cause) { - super(cause); - } - -} diff --git a/test/java/org/apache/fop/fo/complete_document.fo b/test/java/org/apache/fop/fo/complete_document.fo deleted file mode 100644 index b103744ae..000000000 --- a/test/java/org/apache/fop/fo/complete_document.fo +++ /dev/null @@ -1,176 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- - 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$ --> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> - - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="400pt" page-width="300pt" margin="20pt" margin-top="10pt"> - <fo:region-body margin-top="20pt"/> - <fo:region-before extent="15pt"/> - </fo:simple-page-master> - </fo:layout-master-set> - - <fo:page-sequence master-reference="page"> - <fo:static-content flow-name="xsl-region-before"> - <fo:block id="1" font-size="7pt" text-align-last="justify" padding-bottom="2pt" - border-bottom="0.25pt solid black">This is the page header<fo:leader/>Page <fo:page-number - id="2"/></fo:block> - </fo:static-content> - <fo:static-content flow-name="xsl-footnote-separator"> - <fo:block id="3"><fo:leader leader-length="100pt" leader-pattern="rule"/></fo:block> - </fo:static-content> - <fo:flow flow-name="xsl-region-body"> - <fo:block id="4">This is a link to the <fo:wrapper id="5" color="blue"><fo:basic-link id="6" - internal-destination="second-start" fox:alt-text="">next page-sequence</fo:basic-link></fo:wrapper> - (which starts on page <fo:page-number-citation id="7" ref-id="second-start"/> and ends on - page <fo:page-number-citation-last id="8" ref-id="second-end"/>).</fo:block> - <fo:block id="9" font-family="sans-serif" font-weight="bold" space-before="1em" - space-after="0.2em" role="H1"><fo:block id="10">A Title Block</fo:block></fo:block> - <fo:block id="11">This block of text contains a footnote<fo:footnote id="12"><fo:inline id="13" - baseline-shift="super" font-size="70%">1</fo:inline><fo:footnote-body id="14"><fo:block - id="15">A footnote with a link to the <fo:wrapper id="16" color="blue"><fo:basic-link - id="17" external-destination="http://xmlgraphics.apache.org/fop/" fox:alt-text="">FOP - website</fo:basic-link></fo:wrapper></fo:block></fo:footnote-body></fo:footnote> - call.</fo:block> - <fo:table id="18" space-before="1em" width="100%" table-layout="fixed"> - <fo:table-column id="19" column-width="proportional-column-width(1)"/> - <fo:table-column id="20" column-width="proportional-column-width(2)"/> - <fo:table-header id="21"> - <fo:table-row id="22"> - <fo:table-cell id="23" border="2pt solid black" padding="2pt 2pt 0"> - <fo:block id="24">Header 1.1</fo:block> - </fo:table-cell> - <fo:table-cell id="25" border="2pt solid black" padding="2pt 2pt 0"> - <fo:block id="26">Header 1.2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-header> - <fo:table-footer id="27"> - <fo:table-row id="28"> - <fo:table-cell id="29" border="2pt solid black" padding="2pt 2pt 0"> - <fo:block id="30">Footer 1.1</fo:block> - </fo:table-cell> - <fo:table-cell id="31" border="2pt solid black" padding="2pt 2pt 0"> - <fo:block id="32">Footer 1.2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-footer> - <fo:table-body id="33"> - <fo:table-row id="34"> - <fo:table-cell id="35" border="1pt solid black" padding="2pt 2pt 0"> - <fo:block id="36">Cell 1.1</fo:block> - </fo:table-cell> - <fo:table-cell id="37" border="1pt solid black" padding="2pt 2pt 0"> - <fo:block id="38">Cell 1.2</fo:block> - </fo:table-cell> - </fo:table-row> - <fo:table-row id="39"> - <fo:table-cell id="40" border="1pt solid black" padding="2pt 2pt 0"> - <fo:block id="41">Cell 2.1</fo:block> - </fo:table-cell> - <fo:table-cell id="42" border="1pt solid black" padding="2pt 2pt 0"> - <fo:block id="43">Cell 2.2</fo:block> - </fo:table-cell> - </fo:table-row> - </fo:table-body> - </fo:table> - <fo:block-container id="44" space-before="1.2em"> - <fo:block-container id="45" absolute-position="absolute" top="6pt" right="2.5pt" - inline-progression-dimension="37%" padding="3pt 1pt 2pt 3pt" border="1.5pt solid - darkblue"> - <fo:block id="46" color="darkblue" font-size="80%">This is an absolutely positioned - block-container. Nullam interdum mattis ipsum sit amet molestie.</fo:block> - </fo:block-container> - <fo:block id="47" end-indent="37% + 15pt">Lorem ipsum dolor sit amet, consectetur adipiscing - elit. Integer vel lacinia diam. Etiam venenatis magna vel libero imperdiet - rhoncus.</fo:block> - </fo:block-container> - </fo:flow> - </fo:page-sequence> - - <fo:page-sequence master-reference="page"> - <fo:static-content id="48" flow-name="xsl-region-before"> - <fo:block id="49" font-size="7pt" text-align-last="justify" padding-bottom="2pt" - border-bottom="0.25pt solid black">This is the page header<fo:leader id="50"/>Page - <fo:page-number id="51"/></fo:block> - </fo:static-content> - <fo:flow flow-name="xsl-region-body" text-align="justify" space-before.minimum="8pt" - space-before.optimum="10pt" space-before.maximum="12pt"> - <fo:block id="second-start">Starting a new page-sequence.</fo:block> - <fo:block id="52" text-align="center">The <fo:external-graphic id="53" - src="test/resources/images/fop-logo-color-24bit.png" - inline-progression-dimension.maximum="50%" content-width="scale-to-fit" - alignment-adjust="-46%" alignment-baseline="middle" fox:alt-text="FOP Logo"/> - logo.</fo:block> - <fo:list-block id="54" provisional-distance-between-starts="15pt" - provisional-label-separation="0" space-before="inherit"> - <fo:list-item id="55"> - <fo:list-item-label id="56" end-indent="label-end()"> - <fo:block id="57">1.</fo:block> - </fo:list-item-label> - <fo:list-item-body id="58" start-indent="body-start()"> - <fo:block id="59">First item of a list</fo:block> - </fo:list-item-body> - </fo:list-item> - <fo:list-item id="60"> - <fo:list-item-label id="61" end-indent="label-end()"> - <fo:block id="62">2.</fo:block> - </fo:list-item-label> - <fo:list-item-body id="63" start-indent="body-start()"> - <fo:block id="64">Second item of a list</fo:block> - </fo:list-item-body> - </fo:list-item> - <fo:list-item id="65"> - <fo:list-item-label id="66" end-indent="label-end()"> - <fo:block id="67">3.</fo:block> - </fo:list-item-label> - <fo:list-item-body id="68" start-indent="body-start()"> - <fo:block id="69">Third item of a list</fo:block> - </fo:list-item-body> - </fo:list-item> - </fo:list-block> - <fo:block id="70" text-align="center"><fo:instream-foreign-object id="71" - inline-progression-dimension.maximum="50%" content-width="scale-to-fit" - fox:alt-text="An inline SVG"> - <svg xmlns="http://www.w3.org/2000/svg" width="319" height="286.6"> - <g style="fill-opacity:0.7; stroke:black; stroke-width:3" - transform="translate(0, 286.6) scale(1, -1) translate(100, 100)"> - <circle cx="50" cy="86.6" r="80" style="fill:red;"/> - <circle cx="0" cy="0" r="80" style="fill:green;"/> - <circle cx="100" cy="0" r="80" style="fill:blue;"/> - </g> - </svg> - </fo:instream-foreign-object></fo:block> - <fo:block id="72" space-before="inherit">A block containing an <fo:inline id="73" - border="0.5pt solid black" padding="2pt" padding-bottom="0">inline</fo:inline> - element.</fo:block> - <fo:block id="74" space-before="inherit">A block containing a fancy <fo:character id="75" - border="1pt solid black" padding="0 2pt 1pt 2pt" font-family="Symbol" character="♦"/> - character.</fo:block> - <fo:block id="76" space-before="inherit" text-align-last="justify">A leader with special - content: <fo:leader id="77" leader-pattern="use-content"><fo:inline id="78"><fo:character - id="79" character=" "/><fo:inline id="80" border="0.5pt solid black" - padding-left="2pt" padding-right="2pt"><fo:character id="81" baseline-shift="-10%" - character="•"/></fo:inline></fo:inline></fo:leader>.</fo:block> - <fo:block id="second-end" space-before="inherit">Ending the page-sequence.</fo:block> - </fo:flow> - </fo:page-sequence> - -</fo:root> diff --git a/test/java/org/apache/fop/fo/extract-events.xsl b/test/java/org/apache/fop/fo/extract-events.xsl deleted file mode 100644 index eae794754..000000000 --- a/test/java/org/apache/fop/fo/extract-events.xsl +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<xsl:stylesheet version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:fo="http://www.w3.org/1999/XSL/Format" - exclude-result-prefixes="fo"> - - <xsl:output indent="yes" omit-xml-declaration="yes"/> - - <xsl:template match="/"> - <event> - <xsl:text>start document</xsl:text> - </event> - <xsl:apply-templates/> - <event> - <xsl:text>end document</xsl:text> - </event> - </xsl:template> - - <xsl:template match="fo:root"> - <event>start root</event> - <xsl:apply-templates select="fo:page-sequence"/> - <event>end root</event> - </xsl:template> - - <xsl:template match="fo:*"> - <xsl:call-template name="process.node"> - <xsl:with-param name="id"> - <xsl:apply-templates select="@id"/> - </xsl:with-param> - </xsl:call-template> - </xsl:template> - - <xsl:template name="process.node"> - <xsl:param name="id" select="''"/> - <event> - <xsl:text>start </xsl:text> - <xsl:value-of select="local-name()"/> - <xsl:value-of select="$id"/> - </event> - <xsl:apply-templates/> - <event> - <xsl:text>end </xsl:text> - <xsl:value-of select="local-name()"/> - <xsl:value-of select="$id"/> - </event> - </xsl:template> - - <xsl:template match="@id"> - <xsl:text> id="</xsl:text> - <xsl:value-of select="."/> - <xsl:text>"</xsl:text> - </xsl:template> - - <xsl:template match="text()"/> - -</xsl:stylesheet> diff --git a/test/java/org/apache/fop/fo/flow/MarkersTestCase.java b/test/java/org/apache/fop/fo/flow/MarkersTestCase.java deleted file mode 100644 index 09a4e129c..000000000 --- a/test/java/org/apache/fop/fo/flow/MarkersTestCase.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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.fo.flow; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -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.fo.Constants; - -public class MarkersTestCase { - - @Test - public void testRegisterAndResolve() { - // consider 3 regions, and a boundary; the first region starts before the boundary and ends inside - // the boundary, the second region is fully inside the boundary, and the third region starts inside - // the boundary and ends after the boundary. in every region there are 2 markers, A and B. - // ======== region 1 - Map<String, Marker> markers_region_1 = new HashMap<String, Marker>(); - Marker marker_1A = mock(Marker.class); - Marker marker_1B = mock(Marker.class); - markers_region_1.put("A", marker_1A); - markers_region_1.put("B", marker_1B); - // ======== region 2 - Map<String, Marker> markers_region_2 = new HashMap<String, Marker>(); - Marker marker_2A = mock(Marker.class); - Marker marker_2B = mock(Marker.class); - markers_region_2.put("A", marker_2A); - markers_region_2.put("B", marker_2B); - // ======== region 3 - Map<String, Marker> markers_region_3 = new HashMap<String, Marker>(); - Marker marker_3A = mock(Marker.class); - Marker marker_3B = mock(Marker.class); - markers_region_3.put("A", marker_3A); - markers_region_3.put("B", marker_3B); - // instantiate markers for the boundary - Markers markers = new Markers(); - // register the markers for the different regions - // region 1 - markers.register(markers_region_1, true, false, true); - markers.register(markers_region_1, false, false, true); - // region 2 - markers.register(markers_region_2, true, true, true); - markers.register(markers_region_2, false, true, true); - // region 3 - markers.register(markers_region_3, true, true, false); - markers.register(markers_region_3, false, true, false); - // now prepare a RetrieveMarker - RetrieveMarker rm = mock(RetrieveMarker.class); - when(rm.getRetrieveClassName()).thenReturn("A"); - when(rm.getLocalName()).thenReturn("retrieve-marker"); - when(rm.getPositionLabel()).thenReturn("position-label"); // not relevant for the test - // and resolve the marker for different positions - // EN_FSWP - when(rm.getPosition()).thenReturn(Constants.EN_FSWP); - // expect marker_2A - assertEquals(marker_2A, markers.resolve(rm)); - // EN_LSWP - when(rm.getPosition()).thenReturn(Constants.EN_LSWP); - // expect marker_3A - assertEquals(marker_3A, markers.resolve(rm)); - // EN_LEWP - when(rm.getPosition()).thenReturn(Constants.EN_LEWP); - // expect marker_2A - assertEquals(marker_2A, markers.resolve(rm)); - // EN_FIC - when(rm.getPosition()).thenReturn(Constants.EN_FIC); - // expect marker_1A - assertEquals(marker_1A, markers.resolve(rm)); - // now prepare a RetrieveTableMarker - RetrieveTableMarker rtm = mock(RetrieveTableMarker.class); - when(rtm.getRetrieveClassName()).thenReturn("B"); - when(rtm.getLocalName()).thenReturn("retrieve-table-marker"); - when(rtm.getPositionLabel()).thenReturn("position-label"); // not relevant for the test - // and resolve the marker for different positions - // EN_FIRST_STARTING - when(rtm.getPosition()).thenReturn(Constants.EN_FIRST_STARTING); - // expect marker_2B - assertEquals(marker_2B, markers.resolve(rtm)); - // EN_LAST_STARTING - when(rtm.getPosition()).thenReturn(Constants.EN_LAST_STARTING); - // expect marker_3B - assertEquals(marker_3B, markers.resolve(rtm)); - // EN_LAST_ENDING - when(rtm.getPosition()).thenReturn(Constants.EN_LAST_ENDING); - // expect marker_2B - assertEquals(marker_2B, markers.resolve(rtm)); - // EN_FIRST_INCLUDING_CARRYOVER - when(rtm.getPosition()).thenReturn(Constants.EN_FIRST_INCLUDING_CARRYOVER); - // expect marker_1B - assertEquals(marker_1B, markers.resolve(rtm)); - // test also an invalid position - when(rm.getPosition()).thenReturn(Constants.EN_ABSOLUTE); - try { - Marker m = markers.resolve(rm); - fail("Expected an exception... instead got:" + m.toString()); - } catch (RuntimeException re) { - // do nothing - } - } -} diff --git a/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java b/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java deleted file mode 100644 index 0f0e347d3..000000000 --- a/test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.fo.flow.table; - -import java.io.FileInputStream; -import java.util.Iterator; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fo.FODocumentParser; -import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; -import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.util.ConsoleEventListenerForTests; - -/** - * Superclass for testcases related to tables, factoring the common stuff. - */ -abstract class AbstractTableTest { - - private FODocumentParser documentParser; - - private TableHandler tableHandler; - - protected void setUp(String filename) throws Exception { - createDocumentParser(); - documentParser.setEventListener(new ConsoleEventListenerForTests(filename)); - documentParser.parse(new FileInputStream("test/fotree/unittests/" + filename)); - } - - private void createDocumentParser() { - documentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() { - public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) { - tableHandler = new TableHandler(foUserAgent); - return tableHandler; - } - }); - } - - protected TableHandler getTableHandler() { - return tableHandler; - } - - protected Iterator getTableIterator() { - return tableHandler.getTables().iterator(); - } -} diff --git a/test/java/org/apache/fop/fo/flow/table/AllTests.java b/test/java/org/apache/fop/fo/flow/table/AllTests.java deleted file mode 100644 index d4b5e8f6f..000000000 --- a/test/java/org/apache/fop/fo/flow/table/AllTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.fo.flow.table; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * All test to be added in FOTreeTestSuite - * - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - CollapsedConditionalBorderTestCase.class, - IllegalRowSpanTestCase.class, - RowGroupBuilderTestCase.class, - TableColumnColumnNumberTestCase.class, - TooManyColumnsTestCase.class }) -public final class AllTests { -} diff --git a/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java b/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java deleted file mode 100644 index 1362ad559..000000000 --- a/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * 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.fo.flow.table; - -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 - * collapsed-conditional-borders_test-generator.py Python script. - */ -public class CollapsedConditionalBorderTestCase extends AbstractTableTest { - - private final Integer border0pt = new Integer(0); - - private final Integer border4pt = new Integer(4000); - - private final Integer border6pt = new Integer(6000); - - private final Integer border8pt = new Integer(8000); - - /** - * Resolved borders for tables without headers and footers, generated from the Python - * script. - */ - private Object[][][] resolvedBorders = { - {{border0pt, Color.black}, {border8pt, Color.black}}, - {{border6pt, Color.red}, {border6pt, Color.magenta}}, - {{border6pt, Color.blue}, {border6pt, Color.yellow}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border6pt, Color.red}, {border6pt, Color.magenta}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border6pt, Color.red}, {border6pt, Color.blue}}, - {{border6pt, Color.magenta}, {border6pt, Color.blue}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border6pt, Color.red}, {border6pt, Color.yellow}}, - {{border6pt, Color.magenta}, {border6pt, Color.yellow}}, - {{border6pt, Color.blue}, {border6pt, Color.yellow}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border6pt, Color.red}}, - {{border6pt, Color.magenta}, {border6pt, Color.blue}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border6pt, Color.red}, {border6pt, Color.magenta}}, - {{border6pt, Color.yellow}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border6pt, Color.red}, {border6pt, Color.blue}}, - {{border6pt, Color.yellow}, {border6pt, Color.magenta}}, - {{border6pt, Color.blue}, {border6pt, Color.yellow}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border6pt, Color.red}, {border6pt, Color.magenta}}, - {{border6pt, Color.blue}, {border6pt, Color.yellow}}, - {{border8pt, Color.black}, {border8pt, Color.black}}, - {{border8pt, Color.black}, {border8pt, Color.black}} - }; - - /** - * Resolved borders for tables with headers and footers, generated from the Python - * script. - */ - private Object[][][] resolvedBordersHF = { -{{border8pt, Color.black}, {border6pt, Color.black}, {border8pt, Color.black}, {border6pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.red}, {border8pt, Color.blue}, {border6pt, Color.black}, {border4pt, Color.magenta}, {border8pt, Color.blue}, {border8pt, Color.blue}, {border4pt, Color.red}, {border4pt, Color.blue}, {border4pt, Color.blue}, {border4pt, Color.magenta}}, -{{border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.black}, {border6pt, Color.blue}, {border4pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.red}, {border8pt, Color.blue}, {border6pt, Color.black}, {border6pt, Color.black}, {border8pt, Color.blue}, {border8pt, Color.blue}, {border4pt, Color.red}, {border4pt, Color.blue}, {border4pt, Color.blue}, {border4pt, Color.magenta}}, -{{border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.red}, {border8pt, Color.red}, {border8pt, Color.red}, {border6pt, Color.blue}, {border4pt, Color.black}, {border4pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.red}, {border8pt, Color.red}, {border4pt, Color.blue}, {border4pt, Color.blue}, {border4pt, Color.magenta}}, -{{border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.red}, {border8pt, Color.red}, {border8pt, Color.red}, {border6pt, Color.blue}, {border4pt, Color.black}, {border4pt, Color.magenta}, {border6pt, Color.blue}, {border8pt, Color.red}, {border8pt, Color.red}, {border4pt, Color.blue}, {border4pt, Color.blue}, {border4pt, Color.magenta}}, -{{border8pt, Color.black}, {border6pt, Color.black}, {border8pt, Color.black}, {border6pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.red}, {border8pt, Color.black}, {border8pt, Color.black}, {border4pt, Color.magenta}, {border8pt, Color.black}, {border6pt, Color.blue}, {border4pt, Color.red}, {border4pt, Color.blue}, {border4pt, Color.blue}, {border4pt, Color.magenta}}, -{{border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.black}, {border6pt, Color.blue}, {border4pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.red}, {border8pt, Color.black}, {border8pt, Color.black}, {border4pt, Color.magenta}, {border8pt, Color.black}, {border6pt, Color.blue}, {border6pt, Color.blue}, {border4pt, Color.blue}, {border4pt, Color.blue}, {border4pt, Color.magenta}}, -{{border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.black}, {border6pt, Color.blue}, {border4pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.red}, {border6pt, Color.black}, {border8pt, Color.magenta}, {border8pt, Color.magenta}, {border6pt, Color.black}, {border4pt, Color.blue}, {border4pt, Color.red}, {border8pt, Color.magenta}, {border8pt, Color.magenta}, {border8pt, Color.magenta}}, -{{border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.black}, {border6pt, Color.blue}, {border4pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.red}, {border8pt, Color.black}, {border8pt, Color.black}, {border8pt, Color.black}, {border8pt, Color.black}, {border4pt, Color.blue}, {border4pt, Color.red}, {border6pt, Color.magenta}, {border6pt, Color.magenta}, {border6pt, Color.magenta}} - }; - - private static GridUnit getGridUnit(TablePart part) { - return (GridUnit) ((List) ((List) part.getRowGroups().get(0)).get(0)).get(0); - } - - private static void checkBorder(String errorMsge, BorderSpecification border, - int expectedLength, Color expectedColor) { - BorderInfo borderInfo = border.getBorderInfo(); - if (expectedLength == 0) { - assertEquals(errorMsge, Constants.EN_NONE, borderInfo.getStyle()); - } else { - assertEquals(errorMsge, expectedLength, borderInfo.getWidth().getLengthValue()); - assertEquals(errorMsge, expectedColor, borderInfo.getColor()); - } - } - - private static void checkBorder(String errorMsge, BorderSpecification border, - Object[] resolvedBorder) { - checkBorder(errorMsge, border, - ((Integer) resolvedBorder[0]).intValue(), - (Color) resolvedBorder[1]); - } - - @Test - public void testCollapsedConditionalBorders() throws Exception { - setUp("table/collapsed-conditional-borders.fo"); - int tableNum = 0; - Iterator tableIterator = getTableIterator(); - do { - String baseErrorMsge = "table " + Integer.toString(tableNum) + " (0-based), "; - Table table = (Table) tableIterator.next(); - TablePart part = (TablePart) table.getChildNodes().next(); - GridUnit gu = getGridUnit(part); - - String errorMsge = baseErrorMsge + "border-before"; - checkBorder(errorMsge, gu.borderBefore.normal, 8000, Color.black); - checkBorder(errorMsge, gu.borderBefore.leadingTrailing, 8000, Color.black); - checkBorder(errorMsge, gu.borderBefore.rest, resolvedBorders[tableNum][0]); - - errorMsge = baseErrorMsge + "border-after"; - checkBorder(errorMsge, gu.borderAfter.normal, 8000, Color.black); - checkBorder(errorMsge, gu.borderAfter.leadingTrailing, 8000, Color.black); - checkBorder(errorMsge, gu.borderAfter.rest, resolvedBorders[tableNum][1]); - - tableNum++; - } while (tableIterator.hasNext()); - } - - @Test - public void testCollapsedConditionalBordersHeaderFooter() throws Exception { - setUp("table/collapsed-conditional-borders_header-footer.fo"); - int tableNum = 0; - Iterator tableIterator = getTableIterator(); - do { - String errorMsge = "table " + Integer.toString(tableNum) + " (0-based)"; - int borderNum = 0; - Table table = (Table) tableIterator.next(); - - TableHeader header = table.getTableHeader(); - GridUnit gu = getGridUnit(header); - checkBorder(errorMsge, gu.borderBefore.normal, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderBefore.rest, - resolvedBordersHF[tableNum][borderNum++]); - - TableFooter footer = table.getTableFooter(); - gu = getGridUnit(footer); - checkBorder(errorMsge, gu.borderAfter.normal, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderAfter.rest, - resolvedBordersHF[tableNum][borderNum++]); - - FONodeIterator bodyIter = table.getChildNodes(); - TableBody body = (TableBody) bodyIter.next(); - gu = getGridUnit(body); - checkBorder(errorMsge, gu.borderBefore.normal, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderBefore.leadingTrailing, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderBefore.rest, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderAfter.normal, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderAfter.leadingTrailing, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderAfter.rest, - resolvedBordersHF[tableNum][borderNum++]); - - body = (TableBody) bodyIter.next(); - gu = getGridUnit(body); - checkBorder(errorMsge, gu.borderBefore.normal, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderBefore.leadingTrailing, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderBefore.rest, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderAfter.normal, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderAfter.leadingTrailing, - resolvedBordersHF[tableNum][borderNum++]); - checkBorder(errorMsge, gu.borderAfter.rest, - resolvedBordersHF[tableNum][borderNum++]); - - tableNum++; - } while (tableIterator.hasNext()); - } -} diff --git a/test/java/org/apache/fop/fo/flow/table/ErrorCheckTest.java b/test/java/org/apache/fop/fo/flow/table/ErrorCheckTest.java deleted file mode 100644 index b30c64c07..000000000 --- a/test/java/org/apache/fop/fo/flow/table/ErrorCheckTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.fo.flow.table; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.apache.fop.fo.LoadingException; -import org.apache.fop.fo.ValidationException; - -/** - * Abstract class for testing erroneous files, checking that a ValidationException is thrown. - */ -abstract class ErrorCheckTest extends AbstractTableTest { - - protected void launchTest(String filename) throws Exception { - try { - setUp(filename); - fail("Expected ValidationException to be thrown"); - } catch (LoadingException e) { - // TODO check location - assertTrue(e.getCause() instanceof ValidationException); - } - } - -} diff --git a/test/java/org/apache/fop/fo/flow/table/HeaderColumnTestCase.java b/test/java/org/apache/fop/fo/flow/table/HeaderColumnTestCase.java deleted file mode 100644 index 4cc94b5e0..000000000 --- a/test/java/org/apache/fop/fo/flow/table/HeaderColumnTestCase.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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.fo.flow.table; - -import org.junit.Test; -import org.xml.sax.Attributes; -import org.xml.sax.Locator; -import org.xml.sax.helpers.AttributesImpl; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.events.EventBroadcaster; -import org.apache.fop.fo.ElementMappingRegistry; -import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.fo.FONodeMocks; -import org.apache.fop.fo.FOValidationEventProducer; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.StaticPropertyList; -import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.expr.PropertyException; -import org.apache.fop.fo.extensions.ExtensionElementMapping; -import org.apache.fop.util.XMLUtil; - -/** - * Tests that the fox:header property is correctly parsed and set up at the FO tree level. - */ -public class HeaderColumnTestCase { - - @Test - public void testWrongValue() throws ValidationException { - Table parent = createTableParent(); - EventBroadcaster mockEventBroadcaster = FONodeMocks.mockGetEventBroadcaster( - parent.getFOEventHandler().getUserAgent()); - FOValidationEventProducer eventProducer = mockGetEventProducerFor(mockEventBroadcaster); - TableColumn column = new TableColumn(parent); - PropertyList propertyList = new StaticPropertyList(column, null); - Attributes atts = createScopeAttribute("blah"); - propertyList.addAttributesToList(atts); - verify(eventProducer).invalidPropertyValue(any(), eq("fo:table-column"), - eq("fox:header"), eq("blah"), any(PropertyException.class), any(Locator.class)); - } - - @Test - public void testCorrectValue() throws Exception { - testCorrectValue(true); - testCorrectValue(false); - } - - private void testCorrectValue(boolean expectedValue) throws Exception { - Table parent = createTableParent(); - FONodeMocks.mockGetColumnNumberManager(parent); - TableColumn column = new TableColumn(parent, true); - PropertyList propertyList = new StaticPropertyList(column, null); - Attributes atts = createScopeAttribute(String.valueOf(expectedValue)); - propertyList.addAttributesToList(atts); - column.bind(propertyList); - assertEquals(expectedValue, column.isHeader()); - } - - private Table createTableParent() { - Table parent = mock(Table.class); - FOEventHandler mockFOEventHandler = FONodeMocks.mockGetFOEventHandler(parent); - FOUserAgent mockUserAgent = mockFOEventHandler.getUserAgent(); - mockGetElementMappingRegistry(mockUserAgent); - return parent; - } - - private Attributes createScopeAttribute(String value) { - AttributesImpl atts = new AttributesImpl(); - atts.addAttribute(ExtensionElementMapping.URI, "header", "fox:header", XMLUtil.CDATA, value); - return atts; - } - - private ElementMappingRegistry mockGetElementMappingRegistry(FOUserAgent mockUserAgent) { - ElementMappingRegistry mockRegistry = mock(ElementMappingRegistry.class); - when(mockRegistry.getElementMapping(anyString())).thenReturn(new ExtensionElementMapping()); - when(mockUserAgent.getElementMappingRegistry()).thenReturn(mockRegistry); - return mockRegistry; - } - - private FOValidationEventProducer mockGetEventProducerFor(EventBroadcaster mockEventBroadcaster) { - FOValidationEventProducer mockEventProducer = mock(FOValidationEventProducer.class); - when(mockEventBroadcaster.getEventProducerFor(eq(FOValidationEventProducer.class))) - .thenReturn(mockEventProducer); - return mockEventProducer; - } - -} diff --git a/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java b/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java deleted file mode 100644 index b2e7a2c9d..000000000 --- a/test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.fo.flow.table; - -import org.junit.Test; - -/** - * Testcase checking that cells spanning further than their parent element aren't - * accepted. - */ -public class IllegalRowSpanTestCase extends ErrorCheckTest { - - @Test - public void testBody1() throws Exception { - launchTest("table/illegal-row-span_body_1.fo"); - } - - @Test - public void testBody2() throws Exception { - launchTest("table/illegal-row-span_body_2.fo"); - } - - @Test - public void testHeader() throws Exception { - launchTest("table/illegal-row-span_header.fo"); - } - - @Test - public void testFooter() throws Exception { - launchTest("table/illegal-row-span_footer.fo"); - } - -} diff --git a/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java b/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java deleted file mode 100644 index 884116441..000000000 --- a/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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.fo.flow.table; - -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. - */ -public class RowGroupBuilderTestCase extends AbstractTableTest { - - /** - * Checks that the given table-body(header,footer) will return row groups as expected. - * More precisely, checks that the number of row groups corresponds to the size of the - * given array, and that the number of rows inside each row group is equal to the - * corresponding integer in the array. - * - * @param part a table part whose row groups are to be checked - * @param expectedRowLengths expected lengths of all the row groups of this part of - * the table - */ - private void checkTablePartRowGroups(TablePart part, int[] expectedRowLengths) { - Iterator rowGroupIter = part.getRowGroups().iterator(); - for (int i = 0; i < expectedRowLengths.length; i++) { - assertTrue(rowGroupIter.hasNext()); - List rowGroup = (List) rowGroupIter.next(); - assertEquals(expectedRowLengths[i], rowGroup.size()); - } - assertFalse(rowGroupIter.hasNext()); - } - - /** - * Gets the next table and checks its row-groups. - * @param tableIter an iterator over the tables to check - * @param expectedHeaderRowLengths expected row-group sizes for the header. If null - * the table is not expected to have a header - * @param expectedFooterRowLengths expected row-group sizes for the footer. If null - * the table is not expected to have a footer - * @param expectedBodyRowLengths expected row-group sizes for the body(-ies) - */ - private void checkNextTableRowGroups(Iterator tableIter, - int[] expectedHeaderRowLengths, int[] expectedFooterRowLengths, int[][] expectedBodyRowLengths) { - Table table = (Table) tableIter.next(); - if (expectedHeaderRowLengths == null) { - assertNull(table.getTableHeader()); - } else { - checkTablePartRowGroups(table.getTableHeader(), expectedHeaderRowLengths); - } - if (expectedFooterRowLengths == null) { - assertNull(table.getTableFooter()); - } else { - checkTablePartRowGroups(table.getTableFooter(), expectedFooterRowLengths); - } - Iterator bodyIter = table.getChildNodes(); - for (int i = 0; i < expectedBodyRowLengths.length; i++) { - assertTrue(bodyIter.hasNext()); - checkTablePartRowGroups((TableBody) bodyIter.next(), expectedBodyRowLengths[i]); - } - } - - public void checkSimple(String filename) throws Exception { - setUp(filename); - Iterator tableIter = getTableIterator(); - - // Table 1: no header, no footer, one body (1 row) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{1}}); - - // Table 2: no header, no footer, one body (2 rows) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{1, 1}}); - - // Table 3: no header, no footer, two bodies (1 row, 1 row) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{1}, {1}}); - - // Table 4: no header, no footer, two bodies (2 rows, 3 rows) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{1, 1}, {1, 1, 1}}); - - // Table 5: one header (1 row), no footer, one body (1 row) - checkNextTableRowGroups(tableIter, new int[] {1}, null, new int[][] {{1}}); - - // Table 6: no header, one footer (1 row), one body (1 row) - checkNextTableRowGroups(tableIter, null, new int[] {1}, new int[][] {{1}}); - - // Table 7: one header (1 row), one footer (1 row), one body (1 row) - checkNextTableRowGroups(tableIter, new int[] {1}, new int[] {1}, new int[][] {{1}}); - - // Table 8: one header (2 rows), one footer (3 rows), one body (2 rows) - checkNextTableRowGroups(tableIter, new int[] {1, 1}, new int[] {1, 1, 1}, new int[][] {{1, 1}}); - - // Table 9: one header (3 rows), one footer (2 rows), three bodies (2 rows, 1 row, 3 rows) - checkNextTableRowGroups(tableIter, new int[] {1, 1, 1}, new int[] {1, 1}, new int[][] {{1, 1}, {1}, {1, 1, 1}}); - } - - public void checkSpans(String filename) throws Exception { - setUp(filename); - Iterator tableIter = getTableIterator(); - - // Table 1: no header, no footer, one body (1 row with column-span) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{1}}); - - // Table 2: no header, no footer, one body (1 row-group of 2 rows) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{2}}); - - // Table 3: no header, no footer, one body (1 row-group of 2 rows, 1 row) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{2, 1}}); - - // Table 4: no header, no footer, one body (1 row, 1 row-group of 2 rows) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{1, 2}}); - - // Table 5: no header, no footer, one body (1 row, 1 row-group of 3 rows, 1 row) - checkNextTableRowGroups(tableIter, null, null, new int[][] {{1, 3, 1}}); - - // Table 6: one header (1 row-group of 2 rows), one footer (1 row, 1 row-group of 3 rows), - // one body (1 row-group of 2 rows, 1 row, 1 row-group of 3 rows) - checkNextTableRowGroups(tableIter, new int[] {2}, new int[] {1, 3}, new int[][] {{2, 1, 3}}); - } - - @Test - public void testWithRowsSimple() throws Exception { - checkSimple("table/RowGroupBuilder_simple.fo"); - } - - @Test - public void testWithRowsSpans() throws Exception { - checkSpans("table/RowGroupBuilder_spans.fo"); - } - - @Test - public void testNoRowSimple() throws Exception { - checkSimple("table/RowGroupBuilder_no-row_simple.fo"); - } - - @Test - public void testNoRowSpans() throws Exception { - checkSpans("table/RowGroupBuilder_no-row_spans.fo"); - } - - @Test - public void testNoColWithRowsSimple() throws Exception { - checkSimple("table/RowGroupBuilder_no-col_simple.fo"); - } - - @Test - public void testNoColWithRowsSpans() throws Exception { - checkSpans("table/RowGroupBuilder_no-col_spans.fo"); - } - - @Test - public void testNoColNoRowSimple() throws Exception { - checkSimple("table/RowGroupBuilder_no-col_no-row_simple.fo"); - } - - @Test - public void testNoColNoRowSpans() throws Exception { - checkSpans("table/RowGroupBuilder_no-col_no-row_spans.fo"); - } -} diff --git a/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java b/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java deleted file mode 100644 index be049eac9..000000000 --- a/test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.fo.flow.table; - -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; - -public class TableColumnColumnNumberTestCase extends AbstractTableTest { - - /** - * A percentBaseContext that mimics the behaviour of TableLM for computing the widths - * of columns. All what needs to be known is the width of a table unit (as in - * proportional-column-width()). - */ - private class TablePercentBaseContext implements PercentBaseContext { - - private int unitaryWidth; - - void setUnitaryWidth(int unitaryWidth) { - this.unitaryWidth = unitaryWidth; - } - - public int getBaseLength(int lengthBase, FObj fobj) { - return unitaryWidth; - } - } - - private TablePercentBaseContext percentBaseContext = new TablePercentBaseContext(); - - private void checkColumn(Table t, int number, boolean isImplicit, int spans, int repeated, int width) { - TableColumn c = t.getColumn(number - 1); - // TODO a repeated column has a correct number only for its first occurrence -// assertEquals(number, c.getColumnNumber()); - assertEquals(isImplicit, c.isImplicitColumn()); - assertEquals(spans, c.getNumberColumnsSpanned()); - assertEquals(repeated, c.getNumberColumnsRepeated()); - assertEquals(width, c.getColumnWidth().getValue(percentBaseContext)); - } - - @Test - public void testColumnNumber() throws Exception { - setUp("table/table-column_column-number.fo"); - Iterator tableIter = getTableIterator(); - Table t = (Table) tableIter.next(); - assertEquals(2, t.getNumberOfColumns()); - checkColumn(t, 1, false, 1, 2, 100000); - checkColumn(t, 2, false, 1, 2, 100000); - - t = (Table) tableIter.next(); - assertEquals(2, t.getNumberOfColumns()); - checkColumn(t, 1, false, 1, 1, 200000); - checkColumn(t, 2, false, 1, 1, 100000); - - t = (Table) tableIter.next(); - assertEquals(3, t.getNumberOfColumns()); - checkColumn(t, 1, false, 1, 1, 100000); - checkColumn(t, 2, false, 1, 1, 150000); - checkColumn(t, 3, false, 1, 1, 200000); - - t = (Table) tableIter.next(); - percentBaseContext.setUnitaryWidth(125000); - assertEquals(4, t.getNumberOfColumns()); - checkColumn(t, 1, false, 1, 1, 100000); - checkColumn(t, 2, true, 1, 1, 125000); - checkColumn(t, 3, false, 1, 1, 150000); - checkColumn(t, 4, false, 1, 1, 175000); - } - - private void checkImplicitColumns(Iterator tableIter, int columnNumber) { - Table t = (Table) tableIter.next(); - assertEquals(columnNumber, t.getNumberOfColumns()); - for (int i = 1; i <= columnNumber; i++) { - checkColumn(t, i, true, 1, 1, 100000); - } - } - - @Test - public void testImplicitColumns() throws Exception { - setUp("table/implicit_columns_column-number.fo"); - percentBaseContext.setUnitaryWidth(100000); - Iterator tableIter = getTableIterator(); - - checkImplicitColumns(tableIter, 2); - checkImplicitColumns(tableIter, 2); - checkImplicitColumns(tableIter, 2); - checkImplicitColumns(tableIter, 2); - checkImplicitColumns(tableIter, 3); - checkImplicitColumns(tableIter, 4); - checkImplicitColumns(tableIter, 3); - } -} diff --git a/test/java/org/apache/fop/fo/flow/table/TableHandler.java b/test/java/org/apache/fop/fo/flow/table/TableHandler.java deleted file mode 100644 index 04da32b47..000000000 --- a/test/java/org/apache/fop/fo/flow/table/TableHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.fo.flow.table; - -import java.util.LinkedList; -import java.util.List; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fo.FOEventHandler; - -public class TableHandler extends FOEventHandler { - - /** All the tables encountered in the FO file. List of Table objects. */ - private List tables = new LinkedList(); - - TableHandler(FOUserAgent foUserAgent) { - super(foUserAgent); - } - - public void endTable(Table tbl) { - tables.add(tbl); - } - - List getTables() { - return tables; - } -} diff --git a/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java b/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java deleted file mode 100644 index 76a5d196d..000000000 --- a/test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.fo.flow.table; - -import org.junit.Test; - -public class TooManyColumnsTestCase extends ErrorCheckTest { - - @Test - public void testBody1() throws Exception { - launchTest("table/too-many-columns_body_1.fo"); - } - - @Test - public void testBody2() throws Exception { - launchTest("table/too-many-columns_body_2.fo"); - } - - @Test - public void testBody3() throws Exception { - launchTest("table/too-many-columns_body_3.fo"); - } - - @Test - public void testBody4() throws Exception { - launchTest("table/too-many-columns_body_4.fo"); - } - - @Test - public void testHeader() throws Exception { - launchTest("table/too-many-columns_header.fo"); - } - - @Test - public void testFooter() throws Exception { - launchTest("table/too-many-columns_footer.fo"); - } -} diff --git a/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java b/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java deleted file mode 100644 index 1a5e38291..000000000 --- a/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.fo.flow.table; - -/** - * This class aims at easing testing, by preventing the event notification system from - * getting in the way just to issue an Unimplemented Feature warning. - */ -public final class UnimplementedWarningNeutralizer { - - private UnimplementedWarningNeutralizer() { } - - /** - * Neutralizes Unimplemented Feature events from the {@link TableAndCaption} and - * {@link TableCaption} classes. - */ - public static void neutralizeUnimplementedWarning() { - TableAndCaption.notImplementedWarningGiven = true; - TableCaption.notImplementedWarningGiven = true; - } -} diff --git a/test/java/org/apache/fop/fo/pagination/AllTests.java b/test/java/org/apache/fop/fo/pagination/AllTests.java deleted file mode 100644 index bd5b21c14..000000000 --- a/test/java/org/apache/fop/fo/pagination/AllTests.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.fo.pagination; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * All test to be added in FOTreeTestSuite - * - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ PageSequenceMasterTestCase.class, - RepeatablePageMasterAlternativesTestCase.class }) -public final class AllTests { -} diff --git a/test/java/org/apache/fop/fo/pagination/LayoutMasterSetTestCase.java b/test/java/org/apache/fop/fo/pagination/LayoutMasterSetTestCase.java deleted file mode 100644 index cfe71f529..000000000 --- a/test/java/org/apache/fop/fo/pagination/LayoutMasterSetTestCase.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.fo.pagination; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fo.FODocumentParser; -import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; -import org.apache.fop.fo.FOEventHandler; - -public class LayoutMasterSetTestCase { - - private static class FlowMappingTester extends FOEventHandler { - - private static final String[][] FLOW_MAPPINGS = { - - {"first-page-before", "xsl-region-before"}, - {"first-page-after", "xsl-region-after"}, - {"first-page-start", "xsl-region-start"}, - {"first-page-end", "xsl-region-end"}, - - {"odd-page-before", "xsl-region-before"}, - {"odd-page-after", "xsl-region-after"}, - {"odd-page-start", "xsl-region-start"}, - {"odd-page-end", "xsl-region-end"}, - - {"odd-page-before", "xsl-region-before"}, - {"odd-page-after", "xsl-region-after"}, - {"odd-page-start", "xsl-region-start"}, - {"odd-page-end", "xsl-region-end"}, - - {"blank-page-before", "xsl-region-before"}, - {"blank-page-after", "xsl-region-after"}, - {"blank-page-start", "xsl-region-start"}, - {"blank-page-end", "xsl-region-end"}, - - {"last-page-before", "xsl-region-before"}, - {"last-page-after", "xsl-region-after"}, - {"last-page-start", "xsl-region-start"}, - {"last-page-end", "xsl-region-end"}, - - {"xsl-footnote-separator", "xsl-footnote-separator"} - - }; - - FlowMappingTester(FOUserAgent userAgent) { - super(userAgent); - } - - @Override - public void startPageSequence(PageSequence pageSeq) { - super.startPageSequence(pageSeq); - LayoutMasterSet layoutMasterSet = pageSeq.getRoot().getLayoutMasterSet(); - for (String[] mapping : FLOW_MAPPINGS) { - assertEquals(mapping[1], layoutMasterSet.getDefaultRegionNameFor(mapping[0])); - } - } - - } - - /** - * Tests the {@link LayoutMasterSet#getDefaultRegionNameFor(String)} method. - */ - @Test - public void testFlowMapping() throws Exception { - FODocumentParser foDocumentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() { - - public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) { - return new FlowMappingTester(foUserAgent); - } - }); - foDocumentParser.parse(getClass().getResourceAsStream("side-regions.fo")); - } - -} diff --git a/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java b/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java deleted file mode 100644 index 9a4515b31..000000000 --- a/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.fo.pagination; - -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; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.BlockLevelEventProducer; - -/** - * Unit Test for PageSequenceMaster - * - */ -public class PageSequenceMasterTestCase { - - /** - * Test that block level events are produced in line with - * XSL:FO - 6.4.8 fo:page-sequence-master - - * "It is an error if the entire sequence of sub-sequence-specifiers children is exhausted - * while some areas returned by an fo:flow are not placed. Implementations may recover, - * if possible, by re-using the sub-sequence-specifier that was last used to generate a page." - * - * @throws Exception exception - */ - @Test - public void testGetNextSimplePageMasterExhausted() throws Exception { - - //Test when the last sub-sequence specifier is not repeatable - testGetNextSimplePageMasterExhausted(true); - - //Test when the last sub-sequence specifier is repeatable - testGetNextSimplePageMasterExhausted(false); - - } - - private void testGetNextSimplePageMasterExhausted(boolean canResume) throws Exception { - - SimplePageMaster spm = mock(SimplePageMaster.class); - SubSequenceSpecifier mockSinglePageMasterReference - = mock(SubSequenceSpecifier.class); - BlockLevelEventProducer mockBlockLevelEventProducer = mock(BlockLevelEventProducer.class); - - // subject under test - PageSequenceMaster pageSequenceMaster = createPageSequenceMaster( - mockBlockLevelEventProducer); - pageSequenceMaster.addSubsequenceSpecifier(mockSinglePageMasterReference); - - //Setup to mock the exhaustion of the last sub-sequence specifier - when(mockSinglePageMasterReference.getNextPageMaster(anyBoolean(), anyBoolean(), - anyBoolean(), anyBoolean())).thenReturn(null, spm); - - //Need this for the method to return normally - when(mockSinglePageMasterReference.canProcess(anyString())).thenReturn(true); - - when(mockSinglePageMasterReference.isReusable()).thenReturn(canResume); - - pageSequenceMaster.getNextSimplePageMaster(false, false, false, false, null); - - verify(mockBlockLevelEventProducer).pageSequenceMasterExhausted((Locator)anyObject(), - anyString(), eq(canResume), (Locator)anyObject()); - } - - /** - * Test that PageProductionException is thrown if the final simple-page-master - * cannot handle the main-flow of the page sequence - * @throws Exception exception - */ - @Test - public void testGetNextSimplePageMasterException() throws Exception { - - final String mainFlowRegionName = "main"; - final String emptyFlowRegionName = "empty"; - - // This will represent a page master that does not map to the main flow - // of the page sequence - SimplePageMaster mockEmptySPM = mock(SimplePageMaster.class); - Region mockRegion = mock(Region.class); - SinglePageMasterReference mockSinglePageMasterReference - = mock(SinglePageMasterReference.class); - BlockLevelEventProducer mockBlockLevelEventProducer = mock(BlockLevelEventProducer.class); - - LayoutMasterSet mockLayoutMasterSet = mock(LayoutMasterSet.class); - //The layout master set should return the empty page master - when(mockLayoutMasterSet.getSimplePageMaster(anyString())).thenReturn(mockEmptySPM); - when(mockEmptySPM.getRegion(anyInt())).thenReturn(mockRegion); - - when(mockRegion.getRegionName()).thenReturn(emptyFlowRegionName); - - when(mockSinglePageMasterReference.getNextPageMaster(anyBoolean(), anyBoolean(), - anyBoolean(), anyBoolean())) - .thenReturn(null, mockEmptySPM); - - PageSequenceMaster pageSequenceMaster = createPageSequenceMaster(mockLayoutMasterSet, - mockBlockLevelEventProducer); - - pageSequenceMaster.startOfNode(); - pageSequenceMaster.addSubsequenceSpecifier(mockSinglePageMasterReference); - - try { - pageSequenceMaster.getNextSimplePageMaster(false, false, false, false, - mainFlowRegionName); - fail("The next simple page master does not refer to the main flow"); - } catch (PageProductionException ppe) { - //Passed test - } - } - - - private PageSequenceMaster createPageSequenceMaster( - BlockLevelEventProducer blockLevelEventProducer) throws FOPException { - - return createPageSequenceMaster(mock(LayoutMasterSet.class), blockLevelEventProducer); - } - - private PageSequenceMaster createPageSequenceMaster(LayoutMasterSet layoutMasterSet, - BlockLevelEventProducer blockLevelEventProducer) throws FOPException { - FONode mockParent = mock(FONode.class); - Root mockRoot = mock(Root.class); - - //Stub generic components - when(mockParent.getRoot()).thenReturn(mockRoot); - when(mockRoot.getLayoutMasterSet()).thenReturn(layoutMasterSet); - - PageSequenceMaster psm = new PageSequenceMaster(mockParent, blockLevelEventProducer); - psm.startOfNode(); - - return psm; - } - -} - diff --git a/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java b/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java deleted file mode 100644 index ce1a97638..000000000 --- a/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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.fo.pagination; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.fo.Constants; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.expr.NumericProperty; -import org.apache.fop.fo.properties.Property; - -/** - * Unit Test for RepeatablePageMasterAlternatives - * - */ -public class RepeatablePageMasterAlternativesTestCase implements Constants { - - /** - * - * @throws Exception exception - */ - @Test - public void testIsInfinite1() throws Exception { - // Create fixture - Property maximumRepeats = mock(Property.class); - ConditionalPageMasterReference cpmr = createCPMR("empty"); - - when(maximumRepeats.getEnum()).thenReturn(EN_NO_LIMIT); - - RepeatablePageMasterAlternatives objectUnderTest - = createRepeatablePageMasterAlternatives(cpmr, maximumRepeats); - - assertTrue("is infinite", objectUnderTest.isInfinite()); - } - - /** - * - * @throws Exception exception - */ - @Test - public void testIsInfinite2() throws Exception { - // Create fixture - Property maximumRepeats = mock(Property.class); - ConditionalPageMasterReference cpmr = createCPMR("empty"); - - NumericProperty numericProperty = mock(NumericProperty.class); - - final int maxRepeatNum = 0; - assertTrue(maxRepeatNum != EN_NO_LIMIT); - - when(maximumRepeats.getEnum()).thenReturn(maxRepeatNum); - when(maximumRepeats.getNumeric()).thenReturn(numericProperty); - - RepeatablePageMasterAlternatives objectUnderTest - = createRepeatablePageMasterAlternatives(createCPMR("empty"), - maximumRepeats); - - assertTrue("is infinite", !objectUnderTest.isInfinite()); - } - - /** - * Test that an infinite sequence of empty page masters has - * willTerminiate() returning false - * @throws Exception exception - */ - @Test - public void testCanProcess1() throws Exception { - // Create fixture - Property maximumRepeats = mock(Property.class); - ConditionalPageMasterReference cpmr = createCPMR("empty"); - - when(maximumRepeats.getEnum()).thenReturn(EN_NO_LIMIT); - when(cpmr.isValid(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean())) - .thenReturn(true); - - RepeatablePageMasterAlternatives objectUnderTest - = createRepeatablePageMasterAlternatives(cpmr, maximumRepeats); - - //Fixture assertion - assertTrue("Should be infinite", objectUnderTest.isInfinite()); - - //Test assertion - assertTrue("Infinite sequences that do not process the main flow will " - + " not terminate", - !objectUnderTest.canProcess("main-flow")); - } - /** - * Test that a finite sequence of simple page masters has - * willTerminate() returning true - * - * @throws Exception exception - */ - @Test - public void testCanProcess2() throws Exception { - // Create fixture - Property maximumRepeats = mock(Property.class); - NumericProperty numericProperty = mock(NumericProperty.class); - - final int maxRepeatNum = 0; - - when(maximumRepeats.getEnum()).thenReturn(maxRepeatNum); - when(maximumRepeats.getNumeric()).thenReturn(numericProperty); - - RepeatablePageMasterAlternatives objectUnderTest - = createRepeatablePageMasterAlternatives(createCPMR("empty"), - maximumRepeats); - - //Fixture assertion - assertTrue("Should be finite sequence", !objectUnderTest.isInfinite()); - - //Test assertion - assertTrue("Finite sequences will terminate", - objectUnderTest.canProcess("main-flow")); - } - - private ConditionalPageMasterReference createCPMR(String regionName) { - ConditionalPageMasterReference cpmr = mock(ConditionalPageMasterReference.class); - SimplePageMaster master = mock(SimplePageMaster.class); - Region region = mock(Region.class); - when(master.getRegion(anyInt())).thenReturn(region); - when(region.getRegionName()).thenReturn(regionName); - when(cpmr.getMaster()).thenReturn(master); - - return cpmr; - } - - private RepeatablePageMasterAlternatives createRepeatablePageMasterAlternatives( - ConditionalPageMasterReference cpmr, Property maximumRepeats) throws Exception { - - PropertyList pList = mock(PropertyList.class); - - when(pList.get(anyInt())).thenReturn(maximumRepeats); - - PageSequenceMaster parent = mock(PageSequenceMaster.class); - when(parent.getName()).thenReturn("fo:page-sequence-master"); - - RepeatablePageMasterAlternatives sut = new RepeatablePageMasterAlternatives(parent); - - sut.startOfNode(); - sut.bind(pList); - sut.addConditionalPageMasterReference(cpmr); - return sut; - } - -} - diff --git a/test/java/org/apache/fop/fo/pagination/side-regions.fo b/test/java/org/apache/fop/fo/pagination/side-regions.fo deleted file mode 100644 index 8a0fba2ec..000000000 --- a/test/java/org/apache/fop/fo/pagination/side-regions.fo +++ /dev/null @@ -1,181 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> - <fo:layout-master-set> - <fo:simple-page-master master-name="first-page" - page-height="100pt" page-width="150pt"> - <fo:region-body margin="12pt" display-align="center" background-color="#FFF0F0"/> - <fo:region-before region-name="first-page-before" extent="10pt" precedence="true" - display-align="after"/> - <fo:region-after region-name="first-page-after" extent="10pt" precedence="true"/> - <fo:region-start region-name="first-page-start" extent="10pt" reference-orientation="90" - display-align="after"/> - <fo:region-end region-name="first-page-end" extent="10pt" reference-orientation="-90" - display-align="after"/> - </fo:simple-page-master> - <fo:simple-page-master master-name="odd-page" - page-height="100pt" page-width="150pt"> - <fo:region-body margin="12pt" display-align="center" background-color="#FFFFF0"/> - <fo:region-before region-name="odd-page-before" extent="10pt" precedence="true" - display-align="after"/> - <fo:region-after region-name="odd-page-after" extent="10pt" precedence="true"/> - <fo:region-start region-name="odd-page-start" extent="10pt" reference-orientation="90" - display-align="after"/> - <fo:region-end region-name="odd-page-end" extent="10pt" reference-orientation="-90" - display-align="after"/> - </fo:simple-page-master> - <fo:simple-page-master master-name="even-page" - page-height="100pt" page-width="150pt"> - <fo:region-body margin="12pt" display-align="center" background-color="#F0FFF0"/> - <fo:region-before region-name="even-page-before" extent="10pt" precedence="true" - display-align="after"/> - <fo:region-after region-name="even-page-after" extent="10pt" precedence="true"/> - <fo:region-start region-name="even-page-start" extent="10pt" reference-orientation="90" - display-align="after"/> - <fo:region-end region-name="even-page-end" extent="10pt" reference-orientation="-90" - display-align="after"/> - </fo:simple-page-master> - <fo:simple-page-master master-name="blank-page" - page-height="100pt" page-width="150pt"> - <fo:region-body margin="12pt" display-align="center" background-color="#F0F0F0"/> - <fo:region-before region-name="blank-page-before" extent="10pt" precedence="true" - display-align="after"/> - <fo:region-after region-name="blank-page-after" extent="10pt" precedence="true"/> - <fo:region-start region-name="blank-page-start" extent="10pt" reference-orientation="90" - display-align="after"/> - <fo:region-end region-name="blank-page-end" extent="10pt" reference-orientation="-90" - display-align="after"/> - </fo:simple-page-master> - <fo:simple-page-master master-name="last-page" - page-height="100pt" page-width="150pt"> - <fo:region-body margin="45pt 12pt" display-align="center" background-color="#F0F0FF"/> - <fo:region-before region-name="last-page-before" extent="10pt" precedence="true" - display-align="after"/> - <fo:region-after region-name="last-page-after" extent="10pt" precedence="true"/> - <fo:region-start region-name="last-page-start" extent="10pt" reference-orientation="90" - display-align="after"/> - <fo:region-end region-name="last-page-end" extent="10pt" reference-orientation="-90" - display-align="after"/> - </fo:simple-page-master> - <fo:page-sequence-master master-name="pages"> - <fo:repeatable-page-master-alternatives> - <fo:conditional-page-master-reference page-position="first" master-reference="first-page"/> - <fo:conditional-page-master-reference page-position="last" master-reference="last-page"/> - <fo:conditional-page-master-reference blank-or-not-blank="blank" - master-reference="blank-page"/> - <fo:conditional-page-master-reference odd-or-even="odd" master-reference="odd-page"/> - <fo:conditional-page-master-reference odd-or-even="even" master-reference="even-page"/> - </fo:repeatable-page-master-alternatives> - </fo:page-sequence-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="pages" force-page-count="even" font-size="4pt" - text-align="center"> - - <fo:static-content flow-name="first-page-before"> - <fo:block start-indent="12pt" end-indent="12pt" border-bottom="0.5pt solid red" - padding-bottom="0.5pt">First Page Before.</fo:block> - </fo:static-content> - <fo:static-content flow-name="first-page-after"> - <fo:block start-indent="12pt" end-indent="12pt" border-top="0.5pt solid red" - padding-top="0.5pt">First Page After.</fo:block> - </fo:static-content> - <fo:static-content flow-name="first-page-start"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid red" - padding-bottom="0.5pt">First Page Start.</fo:block> - </fo:static-content> - <fo:static-content flow-name="first-page-end"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid red" - padding-bottom="0.5pt">First Page End.</fo:block> - </fo:static-content> - - <fo:static-content flow-name="odd-page-after"> - <fo:block start-indent="12pt" end-indent="12pt" border-top="0.5pt solid orange" - padding-top="0.5pt">Odd Page After.</fo:block> - </fo:static-content> - <fo:static-content flow-name="odd-page-end"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid orange" - padding-bottom="0.5pt">Odd Page End.</fo:block> - </fo:static-content> - <fo:static-content flow-name="odd-page-start"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid orange" - padding-bottom="0.5pt">Odd Page Start.</fo:block> - </fo:static-content> - <fo:static-content flow-name="odd-page-before"> - <fo:block start-indent="12pt" end-indent="12pt" border-bottom="0.5pt solid orange" - padding-bottom="0.5pt">Odd Page Before.</fo:block> - </fo:static-content> - - <fo:static-content flow-name="even-page-end"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid green" - padding-bottom="0.5pt">Even Page End.</fo:block> - </fo:static-content> - <fo:static-content flow-name="even-page-start"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid green" - padding-bottom="0.5pt">Even Page Start.</fo:block> - </fo:static-content> - <fo:static-content flow-name="even-page-after"> - <fo:block start-indent="12pt" end-indent="12pt" border-top="0.5pt solid green" - padding-top="0.5pt">Even Page After.</fo:block> - </fo:static-content> - <fo:static-content flow-name="even-page-before"> - <fo:block start-indent="12pt" end-indent="12pt" border-bottom="0.5pt solid green" - padding-bottom="0.5pt">Even Page Before.</fo:block> - </fo:static-content> - - <fo:static-content flow-name="blank-page-start"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid black" - padding-bottom="0.5pt">Blank Page Start.</fo:block> - </fo:static-content> - <fo:static-content flow-name="blank-page-after"> - <fo:block start-indent="12pt" end-indent="12pt" border-top="0.5pt solid black" - padding-top="0.5pt">Blank Page After.</fo:block> - </fo:static-content> - <fo:static-content flow-name="blank-page-before"> - <fo:block start-indent="12pt" end-indent="12pt" border-bottom="0.5pt solid black" - padding-bottom="0.5pt">Blank Page Before.</fo:block> - </fo:static-content> - <fo:static-content flow-name="blank-page-end"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid black" - padding-bottom="0.5pt">Blank Page End.</fo:block> - </fo:static-content> - - <fo:static-content flow-name="last-page-before"> - <fo:block start-indent="12pt" end-indent="12pt" border-bottom="0.5pt solid blue" - padding-bottom="0.5pt">Last Page Before.</fo:block> - </fo:static-content> - <fo:static-content flow-name="last-page-end"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid blue" - padding-bottom="0.5pt">Last Page End.</fo:block> - </fo:static-content> - <fo:static-content flow-name="last-page-after"> - <fo:block start-indent="12pt" end-indent="12pt" border-top="0.5pt solid blue" - padding-top="0.5pt">Last Page After.</fo:block> - </fo:static-content> - <fo:static-content flow-name="last-page-start"> - <fo:block start-indent="2pt" end-indent="2pt" border-bottom="0.5pt solid blue" - padding-bottom="0.5pt">Last Page Start.</fo:block> - </fo:static-content> - - <fo:static-content flow-name="xsl-footnote-separator"> - <fo:block> - <fo:leader leader-pattern="rule" leader-length="40%" rule-thickness="0.5pt"/> - </fo:block> - </fo:static-content> - - <fo:flow flow-name="xsl-region-body" font-size="8pt" line-height="10pt"> - <fo:block>Apache™ FOP (Formatting Objects Processor) is a print formatter driven by XSL - formatting objects (XSL-FO) and an output independent formatter.</fo:block> - <fo:block break-before="page">It is an application<fo:footnote><fo:inline>*</fo:inline> - <fo:footnote-body><fo:block font-size="80%">* written in - Java</fo:block></fo:footnote-body></fo:footnote> that reads a formatting object (FO) - tree and renders the resulting pages to a specified output.</fo:block> - <fo:block break-before="page">The FOP project is part of the Apache Software Foundation, which - is a wider community of users and developers of open source projects.</fo:block> - <fo:block break-before="page">Apache™ FOP (Formatting Objects Processor) is a print formatter - driven by XSL formatting objects (XSL-FO) and an output independent formatter.</fo:block> - <fo:block break-before="page">It is a Java application that reads a formatting object (FO) - tree and renders the resulting pages to a specified output.</fo:block> - <fo:block break-before="page">The FOP project is part of the Apache Software Foundation, which - is a wider community of users and developers of open source projects.</fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java b/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java deleted file mode 100644 index eae290be3..000000000 --- a/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.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.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fo.Constants; -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FONodeMocks; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.expr.PropertyException; -import org.apache.fop.fo.flow.AbstractGraphics; -import org.apache.fop.fo.flow.ExternalGraphic; -import org.apache.fop.fo.flow.InstreamForeignObject; - -/** - * Tests that the fox:alt-text property is correctly set on objects that support it. - */ -public class AltTextHolderTestCase { - - private final String altText = "alternative text"; - - @Test - public void externalGraphicHasAltText() throws FOPException { - testAltTextGetter(new ExternalGraphic(mockFONode())); - } - - @Test - public void instreamForeignObjectHasAltText() throws FOPException { - testAltTextGetter(new InstreamForeignObject(mockFONode())); - } - - private FONode mockFONode() { - FONode mockFONode = FONodeMocks.mockFONode(); - FOUserAgent mockFOUserAgent = mockFONode.getFOEventHandler().getUserAgent(); - when(mockFOUserAgent.isAccessibilityEnabled()).thenReturn(true); - return mockFONode; - } - - private void testAltTextGetter(AbstractGraphics g) throws FOPException { - g.bind(mockPropertyList()); - assertEquals(altText, g.getAltText()); - } - - private PropertyList mockPropertyList() throws PropertyException { - PropertyList mockPropertyList = PropertyListMocks.mockPropertyList(); - Property mockAltText = mock(Property.class); - when(mockAltText.getString()).thenReturn(altText); - when(mockPropertyList.get(Constants.PR_X_ALT_TEXT)).thenReturn(mockAltText); - return mockPropertyList; - } - -} diff --git a/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java b/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java deleted file mode 100644 index 81ebc2f41..000000000 --- a/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.fo.properties; - -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; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.expr.PropertyException; -import org.apache.fop.fo.flow.table.UnimplementedWarningNeutralizer; - -/** - * This tests that all the FONodes that implement CommonAccessibilityHolder correctly configure - * the CommonAccessibility property. - */ -public class CommonAccessibilityHolderTestCase { - - private static final List<Class<? extends CommonAccessibilityHolder>> IMPLEMENTATIONS - = new ArrayList<Class<? extends CommonAccessibilityHolder>>(); - - private final String role = "role"; - - private final String sourceDocument = "source document"; - - static { - /* This triggers 'unimplemented feature' FO validation events so that the event system is - * not triggered when testing, avoiding extra convoluted dependency stubbing. */ - UnimplementedWarningNeutralizer.neutralizeUnimplementedWarning(); - - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.BasicLink.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Block.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.bookmarks.Bookmark.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.bookmarks.BookmarkTitle.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ExternalGraphic.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Footnote.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.FootnoteBody.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.InitialPropertySet.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Inline.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.InstreamForeignObject.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Leader.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ListBlock.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ListItem.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ListItemBody.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ListItemLabel.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.PageNumber.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.PageNumberCitation.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.PageNumberCitationLast.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.Root.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.Table.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableAndCaption.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableBody.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableCaption.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableCell.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableFooter.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableHeader.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableRow.class); - IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.Title.class); - } - - /** - * Bind should be overridden to correctly configure the CommonAccessibility property - * @throws Exception - - */ - @Test - public void bindMustSetRoleAndSourceDoc() throws Exception { - final PropertyList mockPList = mockPropertyList(); - final FONode parent = FONodeMocks.mockFONode(); - for (Class<? extends CommonAccessibilityHolder> clazz : IMPLEMENTATIONS) { - Constructor<? extends CommonAccessibilityHolder> constructor - = clazz.getConstructor(FONode.class); - CommonAccessibilityHolder sut = constructor.newInstance(parent); - ((FONode)sut).bind(mockPList); - String errorMessage = "Test failed for " + clazz + ": "; - assertEquals(errorMessage, role, sut.getCommonAccessibility().getRole()); - assertEquals(errorMessage, sourceDocument, - sut.getCommonAccessibility().getSourceDocument()); - } - } - - private PropertyList mockPropertyList() throws PropertyException { - final PropertyList mockPList = PropertyListMocks.mockPropertyList(); - PropertyListMocks.mockTableProperties(mockPList); - PropertyListMocks.mockCommonBorderPaddingBackgroundProps(mockPList); - mockRoleProperty(mockPList); - mockSourceDocProperty(mockPList); - return mockPList; - } - - private void mockRoleProperty(PropertyList mockPList) throws PropertyException { - final Property mockRoleProperty = mock(Property.class); - when(mockRoleProperty.getString()).thenReturn(role); - when(mockPList.get(Constants.PR_ROLE)).thenReturn(mockRoleProperty); - } - - private void mockSourceDocProperty(PropertyList mockPList) throws PropertyException { - final Property mockSourceDocProperty = mock(Property.class); - when(mockSourceDocProperty.getString()).thenReturn(sourceDocument); - when(mockPList.get(Constants.PR_SOURCE_DOCUMENT)).thenReturn(mockSourceDocProperty); - } - -} diff --git a/test/java/org/apache/fop/fo/properties/CommonHyphenationTestCase.java b/test/java/org/apache/fop/fo/properties/CommonHyphenationTestCase.java deleted file mode 100644 index 029146413..000000000 --- a/test/java/org/apache/fop/fo/properties/CommonHyphenationTestCase.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.fo.properties; - -import java.util.Locale; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -public class CommonHyphenationTestCase { - - private final String lang = "en"; - - @Test - public void testToLocaleNull() { - Locale locale = CommonHyphenation.toLocale(null, null); - assertNull(locale); - locale = CommonHyphenation.toLocale("none", null); - assertNull(locale); - locale = CommonHyphenation.toLocale("NoNe", "US"); - assertNull(locale); - } - - @Test - public void testToLocaleWithJustLanguage() { - Locale locale = new Locale(lang); - assertEquals(locale, CommonHyphenation.toLocale(lang, null)); - assertEquals(locale, CommonHyphenation.toLocale(lang, "none")); - assertEquals(locale, CommonHyphenation.toLocale(lang, "NONE")); - } - - @Test - public void testToLocaleWithLanguageAndCountry() { - Locale locale = new Locale(lang, "US"); - assertEquals(locale, CommonHyphenation.toLocale(lang, "US")); - assertEquals(locale, CommonHyphenation.toLocale(lang, "us")); - } - -} diff --git a/test/java/org/apache/fop/fo/properties/PropertyListMocks.java b/test/java/org/apache/fop/fo/properties/PropertyListMocks.java deleted file mode 100644 index f364c9034..000000000 --- a/test/java/org/apache/fop/fo/properties/PropertyListMocks.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.fo.properties; - -import static org.mockito.Matchers.anyInt; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.fo.Constants; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.expr.PropertyException; - -/** - * A helper class for mocking a property list. - */ -public final class PropertyListMocks { - - private PropertyListMocks() { } - - /** - * Creates and returns a mock property list returning a generic default for the - * {@link PropertyList#get(int)} method. - * - * @return a mock property list - */ - public static PropertyList mockPropertyList() { - try { - final PropertyList mockPList = mock(PropertyList.class); - final Property mockGenericProperty = PropertyMocks.mockGenericProperty(); - when(mockPList.get(anyInt())).thenReturn(mockGenericProperty); - return mockPList; - } catch (PropertyException e) { - throw new RuntimeException(e); - } - } - - /** - * Overrides with working mock properties the values returned by - * {@link PropertyList#get(int)} for {@link Constants#PR_COLUMN_NUMBER}, - * {@link Constants#PR_NUMBER_COLUMNS_SPANNED}, - * {@link Constants#PR_NUMBER_ROWS_SPANNED} and {@link Constants#PR_BORDER_COLLAPSE}. - * - * @param mockPList a mock property list - */ - public static void mockTableProperties(PropertyList mockPList) { - try { - final Property mockNumberProperty = PropertyMocks.mockNumberProperty(); - when(mockPList.get(Constants.PR_COLUMN_NUMBER)).thenReturn(mockNumberProperty); - when(mockPList.get(Constants.PR_NUMBER_COLUMNS_SPANNED)).thenReturn(mockNumberProperty); - when(mockPList.get(Constants.PR_NUMBER_ROWS_SPANNED)).thenReturn(mockNumberProperty); - - final Property borderCollapseProperty = mock(Property.class); - when(borderCollapseProperty.getEnum()).thenReturn(Constants.EN_SEPARATE); - when(mockPList.get(Constants.PR_BORDER_COLLAPSE)).thenReturn(borderCollapseProperty); - - final Property writingModeProperty = mock(Property.class); - when(writingModeProperty.getEnum()).thenReturn(Constants.EN_LR_TB); - when(mockPList.get(Constants.PR_WRITING_MODE)).thenReturn(writingModeProperty); - } catch (PropertyException e) { - throw new RuntimeException(e); - } - } - - /** - * Overrides with a working mock property the value returned by - * {@link PropertyList#getBorderPaddingBackgroundProps()}. - * - * @param mockPList a mock property list - */ - public static void mockCommonBorderPaddingBackgroundProps(PropertyList mockPList) { - try { - final CommonBorderPaddingBackground mockCommonBorderPaddingBackground - = mock(CommonBorderPaddingBackground.class); - when(mockPList.getBorderPaddingBackgroundProps()) - .thenReturn(mockCommonBorderPaddingBackground); - } catch (PropertyException e) { - throw new RuntimeException(e); - } - } - -} diff --git a/test/java/org/apache/fop/fo/properties/PropertyMocks.java b/test/java/org/apache/fop/fo/properties/PropertyMocks.java deleted file mode 100644 index 40c923249..000000000 --- a/test/java/org/apache/fop/fo/properties/PropertyMocks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.fo.properties; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.datatypes.Numeric; -import org.apache.fop.datatypes.PercentBaseContext; -import org.apache.fop.fo.Constants; - -/** - * Helper class to create mocks of various kinds of properties. - */ -public final class PropertyMocks { - - private PropertyMocks() { } - - /** - * Creates and returns a generic mock property returning decent defaults for the - * {@link Property#getString()}, {@link Property#getEnum()} and - * {@link Property#getLengthRange()} methods. - * - * @return a mock all-purpose property - */ - public static Property mockGenericProperty() { - final Property mockGenericProperty = mock(Property.class); - when(mockGenericProperty.getString()).thenReturn("A non-empty string"); - when(mockGenericProperty.getEnum()).thenReturn(Constants.EN_SPACE); - LengthRangeProperty lengthRangeProperty = mockLengthRangeProperty(); - when(mockGenericProperty.getLengthRange()).thenReturn(lengthRangeProperty); - return mockGenericProperty; - } - - private static LengthRangeProperty mockLengthRangeProperty() { - final LengthRangeProperty mockLengthRangeProperty = mock(LengthRangeProperty.class); - final Property optimum = mockOptimumProperty(); - when(mockLengthRangeProperty.getOptimum(any(PercentBaseContext.class))) - .thenReturn(optimum); - return mockLengthRangeProperty; - } - - /** - * Creates and returns a mock property returning a decent default for the - * {@link Property#getNumeric()} method. - * - * @return a mock number property - */ - public static Property mockNumberProperty() { - final Property mockNumberProperty = mock(Property.class); - final Numeric mockNumeric = mock(Numeric.class); - when(mockNumberProperty.getNumeric()).thenReturn(mockNumeric); - return mockNumberProperty; - } - - private static Property mockOptimumProperty() { - final Property optimum = mock(Property.class); - when(optimum.isAuto()).thenReturn(true); - return optimum; - } - -} diff --git a/test/java/org/apache/fop/fonts/CIDFullTestCase.java b/test/java/org/apache/fop/fonts/CIDFullTestCase.java deleted file mode 100644 index 7df6cc25b..000000000 --- a/test/java/org/apache/fop/fonts/CIDFullTestCase.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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.fonts; - -import java.util.BitSet; -import java.util.HashMap; -import java.util.Map; - -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.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.util.CharUtilities; - -public class CIDFullTestCase { - - private CIDFull cidFull; - private MultiByteFont mbFont; - private BitSet bs; - private char[] chars; - private int[] widths; - private Map<Integer, Integer> glyphs; - - @Before - public void setup() { - bs = new BitSet(); - glyphs = new HashMap<Integer, Integer>(); - chars = new char[18]; - widths = new int[18]; - int i = 0; - for (int j = 0; j < 20; j++) { - if (j == 10 || j == 11) { - continue; - } - bs.set(j); - glyphs.put(Integer.valueOf(j), Integer.valueOf(j)); - chars[i] = (char) j; - widths[i] = 100; - i++; - } - mbFont = mock(MultiByteFont.class); - when(mbFont.getGlyphIndices()).thenReturn(bs); - when(mbFont.getChars()).thenReturn(chars); - when(mbFont.getWidths()).thenReturn(widths); - cidFull = new CIDFull(mbFont); - } - - @Test - public void testGetOriginalGlyphIndex() { - // index 5 exists - assertEquals(cidFull.getOriginalGlyphIndex(5), 5); - } - - @Test - public void testGetUnicode() { - // index 9 exists - assertEquals(cidFull.getUnicode(9), (char) 9); - // index 10 does not - assertEquals(cidFull.getUnicode(10), CharUtilities.NOT_A_CHARACTER); - } - - @Test - public void testMapChar() { - // index 9 exists - char c = 'a'; - assertEquals(cidFull.mapChar(9, c), (char) 9); - } - - @Test - public void testGetGlyphs() { - Map<Integer, Integer> fontGlyphs = cidFull.getGlyphs(); - for (Integer key : fontGlyphs.keySet()) { - assertEquals(fontGlyphs.get(key), glyphs.get(key)); - } - assertTrue(fontGlyphs.size() == glyphs.size()); - } - - @Test - public void testGetChars() { - assertArrayEquals(cidFull.getChars(), chars); - } - - @Test - public void testGetNumberOfGlyphs() { - assertTrue(cidFull.getNumberOfGlyphs() == 20); - } - - @Test - public void testGetGlyphIndices() { - assertEquals(bs, cidFull.getGlyphIndices()); - } - - @Test - public void testGetWidths() { - assertArrayEquals(cidFull.getWidths(), widths); - } - -} diff --git a/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java b/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java deleted file mode 100644 index c4b471ee5..000000000 --- a/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.fonts; - -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; - -/** - * - */ -public class DejaVuLGCSerifTestCase { - - private InternalResourceResolver resolver = - ResourceResolverFactory.createDefaultInternalResourceResolver(new File(".").toURI()); - private CustomFont font; - - /** - * sets up the testcase by loading the DejaVu Font. - * - * @throws Exception - * if the test fails. - */ - @Before - public void setUp() throws Exception { - File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf"); - FontUris fontUris = new FontUris(file.toURI(), null); - font = FontLoader.loadFont(fontUris, "", true, EmbeddingMode.AUTO, EncodingMode.AUTO, - false, false, resolver); - } - - /** - * Simple test to see if font name was detected correctly. - */ - @Test - 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 deleted file mode 100644 index e4179f1f6..000000000 --- a/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.fonts; - -import java.net.URI; -import java.util.ArrayList; -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; - -/** - * Testcase for {@link EmbedFontInfo}. - */ -public class EmbedFontInfoTestCase { - - public EmbedFontInfoTestCase() { } - - private EmbedFontInfo sut; - - private final URI metricsURI = URI.create("test/resources/fonts/ttf/glb12.ttf.xml"); - private final URI embedURI = URI.create("test/resources/fonts/ttf/glb12.ttf"); - private final boolean kerning = false; - private final boolean useAdvanced = false; - private final String subFontName = "Gladiator Bold"; - private final EncodingMode encMode = EncodingMode.CID; - private final EmbeddingMode embedMode = EmbeddingMode.AUTO; - private final FontTriplet triplet = new FontTriplet(subFontName, "bold", Font.WEIGHT_BOLD); - - @Before - public void setUp() { - List<FontTriplet> triplets = new ArrayList<FontTriplet>(); - triplets.add(triplet); - FontUris fontUris = new FontUris(embedURI, metricsURI); - sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, triplets, subFontName, encMode, embedMode); - } - - @Test - public void testImmutableGetters() { - assertEquals(metricsURI, sut.getMetricsURI()); - assertEquals(embedURI, sut.getEmbedURI()); - assertEquals(kerning, sut.getKerning()); - assertEquals(subFontName, sut.getSubFontName()); - assertEquals(encMode, sut.getEncodingMode()); - - assertEquals(1, sut.getFontTriplets().size()); - assertEquals(triplet, sut.getFontTriplets().get(0)); - - assertTrue(sut.isEmbedded()); - } - - @Test - public void testMutableGetterSetters() { - String psName = "Test Name"; - sut.setPostScriptName(psName); - assertEquals(psName, sut.getPostScriptName()); - - sut.setEmbedded(false); - assertFalse(sut.isEmbedded()); - } - - @Test - public void testQuirkyBoundaryCasesIsEmbedded() { - FontUris fontUris = new FontUris(null, metricsURI); - sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, sut.getFontTriplets(), subFontName, encMode, - embedMode); - sut.setEmbedded(true); - assertFalse(sut.isEmbedded()); - - sut.setEmbedded(false); - assertFalse(sut.isEmbedded()); - } - -} diff --git a/test/java/org/apache/fop/fonts/EncodingModeTestCase.java b/test/java/org/apache/fop/fonts/EncodingModeTestCase.java deleted file mode 100644 index 8cab9eb8b..000000000 --- a/test/java/org/apache/fop/fonts/EncodingModeTestCase.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.fonts; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Tests {@link EncodingMode}. - */ -public class EncodingModeTestCase { - - @Test - public void testGetName() { - assertEquals("auto", EncodingMode.AUTO.getName()); - assertEquals("single-byte", EncodingMode.SINGLE_BYTE.getName()); - assertEquals("cid", EncodingMode.CID.getName()); - } - - @Test - public void testGetValue() { - assertEquals(EncodingMode.AUTO, EncodingMode.getValue("auto")); - assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getValue("single-byte")); - assertEquals(EncodingMode.CID, EncodingMode.getValue("cid")); - } - - @Test(expected = IllegalArgumentException.class) - public void getValueMustCheckForIllegalArguments() { - EncodingMode.getValue("fail"); - } -} diff --git a/test/java/org/apache/fop/fonts/FOPFontsTestSuite.java b/test/java/org/apache/fop/fonts/FOPFontsTestSuite.java deleted file mode 100644 index 8e1a0040d..000000000 --- a/test/java/org/apache/fop/fonts/FOPFontsTestSuite.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.fonts; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.apache.fop.fonts.truetype.FontFileReaderTestCase; -import org.apache.fop.fonts.truetype.TTFFileTestCase; -import org.apache.fop.fonts.truetype.TTFSubSetFileTestCase; -import org.apache.fop.fonts.truetype.TTFTableNameTestCase; - -/** - * A test suite designed for org.apache.fop.fonts.* - */ -@RunWith(Suite.class) -@SuiteClasses({ - EncodingModeTestCase.class, - FontFileReaderTestCase.class, - TTFFileTestCase.class, - TTFSubSetFileTestCase.class, - TTFTableNameTestCase.class }) -public final class FOPFontsTestSuite { -} diff --git a/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java b/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java deleted file mode 100644 index b4271ba60..000000000 --- a/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.fonts; - -import java.io.InputStream; -import java.net.URI; - -import org.junit.Test; - -import org.apache.xmlgraphics.util.MimeConstants; - -import org.apache.fop.events.EventProcessingTestCase; - -/** - * Testing font events. - */ -public class FontEventProcessingTestCase { - - private EventProcessingTestCase eventsTests = new EventProcessingTestCase(); - - private static final URI CONFIG_BASE_DIR = EventProcessingTestCase.CONFIG_BASE_DIR; - - @Test - public void testFont() throws Exception { - InputStream inStream = getClass().getResourceAsStream("substituted-font.fo"); - eventsTests.doTest(inStream, null, FontEventProducer.class.getName() + ".fontSubstituted", - MimeConstants.MIME_PDF); - } - - @Test - public void testFontWithBadDirectory() throws Exception { - InputStream inStream = getClass().getResourceAsStream("substituted-font.fo"); - eventsTests.doTest(inStream, CONFIG_BASE_DIR.resolve("test_fonts_directory_bad.xconf"), - FontEventProducer.class.getName() + ".fontDirectoryNotFound", - MimeConstants.MIME_PDF); - } - -} diff --git a/test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java b/test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java deleted file mode 100644 index d653171b7..000000000 --- a/test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.fonts; - -import java.io.File; -import java.io.IOException; -import java.net.URI; - -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; - -/** - * A test case for {@link FontManagerConfigurator}. - */ -public class FontManagerConfiguratorTestCase { - - private FopConfBuilder builder; - public final URI baseURI = new File("test/config/").getAbsoluteFile().toURI(); - - @Before - public void setUp() { - builder = new FopConfBuilder(); - } - - private FontManager setBaseAndGetManager(String fontBase) { - builder.setFontBaseURI(fontBase); - return getManager(); - } - - private FontManager getManager() { - FopFactory factory = getFopFactory(builder.build(), baseURI); - return factory.getFontManager(); - } - - @Test(expected = FOPException.class) - public void invalidURI() throws SAXException, IOException { - builder.setFontBaseURI("$$%%**~{}]["); - FopConfParser confParser = new FopConfParser(builder.build(), baseURI); - confParser.getFopFactoryBuilder().build(); - } - - @Test - public void relativeFontBaseURITest() { - String actualBase = "../../resources/fonts/ttf/"; - FontManager fontManager = setBaseAndGetManager(actualBase); - URI expectedURI = baseURI.resolve(actualBase); - assertEquals(expectedURI, fontManager.getResourceResolver().getBaseURI()); - } - - @Test - public void currentRelativeFontBaseTest() { - String actualBase = "."; - FontManager fontManager = setBaseAndGetManager(actualBase); - assertEquals(baseURI, fontManager.getResourceResolver().getBaseURI()); - } - - /** - * 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 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 - public void fontBaseDoesntExist() { - // TODO: Sort this out - String actualBase = "non-existing-dir/"; - FontManager fontManager = setBaseAndGetManager(actualBase); - assertEquals(baseURI.resolve("non-existing-dir/"), - fontManager.getResourceResolver().getBaseURI()); - } - - /** - * Tests that when no <font-base> is given, it falls back to the URI used in <base>. - */ - @Test - public void noFontBaseURITest() { - String actualBase = "../../resources/images/"; - builder.setBaseURI(actualBase); - FontManager fontManager = getManager(); - assertEquals(baseURI.resolve(actualBase), - fontManager.getResourceResolver().getBaseURI()); - } - - @Test - public void absoluteBaseURI() { - String absoluteBase = "test:///absolute/"; - FontManager fontManager = setBaseAndGetManager(absoluteBase); - assertEquals(URI.create(absoluteBase), fontManager.getResourceResolver().getBaseURI()); - } -} diff --git a/test/java/org/apache/fop/fonts/FontManagerTestCase.java b/test/java/org/apache/fop/fonts/FontManagerTestCase.java deleted file mode 100644 index 9012f843b..000000000 --- a/test/java/org/apache/fop/fonts/FontManagerTestCase.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.fonts; - -import java.net.URI; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.io.InternalResourceResolver; - -public class FontManagerTestCase { - - private FontManager sut; - private FontCacheManager fontCacheManager; - private FontDetector fontDetector; - private InternalResourceResolver resolver; - - @Before - public void setUp() { - resolver = mock(InternalResourceResolver.class); - fontCacheManager = mock(FontCacheManager.class); - fontDetector = mock(FontDetector.class); - - sut = new FontManager(resolver, fontDetector, fontCacheManager); - } - - @Test - public void testSetCacheFile() { - URI testURI = URI.create("test/uri"); - sut.setCacheFile(testURI); - - InOrder inOrder = inOrder(resolver, fontCacheManager); - inOrder.verify(resolver).resolveFromBase(testURI); - inOrder.verify(fontCacheManager).setCacheFile(any(URI.class)); - } - - @Test - public void testGetFontCache() { - sut.getFontCache(); - verify(fontCacheManager).load(); - } - - @Test - public void testSaveCache() throws FOPException { - sut.saveCache(); - verify(fontCacheManager).save(); - } - - @Test - public void testDeleteCache() throws FOPException { - sut.deleteCache(); - verify(fontCacheManager).delete(); - } -} diff --git a/test/java/org/apache/fop/fonts/FontsTestSuite.java b/test/java/org/apache/fop/fonts/FontsTestSuite.java deleted file mode 100644 index 1baba49df..000000000 --- a/test/java/org/apache/fop/fonts/FontsTestSuite.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.fonts; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * A test suite for the o.a.f.fonts package. - */ -@RunWith(Suite.class) -@SuiteClasses({ - FontManagerConfiguratorTestCase.class, - EmbedFontInfoTestCase.class, - FontEventProcessingTestCase.class, - FontManagerConfiguratorTestCase.class -}) -public class FontsTestSuite { - -} diff --git a/test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java b/test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java deleted file mode 100644 index 97ea5c52b..000000000 --- a/test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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.fonts.cff; - -import java.io.IOException; -import java.util.Map; -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; - -public class CFFDataReaderTestCase { - private CFFDataReader cffReader; - - /** - * Initializes the CFFDataReader for testing purposes - */ - @Before - public void setUp() { - cffReader = new CFFDataReader(); - } - - /** - * Parses a test dictionary to verify whether the stored data is read correctly. - * @throws IOException - */ - @Test - public void parseDictData() throws IOException { - byte[] testDictData = prepareDictData(); - Map<String, DICTEntry> testTopDict = cffReader.parseDictData(testDictData); - validateDictData(testTopDict); - } - - private byte[] prepareDictData() { - byte[] testDictData = new byte[0]; - //Version - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 392, new int[] { 0 }, -1)); - //Notice - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 393, new int[] { 1 }, -1)); - //Copyright - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 394, new int[] { 12, 0 }, -1)); - //FullName - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 395, new int[] { 2 }, -1)); - //FamilyName - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 396, new int[] { 3 }, -1)); - //Weight - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 397, new int[] { 4 }, -1)); - //isFixedPitch (boolean = false) - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 0, new int[] { 12, 1 }, -1)); - //FontBBox - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - -50, new int[0], -1)); - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - -40, new int[0], -1)); - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 100, new int[0], -1)); - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 120, new int[] { 5 }, -1)); - //charset - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 1234, new int[] { 15 }, -1)); - //CharStrings - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 3654, new int[] { 17 }, -1)); - //Private - testDictData = OTFSubSetFile.concatArray(testDictData, OTFSubSetFile.createNewRef( - 11454, new int[] { 18 }, -1)); - return testDictData; - } - - private void validateDictData(Map<String, DICTEntry> dictMap) { - //SID Values (numbers) - assertEquals(dictMap.get("version").getOperands().get(0).intValue(), 392); - assertEquals(dictMap.get("Notice").getOperands().get(0).intValue(), 393); - assertEquals(dictMap.get("Copyright").getOperands().get(0).intValue(), 394); - assertEquals(dictMap.get("FullName").getOperands().get(0).intValue(), 395); - assertEquals(dictMap.get("FamilyName").getOperands().get(0).intValue(), 396); - assertEquals(dictMap.get("Weight").getOperands().get(0).intValue(), 397); - //Boolean comparison - assertEquals(dictMap.get("isFixedPitch").getOperands().get(0).intValue(), 0); - //Array comparison - int[] fontBBox = { -50, -40, 100, 120 }; - DICTEntry fontBBoxEntry = dictMap.get("FontBBox"); - for (int i = 0; i < fontBBoxEntry.getOperands().size(); i++) { - assertEquals(fontBBoxEntry.getOperands().get(i).intValue(), fontBBox[i]); - } - //Multi-byte offset (number) - assertEquals(dictMap.get("charset").getOperands().get(0).intValue(), 1234); - assertEquals(dictMap.get("CharStrings").getOperands().get(0).intValue(), 3654); - //Larger offset - assertEquals(dictMap.get("Private").getOperands().get(0).intValue(), 11454); - } - - /** - * Tests the parsing of an example byte data index structure - * @throws IOException - */ - @Test - public void testIndexParsing() throws IOException { - byte[] testIndex = { - 0, 5, //Number of objects - 1, //Offset size - 1, //Offsets... - 5, - 12, - 24, - 27, - 32 - }; - Random randGen = new Random(); - byte[] data = new byte[31]; - for (int i = 0; i < data.length; i++) { - data[i] = (byte)randGen.nextInt(255); - } - testIndex = OTFSubSetFile.concatArray(testIndex, data); - CFFIndexData indexData = cffReader.readIndex(new CFFDataInput(testIndex)); - assertEquals(indexData.getNumObjects(), 5); - assertEquals(indexData.getOffSize(), 1); - assertEquals(indexData.getOffsets().length, 6); - assertEquals(indexData.getOffsets()[5], 32); - } -} diff --git a/test/java/org/apache/fop/fonts/substituted-font.fo b/test/java/org/apache/fop/fonts/substituted-font.fo deleted file mode 100644 index 551527522..000000000 --- a/test/java/org/apache/fop/fonts/substituted-font.fo +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> - <fo:layout-master-set> - <fo:simple-page-master master-name="page" - page-height="420pt" page-width="320pt" margin="10pt"> - <fo:region-body background-color="#F0F0F0"/> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="page"> - <fo:flow flow-name="xsl-region-body"> - <fo:block font-family="blah">This block uses an unknown font.</fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/fonts/truetype/FontFileReaderTestCase.java b/test/java/org/apache/fop/fonts/truetype/FontFileReaderTestCase.java deleted file mode 100644 index 5c1fec175..000000000 --- a/test/java/org/apache/fop/fonts/truetype/FontFileReaderTestCase.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * 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.fonts.truetype; - -import java.io.ByteArrayInputStream; -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * A test class for org.apache.fop.truetype.FontFileReader - */ -public class FontFileReaderTestCase { - private FontFileReader fontReader; - private final InputStream in; - private final byte[] byteArray; - - /** - * Constructor - initialises an array that only needs to be created once. It creates a byte[] - * of form { 0x00, 0x01, 0x02, 0x03..., 0xff}; - */ - public FontFileReaderTestCase() { - byteArray = new byte[256]; - for (int i = 0; i < 256; i++) { - byteArray[i] = (byte) i; - } - in = new ByteArrayInputStream(byteArray); - } - - /** - * sets up the test subject object for testing. - */ - @Before - public void setUp() { - try { - fontReader = new FontFileReader(in); - } catch (Exception e) { - fail("Error: " + e.getMessage()); - } - } - - /** - * the "destructor" method. - * - */ - public void tearDown() { - fontReader = null; - } - - /** - * Test readTTFByte() - * @throws IOException exception - */ - @Test - public void testReadTTFByte() throws IOException { - for (int i = 0; i < 256; i++) { - assertEquals((byte) i, fontReader.readTTFByte()); - } - } - - /** - * Test seekSet() - check that it moves to the correct position and enforce a failure case. - * @throws IOException exception - */ - @Test - public void testSeekSet() throws IOException { - fontReader.seekSet(10); - assertEquals(10, fontReader.readTTFByte()); - try { - fontReader.seekSet(257); - fail("FileFontReaderTest Failed testSeekSet"); - } catch (IOException e) { - // Passed - } - } - - /** - * Test skip() - check that it moves to the correct position and enforce a failure case. - * @throws IOException exception - */ - @Test - public void testSkip() throws IOException { - fontReader.skip(100); - assertEquals(100, fontReader.readTTFByte()); - try { - // 100 (seekAdd) + 1 (read() = 1 byte) + 156 = 257 - fontReader.skip(156); - fail("FileFontReaderTest Failed testSkip"); - } catch (IOException e) { - // Passed - } - } - - /** - * Test getCurrentPos() - 3 checks: - * 1) test with seekSet(int) - * 2) test with skip(int) - * 3) test with a readTTFByte() (this moves the position by the size of the data being read) - * @throws IOException exception - */ - @Test - public void testGetCurrentPos() throws IOException { - fontReader.seekSet(10); - fontReader.skip(100); - assertEquals(110, fontReader.getCurrentPos()); - fontReader.readTTFByte(); - assertEquals(111, fontReader.getCurrentPos()); - } - - /** - * Test getFileSize() - */ - @Test - public void testGetFileSize() { - assertEquals(256, fontReader.getFileSize()); - } - - /** - * Test readTTFUByte() - * @throws IOException exception - */ - @Test - public void testReadTTFUByte() throws IOException { - for (int i = 0; i < 256; i++) { - assertEquals(i, fontReader.readTTFUByte()); - } - } - - /** - * Test readTTFShort() - Test positive and negative numbers (two's compliment). - * @throws IOException exception - */ - @Test - public void testReadTTFShort() throws IOException { - // 0x0001 = 1 - assertEquals("Should have been 1 (0x0001)", 1, fontReader.readTTFShort()); - // 0x0203 = 515 - assertEquals(515, fontReader.readTTFShort()); - // now test negative numbers - fontReader.seekSet(250); - // 0xfafb - assertEquals(-1285, fontReader.readTTFShort()); - } - - /** - * Test readTTFUShort() - Test positive and potentially negative numbers (two's compliment). - * @throws IOException exception - */ - @Test - public void testReadTTFUShort() throws IOException { - // 0x0001 - assertEquals(1, fontReader.readTTFUShort()); - // 0x0203 - assertEquals(515, fontReader.readTTFUShort()); - // test potential negatives - fontReader.seekSet(250); - // 0xfafb - assertEquals((250 << 8) + 251, fontReader.readTTFUShort()); - } - - /** - * Test readTTFShort(int) - test reading ahead of current position and behind current position - * and in both cases ensure that our current position isn't changed. - * @throws IOException exception - */ - @Test - public void testReadTTFShortWithArg() throws IOException { - // 0x6465 - assertEquals(25701, fontReader.readTTFShort(100)); - assertEquals(0, fontReader.getCurrentPos()); - // read behind current position (and negative) - fontReader.seekSet(255); - // 0xfafb - assertEquals(-1285, fontReader.readTTFShort(250)); - assertEquals(255, fontReader.getCurrentPos()); - } - - /** - * Test readTTFUShort(int arg) - test reading ahead of current position and behind current - * position and in both cases ensure that our current position isn't changed. - * @throws IOException exception - */ - @Test - public void testReadTTFUShortWithArg() throws IOException { - // 0x6465 - assertEquals(25701, fontReader.readTTFUShort(100)); - assertEquals(0, fontReader.getCurrentPos()); - // read behind current position (and potential negative) - fontReader.seekSet(255); - // 0xfafb - assertEquals(64251, fontReader.readTTFUShort(250)); - assertEquals(255, fontReader.getCurrentPos()); - } - - /** - * Test readTTFLong() - * @throws IOException exception - */ - @Test - public void testReadTTFLong() throws IOException { - // 0x00010203 - assertEquals(66051, fontReader.readTTFLong()); - // test negative numbers - fontReader.seekSet(250); - // 0xf0f1f2f3 - assertEquals(-84148995, fontReader.readTTFLong()); - } - - /** - * Test readTTFULong() - * @throws IOException exception - */ - @Test - public void testReadTTFULong() throws IOException { - // 0x00010203 - assertEquals(66051, fontReader.readTTFULong()); - // test negative numbers - fontReader.seekSet(250); - // 0xfafbfcfd - assertEquals(4210818301L, fontReader.readTTFULong()); - } - - /** - * Test readTTFString() - there are two paths to test here: - * 1) A null terminated string - * 2) A string not terminated with a null (we expect this to throw an EOFException) - * @throws IOException exception - */ - @Test - public void testReadTTFString() throws IOException { - byte[] strByte = {(byte)'t', (byte)'e', (byte)'s', (byte)'t', 0x00}; - fontReader = new FontFileReader(new ByteArrayInputStream(strByte)); - assertEquals("test", fontReader.readTTFString()); - try { - // not NUL terminated - byte[] strByteNoNull = {(byte)'t', (byte)'e', (byte)'s', (byte)'t'}; - fontReader = new FontFileReader(new ByteArrayInputStream(strByteNoNull)); - assertEquals("test", fontReader.readTTFString()); - fail("FontFileReaderTest testReadTTFString Fails."); - } catch (EOFException e) { - // Pass - } - } - - /** - * Test readTTFString(int arg) - * @throws IOException exception - */ - @Test - public void testReadTTFStringIntArg() throws IOException { - byte[] strByte = {(byte)'t', (byte)'e', (byte)'s', (byte)'t'}; - fontReader = new FontFileReader(new ByteArrayInputStream(strByte)); - assertEquals("test", fontReader.readTTFString(4)); - try { - fontReader = new FontFileReader(new ByteArrayInputStream(strByte)); - assertEquals("test", fontReader.readTTFString(5)); - fail("FontFileReaderTest testReadTTFStringIntArg Fails."); - } catch (EOFException e) { - // Pass - } - } - - /** - * Test readTTFString(int arg1, int arg2) - */ - public void testReadTTFString2IntArgs() { - // currently the same as above - } - - /** - * Test getBytes() - * @throws IOException exception - */ - @Test - public void testGetBytes() throws IOException { - byte[] retrievedBytes = fontReader.getBytes(0, 256); - assertTrue(Arrays.equals(byteArray, retrievedBytes)); - } -} diff --git a/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java b/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java deleted file mode 100644 index 952c3ec1f..000000000 --- a/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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.fonts.truetype; - -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * Tests {@link GlyfTable}. - */ -public class GlyfTableTestCase { - - private static final class DirData { - - final long offset; - final long length; - - DirData(long offset, long length) { - this.offset = offset; - this.length = length; - } - } - - private FontFileReader subsetReader; - - private long[] glyphOffsets; - - private FontFileReader originalFontReader; - - @Before - public void setUp() throws IOException { - FileInputStream fontStream = new FileInputStream( - "test/resources/fonts/ttf/DejaVuLGCSerif.ttf"); - try { - originalFontReader = new FontFileReader(fontStream); - } finally { - fontStream.close(); - } - } - - /** - * Tests that composed glyphs are included in the glyph subset if a composite glyph is used. - * - * @throws IOException if an I/O error occurs - */ - @Test - public void testPopulateGlyphsWithComposites() throws IOException { - // Glyph 408 -> U+01D8 "uni01D8" this is a composite glyph. - int[] composedIndices = setupTest(408); - - int[] expected = new int[composedIndices.length]; - expected[1] = 6; - expected[5] = 2; - expected[6] = 4; - - assertArrayEquals(expected, composedIndices); - } - - /** - * Tests that no glyphs are added if there are no composite glyphs the subset. - * - * @throws IOException if an I/O error occurs - */ - @Test - public void testPopulateNoCompositeGlyphs() throws IOException { - int[] composedIndices = setupTest(36, 37, 38); // "A", "B", "C" - int[] expected = new int[composedIndices.length]; - - // There should be NO composite glyphs - assertArrayEquals(expected, composedIndices); - } - - /** - * Tests that glyphs aren't remapped twice if the glyph before a composite glyph has 0-length. - * - * @throws IOException if an I/O error occurs - */ - @Test - public void testGlyphsNotRemappedTwice() throws IOException { - int composedGlyph = 12; - // The order of these glyph indices, must NOT be changed! (see javadoc above) - int[] composedIndices = setupTest(1, 2, 3, 16, 2014, 4, 7, 8, 13, 2015, composedGlyph); - - // There are 2 composed glyphs within the subset - int[] expected = new int[composedIndices.length]; - expected[10] = composedGlyph; - - assertArrayEquals(expected, composedIndices); - } - - /** - * Tests that the correct glyph is included in the subset, when a composite glyph composed of a - * composite glyph is used. - * - * @throws IOException if an I/O error occurs - */ - @Test - public void testSingleRecursionStep() throws IOException { - // Glyph 2077 -> U+283F "uni283F" this is composed of a composite glyph (recursive). - int[] composedIndices = setupTest(2077); - - int[] expected = new int[composedIndices.length]; - expected[1] = 2; - - assertArrayEquals(expected, composedIndices); - } - - private int[] setupTest(int... glyphIndices) throws IOException { - Map<Integer, Integer> glyphs = new HashMap<Integer, Integer>(); - int index = 0; - glyphs.put(0, index++); // Glyph 0 (.notdef) must ALWAYS be in the subset - - for (int glyphIndex : glyphIndices) { - glyphs.put(glyphIndex, index++); - } - setupSubsetReader(glyphs); - readLoca(); - - return retrieveIndicesOfComposedGlyphs(); - } - - private void setupSubsetReader(Map<Integer, Integer> glyphs) throws IOException { - TTFSubSetFile fontFile = new TTFSubSetFile(); - String header = OFFontLoader.readHeader(subsetReader); - fontFile.readFont(originalFontReader, "Deja", header, glyphs); - byte[] subsetFont = fontFile.getFontSubset(); - InputStream intputStream = new ByteArrayInputStream(subsetFont); - subsetReader = new FontFileReader(intputStream); - } - - private void readLoca() throws IOException { - DirData loca = getTableData(OFTableName.LOCA.getName()); - int numberOfGlyphs = (int) (loca.length - 4) / 4; - glyphOffsets = new long[numberOfGlyphs]; - subsetReader.seekSet(loca.offset); - - for (int i = 0; i < numberOfGlyphs; i++) { - glyphOffsets[i] = subsetReader.readTTFULong(); - } - } - - private int[] retrieveIndicesOfComposedGlyphs() throws IOException { - DirData glyf = getTableData(OFTableName.GLYF.getName()); - int[] composedGlyphIndices = new int[glyphOffsets.length]; - - for (int i = 0; i < glyphOffsets.length; i++) { - long glyphOffset = glyphOffsets[i]; - if (i != glyphOffsets.length - 1 && glyphOffset == glyphOffsets[i + 1]) { - continue; - } - subsetReader.seekSet(glyf.offset + glyphOffset); - short numberOfContours = subsetReader.readTTFShort(); - if (numberOfContours < 0) { - subsetReader.skip(8); - subsetReader.readTTFUShort(); // flags - int glyphIndex = subsetReader.readTTFUShort(); - composedGlyphIndices[i] = glyphIndex; - } - } - return composedGlyphIndices; - } - - private DirData getTableData(String tableName) throws IOException { - subsetReader.seekSet(0); - subsetReader.skip(12); - String name; - do { - name = subsetReader.readTTFString(4); - subsetReader.skip(4 * 3); - } while (!name.equals(tableName)); - - subsetReader.skip(-8); // We've found the table, go back to get the data we skipped over - return new DirData(subsetReader.readTTFLong(), subsetReader.readTTFLong()); - } - - private void assertArrayEquals(int[] expected, int[] actual) { - assertTrue(Arrays.equals(expected, actual)); - } -} diff --git a/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java b/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java deleted file mode 100644 index 39b6fd50f..000000000 --- a/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.fonts.truetype; - -import java.io.FileInputStream; -import java.io.InputStream; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class OTFFileTestCase { - protected OTFFile sourceSansProBold; - protected FontFileReader sourceSansReader; - protected OTFFile alexBrush; - protected FontFileReader alexBrushReader; - - /** - * Initializes fonts used for the testing of reading OTF CFF - * @throws java.io.IOException - */ - @Before - public void setUp() throws Exception { - sourceSansProBold = new OTFFile(); - InputStream sourceSansStream = new FileInputStream("test/resources/fonts/otf/SourceSansProBold.otf"); - sourceSansReader = new FontFileReader(sourceSansStream); - String sourceSansHeader = OFFontLoader.readHeader(sourceSansReader); - sourceSansProBold.readFont(sourceSansReader, sourceSansHeader); - sourceSansStream.close(); - - InputStream alexBrushStream = new FileInputStream("test/resources/fonts/otf/AlexBrushRegular.otf"); - alexBrush = new OTFFile(); - alexBrushReader = new FontFileReader(alexBrushStream); - String carolynaHeader = OFFontLoader.readHeader(alexBrushReader); - alexBrush.readFont(alexBrushReader, carolynaHeader); - alexBrushStream.close(); - } - - /** - * Tests the font names being read from the file - */ - @Test - public void testFontNames() { - assertTrue(sourceSansProBold.getFamilyNames().contains("Source Sans Pro")); - assertTrue(alexBrush.getFamilyNames().contains("Alex Brush")); - } - - /** - * Tests the number of glyphs and a select number of widths from each font - */ - @Test - public void testGlyphNumberAndWidths() { - assertEquals(824, sourceSansProBold.numberOfGlyphs); - assertEquals(256, alexBrush.numberOfGlyphs); - - int[] gids = {32, 42, 44, 47}; - int[] sourceSansWidths = {516, 555, 572, 383}; - 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++) { - 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 deleted file mode 100644 index fecb1e9f1..000000000 --- a/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * 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.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; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.apache.fontbox.cff.CFFFont; - -import org.apache.fop.fonts.cff.CFFDataReader; -import org.apache.fop.fonts.cff.CFFDataReader.CFFIndexData; -import org.apache.fop.fonts.cff.CFFDataReader.DICTEntry; -import org.apache.fop.fonts.truetype.OTFSubSetFile.BytesNumber; - -public class OTFSubSetFileTestCase extends OTFFileTestCase { - - CFFDataReader cffReaderSourceSans; - private OTFSubSetFile sourceSansSubset; - private byte[] sourceSansData; - CFFDataReader cffReaderHeitiStd; - - /** - * Initialises the test by creating the font subset. A CFFDataReader is - * also created based on the subset data for use in the tests. - * @throws IOException - */ - @Before - public void setUp() throws Exception { - super.setUp(); - - Map<Integer, Integer> glyphs = new HashMap<Integer, Integer>(); - for (int i = 0; i < 256; i++) { - glyphs.put(i, i); - } - - sourceSansSubset = new OTFSubSetFile(); - String sourceSansHeader = OFFontLoader.readHeader(sourceSansReader); - sourceSansSubset.readFont(sourceSansReader, "SourceSansProBold", sourceSansHeader, glyphs); - sourceSansData = sourceSansSubset.getFontSubset(); - cffReaderSourceSans = new CFFDataReader(sourceSansData); - } - - /** - * Validates the CharString data against the original font - * @throws IOException - */ - @Test - public void testCharStringIndex() throws IOException { - assertEquals(256, cffReaderSourceSans.getCharStringIndex().getNumObjects()); - assertTrue(checkCorrectOffsets(cffReaderSourceSans.getCharStringIndex())); - 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++) { - if (indexData.getOffsets()[i] < last) { - return false; - } - last = indexData.getOffsets()[i]; - } - return true; - } - - /** - * 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(); - 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; - } - - /** - * 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(); - } - } - - /** - * 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; - } - - /** - * 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; - } - } - - /** - * A class representing an operator from the CharString data - */ - private class Operator extends BytesNumber { - private String opName = ""; - - public Operator(int number, int numBytes, String opName) { - super(number, numBytes); - this.opName = opName; - } - public String toString() { - return String.format("[%s]", opName); - } - } - - /** - * 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 - */ - @Test - public void testStringIndex() throws IOException { - assertEquals(164, cffReaderSourceSans.getStringIndex().getNumObjects()); - assertTrue(checkCorrectOffsets(cffReaderSourceSans.getStringIndex())); - assertEquals("Amacron", new String(cffReaderSourceSans.getStringIndex().getValue(5))); - assertEquals("Edotaccent", new String(cffReaderSourceSans.getStringIndex().getValue(32))); - assertEquals("uni0122", new String(cffReaderSourceSans.getStringIndex().getValue(45))); - } - - /** - * Validates the Top Dict data - * @throws IOException - */ - @Test - public void testTopDictData() throws IOException { - Map<String, DICTEntry> topDictEntries = cffReaderSourceSans.parseDictData( - cffReaderSourceSans.getTopDictIndex().getData()); - assertEquals(10, topDictEntries.size()); - } -} diff --git a/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java b/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java deleted file mode 100644 index a78b3e674..000000000 --- a/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * 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.fonts.truetype; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; - -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.fonts.truetype.OpenFont.PostScriptVersion; - -/** - * Class for testing org.apache.fop.fonts.truetype.TTFFile - */ -public class TTFFileTestCase { - // We only want to initialize the FontFileReader once (for performance reasons) - /** The truetype font file (DejaVuLGCSerif) */ - protected final TTFFile dejavuTTFFile; - /** The FontFileReader for ttfFile (DejaVuLGCSerif) */ - protected final FontFileReader dejavuReader; - /** The truetype font file (DroidSansMono) */ - protected final TTFFile droidmonoTTFFile; - /** The FontFileReader for ttfFile (DroidSansMono) */ - protected final FontFileReader droidmonoReader; - - - /** - * Constructor initialises FileFontReader to - * @throws IOException exception - */ - public TTFFileTestCase() throws IOException { - dejavuTTFFile = new TTFFile(); - InputStream dejaStream = new FileInputStream("test/resources/fonts/ttf/DejaVuLGCSerif.ttf"); - dejavuReader = new FontFileReader(dejaStream); - String dejavuHeader = OFFontLoader.readHeader(dejavuReader); - dejavuTTFFile.readFont(dejavuReader, dejavuHeader); - dejaStream.close(); - - InputStream droidStream = new FileInputStream("test/resources/fonts/ttf/DroidSansMono.ttf"); - - droidmonoTTFFile = new TTFFile(); - droidmonoReader = new FontFileReader(droidStream); - String droidmonoHeader = OFFontLoader.readHeader(droidmonoReader); - droidmonoTTFFile.readFont(droidmonoReader, droidmonoHeader); - droidStream.close(); - } - - /** - * Test convertTTFUnit2PDFUnit() - The units per em retrieved reading the HEAD table from - * the font file. (DroidSansMono has the same units per em as DejaVu so no point testing it) - */ - @Test - public void testConvertTTFUnit2PDFUnit() { - // DejaVu has 2048 units per em (PDF works in millipts, thus the 1000) - // test rational number - assertEquals(1000, dejavuTTFFile.convertTTFUnit2PDFUnit(2048)); - // test smallest case, this should = 0.488 (round down to 0) - assertEquals(0, dejavuTTFFile.convertTTFUnit2PDFUnit(1)); - // this should round up, but since it's millipts... - assertEquals(0, dejavuTTFFile.convertTTFUnit2PDFUnit(2)); - // ensure behaviour is the same for negative numbers - assertEquals(0, dejavuTTFFile.convertTTFUnit2PDFUnit(-0)); - assertEquals(-1000, dejavuTTFFile.convertTTFUnit2PDFUnit(-2048)); - assertEquals(0, dejavuTTFFile.convertTTFUnit2PDFUnit(-1)); - assertEquals(0, dejavuTTFFile.convertTTFUnit2PDFUnit(-2)); - } - - /** - * Test checkTTC() - * @throws IOException exception - */ - @Test - public void testCheckTTC() throws IOException { - // DejaVu is not a TTC, thus this returns true - String dejavuHeader = OFFontLoader.readHeader(dejavuReader); - assertTrue(dejavuTTFFile.checkTTC(dejavuHeader, "")); - String droidmonoHeader = OFFontLoader.readHeader(droidmonoReader); - assertTrue(droidmonoTTFFile.checkTTC(droidmonoHeader, "")); - /* - * Cannot reasonably test the rest of this method without an actual truetype collection - * because all methods in FontFileReader are "final" and thus mocking isn't possible. - */ - } - - /** - * Test getAnsiKerning() - Tests values retrieved from the kern table in the font file. - */ - @Test - public void testGetAnsiKerning() { - Map<Integer, Map<Integer, Integer>> ansiKerning = dejavuTTFFile.getKerning(); - if (ansiKerning.isEmpty()) { - fail(); - } - Integer k1 = ansiKerning.get(Integer.valueOf('A')).get( - Integer.valueOf('T')); - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(-112), k1.intValue()); - Integer k2 = ansiKerning.get(Integer.valueOf('Y')).get(Integer.valueOf('u')); - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(-178), k2.intValue()); - - // DroidSansMono doens't have kerning (it's mono-spaced) - ansiKerning = droidmonoTTFFile.getAnsiKerning(); - if (!ansiKerning.isEmpty()) { - fail("DroidSansMono shouldn't have any kerning data."); - } - } - - /** - * Test getCapHeight - there are several paths to test: - * 1) The PCLT table (if present) - * 2) The yMax (3rd) value, for the bounding box, for 'H' in the glyf table. - * if not the above: - * 3) The caps height in the OS/2 table - * Tests values retrieved from analysing the font file. - */ - @Test - public void testGetCapHeight() { - // DejaVu doesn't have the PCLT table and so these have to be guessed - // The height is approximated to be the height of the "H" which for - // Deja = 1493 TTFunits - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(1493), dejavuTTFFile.getCapHeight()); - // DroidSansMono doesn't have a PCLT table either - // height of "H" = 1462 - assertEquals(droidmonoTTFFile.convertTTFUnit2PDFUnit(1462), - droidmonoTTFFile.getCapHeight()); - } - - /** - * Test getCharSetName() - check that it returns "WinAnsiEncoding". - */ - @Test - public void testGetCharSetName() { - assertTrue("WinAnsiEncoding".equals(dejavuTTFFile.getCharSetName())); - assertTrue("WinAnsiEncoding".equals(droidmonoTTFFile.getCharSetName())); - } - - /** - * Test getCharWidth() - Test values retrieved from the metrics in the glyf table in - * the font file. - */ - @Test - public void testGetCharWidth() { - // Arbitrarily test a few values: - // The width of "H" (Unicode index 0x0048) is 1786 - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(1786), dejavuTTFFile.getCharWidth(0x48)); - // The width of "i" (unicode index 0x0069) is 655 TTFunits - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(655), dejavuTTFFile.getCharWidth(0x69)); - // final check, "!" (unicode index 0x0021) is 823 TTFunits - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(823), dejavuTTFFile.getCharWidth(0x21)); - - // All the glyphs should be the same width in DroidSansMono (mono-spaced) - int charWidth = droidmonoTTFFile.convertTTFUnit2PDFUnit(1229); - for (int i = 0; i < 255; i++) { - assertEquals(charWidth, droidmonoTTFFile.getCharWidth(i)); - } - } - - /** - * TODO: add implementation to this test - */ - public void testGetCMaps() { - } - - /** - * Test getFamilyNames() - Test value retrieved from the name table in the font file. - */ - @Test - public void testGetFamilyNames() { - assertEquals(1, dejavuTTFFile.getFamilyNames().size()); - for (String name : dejavuTTFFile.getFamilyNames()) { - assertEquals("DejaVu LGC Serif", name); - } - assertEquals(1, droidmonoTTFFile.getFamilyNames().size()); - for (String name : droidmonoTTFFile.getFamilyNames()) { - assertEquals("Droid Sans Mono", name); - } - } - - /** - * Test getFirstChar() - TODO: implement a more intelligent test here. - */ - @Test - public void testGetFirstChar() { - // Not really sure how to test this intelligently - assertEquals(0, dejavuTTFFile.getFirstChar()); - assertEquals(0, droidmonoTTFFile.getFirstChar()); - } - - /** - * Test getFlags() - Test values retrieved from the POST table in the font file. - */ - @Test - public void testGetFlags() { - /* DejaVu flags are: - * italic angle = 0 - * fixed pitch = 0 - * has serifs = true (default value; this font doesn't have a PCLT table) - */ - int flags = dejavuTTFFile.getFlags(); - assertEquals(0, flags & 64); // Italics angle = 0 - assertEquals(32, flags & 32); // Adobe standard charset - assertEquals(0, flags & 2); // fixed pitch = 0 - assertEquals(1, flags & 1); // has serifs = 1 (true) - /* - * Droid flags are: - * italic angle = 0 - * fixed pitch = 1 - * has serifs = true (default value; this font doesn't have a PCLT table) - */ - flags = droidmonoTTFFile.getFlags(); - assertEquals(0, flags & 64); - assertEquals(32, flags & 32); - assertEquals(2, flags & 2); - assertEquals(1, flags & 1); - } - - /** - * Test getFontBBox() - Test values retrieved from values in the HEAD table in the font file. - */ - @Test - public void testGetFontBBox() { - int[] bBox = dejavuTTFFile.getFontBBox(); - /* - * The head table has the following values(DejaVu): - * xmin = -1576, ymin = -710, xmax = 3439, ymax = 2544 - */ - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(-1576), bBox[0]); - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(-710), bBox[1]); - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(3439), bBox[2]); - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(2544), bBox[3]); - /* - * The head table has the following values (DroidSansMono): - * xmin = -312, ymin= -555, xmax = 1315, ymax = 2163 - */ - bBox = droidmonoTTFFile.getFontBBox(); - assertEquals(droidmonoTTFFile.convertTTFUnit2PDFUnit(-312), bBox[0]); - assertEquals(droidmonoTTFFile.convertTTFUnit2PDFUnit(-555), bBox[1]); - assertEquals(droidmonoTTFFile.convertTTFUnit2PDFUnit(1315), bBox[2]); - assertEquals(droidmonoTTFFile.convertTTFUnit2PDFUnit(2163), bBox[3]); - } - - /** - * Test getFullName() - Test value retrieved from the name table in the font file. - */ - @Test - public void testGetFullName() { - assertEquals("DejaVu LGC Serif", dejavuTTFFile.getFullName()); - assertEquals("Droid Sans Mono", droidmonoTTFFile.getFullName()); - } - - /** - * Test getGlyphName - Test value retrieved from the POST table in the font file. - */ - @Test - public void testGetGlyphName() { - assertEquals("H", dejavuTTFFile.getGlyphName(43)); - assertEquals("H", droidmonoTTFFile.getGlyphName(43)); - } - - /** - * Test getItalicAngle() - Test value retrieved from the POST table in the font file. - */ - @Test - public void testGetItalicAngle() { - assertEquals("0", dejavuTTFFile.getItalicAngle()); - assertEquals("0", droidmonoTTFFile.getItalicAngle()); - } - - /** - * Test getKerning() - Test values retrieved from the kern table in the font file. - */ - @Test - public void testGetKerning() { - Map<Integer, Map<Integer, Integer>> kerning = dejavuTTFFile.getKerning(); - if (kerning.isEmpty()) { - fail(); - } - Integer k1 = kerning.get(Integer.valueOf('A')).get(Integer.valueOf('T')); - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(-112), k1.intValue()); - Integer k2 = kerning.get(Integer.valueOf('K')).get(Integer.valueOf('u')); - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(-45), k2.intValue()); - - // DroidSansMono has no kerning data (mono-spaced) - kerning = droidmonoTTFFile.getKerning(); - if (!kerning.isEmpty()) { - fail("DroidSansMono shouldn't have any kerning data"); - } - } - - /** - * Test lastChar() - TODO: implement a more intelligent test - */ - @Test - public void testLastChar() { - assertEquals(0xff, dejavuTTFFile.getLastChar()); - assertEquals(0xff, droidmonoTTFFile.getLastChar()); - } - - /** - * Test getLowerCaseAscent() - There are several paths to test: - * 1) The values in the HHEA table (see code) - * 2) Fall back to values from the OS/2 table - * Test values retrieved from the font file. - */ - @Test - public void testGetLowerCaseAscent() { - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(1556), - dejavuTTFFile.getLowerCaseAscent()); - // Curiously the same value - assertEquals(droidmonoTTFFile.convertTTFUnit2PDFUnit(1556), - droidmonoTTFFile.getLowerCaseAscent()); - } - - /** - * Test getPostScriptName() - Test values retrieved from the post table in the font file. - */ - @Test - public void testGetPostScriptName() { - assertEquals(PostScriptVersion.V2, dejavuTTFFile.getPostScriptVersion()); - assertEquals(PostScriptVersion.V2, droidmonoTTFFile.getPostScriptVersion()); - } - - /** - * Test getStemV() - Undefined. - */ - @Test - public void testGetStemV() { - // Undefined - assertEquals("0", dejavuTTFFile.getStemV()); - assertEquals("0", droidmonoTTFFile.getStemV()); - } - - /** - * Test getSubFamilyName() - Test values retrieved from the name table in the font file. - */ - @Test - public void testGetSubFamilyName() { - assertEquals("Book", dejavuTTFFile.getSubFamilyName()); - assertEquals("Regular", droidmonoTTFFile.getSubFamilyName()); - } - - /** - * Test getTTCnames() - TODO: add implementation with TTC font. - */ - public void testGetTTCnames() { - // Can't test with with DejaVu since it's not a TrueType Collection - } - - /** - * Test getWeightClass() - Test value retrieved from the OS/2 table in the font file. - */ - @Test - public void testGetWeightClass() { - // Retrieved from OS/2 table - assertEquals(400, dejavuTTFFile.getWeightClass()); - assertEquals(400, droidmonoTTFFile.getWeightClass()); - } - - /** - * Test getWidths() - Test values retrieved from the hmtx table in the font file. - */ - @Test - public void testGetWidths() { - int[] widths = dejavuTTFFile.getWidths(); - // using the width of 'A' index = 36 - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(1479), widths[36]); - // using the width of '|' index = 95 - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(690), widths[95]); - widths = droidmonoTTFFile.getWidths(); - // DroidSansMono should have all widths the same size (mono-spaced) - int width = droidmonoTTFFile.convertTTFUnit2PDFUnit(1229); - for (int i = 0; i < 255; i++) { - assertEquals(width, widths[i]); - } - } - - /** - * Test getXHeight() - There are several paths to test: - * 1) The PCLT table (if available) - * 2) The yMax for the bounding box for 'x' in the glyf table. - * Fall back: - * 3) The xheight in the OS/2 table. - */ - @Test - public void testGetXHeight() { - // Since there's no PCLT table, the height of 'x' is used for both DejaVu and DroidSansMono - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(1064), dejavuTTFFile.getXHeight()); - assertEquals(droidmonoTTFFile.convertTTFUnit2PDFUnit(1098), droidmonoTTFFile.getXHeight()); - } - - /** - * Test isCFF() - TODO: add test for a CFF font. - */ - @Test - public void testIsCFF() { - // Neither DejaVu nor DroidSansMono are a compact format font - assertEquals(false, dejavuTTFFile.isCFF()); - assertEquals(false, droidmonoTTFFile.isCFF()); - } - - /** - * Test isEmbeddable() - Test value retrieved from the OS/2 table in the font file. - */ - @Test - public void testIsEmbeddable() { - // Dejavu and DroidSansMono are both embeddable - assertEquals(true, dejavuTTFFile.isEmbeddable()); - 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. - */ - public void testReadFont() { - // I'm pretty sure we've tested this with all the other tests - } -} diff --git a/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java b/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java deleted file mode 100644 index 899fe1d73..000000000 --- a/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.fonts.truetype; - -import java.io.File; -import java.io.IOException; -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; - -/** - * Test case for {@link OFFontLoader}. - */ -public class TTFFontLoaderTestCase { - - @Test - public void testUseKerning() throws IOException { - boolean useComplexScriptFeatures = false; - File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf"); - URI absoluteFilePath = file.toURI(); - InternalResourceResolver resourceResolver = ResourceResolverFactory.createDefaultInternalResourceResolver( - new File(".").toURI()); - String fontName = "Deja Vu"; - boolean embedded = false; - boolean useKerning = true; - - OFFontLoader fontLoader = new OFFontLoader(absoluteFilePath, fontName, embedded, - EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resourceResolver); - assertTrue(fontLoader.getFont().hasKerningInfo()); - useKerning = false; - - fontLoader = new OFFontLoader(absoluteFilePath, fontName, embedded, EmbeddingMode.AUTO, - EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resourceResolver); - assertFalse(fontLoader.getFont().hasKerningInfo()); - } -} diff --git a/test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTestCase.java b/test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTestCase.java deleted file mode 100644 index ef0dff5d5..000000000 --- a/test/java/org/apache/fop/fonts/truetype/TTFSubSetFileTestCase.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.fonts.truetype; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * This class tests TTFSubSetFile - * TODO: Test with more than just a single font - */ -public class TTFSubSetFileTestCase extends TTFFileTestCase { - private TTFSubSetFile ttfSubset; - private byte[] subset; - /** - * Constructor - * @throws IOException exception - */ - public TTFSubSetFileTestCase() throws IOException { - super(); - } - - /** - * setUp() - * @exception IOException file read error - */ - @Before - public void setUp() throws IOException { - ttfSubset = new TTFSubSetFile(); - Map<Integer, Integer> glyphs = new HashMap<Integer, Integer>(); - for (int i = 0; i < 255; i++) { - glyphs.put(i, i); - } - String header = OFFontLoader.readHeader(dejavuReader); - ttfSubset.readFont(dejavuReader, "DejaVu", header, glyphs); - subset = ttfSubset.getFontSubset(); - } - /** - * Test readFont(FontFileReader, String, Map) - Reads the font and tests the output by injecting - * it into a TTFFile object to check the validity of the file as a font. This currently doesn't - * create a cmap table, and so the font doesn't contain ALL of the mandatory tables. - * @throws IOException exception - */ - @Test - public void testReadFont3Args() throws IOException { - - ByteArrayInputStream byteArray = new ByteArrayInputStream(subset); - FontFileReader reader = new FontFileReader(byteArray); - String header = OFFontLoader.readHeader(reader); - dejavuTTFFile.readFont(reader, header); - // Test a couple arbitrary values - assertEquals(dejavuTTFFile.convertTTFUnit2PDFUnit(-1576), dejavuTTFFile.getFontBBox()[0]); - assertEquals(dejavuTTFFile.getFullName(), "DejaVu LGC Serif"); - } -} diff --git a/test/java/org/apache/fop/fonts/truetype/TTFTableNameTestCase.java b/test/java/org/apache/fop/fonts/truetype/TTFTableNameTestCase.java deleted file mode 100644 index ac5ab3ddc..000000000 --- a/test/java/org/apache/fop/fonts/truetype/TTFTableNameTestCase.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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.fonts.truetype; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * This class tests the enum org.apache.fop.fonts.truetype.TTFTableName - * - */ -public class TTFTableNameTestCase { - /** - * Test getName() - tests that the getName() method returns the expected String as expected in - * the Directory Table. - * @exception IllegalAccessException error - */ - @Test - public void testGetName() throws IllegalAccessException { - assertEquals("tableDirectory", OFTableName.TABLE_DIRECTORY.getName()); - assertEquals("EBDT", OFTableName.EBDT.getName()); - assertEquals("EBLC", OFTableName.EBLC.getName()); - assertEquals("EBSC", OFTableName.EBSC.getName()); - assertEquals("FFTM", OFTableName.FFTM.getName()); - assertEquals("GDEF", OFTableName.GDEF.getName()); - assertEquals("GPOS", OFTableName.GPOS.getName()); - assertEquals("GSUB", OFTableName.GSUB.getName()); - assertEquals("LTSH", OFTableName.LTSH.getName()); - assertEquals("OS/2", OFTableName.OS2.getName()); - assertEquals("PCLT", OFTableName.PCLT.getName()); - assertEquals("VDMX", OFTableName.VDMX.getName()); - assertEquals("cmap", OFTableName.CMAP.getName()); - assertEquals("cvt ", OFTableName.CVT.getName()); - assertEquals("fpgm", OFTableName.FPGM.getName()); - assertEquals("gasp", OFTableName.GASP.getName()); - assertEquals("glyf", OFTableName.GLYF.getName()); - assertEquals("hdmx", OFTableName.HDMX.getName()); - assertEquals("head", OFTableName.HEAD.getName()); - assertEquals("hhea", OFTableName.HHEA.getName()); - assertEquals("hmtx", OFTableName.HMTX.getName()); - assertEquals("kern", OFTableName.KERN.getName()); - assertEquals("loca", OFTableName.LOCA.getName()); - assertEquals("maxp", OFTableName.MAXP.getName()); - assertEquals("name", OFTableName.NAME.getName()); - assertEquals("post", OFTableName.POST.getName()); - assertEquals("prep", OFTableName.PREP.getName()); - assertEquals("vhea", OFTableName.VHEA.getName()); - assertEquals("vmtx", OFTableName.VMTX.getName()); - // make sure it works with other table names - OFTableName test = OFTableName.getValue("test"); - assertEquals("test", test.getName()); - } - - /** - * Test getValue(String) - tests that the getValue(String) method returns the expected - * TTFTableNames value when it is given a String (name of a table). - * @exception IllegalAccessException error - */ - @Test - public void testGetValue() throws IllegalAccessException { - assertEquals(OFTableName.EBDT, OFTableName.getValue("EBDT")); - assertEquals(OFTableName.EBLC, OFTableName.getValue("EBLC")); - assertEquals(OFTableName.EBSC, OFTableName.getValue("EBSC")); - assertEquals(OFTableName.FFTM, OFTableName.getValue("FFTM")); - assertEquals(OFTableName.LTSH, OFTableName.getValue("LTSH")); - assertEquals(OFTableName.OS2, OFTableName.getValue("OS/2")); - assertEquals(OFTableName.PCLT, OFTableName.getValue("PCLT")); - assertEquals(OFTableName.VDMX, OFTableName.getValue("VDMX")); - assertEquals(OFTableName.CMAP, OFTableName.getValue("cmap")); - assertEquals(OFTableName.CVT, OFTableName.getValue("cvt ")); - assertEquals(OFTableName.FPGM, OFTableName.getValue("fpgm")); - assertEquals(OFTableName.GASP, OFTableName.getValue("gasp")); - assertEquals(OFTableName.GLYF, OFTableName.getValue("glyf")); - assertEquals(OFTableName.HDMX, OFTableName.getValue("hdmx")); - assertEquals(OFTableName.HEAD, OFTableName.getValue("head")); - assertEquals(OFTableName.HHEA, OFTableName.getValue("hhea")); - assertEquals(OFTableName.HMTX, OFTableName.getValue("hmtx")); - assertEquals(OFTableName.KERN, OFTableName.getValue("kern")); - assertEquals(OFTableName.LOCA, OFTableName.getValue("loca")); - assertEquals(OFTableName.MAXP, OFTableName.getValue("maxp")); - assertEquals(OFTableName.NAME, OFTableName.getValue("name")); - assertEquals(OFTableName.POST, OFTableName.getValue("post")); - assertEquals(OFTableName.PREP, OFTableName.getValue("prep")); - assertEquals(OFTableName.VHEA, OFTableName.getValue("vhea")); - assertEquals(OFTableName.VMTX, OFTableName.getValue("vmtx")); - // Test that we can store a random table name and it will not fail or throw an error. - OFTableName test = OFTableName.getValue("random"); - assertTrue(test instanceof OFTableName); - } - - /** - * This class overrides hashCode() - we need to ensure it works properly by instantiating two - * objects and comparing their hash-codes. - * @exception IllegalAccessException error - */ - @Test - public void testHashCode() throws IllegalAccessException { - OFTableName a = OFTableName.getValue("testObject"); - OFTableName b = OFTableName.getValue("testObject"); - assertTrue(a.hashCode() == b.hashCode()); - OFTableName c = OFTableName.getValue("fail"); - assertFalse(a.hashCode() == c.hashCode()); - } - - /** - * This class overrides equals(object) - we need to test: - * 1) Reflexivity - * 2) Symmetry - * 3) Transitivity - * 4) Consistency - * 5) check it fails if you put in a null value - * @throws IllegalAccessException error - */ - @Test - public void testEquals() throws IllegalAccessException { - // Reflexivity - OFTableName a = OFTableName.getValue("test"); - assertTrue(a.equals(a)); - // Symmetry - OFTableName b = OFTableName.getValue("test"); - assertTrue(a.equals(b)); - assertTrue(b.equals(a)); - // Transitivity (tested with symmetry) - // Consistency (test that a == b is true and that a == c fails) - OFTableName c = OFTableName.getValue("fail"); - for (int i = 0; i < 100; i++) { - assertTrue(a.equals(b)); - assertFalse(a.equals(c)); - } - // check with null value - assertFalse(a.equals(null)); - } -} diff --git a/test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java b/test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java deleted file mode 100644 index 31a613567..000000000 --- a/test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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.fonts.type1; - -import java.awt.Rectangle; -import java.io.IOException; -import java.io.InputStream; -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}. - */ -public class AFMParserTestCase { - - private AFMParser sut = new AFMParser(); - - /** - * We're testing with two identical files except one has: - * EncodingScheme AdobeStandardEncoding - * the other has: - * EncodingScheme ExpectedEncoding - * Both files have the correct character metrics data, and we're checking that both are handled - * consistently with both encoding settings. - * - * @throws IOException if an I/O error occurs - */ - @Test - public void testMappingAgainstAdobeStandardEncoding() throws IOException { - InputStream expectedStream = getClass().getResourceAsStream( - "adobe-charset_unknown-encoding.afm"); - InputStream adobeStandardStream = getClass().getResourceAsStream( - "adobe-charset_adobe-encoding.afm"); - AFMFile expectedParser = sut.parse(expectedStream, null); - AFMFile adobeStandard = sut.parse(adobeStandardStream, null); - List<AFMCharMetrics> adobeMetrics = adobeStandard.getCharMetrics(); - checkCharMtrxList(true, expectedParser.getCharMetrics(), adobeMetrics); - - compareMetrics(adobeMetrics); - - nonAdobeCharsetUnknownEncoding(adobeMetrics); - - nonAdobeCharsetAdobeEncoding(adobeMetrics); - } - - private void compareMetrics(List<AFMCharMetrics> charMetrics) { - // in order to ensure that every character is parsed properly, we're going to check them - // against the AFM file (bboxes were created with a counter) - AdobeStandardEncoding[] standardEncoding = AdobeStandardEncoding.values(); - for (int i = 0; i < charMetrics.size(); i++) { - Rectangle expectedBbox = new Rectangle(i + 1, i + 1, 0, 0); - AFMCharMetrics thisMetric = charMetrics.get(i); - assertTrue(thisMetric.getBBox().equals(expectedBbox)); - assertEquals(thisMetric.getCharName(), standardEncoding[i].getAdobeName()); - } - } - - /** - * A non-adobe encoded file is tested, all the character codes are not AdobeStandardEncoding and - * the encoding is not AdobeStandardEncoding, we are checking a failure case here. Checking that - * the AdobeStandardEncoding isn't forced on other encodings. - * - * @param expected the AdobeStandardEncoding encoded character metrics list - * @throws IOException if an IO error occurs - */ - private void nonAdobeCharsetUnknownEncoding(List<AFMCharMetrics> expected) - throws IOException { - InputStream inStream = getClass().getResourceAsStream( - "notadobe-charset_unknown-encoding.afm"); - AFMFile afmFile = sut.parse(inStream, null); - List<AFMCharMetrics> unknownEncodingMetrics = afmFile.getCharMetrics(); - checkCharMtrxList(false, expected, unknownEncodingMetrics); - } - - /** - * This tests a poorly encoded file, it has AdobeStandardEncoding. We are checking that the - * metrics are correctly analysed against properly encoded char metrics. - * - * @param expected - * @throws IOException - */ - private void nonAdobeCharsetAdobeEncoding(List<AFMCharMetrics> expected) - throws IOException { - InputStream inStream = getClass().getResourceAsStream( - "notadobe-charset_adobe-encoding.afm"); - AFMFile afmFile = sut.parse(inStream, null); - List<AFMCharMetrics> correctedCharMetrics = afmFile.getCharMetrics(); - checkCharMtrxList(true, expected, correctedCharMetrics); - } - - private boolean charMetricsEqual(AFMCharMetrics o1, AFMCharMetrics o2) { - return o1.getCharCode() == o2.getCharCode() - && objectEquals(o1.getCharacter(), o2.getCharacter()) - && o1.getWidthX() == o2.getWidthX() - && o1.getWidthY() == o2.getWidthY() - && objectEquals(o1.getBBox(), o2.getBBox()); - } - - private void checkCharMtrxList(boolean expectedResult, List<AFMCharMetrics> expectedList, - List<AFMCharMetrics> actualList) { - assertEquals(expectedList.size(), actualList.size()); - for (int i = 0; i < expectedList.size(); i++) { - assertEquals(expectedResult, charMetricsEqual(expectedList.get(i), actualList.get(i))); - } - } - - 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/AdobeStandardEncoding.txt b/test/java/org/apache/fop/fonts/type1/AdobeStandardEncoding.txt deleted file mode 100644 index e39486a31..000000000 --- a/test/java/org/apache/fop/fonts/type1/AdobeStandardEncoding.txt +++ /dev/null @@ -1,213 +0,0 @@ -# -# Name: Adobe Standard Encoding to Unicode -# Unicode version: 2.0 -# Table version: 1.0 -# Date: 2011 July 12 -# -# Copyright (c) 1991-2011 Unicode, Inc. All Rights reserved. -# -# This file is provided as-is by Unicode, Inc. (The Unicode Consortium). No -# claims are made as to fitness for any particular purpose. No warranties of -# any kind are expressed or implied. The recipient agrees to determine -# applicability of information provided. If this file has been provided on -# magnetic media by Unicode, Inc., the sole remedy for any claim will be -# exchange of defective media within 90 days of receipt. -# -# Unicode, Inc. hereby grants the right to freely use the information -# supplied in this file in the creation of products supporting the -# Unicode Standard, and to make copies of this file in any form for -# internal or external distribution as long as this notice remains -# attached. -# -# Format: 4 tab-delimited fields: -# -# (1) The Unicode value (in hexadecimal) -# (2) The Adobe Standard Encoding code point (in hexadecimal) -# (3) # Unicode name -# (4) # PostScript character name -# -# General Notes: -# -# The Unicode values in this table were produced as the result of applying -# the algorithm described in the section "Populating a Unicode space" in the -# document "Unicode and Glyph Names," at -# http://partners.adobe.com/asn/developer/typeforum/unicodegn.html -# to the characters encoded in Adobe Standard Encoding. Note that some -# Standard Encoding characters, such as "space", are mapped to 2 Unicode -# values. Refer to the above document for more details. -# -# 2011 July 12: The above link is no longer valid. For comparable, -# more current information, see the document, "Glyph", at: -# <http://www.adobe.com/devnet/opentype/archives/glyph.html> -# -# Revision History: -# -# [v1.0, 2011 July 12] -# Updated terms of use to current wording. -# Updated contact information and document link. -# No changes to the mapping data. -# -# [v0.2, 30 March 1999] -# Different algorithm to produce Unicode values (see notes above) results in -# some character codes being mapped to 2 Unicode values. Updated Unicode -# names to Unicode 2.0 names. -# -# [v0.1, 5 May 1995] First release. -# -# Use the Unicode reporting form <http://www.unicode.org/reporting.html> -# for any questions or comments or to report errors in the data. -# -0020 20 # SPACE # space -00A0 20 # NO-BREAK SPACE # space -0021 21 # EXCLAMATION MARK # exclam -0022 22 # QUOTATION MARK # quotedbl -0023 23 # NUMBER SIGN # numbersign -0024 24 # DOLLAR SIGN # dollar -0025 25 # PERCENT SIGN # percent -0026 26 # AMPERSAND # ampersand -2019 27 # RIGHT SINGLE QUOTATION MARK # quoteright -0028 28 # LEFT PARENTHESIS # parenleft -0029 29 # RIGHT PARENTHESIS # parenright -002A 2A # ASTERISK # asterisk -002B 2B # PLUS SIGN # plus -002C 2C # COMMA # comma -002D 2D # HYPHEN-MINUS # hyphen -00AD 2D # SOFT HYPHEN # hyphen -002E 2E # FULL STOP # period -002F 2F # SOLIDUS # slash -0030 30 # DIGIT ZERO # zero -0031 31 # DIGIT ONE # one -0032 32 # DIGIT TWO # two -0033 33 # DIGIT THREE # three -0034 34 # DIGIT FOUR # four -0035 35 # DIGIT FIVE # five -0036 36 # DIGIT SIX # six -0037 37 # DIGIT SEVEN # seven -0038 38 # DIGIT EIGHT # eight -0039 39 # DIGIT NINE # nine -003A 3A # COLON # colon -003B 3B # SEMICOLON # semicolon -003C 3C # LESS-THAN SIGN # less -003D 3D # EQUALS SIGN # equal -003E 3E # GREATER-THAN SIGN # greater -003F 3F # QUESTION MARK # question -0040 40 # COMMERCIAL AT # at -0041 41 # LATIN CAPITAL LETTER A # A -0042 42 # LATIN CAPITAL LETTER B # B -0043 43 # LATIN CAPITAL LETTER C # C -0044 44 # LATIN CAPITAL LETTER D # D -0045 45 # LATIN CAPITAL LETTER E # E -0046 46 # LATIN CAPITAL LETTER F # F -0047 47 # LATIN CAPITAL LETTER G # G -0048 48 # LATIN CAPITAL LETTER H # H -0049 49 # LATIN CAPITAL LETTER I # I -004A 4A # LATIN CAPITAL LETTER J # J -004B 4B # LATIN CAPITAL LETTER K # K -004C 4C # LATIN CAPITAL LETTER L # L -004D 4D # LATIN CAPITAL LETTER M # M -004E 4E # LATIN CAPITAL LETTER N # N -004F 4F # LATIN CAPITAL LETTER O # O -0050 50 # LATIN CAPITAL LETTER P # P -0051 51 # LATIN CAPITAL LETTER Q # Q -0052 52 # LATIN CAPITAL LETTER R # R -0053 53 # LATIN CAPITAL LETTER S # S -0054 54 # LATIN CAPITAL LETTER T # T -0055 55 # LATIN CAPITAL LETTER U # U -0056 56 # LATIN CAPITAL LETTER V # V -0057 57 # LATIN CAPITAL LETTER W # W -0058 58 # LATIN CAPITAL LETTER X # X -0059 59 # LATIN CAPITAL LETTER Y # Y -005A 5A # LATIN CAPITAL LETTER Z # Z -005B 5B # LEFT SQUARE BRACKET # bracketleft -005C 5C # REVERSE SOLIDUS # backslash -005D 5D # RIGHT SQUARE BRACKET # bracketright -005E 5E # CIRCUMFLEX ACCENT # asciicircum -005F 5F # LOW LINE # underscore -2018 60 # LEFT SINGLE QUOTATION MARK # quoteleft -0061 61 # LATIN SMALL LETTER A # a -0062 62 # LATIN SMALL LETTER B # b -0063 63 # LATIN SMALL LETTER C # c -0064 64 # LATIN SMALL LETTER D # d -0065 65 # LATIN SMALL LETTER E # e -0066 66 # LATIN SMALL LETTER F # f -0067 67 # LATIN SMALL LETTER G # g -0068 68 # LATIN SMALL LETTER H # h -0069 69 # LATIN SMALL LETTER I # i -006A 6A # LATIN SMALL LETTER J # j -006B 6B # LATIN SMALL LETTER K # k -006C 6C # LATIN SMALL LETTER L # l -006D 6D # LATIN SMALL LETTER M # m -006E 6E # LATIN SMALL LETTER N # n -006F 6F # LATIN SMALL LETTER O # o -0070 70 # LATIN SMALL LETTER P # p -0071 71 # LATIN SMALL LETTER Q # q -0072 72 # LATIN SMALL LETTER R # r -0073 73 # LATIN SMALL LETTER S # s -0074 74 # LATIN SMALL LETTER T # t -0075 75 # LATIN SMALL LETTER U # u -0076 76 # LATIN SMALL LETTER V # v -0077 77 # LATIN SMALL LETTER W # w -0078 78 # LATIN SMALL LETTER X # x -0079 79 # LATIN SMALL LETTER Y # y -007A 7A # LATIN SMALL LETTER Z # z -007B 7B # LEFT CURLY BRACKET # braceleft -007C 7C # VERTICAL LINE # bar -007D 7D # RIGHT CURLY BRACKET # braceright -007E 7E # TILDE # asciitilde -00A1 A1 # INVERTED EXCLAMATION MARK # exclamdown -00A2 A2 # CENT SIGN # cent -00A3 A3 # POUND SIGN # sterling -2044 A4 # FRACTION SLASH # fraction -2215 A4 # DIVISION SLASH # fraction -00A5 A5 # YEN SIGN # yen -0192 A6 # LATIN SMALL LETTER F WITH HOOK # florin -00A7 A7 # SECTION SIGN # section -00A4 A8 # CURRENCY SIGN # currency -0027 A9 # APOSTROPHE # quotesingle -201C AA # LEFT DOUBLE QUOTATION MARK # quotedblleft -00AB AB # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK # guillemotleft -2039 AC # SINGLE LEFT-POINTING ANGLE QUOTATION MARK # guilsinglleft -203A AD # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK # guilsinglright -FB01 AE # LATIN SMALL LIGATURE FI # fi -FB02 AF # LATIN SMALL LIGATURE FL # fl -2013 B1 # EN DASH # endash -2020 B2 # DAGGER # dagger -2021 B3 # DOUBLE DAGGER # daggerdbl -00B7 B4 # MIDDLE DOT # periodcentered -2219 B4 # BULLET OPERATOR # periodcentered -00B6 B6 # PILCROW SIGN # paragraph -2022 B7 # BULLET # bullet -201A B8 # SINGLE LOW-9 QUOTATION MARK # quotesinglbase -201E B9 # DOUBLE LOW-9 QUOTATION MARK # quotedblbase -201D BA # RIGHT DOUBLE QUOTATION MARK # quotedblright -00BB BB # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK # guillemotright -2026 BC # HORIZONTAL ELLIPSIS # ellipsis -2030 BD # PER MILLE SIGN # perthousand -00BF BF # INVERTED QUESTION MARK # questiondown -0060 C1 # GRAVE ACCENT # grave -00B4 C2 # ACUTE ACCENT # acute -02C6 C3 # MODIFIER LETTER CIRCUMFLEX ACCENT # circumflex -02DC C4 # SMALL TILDE # tilde -00AF C5 # MACRON # macron -02C9 C5 # MODIFIER LETTER MACRON # macron -02D8 C6 # BREVE # breve -02D9 C7 # DOT ABOVE # dotaccent -00A8 C8 # DIAERESIS # dieresis -02DA CA # RING ABOVE # ring -00B8 CB # CEDILLA # cedilla -02DD CD # DOUBLE ACUTE ACCENT # hungarumlaut -02DB CE # OGONEK # ogonek -02C7 CF # CARON # caron -2014 D0 # EM DASH # emdash -00C6 E1 # LATIN CAPITAL LETTER AE # AE -00AA E3 # FEMININE ORDINAL INDICATOR # ordfeminine -0141 E8 # LATIN CAPITAL LETTER L WITH STROKE # Lslash -00D8 E9 # LATIN CAPITAL LETTER O WITH STROKE # Oslash -0152 EA # LATIN CAPITAL LIGATURE OE # OE -00BA EB # MASCULINE ORDINAL INDICATOR # ordmasculine -00E6 F1 # LATIN SMALL LETTER AE # ae -0131 F5 # LATIN SMALL LETTER DOTLESS I # dotlessi -0142 F8 # LATIN SMALL LETTER L WITH STROKE # lslash -00F8 F9 # LATIN SMALL LETTER O WITH STROKE # oslash -0153 FA # LATIN SMALL LIGATURE OE # oe -00DF FB # LATIN SMALL LETTER SHARP S # germandbls diff --git a/test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java b/test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java deleted file mode 100644 index a3a3e1c40..000000000 --- a/test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.fonts.type1; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -import org.junit.BeforeClass; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Test case for {@link AdobeStandardEncoding}. - */ -public class AdobeStandardEncodingTestCase { - - private static BufferedReader adobeStandardEncoding; - - /** - * Sets up the file reader, this file was retrieved from the url below. - * http://unicode.org/Public/MAPPINGS/VENDORS/ADOBE/stdenc.txt - * - * @throws FileNotFoundException if the file was not found - */ - @BeforeClass - public static void setupReader() throws FileNotFoundException { - InputStream inStream = AdobeStandardEncodingTestCase.class.getResourceAsStream( - "AdobeStandardEncoding.txt"); - adobeStandardEncoding = new BufferedReader(new InputStreamReader(inStream)); - } - - /** - * Probably the best way to test the encoding is by converting it back to format specified in - * the file, that way we can ensure data has been migrated properly. - * - * @throws IOException if an I/O error occurs - */ - @Test - public void testCorrectEncoding() throws IOException { - for (AdobeStandardEncoding encoding : AdobeStandardEncoding.values()) { - String expectedLine = getLine(); - String hexUnicode = toHexString(encoding.getUnicodeIndex(), 4); - String hexAdobe = toHexString(encoding.getAdobeCodePoint(), 2); - String actualLine = hexUnicode + "\t" - + hexAdobe + "\t# " - + encoding.getUnicodeName() + "\t# " - + encoding.getAdobeName(); - assertEquals(expectedLine, actualLine); - } - } - - private String getLine() throws IOException { - String line = "# The first few lines are comments, these should be ignored"; - while (line.startsWith("#")) { - line = adobeStandardEncoding.readLine(); - } - return line; - } - - private String toHexString(int number, int length) { - return String.format("%0" + length + "X", number); - } -} diff --git a/test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java b/test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java deleted file mode 100644 index c3e9334dd..000000000 --- a/test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.fonts.type1; - -import java.awt.Rectangle; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -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; - -/** - * Test case for {@link CharMetricsHandler}. - */ -public class CharMetricsHandlerTestCase { - - private static final String GOOD_LINE = "C 32 ; WX 32 ; N space ; B 1 1 1 1"; - - private static final AFMCharMetrics EXPECTED_CHM; - - static { - EXPECTED_CHM = new AFMCharMetrics(); - EXPECTED_CHM.setCharCode(32); - EXPECTED_CHM.setWidthX(32.0); - EXPECTED_CHM.setCharacter(new NamedCharacter("space")); - EXPECTED_CHM.setBBox(new Rectangle(1, 1, 0, 0)); - } - - @Test - public void testHandlers() throws IOException { - testEncodingWithMetricsLine("", GOOD_LINE); - testEncodingWithMetricsLine("WrongEncoding", GOOD_LINE); - testEncodingWithMetricsLine("AdobeStandardEncoding", GOOD_LINE); - } - - private void testEncodingWithMetricsLine(String encoding, String line) throws IOException { - Map<String, ValueHandler> valueParsers = mock(HashMap.class); - ValueHandler cHandler = mock(ValueHandler.class); - ValueHandler wxHandler = mock(ValueHandler.class); - ValueHandler nHandler = mock(ValueHandler.class); - ValueHandler bHandler = mock(ValueHandler.class); - when(valueParsers.get("C")).thenReturn(cHandler); - when(valueParsers.get("WX")).thenReturn(wxHandler); - when(valueParsers.get("N")).thenReturn(nHandler); - when(valueParsers.get("B")).thenReturn(bHandler); - - CharMetricsHandler handler = CharMetricsHandler.getHandler(valueParsers, encoding); - Stack<Object> stack = new Stack<Object>(); - handler.parse(line, stack, null); - - verify(valueParsers).get("C"); - verify(valueParsers).get("WX"); - verify(valueParsers).get("N"); - verify(valueParsers).get("B"); - verify(cHandler).parse("32", 0, new Stack<Object>()); - verify(wxHandler).parse("32", 0, new Stack<Object>()); - verify(nHandler).parse("space", 0, new Stack<Object>()); - verify(bHandler).parse("1 1 1 1", 0, new Stack<Object>()); - } -} diff --git a/test/java/org/apache/fop/fonts/type1/PostscriptParserTestCase.java b/test/java/org/apache/fop/fonts/type1/PostscriptParserTestCase.java deleted file mode 100644 index 8686dc048..000000000 --- a/test/java/org/apache/fop/fonts/type1/PostscriptParserTestCase.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.fonts.type1; - -import java.io.IOException; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.apache.fop.fonts.type1.PostscriptParser.PSDictionary; -import org.apache.fop.fonts.type1.PostscriptParser.PSElement; -import org.apache.fop.fonts.type1.PostscriptParser.PSFixedArray; -import org.apache.fop.fonts.type1.PostscriptParser.PSSubroutine; -import org.apache.fop.fonts.type1.PostscriptParser.PSVariable; -import org.apache.fop.fonts.type1.PostscriptParser.PSVariableArray; - -public class PostscriptParserTestCase { - private PostscriptParser parser; - private String eol = new String(new byte[] {13}); - private String postscriptElements = - "/myVariable 100 def" + eol - + "/-| {def} executeonly def" + eol - + "/myFixedArray 6 array" + eol - + "0 1 5 {1 index exch /.notdef put } for" + eol - + "dup 1 /a put" + eol - + "dup 2 /b put" + eol - + "dup 3 /c put" + eol - + "dup 4 /d put" + eol - + "readonly def" + eol - + "/myVariableArray [ { this } { is } { a } { test } ] no access def" + eol - + "/refVarSubr myValue -|"; - - @Before - public void setUp() { - parser = new PostscriptParser(); - } - - /** - * Tests parsing an example Postscript document and verifying what - * has been read. - * @throws IOException - */ - @Test - public void testPostscriptParsing() throws IOException { - List<PSElement> elements = parser.parse(postscriptElements.getBytes()); - assertEquals(elements.size(), 5); - assertTrue(elements.get(0) instanceof PSVariable); - assertTrue(elements.get(2) instanceof PSFixedArray); - assertTrue(elements.get(3) instanceof PSVariableArray); - PSFixedArray fixedArray = (PSFixedArray)elements.get(2); - assertEquals(fixedArray.getEntries().size(), 4); - assertEquals(fixedArray.getEntries().get(2), "dup 2 /b put "); - PSVariableArray variableArray = (PSVariableArray)elements.get(3); - assertEquals(variableArray.getEntries().size(), 4); - /* Currently only variable arrays containing subroutines are supported, though - * this can be modified to support single values and also strip out unnecessary - * characters like the { } below. */ - assertEquals(variableArray.getEntries().get(0).trim(), "{ this }"); - } - - /** - * Tests that the correct element is returned given the operator and element ID provided - */ - @Test - public void testCreateElement() { - assertTrue(parser.createElement("/custDictionary", "dict", -1) instanceof PSDictionary); - assertEquals(parser.createElement("/Private", "dict", -1), null); - assertTrue(parser.createElement("/aFixedArray", "array", -1) instanceof PSFixedArray); - assertTrue(parser.createElement("/aVariableArray", "[", -1) instanceof PSVariableArray); - assertTrue(parser.createElement("/aSubroutine", "{", -1) instanceof PSSubroutine); - } -} diff --git a/test/java/org/apache/fop/fonts/type1/Type1SubsetFileTestCase.java b/test/java/org/apache/fop/fonts/type1/Type1SubsetFileTestCase.java deleted file mode 100644 index 3d7093bd3..000000000 --- a/test/java/org/apache/fop/fonts/type1/Type1SubsetFileTestCase.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * 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.fonts.type1; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Test; - -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.fonts.Glyphs; - -import org.apache.fop.fonts.SingleByteFont; -import org.apache.fop.fonts.type1.PostscriptParser.PSDictionary; -import org.apache.fop.fonts.type1.PostscriptParser.PSElement; -import org.apache.fop.fonts.type1.PostscriptParser.PSFixedArray; -import org.apache.fop.fonts.type1.Type1SubsetFile.BinaryCoder; -import org.apache.fop.fonts.type1.Type1SubsetFile.BytesNumber; - -public class Type1SubsetFileTestCase { - - private List<byte[]> decodedSections; - private static final String TEST_FONT_A = "./test/resources/fonts/type1/c0419bt_.pfb"; - - @Test - public void test() throws IOException { - InputStream in = new FileInputStream(TEST_FONT_A); - compareCharStringData(TEST_FONT_A, createFontASubset(in, TEST_FONT_A)); - } - - @Test - public void testStitchFont() throws IOException { - ByteArrayOutputStream baosHeader = new ByteArrayOutputStream(); - ByteArrayOutputStream baosMain = new ByteArrayOutputStream(); - ByteArrayOutputStream baosTrailer = new ByteArrayOutputStream(); - - //Header - for (int i = 0; i < 10; i++) { - baosHeader.write(123); - baosMain.write(123); - } - for (int i = 0; i < 10; i++) { - baosTrailer.write(0); - } - - Type1SubsetFile subset = new Type1SubsetFile(); - byte[] result = subset.stitchFont(baosHeader, baosMain, baosTrailer); - ByteArrayInputStream bais = new ByteArrayInputStream(result); - assertEquals(result.length, 50); - PFBParser parser = new PFBParser(); - parser.parsePFB(bais); - } - - @Test - public void testUpdateSectionSize() throws IOException { - Type1SubsetFile subset = new Type1SubsetFile(); - ByteArrayOutputStream baos = subset.updateSectionSize(456); - byte[] lowOrderSize = baos.toByteArray(); - assertEquals(lowOrderSize[0], -56); - assertEquals(lowOrderSize[1], 1); - } - - @Test - public void testVariableContents() { - Type1SubsetFile subset = new Type1SubsetFile(); - String result = subset.readVariableContents("/myvariable {some variable contents}"); - assertEquals(result, "some variable contents"); - result = subset.readVariableContents("/myvariable {hello {some more text {test} and some more}test}"); - //Should only reads one level deep - assertEquals(result, "hello test"); - } - - @Test - public void getOpPositionAndLength() { - Type1SubsetFile subset = new Type1SubsetFile(); - ArrayList<BytesNumber> ops = new ArrayList<BytesNumber>(); - ops.add(new BytesNumber(10, 1)); - ops.add(new BytesNumber(255, 2)); - ops.add(new BytesNumber(100, 1)); - ops.add(new BytesNumber(97, 1)); - ops.add(new BytesNumber(856, 2)); - assertEquals(subset.getOpPosition(4, ops), 4); - assertEquals(subset.getOperandsLength(ops), 7); - } - - @Test - public void testConcatArrays() { - byte[] arrayA = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}; - byte[] arrayB = {(byte)6, (byte)7, (byte)8, (byte)9, (byte)10}; - Type1SubsetFile subset = new Type1SubsetFile(); - byte[] concatArray = subset.concatArray(arrayA, arrayB); - assertEquals(concatArray.length, 10); - assertEquals(concatArray[5], 6); - assertEquals(concatArray[3], 4); - } - - @Test - public void testGetBinaryEntry() { - byte[] decoded = {(byte)34, (byte)23, (byte)78, (byte)55, (byte)12, - (byte)2, (byte)65, (byte)49, (byte)90, (byte)10}; - int[] section = {3, 7}; - Type1SubsetFile subset = new Type1SubsetFile(); - byte[] segment = subset.getBinaryEntry(section, decoded); - assertEquals(segment.length, 4); - assertEquals(segment[0], 55); - assertEquals(segment[3], 65); - } - - private void compareCharStringData(String font, byte[] subsetFont) - throws IOException { - decodedSections = new ArrayList<byte[]>(); - - //Reinitialise the input stream as reset only supports 1000 bytes. - InputStream in = new FileInputStream(font); - List<PSElement> origElements = parseElements(in); - List<PSElement> subsetElements = parseElements(new ByteArrayInputStream(subsetFont)); - - PSFixedArray origSubs = (PSFixedArray)findElement(origElements, "/Subrs"); - PSFixedArray subsetSubs = (PSFixedArray)findElement(subsetElements, "/Subrs"); - PSDictionary origCharStrings = (PSDictionary)findElement(origElements, "/CharStrings"); - PSDictionary subsetCharStrings = (PSDictionary)findElement(subsetElements, "/CharStrings"); - for (String element : subsetCharStrings.getEntries().keySet()) { - if (element.equals("/.notdef")) { - continue; - } - int[] origBinaryCharLocation = origCharStrings.getBinaryEntries().get(element); - int[] subsetBinaryCharLocation = subsetCharStrings.getBinaryEntries().get(element); - - int origLength = origBinaryCharLocation[1] - origBinaryCharLocation[0]; - int subsetLength = subsetBinaryCharLocation[1] - subsetBinaryCharLocation[0]; - byte[] origCharData = new byte[origLength]; - byte[] subsetCharData = new byte[subsetLength]; - System.arraycopy(decodedSections.get(0), origBinaryCharLocation[0], origCharData, 0, origLength); - System.arraycopy(decodedSections.get(1), subsetBinaryCharLocation[0], subsetCharData, 0, subsetLength); - origCharData = BinaryCoder.decodeBytes(origCharData, 4330, 4); - subsetCharData = BinaryCoder.decodeBytes(subsetCharData, 4330, 4); - byte[] origFullCharData = readFullCharString(decodedSections.get(0), origCharData, origSubs); - byte[] subsetFullCharData = readFullCharString(decodedSections.get(1), subsetCharData, subsetSubs); - assertArrayEquals(origFullCharData, subsetFullCharData); - } - } - - private byte[] createFontASubset(InputStream in, String font) throws IOException { - SingleByteFont sbfont = mock(SingleByteFont.class); - //Glyph index & selector - Map<Integer, Integer> glyphs = new HashMap<Integer, Integer>(); - Map<Integer, String> usedCharNames = new HashMap<Integer, String>(); - int count = 0; - for (int i = 32; i < 127; i++) { - glyphs.put(i, count++); - when(sbfont.getUnicodeFromSelector(count)).thenReturn((char)i); - usedCharNames.put(i, String.format("/%s", Glyphs.charToGlyphName((char)i))); - when(sbfont.getGlyphName(i)).thenReturn(AdobeStandardEncoding.getCharFromCodePoint(i)); - } - for (int i = 161; i < 204; i++) { - glyphs.put(i, count++); - when(sbfont.getUnicodeFromSelector(count)).thenReturn((char)i); - usedCharNames.put(i, String.format("/%s", Glyphs.charToGlyphName((char)i))); - when(sbfont.getGlyphName(i)).thenReturn(AdobeStandardEncoding.getCharFromCodePoint(i)); - } - int[] randomGlyphs = {205, 206, 207, 208, 225, 227, 232, 233, 234, 235, 241, 245, - 248, 249, 250, 251 - }; - for (int i = 0; i < randomGlyphs.length; i++) { - glyphs.put(randomGlyphs[i], count++); - when(sbfont.getUnicodeFromSelector(count)).thenReturn((char)randomGlyphs[i]); - usedCharNames.put(i, String.format("/%s", Glyphs.charToGlyphName((char)i))); - when(sbfont.getGlyphName(i)).thenReturn(AdobeStandardEncoding.getCharFromCodePoint(i)); - } - for (int i = 256; i < 335; i++) { - glyphs.put(i, count++); - when(sbfont.getUnicodeFromSelector(count)).thenReturn((char)i); - usedCharNames.put(i, String.format("/%s", Glyphs.charToGlyphName((char)i))); - when(sbfont.getGlyphName(i)).thenReturn(AdobeStandardEncoding.getCharFromCodePoint(i)); - } - when(sbfont.getUsedGlyphNames()).thenReturn(usedCharNames); - when(sbfont.getUsedGlyphs()).thenReturn(glyphs); - when(sbfont.getEmbedFileURI()).thenReturn(URI.create(font)); - Type1SubsetFile subset = new Type1SubsetFile(); - return subset.createSubset(in, sbfont); - } - - private List<PSElement> parseElements(InputStream in) - throws IOException { - PFBParser pfbParser = new PFBParser(); - PFBData origData = pfbParser.parsePFB(in); - PostscriptParser parser = new PostscriptParser(); - byte[] decoded = BinaryCoder.decodeBytes(origData.getEncryptedSegment(), 55665, 4); - decodedSections.add(decoded); - return parser.parse(decoded); - } - - private PSElement findElement(List<PSElement> elements, String operator) { - for (PSElement element : elements) { - if (element.getOperator().equals(operator)) { - return element; - } - } - return null; - } - - private byte[] readFullCharString(byte[] decoded, byte[] data, PSFixedArray subroutines) { - List<BytesNumber> operands = new ArrayList<BytesNumber>(); - for (int i = 0; i < data.length; i++) { - int cur = data[i] & 0xFF; - if (cur >= 0 && cur <= 31) { - //Found subroutine. Read subroutine, recursively scan and update references - if (cur == 10) { - if (operands.size() == 0) { - continue; - } - int[] subrData = subroutines.getBinaryEntryByIndex(operands.get(0).getNumber()); - byte[] subroutine = getBinaryEntry(subrData, decoded); - subroutine = BinaryCoder.decodeBytes(subroutine, 4330, 4); - subroutine = readFullCharString(decoded, subroutine, subroutines); - data = replaceReference(data, subroutine, i - 1 + operands.get(0).getNumBytes(), i); - } else { - int next = -1; - if (cur == 12) { - next = data[++i] & 0xFF; - } - BytesNumber operand = new BytesNumber(cur, i); - operand.setName(getName(cur, next)); - } - operands.clear(); - } - if (cur >= 32 && cur <= 246) { - operands.add(new BytesNumber(cur - 139, 1)); - } else if (cur >= 247 && cur <= 250) { - operands.add(new BytesNumber((cur - 247) * 256 + (data[i + 1] & 0xFF) + 108, 2)); - i++; - } else if (cur >= 251 && cur <= 254) { - operands.add(new BytesNumber(-(cur - 251) * 256 - (data[i + 1] & 0xFF) - 108, 2)); - i++; - } else if (cur == 255) { - int b1 = data[i + 1] & 0xFF; - int b2 = data[i + 2] & 0xFF; - int b3 = data[i + 3] & 0xFF; - int b4 = data[i + 4] & 0xFF; - int value = b1 << 24 | b2 << 16 | b3 << 8 | b4; - operands.add(new BytesNumber(value, 5)); - i += 4; - } - } - return data; - } - - private String getName(int operator, int next) { - switch (operator) { - case 14: return "endchar"; - case 13: return "hsbw"; - case 12: - switch (next) { - case 0: return "dotsection"; - case 1: return "vstem3"; - case 2: return "hstem3"; - case 6: return "seac"; - case 7: return "sbw"; - case 16: return "callothersubr"; - case 17: return "pop"; - case 33: return "setcurrentpoint"; - default: return "unknown"; - } - case 9: return "closepath"; - case 6: return "hlineto"; - case 22: return "hmoveto"; - case 31: return "hvcurveto"; - case 5: return "rlineto"; - case 21: return "rmoveto"; - case 8: return "rrcurveto"; - case 30: return "vhcurveto"; - case 7: return "vlineto"; - case 4: return "vmoveto"; - case 1: return "hstem"; - case 3: return "vstem"; - case 10: return "callsubr"; - case 11: return "return"; - default: return "unknown"; - } - } - - private byte[] replaceReference(byte[] data, byte[] subroutine, int startRef, int endRef) { - byte[] preBytes = new byte[startRef - 1]; - System.arraycopy(data, 0, preBytes, 0, startRef - 1); - byte[] postBytes = new byte[data.length - endRef - 1]; - System.arraycopy(data, endRef + 1, postBytes, 0, data.length - endRef - 1); - data = concatArray(preBytes, subroutine, 1); - data = concatArray(data, postBytes, 0); - return data; - } - - private byte[] getBinaryEntry(int[] position, byte[] decoded) { - int start = position[0]; - int finish = position[1]; - byte[] line = new byte[finish - start]; - System.arraycopy(decoded, start, line, 0, finish - start); - return line; - } - - private byte[] concatArray(byte[] a, byte[] b, int subtract) { - int aLen = a.length; - int bLen = b.length - subtract; - byte[] c = new byte[aLen + bLen]; - System.arraycopy(a, 0, c, 0, aLen); - System.arraycopy(b, 0, c, aLen, bLen); - return c; - } -} diff --git a/test/java/org/apache/fop/fonts/type1/adobe-charset_adobe-encoding.afm b/test/java/org/apache/fop/fonts/type1/adobe-charset_adobe-encoding.afm deleted file mode 100644 index 50f8c3381..000000000 --- a/test/java/org/apache/fop/fonts/type1/adobe-charset_adobe-encoding.afm +++ /dev/null @@ -1,158 +0,0 @@ -StartFontMetrics 2.0 -EncodingScheme AdobeStandardEncoding -StartCharMetrics 154 -C 32 ; WX 32 ; N space ; B 1 1 1 1 -C 32 ; WX 32 ; N space ; B 2 2 2 2 -C 33 ; WX 33 ; N exclam ; B 3 3 3 3 -C 34 ; WX 34 ; N quotedbl ; B 4 4 4 4 -C 35 ; WX 35 ; N numbersign ; B 5 5 5 5 -C 36 ; WX 36 ; N dollar ; B 6 6 6 6 -C 37 ; WX 37 ; N percent ; B 7 7 7 7 -C 38 ; WX 38 ; N ampersand ; B 8 8 8 8 -C 39 ; WX 39 ; N quoteright ; B 9 9 9 9 -C 40 ; WX 40 ; N parenleft ; B 10 10 10 10 -C 41 ; WX 41 ; N parenright ; B 11 11 11 11 -C 42 ; WX 42 ; N asterisk ; B 12 12 12 12 -C 43 ; WX 43 ; N plus ; B 13 13 13 13 -C 44 ; WX 44 ; N comma ; B 14 14 14 14 -C 45 ; WX 45 ; N hyphen ; B 15 15 15 15 -C 45 ; WX 45 ; N hyphen ; B 16 16 16 16 -C 46 ; WX 46 ; N period ; B 17 17 17 17 -C 47 ; WX 47 ; N slash ; B 18 18 18 18 -C 48 ; WX 48 ; N zero ; B 19 19 19 19 -C 49 ; WX 49 ; N one ; B 20 20 20 20 -C 50 ; WX 50 ; N two ; B 21 21 21 21 -C 51 ; WX 51 ; N three ; B 22 22 22 22 -C 52 ; WX 52 ; N four ; B 23 23 23 23 -C 53 ; WX 53 ; N five ; B 24 24 24 24 -C 54 ; WX 54 ; N six ; B 25 25 25 25 -C 55 ; WX 55 ; N seven ; B 26 26 26 26 -C 56 ; WX 56 ; N eight ; B 27 27 27 27 -C 57 ; WX 57 ; N nine ; B 28 28 28 28 -C 58 ; WX 58 ; N colon ; B 29 29 29 29 -C 59 ; WX 59 ; N semicolon ; B 30 30 30 30 -C 60 ; WX 60 ; N less ; B 31 31 31 31 -C 61 ; WX 61 ; N equal ; B 32 32 32 32 -C 62 ; WX 62 ; N greater ; B 33 33 33 33 -C 63 ; WX 63 ; N question ; B 34 34 34 34 -C 64 ; WX 64 ; N at ; B 35 35 35 35 -C 65 ; WX 65 ; N A ; B 36 36 36 36 -C 66 ; WX 66 ; N B ; B 37 37 37 37 -C 67 ; WX 67 ; N C ; B 38 38 38 38 -C 68 ; WX 68 ; N D ; B 39 39 39 39 -C 69 ; WX 69 ; N E ; B 40 40 40 40 -C 70 ; WX 70 ; N F ; B 41 41 41 41 -C 71 ; WX 71 ; N G ; B 42 42 42 42 -C 72 ; WX 72 ; N H ; B 43 43 43 43 -C 73 ; WX 73 ; N I ; B 44 44 44 44 -C 74 ; WX 74 ; N J ; B 45 45 45 45 -C 75 ; WX 75 ; N K ; B 46 46 46 46 -C 76 ; WX 76 ; N L ; B 47 47 47 47 -C 77 ; WX 77 ; N M ; B 48 48 48 48 -C 78 ; WX 78 ; N N ; B 49 49 49 49 -C 79 ; WX 79 ; N O ; B 50 50 50 50 -C 80 ; WX 80 ; N P ; B 51 51 51 51 -C 81 ; WX 81 ; N Q ; B 52 52 52 52 -C 82 ; WX 82 ; N R ; B 53 53 53 53 -C 83 ; WX 83 ; N S ; B 54 54 54 54 -C 84 ; WX 84 ; N T ; B 55 55 55 55 -C 85 ; WX 85 ; N U ; B 56 56 56 56 -C 86 ; WX 86 ; N V ; B 57 57 57 57 -C 87 ; WX 87 ; N W ; B 58 58 58 58 -C 88 ; WX 88 ; N X ; B 59 59 59 59 -C 89 ; WX 89 ; N Y ; B 60 60 60 60 -C 90 ; WX 90 ; N Z ; B 61 61 61 61 -C 91 ; WX 91 ; N bracketleft ; B 62 62 62 62 -C 92 ; WX 92 ; N backslash ; B 63 63 63 63 -C 93 ; WX 93 ; N bracketright ; B 64 64 64 64 -C 94 ; WX 94 ; N asciicircum ; B 65 65 65 65 -C 95 ; WX 95 ; N underscore ; B 66 66 66 66 -C 96 ; WX 96 ; N quoteleft ; B 67 67 67 67 -C 97 ; WX 97 ; N a ; B 68 68 68 68 -C 98 ; WX 98 ; N b ; B 69 69 69 69 -C 99 ; WX 99 ; N c ; B 70 70 70 70 -C 100 ; WX 100 ; N d ; B 71 71 71 71 -C 101 ; WX 101 ; N e ; B 72 72 72 72 -C 102 ; WX 102 ; N f ; B 73 73 73 73 -C 103 ; WX 103 ; N g ; B 74 74 74 74 -C 104 ; WX 104 ; N h ; B 75 75 75 75 -C 105 ; WX 105 ; N i ; B 76 76 76 76 -C 106 ; WX 106 ; N j ; B 77 77 77 77 -C 107 ; WX 107 ; N k ; B 78 78 78 78 -C 108 ; WX 108 ; N l ; B 79 79 79 79 -C 109 ; WX 109 ; N m ; B 80 80 80 80 -C 110 ; WX 110 ; N n ; B 81 81 81 81 -C 111 ; WX 111 ; N o ; B 82 82 82 82 -C 112 ; WX 112 ; N p ; B 83 83 83 83 -C 113 ; WX 113 ; N q ; B 84 84 84 84 -C 114 ; WX 114 ; N r ; B 85 85 85 85 -C 115 ; WX 115 ; N s ; B 86 86 86 86 -C 116 ; WX 116 ; N t ; B 87 87 87 87 -C 117 ; WX 117 ; N u ; B 88 88 88 88 -C 118 ; WX 118 ; N v ; B 89 89 89 89 -C 119 ; WX 119 ; N w ; B 90 90 90 90 -C 120 ; WX 120 ; N x ; B 91 91 91 91 -C 121 ; WX 121 ; N y ; B 92 92 92 92 -C 122 ; WX 122 ; N z ; B 93 93 93 93 -C 123 ; WX 123 ; N braceleft ; B 94 94 94 94 -C 124 ; WX 124 ; N bar ; B 95 95 95 95 -C 125 ; WX 125 ; N braceright ; B 96 96 96 96 -C 126 ; WX 126 ; N asciitilde ; B 97 97 97 97 -C 161 ; WX 161 ; N exclamdown ; B 98 98 98 98 -C 162 ; WX 162 ; N cent ; B 99 99 99 99 -C 163 ; WX 163 ; N sterling ; B 100 100 100 100 -C 164 ; WX 164 ; N fraction ; B 101 101 101 101 -C 164 ; WX 164 ; N fraction ; B 102 102 102 102 -C 165 ; WX 165 ; N yen ; B 103 103 103 103 -C 166 ; WX 166 ; N florin ; B 104 104 104 104 -C 167 ; WX 167 ; N section ; B 105 105 105 105 -C 168 ; WX 168 ; N currency ; B 106 106 106 106 -C 169 ; WX 169 ; N quotesingle ; B 107 107 107 107 -C 170 ; WX 170 ; N quotedblleft ; B 108 108 108 108 -C 171 ; WX 171 ; N guillemotleft ; B 109 109 109 109 -C 172 ; WX 172 ; N guilsinglleft ; B 110 110 110 110 -C 173 ; WX 173 ; N guilsinglright ; B 111 111 111 111 -C 174 ; WX 174 ; N fi ; B 112 112 112 112 -C 175 ; WX 175 ; N fl ; B 113 113 113 113 -C 177 ; WX 177 ; N endash ; B 114 114 114 114 -C 178 ; WX 178 ; N dagger ; B 115 115 115 115 -C 179 ; WX 179 ; N daggerdbl ; B 116 116 116 116 -C 180 ; WX 180 ; N periodcentered ; B 117 117 117 117 -C 180 ; WX 180 ; N periodcentered ; B 118 118 118 118 -C 182 ; WX 182 ; N paragraph ; B 119 119 119 119 -C 183 ; WX 183 ; N bullet ; B 120 120 120 120 -C 184 ; WX 184 ; N quotesinglbase ; B 121 121 121 121 -C 185 ; WX 185 ; N quotedblbase ; B 122 122 122 122 -C 186 ; WX 186 ; N quotedblright ; B 123 123 123 123 -C 187 ; WX 187 ; N guillemotright ; B 124 124 124 124 -C 188 ; WX 188 ; N ellipsis ; B 125 125 125 125 -C 189 ; WX 189 ; N perthousand ; B 126 126 126 126 -C 191 ; WX 191 ; N questiondown ; B 127 127 127 127 -C 193 ; WX 193 ; N grave ; B 128 128 128 128 -C 194 ; WX 194 ; N acute ; B 129 129 129 129 -C 195 ; WX 195 ; N circumflex ; B 130 130 130 130 -C 196 ; WX 196 ; N tilde ; B 131 131 131 131 -C 197 ; WX 197 ; N macron ; B 132 132 132 132 -C 197 ; WX 197 ; N macron ; B 133 133 133 133 -C 198 ; WX 198 ; N breve ; B 134 134 134 134 -C 199 ; WX 199 ; N dotaccent ; B 135 135 135 135 -C 200 ; WX 200 ; N dieresis ; B 136 136 136 136 -C 202 ; WX 202 ; N ring ; B 137 137 137 137 -C 203 ; WX 203 ; N cedilla ; B 138 138 138 138 -C 205 ; WX 205 ; N hungarumlaut ; B 139 139 139 139 -C 206 ; WX 206 ; N ogonek ; B 140 140 140 140 -C 207 ; WX 207 ; N caron ; B 141 141 141 141 -C 208 ; WX 208 ; N emdash ; B 142 142 142 142 -C 225 ; WX 225 ; N AE ; B 143 143 143 143 -C 227 ; WX 227 ; N ordfeminine ; B 144 144 144 144 -C 232 ; WX 232 ; N Lslash ; B 145 145 145 145 -C 233 ; WX 233 ; N Oslash ; B 146 146 146 146 -C 234 ; WX 234 ; N OE ; B 147 147 147 147 -C 235 ; WX 235 ; N ordmasculine ; B 148 148 148 148 -C 241 ; WX 241 ; N ae ; B 149 149 149 149 -C 245 ; WX 245 ; N dotlessi ; B 150 150 150 150 -C 248 ; WX 248 ; N lslash ; B 151 151 151 151 -C 249 ; WX 249 ; N oslash ; B 152 152 152 152 -C 250 ; WX 250 ; N oe ; B 153 153 153 153 -C 251 ; WX 251 ; N germandbls ; B 154 154 154 154 -EndCharMetrics diff --git a/test/java/org/apache/fop/fonts/type1/adobe-charset_unknown-encoding.afm b/test/java/org/apache/fop/fonts/type1/adobe-charset_unknown-encoding.afm deleted file mode 100644 index 8edbe0d76..000000000 --- a/test/java/org/apache/fop/fonts/type1/adobe-charset_unknown-encoding.afm +++ /dev/null @@ -1,158 +0,0 @@ -StartFontMetrics 2.0 -EncodingScheme FontSpecific -StartCharMetrics 154 -C 32 ; WX 32 ; N space ; B 1 1 1 1 -C 32 ; WX 32 ; N space ; B 2 2 2 2 -C 33 ; WX 33 ; N exclam ; B 3 3 3 3 -C 34 ; WX 34 ; N quotedbl ; B 4 4 4 4 -C 35 ; WX 35 ; N numbersign ; B 5 5 5 5 -C 36 ; WX 36 ; N dollar ; B 6 6 6 6 -C 37 ; WX 37 ; N percent ; B 7 7 7 7 -C 38 ; WX 38 ; N ampersand ; B 8 8 8 8 -C 39 ; WX 39 ; N quoteright ; B 9 9 9 9 -C 40 ; WX 40 ; N parenleft ; B 10 10 10 10 -C 41 ; WX 41 ; N parenright ; B 11 11 11 11 -C 42 ; WX 42 ; N asterisk ; B 12 12 12 12 -C 43 ; WX 43 ; N plus ; B 13 13 13 13 -C 44 ; WX 44 ; N comma ; B 14 14 14 14 -C 45 ; WX 45 ; N hyphen ; B 15 15 15 15 -C 45 ; WX 45 ; N hyphen ; B 16 16 16 16 -C 46 ; WX 46 ; N period ; B 17 17 17 17 -C 47 ; WX 47 ; N slash ; B 18 18 18 18 -C 48 ; WX 48 ; N zero ; B 19 19 19 19 -C 49 ; WX 49 ; N one ; B 20 20 20 20 -C 50 ; WX 50 ; N two ; B 21 21 21 21 -C 51 ; WX 51 ; N three ; B 22 22 22 22 -C 52 ; WX 52 ; N four ; B 23 23 23 23 -C 53 ; WX 53 ; N five ; B 24 24 24 24 -C 54 ; WX 54 ; N six ; B 25 25 25 25 -C 55 ; WX 55 ; N seven ; B 26 26 26 26 -C 56 ; WX 56 ; N eight ; B 27 27 27 27 -C 57 ; WX 57 ; N nine ; B 28 28 28 28 -C 58 ; WX 58 ; N colon ; B 29 29 29 29 -C 59 ; WX 59 ; N semicolon ; B 30 30 30 30 -C 60 ; WX 60 ; N less ; B 31 31 31 31 -C 61 ; WX 61 ; N equal ; B 32 32 32 32 -C 62 ; WX 62 ; N greater ; B 33 33 33 33 -C 63 ; WX 63 ; N question ; B 34 34 34 34 -C 64 ; WX 64 ; N at ; B 35 35 35 35 -C 65 ; WX 65 ; N A ; B 36 36 36 36 -C 66 ; WX 66 ; N B ; B 37 37 37 37 -C 67 ; WX 67 ; N C ; B 38 38 38 38 -C 68 ; WX 68 ; N D ; B 39 39 39 39 -C 69 ; WX 69 ; N E ; B 40 40 40 40 -C 70 ; WX 70 ; N F ; B 41 41 41 41 -C 71 ; WX 71 ; N G ; B 42 42 42 42 -C 72 ; WX 72 ; N H ; B 43 43 43 43 -C 73 ; WX 73 ; N I ; B 44 44 44 44 -C 74 ; WX 74 ; N J ; B 45 45 45 45 -C 75 ; WX 75 ; N K ; B 46 46 46 46 -C 76 ; WX 76 ; N L ; B 47 47 47 47 -C 77 ; WX 77 ; N M ; B 48 48 48 48 -C 78 ; WX 78 ; N N ; B 49 49 49 49 -C 79 ; WX 79 ; N O ; B 50 50 50 50 -C 80 ; WX 80 ; N P ; B 51 51 51 51 -C 81 ; WX 81 ; N Q ; B 52 52 52 52 -C 82 ; WX 82 ; N R ; B 53 53 53 53 -C 83 ; WX 83 ; N S ; B 54 54 54 54 -C 84 ; WX 84 ; N T ; B 55 55 55 55 -C 85 ; WX 85 ; N U ; B 56 56 56 56 -C 86 ; WX 86 ; N V ; B 57 57 57 57 -C 87 ; WX 87 ; N W ; B 58 58 58 58 -C 88 ; WX 88 ; N X ; B 59 59 59 59 -C 89 ; WX 89 ; N Y ; B 60 60 60 60 -C 90 ; WX 90 ; N Z ; B 61 61 61 61 -C 91 ; WX 91 ; N bracketleft ; B 62 62 62 62 -C 92 ; WX 92 ; N backslash ; B 63 63 63 63 -C 93 ; WX 93 ; N bracketright ; B 64 64 64 64 -C 94 ; WX 94 ; N asciicircum ; B 65 65 65 65 -C 95 ; WX 95 ; N underscore ; B 66 66 66 66 -C 96 ; WX 96 ; N quoteleft ; B 67 67 67 67 -C 97 ; WX 97 ; N a ; B 68 68 68 68 -C 98 ; WX 98 ; N b ; B 69 69 69 69 -C 99 ; WX 99 ; N c ; B 70 70 70 70 -C 100 ; WX 100 ; N d ; B 71 71 71 71 -C 101 ; WX 101 ; N e ; B 72 72 72 72 -C 102 ; WX 102 ; N f ; B 73 73 73 73 -C 103 ; WX 103 ; N g ; B 74 74 74 74 -C 104 ; WX 104 ; N h ; B 75 75 75 75 -C 105 ; WX 105 ; N i ; B 76 76 76 76 -C 106 ; WX 106 ; N j ; B 77 77 77 77 -C 107 ; WX 107 ; N k ; B 78 78 78 78 -C 108 ; WX 108 ; N l ; B 79 79 79 79 -C 109 ; WX 109 ; N m ; B 80 80 80 80 -C 110 ; WX 110 ; N n ; B 81 81 81 81 -C 111 ; WX 111 ; N o ; B 82 82 82 82 -C 112 ; WX 112 ; N p ; B 83 83 83 83 -C 113 ; WX 113 ; N q ; B 84 84 84 84 -C 114 ; WX 114 ; N r ; B 85 85 85 85 -C 115 ; WX 115 ; N s ; B 86 86 86 86 -C 116 ; WX 116 ; N t ; B 87 87 87 87 -C 117 ; WX 117 ; N u ; B 88 88 88 88 -C 118 ; WX 118 ; N v ; B 89 89 89 89 -C 119 ; WX 119 ; N w ; B 90 90 90 90 -C 120 ; WX 120 ; N x ; B 91 91 91 91 -C 121 ; WX 121 ; N y ; B 92 92 92 92 -C 122 ; WX 122 ; N z ; B 93 93 93 93 -C 123 ; WX 123 ; N braceleft ; B 94 94 94 94 -C 124 ; WX 124 ; N bar ; B 95 95 95 95 -C 125 ; WX 125 ; N braceright ; B 96 96 96 96 -C 126 ; WX 126 ; N asciitilde ; B 97 97 97 97 -C 161 ; WX 161 ; N exclamdown ; B 98 98 98 98 -C 162 ; WX 162 ; N cent ; B 99 99 99 99 -C 163 ; WX 163 ; N sterling ; B 100 100 100 100 -C 164 ; WX 164 ; N fraction ; B 101 101 101 101 -C 164 ; WX 164 ; N fraction ; B 102 102 102 102 -C 165 ; WX 165 ; N yen ; B 103 103 103 103 -C 166 ; WX 166 ; N florin ; B 104 104 104 104 -C 167 ; WX 167 ; N section ; B 105 105 105 105 -C 168 ; WX 168 ; N currency ; B 106 106 106 106 -C 169 ; WX 169 ; N quotesingle ; B 107 107 107 107 -C 170 ; WX 170 ; N quotedblleft ; B 108 108 108 108 -C 171 ; WX 171 ; N guillemotleft ; B 109 109 109 109 -C 172 ; WX 172 ; N guilsinglleft ; B 110 110 110 110 -C 173 ; WX 173 ; N guilsinglright ; B 111 111 111 111 -C 174 ; WX 174 ; N fi ; B 112 112 112 112 -C 175 ; WX 175 ; N fl ; B 113 113 113 113 -C 177 ; WX 177 ; N endash ; B 114 114 114 114 -C 178 ; WX 178 ; N dagger ; B 115 115 115 115 -C 179 ; WX 179 ; N daggerdbl ; B 116 116 116 116 -C 180 ; WX 180 ; N periodcentered ; B 117 117 117 117 -C 180 ; WX 180 ; N periodcentered ; B 118 118 118 118 -C 182 ; WX 182 ; N paragraph ; B 119 119 119 119 -C 183 ; WX 183 ; N bullet ; B 120 120 120 120 -C 184 ; WX 184 ; N quotesinglbase ; B 121 121 121 121 -C 185 ; WX 185 ; N quotedblbase ; B 122 122 122 122 -C 186 ; WX 186 ; N quotedblright ; B 123 123 123 123 -C 187 ; WX 187 ; N guillemotright ; B 124 124 124 124 -C 188 ; WX 188 ; N ellipsis ; B 125 125 125 125 -C 189 ; WX 189 ; N perthousand ; B 126 126 126 126 -C 191 ; WX 191 ; N questiondown ; B 127 127 127 127 -C 193 ; WX 193 ; N grave ; B 128 128 128 128 -C 194 ; WX 194 ; N acute ; B 129 129 129 129 -C 195 ; WX 195 ; N circumflex ; B 130 130 130 130 -C 196 ; WX 196 ; N tilde ; B 131 131 131 131 -C 197 ; WX 197 ; N macron ; B 132 132 132 132 -C 197 ; WX 197 ; N macron ; B 133 133 133 133 -C 198 ; WX 198 ; N breve ; B 134 134 134 134 -C 199 ; WX 199 ; N dotaccent ; B 135 135 135 135 -C 200 ; WX 200 ; N dieresis ; B 136 136 136 136 -C 202 ; WX 202 ; N ring ; B 137 137 137 137 -C 203 ; WX 203 ; N cedilla ; B 138 138 138 138 -C 205 ; WX 205 ; N hungarumlaut ; B 139 139 139 139 -C 206 ; WX 206 ; N ogonek ; B 140 140 140 140 -C 207 ; WX 207 ; N caron ; B 141 141 141 141 -C 208 ; WX 208 ; N emdash ; B 142 142 142 142 -C 225 ; WX 225 ; N AE ; B 143 143 143 143 -C 227 ; WX 227 ; N ordfeminine ; B 144 144 144 144 -C 232 ; WX 232 ; N Lslash ; B 145 145 145 145 -C 233 ; WX 233 ; N Oslash ; B 146 146 146 146 -C 234 ; WX 234 ; N OE ; B 147 147 147 147 -C 235 ; WX 235 ; N ordmasculine ; B 148 148 148 148 -C 241 ; WX 241 ; N ae ; B 149 149 149 149 -C 245 ; WX 245 ; N dotlessi ; B 150 150 150 150 -C 248 ; WX 248 ; N lslash ; B 151 151 151 151 -C 249 ; WX 249 ; N oslash ; B 152 152 152 152 -C 250 ; WX 250 ; N oe ; B 153 153 153 153 -C 251 ; WX 251 ; N germandbls ; B 154 154 154 154 -EndCharMetrics diff --git a/test/java/org/apache/fop/fonts/type1/notadobe-charset_adobe-encoding.afm b/test/java/org/apache/fop/fonts/type1/notadobe-charset_adobe-encoding.afm deleted file mode 100644 index 11cecb17f..000000000 --- a/test/java/org/apache/fop/fonts/type1/notadobe-charset_adobe-encoding.afm +++ /dev/null @@ -1,158 +0,0 @@ -StartFontMetrics 2.0 -EncodingScheme AdobeStandardEncoding -StartCharMetrics 154 -C 33 ; WX 32 ; N space ; B 1 1 1 1 -C 33 ; WX 32 ; N space ; B 2 2 2 2 -C 34 ; WX 33 ; N exclam ; B 3 3 3 3 -C 35 ; WX 34 ; N quotedbl ; B 4 4 4 4 -C 36 ; WX 35 ; N numbersign ; B 5 5 5 5 -C 37 ; WX 36 ; N dollar ; B 6 6 6 6 -C 38 ; WX 37 ; N percent ; B 7 7 7 7 -C 39 ; WX 38 ; N ampersand ; B 8 8 8 8 -C 40 ; WX 39 ; N quoteright ; B 9 9 9 9 -C 41 ; WX 40 ; N parenleft ; B 10 10 10 10 -C 42 ; WX 41 ; N parenright ; B 11 11 11 11 -C 43 ; WX 42 ; N asterisk ; B 12 12 12 12 -C 44 ; WX 43 ; N plus ; B 13 13 13 13 -C 45 ; WX 44 ; N comma ; B 14 14 14 14 -C 46 ; WX 45 ; N hyphen ; B 15 15 15 15 -C 46 ; WX 45 ; N hyphen ; B 16 16 16 16 -C 47 ; WX 46 ; N period ; B 17 17 17 17 -C 48 ; WX 47 ; N slash ; B 18 18 18 18 -C 49 ; WX 48 ; N zero ; B 19 19 19 19 -C 50 ; WX 49 ; N one ; B 20 20 20 20 -C 51 ; WX 50 ; N two ; B 21 21 21 21 -C 52 ; WX 51 ; N three ; B 22 22 22 22 -C 53 ; WX 52 ; N four ; B 23 23 23 23 -C 54 ; WX 53 ; N five ; B 24 24 24 24 -C 55 ; WX 54 ; N six ; B 25 25 25 25 -C 56 ; WX 55 ; N seven ; B 26 26 26 26 -C 57 ; WX 56 ; N eight ; B 27 27 27 27 -C 58 ; WX 57 ; N nine ; B 28 28 28 28 -C 59 ; WX 58 ; N colon ; B 29 29 29 29 -C 60 ; WX 59 ; N semicolon ; B 30 30 30 30 -C 61 ; WX 60 ; N less ; B 31 31 31 31 -C 62 ; WX 61 ; N equal ; B 32 32 32 32 -C 63 ; WX 62 ; N greater ; B 33 33 33 33 -C 64 ; WX 63 ; N question ; B 34 34 34 34 -C 65 ; WX 64 ; N at ; B 35 35 35 35 -C 66 ; WX 65 ; N A ; B 36 36 36 36 -C 67 ; WX 66 ; N B ; B 37 37 37 37 -C 68 ; WX 67 ; N C ; B 38 38 38 38 -C 69 ; WX 68 ; N D ; B 39 39 39 39 -C 70 ; WX 69 ; N E ; B 40 40 40 40 -C 71 ; WX 70 ; N F ; B 41 41 41 41 -C 72 ; WX 71 ; N G ; B 42 42 42 42 -C 73 ; WX 72 ; N H ; B 43 43 43 43 -C 74 ; WX 73 ; N I ; B 44 44 44 44 -C 75 ; WX 74 ; N J ; B 45 45 45 45 -C 76 ; WX 75 ; N K ; B 46 46 46 46 -C 77 ; WX 76 ; N L ; B 47 47 47 47 -C 78 ; WX 77 ; N M ; B 48 48 48 48 -C 79 ; WX 78 ; N N ; B 49 49 49 49 -C 80 ; WX 79 ; N O ; B 50 50 50 50 -C 81 ; WX 80 ; N P ; B 51 51 51 51 -C 82 ; WX 81 ; N Q ; B 52 52 52 52 -C 83 ; WX 82 ; N R ; B 53 53 53 53 -C 84 ; WX 83 ; N S ; B 54 54 54 54 -C 85 ; WX 84 ; N T ; B 55 55 55 55 -C 86 ; WX 85 ; N U ; B 56 56 56 56 -C 87 ; WX 86 ; N V ; B 57 57 57 57 -C 88 ; WX 87 ; N W ; B 58 58 58 58 -C 89 ; WX 88 ; N X ; B 59 59 59 59 -C 90 ; WX 89 ; N Y ; B 60 60 60 60 -C 91 ; WX 90 ; N Z ; B 61 61 61 61 -C 92 ; WX 91 ; N bracketleft ; B 62 62 62 62 -C 93 ; WX 92 ; N backslash ; B 63 63 63 63 -C 94 ; WX 93 ; N bracketright ; B 64 64 64 64 -C 95 ; WX 94 ; N asciicircum ; B 65 65 65 65 -C 96 ; WX 95 ; N underscore ; B 66 66 66 66 -C 97 ; WX 96 ; N quoteleft ; B 67 67 67 67 -C 98 ; WX 97 ; N a ; B 68 68 68 68 -C 99 ; WX 98 ; N b ; B 69 69 69 69 -C 100 ; WX 99 ; N c ; B 70 70 70 70 -C 101 ; WX 100 ; N d ; B 71 71 71 71 -C 102 ; WX 101 ; N e ; B 72 72 72 72 -C 103 ; WX 102 ; N f ; B 73 73 73 73 -C 104 ; WX 103 ; N g ; B 74 74 74 74 -C 105 ; WX 104 ; N h ; B 75 75 75 75 -C 106 ; WX 105 ; N i ; B 76 76 76 76 -C 107 ; WX 106 ; N j ; B 77 77 77 77 -C 108 ; WX 107 ; N k ; B 78 78 78 78 -C 109 ; WX 108 ; N l ; B 79 79 79 79 -C 110 ; WX 109 ; N m ; B 80 80 80 80 -C 111 ; WX 110 ; N n ; B 81 81 81 81 -C 112 ; WX 111 ; N o ; B 82 82 82 82 -C 113 ; WX 112 ; N p ; B 83 83 83 83 -C 114 ; WX 113 ; N q ; B 84 84 84 84 -C 115 ; WX 114 ; N r ; B 85 85 85 85 -C 116 ; WX 115 ; N s ; B 86 86 86 86 -C 117 ; WX 116 ; N t ; B 87 87 87 87 -C 118 ; WX 117 ; N u ; B 88 88 88 88 -C 119 ; WX 118 ; N v ; B 89 89 89 89 -C 120 ; WX 119 ; N w ; B 90 90 90 90 -C 121 ; WX 120 ; N x ; B 91 91 91 91 -C 122 ; WX 121 ; N y ; B 92 92 92 92 -C 123 ; WX 122 ; N z ; B 93 93 93 93 -C 124 ; WX 123 ; N braceleft ; B 94 94 94 94 -C 125 ; WX 124 ; N bar ; B 95 95 95 95 -C 126 ; WX 125 ; N braceright ; B 96 96 96 96 -C 127 ; WX 126 ; N asciitilde ; B 97 97 97 97 -C 162 ; WX 161 ; N exclamdown ; B 98 98 98 98 -C 163 ; WX 162 ; N cent ; B 99 99 99 99 -C 164 ; WX 163 ; N sterling ; B 100 100 100 100 -C 165 ; WX 164 ; N fraction ; B 101 101 101 101 -C 165 ; WX 164 ; N fraction ; B 102 102 102 102 -C 166 ; WX 165 ; N yen ; B 103 103 103 103 -C 167 ; WX 166 ; N florin ; B 104 104 104 104 -C 168 ; WX 167 ; N section ; B 105 105 105 105 -C 169 ; WX 168 ; N currency ; B 106 106 106 106 -C 170 ; WX 169 ; N quotesingle ; B 107 107 107 107 -C 171 ; WX 170 ; N quotedblleft ; B 108 108 108 108 -C 172 ; WX 171 ; N guillemotleft ; B 109 109 109 109 -C 173 ; WX 172 ; N guilsinglleft ; B 110 110 110 110 -C 174 ; WX 173 ; N guilsinglright ; B 111 111 111 111 -C 175 ; WX 174 ; N fi ; B 112 112 112 112 -C 176 ; WX 175 ; N fl ; B 113 113 113 113 -C 178 ; WX 177 ; N endash ; B 114 114 114 114 -C 179 ; WX 178 ; N dagger ; B 115 115 115 115 -C 180 ; WX 179 ; N daggerdbl ; B 116 116 116 116 -C 181 ; WX 180 ; N periodcentered ; B 117 117 117 117 -C 181 ; WX 180 ; N periodcentered ; B 118 118 118 118 -C 183 ; WX 182 ; N paragraph ; B 119 119 119 119 -C 184 ; WX 183 ; N bullet ; B 120 120 120 120 -C 185 ; WX 184 ; N quotesinglbase ; B 121 121 121 121 -C 186 ; WX 185 ; N quotedblbase ; B 122 122 122 122 -C 187 ; WX 186 ; N quotedblright ; B 123 123 123 123 -C 188 ; WX 187 ; N guillemotright ; B 124 124 124 124 -C 189 ; WX 188 ; N ellipsis ; B 125 125 125 125 -C 190 ; WX 189 ; N perthousand ; B 126 126 126 126 -C 192 ; WX 191 ; N questiondown ; B 127 127 127 127 -C 194 ; WX 193 ; N grave ; B 128 128 128 128 -C 195 ; WX 194 ; N acute ; B 129 129 129 129 -C 196 ; WX 195 ; N circumflex ; B 130 130 130 130 -C 197 ; WX 196 ; N tilde ; B 131 131 131 131 -C 198 ; WX 197 ; N macron ; B 132 132 132 132 -C 198 ; WX 197 ; N macron ; B 133 133 133 133 -C 199 ; WX 198 ; N breve ; B 134 134 134 134 -C 200 ; WX 199 ; N dotaccent ; B 135 135 135 135 -C 201 ; WX 200 ; N dieresis ; B 136 136 136 136 -C 203 ; WX 202 ; N ring ; B 137 137 137 137 -C 204 ; WX 203 ; N cedilla ; B 138 138 138 138 -C 206 ; WX 205 ; N hungarumlaut ; B 139 139 139 139 -C 207 ; WX 206 ; N ogonek ; B 140 140 140 140 -C 208 ; WX 207 ; N caron ; B 141 141 141 141 -C 209 ; WX 208 ; N emdash ; B 142 142 142 142 -C 226 ; WX 225 ; N AE ; B 143 143 143 143 -C 228 ; WX 227 ; N ordfeminine ; B 144 144 144 144 -C 233 ; WX 232 ; N Lslash ; B 145 145 145 145 -C 234 ; WX 233 ; N Oslash ; B 146 146 146 146 -C 235 ; WX 234 ; N OE ; B 147 147 147 147 -C 236 ; WX 235 ; N ordmasculine ; B 148 148 148 148 -C 242 ; WX 241 ; N ae ; B 149 149 149 149 -C 246 ; WX 245 ; N dotlessi ; B 150 150 150 150 -C 249 ; WX 248 ; N lslash ; B 151 151 151 151 -C 250 ; WX 249 ; N oslash ; B 152 152 152 152 -C 251 ; WX 250 ; N oe ; B 153 153 153 153 -C 252 ; WX 251 ; N germandbls ; B 154 154 154 154 -EndCharMetrics diff --git a/test/java/org/apache/fop/fonts/type1/notadobe-charset_unknown-encoding.afm b/test/java/org/apache/fop/fonts/type1/notadobe-charset_unknown-encoding.afm deleted file mode 100644 index 1714288ab..000000000 --- a/test/java/org/apache/fop/fonts/type1/notadobe-charset_unknown-encoding.afm +++ /dev/null @@ -1,158 +0,0 @@ -StartFontMetrics 2.0 -EncodingScheme FontSpecific -StartCharMetrics 154 -C 33 ; WX 32 ; N space ; B 1 1 1 1 -C 33 ; WX 32 ; N space ; B 2 2 2 2 -C 34 ; WX 33 ; N exclam ; B 3 3 3 3 -C 35 ; WX 34 ; N quotedbl ; B 4 4 4 4 -C 36 ; WX 35 ; N numbersign ; B 5 5 5 5 -C 37 ; WX 36 ; N dollar ; B 6 6 6 6 -C 38 ; WX 37 ; N percent ; B 7 7 7 7 -C 39 ; WX 38 ; N ampersand ; B 8 8 8 8 -C 40 ; WX 39 ; N quoteright ; B 9 9 9 9 -C 41 ; WX 40 ; N parenleft ; B 10 10 10 10 -C 42 ; WX 41 ; N parenright ; B 11 11 11 11 -C 43 ; WX 42 ; N asterisk ; B 12 12 12 12 -C 44 ; WX 43 ; N plus ; B 13 13 13 13 -C 45 ; WX 44 ; N comma ; B 14 14 14 14 -C 46 ; WX 45 ; N hyphen ; B 15 15 15 15 -C 46 ; WX 45 ; N hyphen ; B 16 16 16 16 -C 47 ; WX 46 ; N period ; B 17 17 17 17 -C 48 ; WX 47 ; N slash ; B 18 18 18 18 -C 49 ; WX 48 ; N zero ; B 19 19 19 19 -C 50 ; WX 49 ; N one ; B 20 20 20 20 -C 51 ; WX 50 ; N two ; B 21 21 21 21 -C 52 ; WX 51 ; N three ; B 22 22 22 22 -C 53 ; WX 52 ; N four ; B 23 23 23 23 -C 54 ; WX 53 ; N five ; B 24 24 24 24 -C 55 ; WX 54 ; N six ; B 25 25 25 25 -C 56 ; WX 55 ; N seven ; B 26 26 26 26 -C 57 ; WX 56 ; N eight ; B 27 27 27 27 -C 58 ; WX 57 ; N nine ; B 28 28 28 28 -C 59 ; WX 58 ; N colon ; B 29 29 29 29 -C 60 ; WX 59 ; N semicolon ; B 30 30 30 30 -C 61 ; WX 60 ; N less ; B 31 31 31 31 -C 62 ; WX 61 ; N equal ; B 32 32 32 32 -C 63 ; WX 62 ; N greater ; B 33 33 33 33 -C 64 ; WX 63 ; N question ; B 34 34 34 34 -C 65 ; WX 64 ; N at ; B 35 35 35 35 -C 66 ; WX 65 ; N A ; B 36 36 36 36 -C 67 ; WX 66 ; N B ; B 37 37 37 37 -C 68 ; WX 67 ; N C ; B 38 38 38 38 -C 69 ; WX 68 ; N D ; B 39 39 39 39 -C 70 ; WX 69 ; N E ; B 40 40 40 40 -C 71 ; WX 70 ; N F ; B 41 41 41 41 -C 72 ; WX 71 ; N G ; B 42 42 42 42 -C 73 ; WX 72 ; N H ; B 43 43 43 43 -C 74 ; WX 73 ; N I ; B 44 44 44 44 -C 75 ; WX 74 ; N J ; B 45 45 45 45 -C 76 ; WX 75 ; N K ; B 46 46 46 46 -C 77 ; WX 76 ; N L ; B 47 47 47 47 -C 78 ; WX 77 ; N M ; B 48 48 48 48 -C 79 ; WX 78 ; N N ; B 49 49 49 49 -C 80 ; WX 79 ; N O ; B 50 50 50 50 -C 81 ; WX 80 ; N P ; B 51 51 51 51 -C 82 ; WX 81 ; N Q ; B 52 52 52 52 -C 83 ; WX 82 ; N R ; B 53 53 53 53 -C 84 ; WX 83 ; N S ; B 54 54 54 54 -C 85 ; WX 84 ; N T ; B 55 55 55 55 -C 86 ; WX 85 ; N U ; B 56 56 56 56 -C 87 ; WX 86 ; N V ; B 57 57 57 57 -C 88 ; WX 87 ; N W ; B 58 58 58 58 -C 89 ; WX 88 ; N X ; B 59 59 59 59 -C 90 ; WX 89 ; N Y ; B 60 60 60 60 -C 91 ; WX 90 ; N Z ; B 61 61 61 61 -C 92 ; WX 91 ; N bracketleft ; B 62 62 62 62 -C 93 ; WX 92 ; N backslash ; B 63 63 63 63 -C 94 ; WX 93 ; N bracketright ; B 64 64 64 64 -C 95 ; WX 94 ; N asciicircum ; B 65 65 65 65 -C 96 ; WX 95 ; N underscore ; B 66 66 66 66 -C 97 ; WX 96 ; N quoteleft ; B 67 67 67 67 -C 98 ; WX 97 ; N a ; B 68 68 68 68 -C 99 ; WX 98 ; N b ; B 69 69 69 69 -C 100 ; WX 99 ; N c ; B 70 70 70 70 -C 101 ; WX 100 ; N d ; B 71 71 71 71 -C 102 ; WX 101 ; N e ; B 72 72 72 72 -C 103 ; WX 102 ; N f ; B 73 73 73 73 -C 104 ; WX 103 ; N g ; B 74 74 74 74 -C 105 ; WX 104 ; N h ; B 75 75 75 75 -C 106 ; WX 105 ; N i ; B 76 76 76 76 -C 107 ; WX 106 ; N j ; B 77 77 77 77 -C 108 ; WX 107 ; N k ; B 78 78 78 78 -C 109 ; WX 108 ; N l ; B 79 79 79 79 -C 110 ; WX 109 ; N m ; B 80 80 80 80 -C 111 ; WX 110 ; N n ; B 81 81 81 81 -C 112 ; WX 111 ; N o ; B 82 82 82 82 -C 113 ; WX 112 ; N p ; B 83 83 83 83 -C 114 ; WX 113 ; N q ; B 84 84 84 84 -C 115 ; WX 114 ; N r ; B 85 85 85 85 -C 116 ; WX 115 ; N s ; B 86 86 86 86 -C 117 ; WX 116 ; N t ; B 87 87 87 87 -C 118 ; WX 117 ; N u ; B 88 88 88 88 -C 119 ; WX 118 ; N v ; B 89 89 89 89 -C 120 ; WX 119 ; N w ; B 90 90 90 90 -C 121 ; WX 120 ; N x ; B 91 91 91 91 -C 122 ; WX 121 ; N y ; B 92 92 92 92 -C 123 ; WX 122 ; N z ; B 93 93 93 93 -C 124 ; WX 123 ; N braceleft ; B 94 94 94 94 -C 125 ; WX 124 ; N bar ; B 95 95 95 95 -C 126 ; WX 125 ; N braceright ; B 96 96 96 96 -C 127 ; WX 126 ; N asciitilde ; B 97 97 97 97 -C 162 ; WX 161 ; N exclamdown ; B 98 98 98 98 -C 163 ; WX 162 ; N cent ; B 99 99 99 99 -C 164 ; WX 163 ; N sterling ; B 100 100 100 100 -C 165 ; WX 164 ; N fraction ; B 101 101 101 101 -C 165 ; WX 164 ; N fraction ; B 102 102 102 102 -C 166 ; WX 165 ; N yen ; B 103 103 103 103 -C 167 ; WX 166 ; N florin ; B 104 104 104 104 -C 168 ; WX 167 ; N section ; B 105 105 105 105 -C 169 ; WX 168 ; N currency ; B 106 106 106 106 -C 170 ; WX 169 ; N quotesingle ; B 107 107 107 107 -C 171 ; WX 170 ; N quotedblleft ; B 108 108 108 108 -C 172 ; WX 171 ; N guillemotleft ; B 109 109 109 109 -C 173 ; WX 172 ; N guilsinglleft ; B 110 110 110 110 -C 174 ; WX 173 ; N guilsinglright ; B 111 111 111 111 -C 175 ; WX 174 ; N fi ; B 112 112 112 112 -C 176 ; WX 175 ; N fl ; B 113 113 113 113 -C 178 ; WX 177 ; N endash ; B 114 114 114 114 -C 179 ; WX 178 ; N dagger ; B 115 115 115 115 -C 180 ; WX 179 ; N daggerdbl ; B 116 116 116 116 -C 181 ; WX 180 ; N periodcentered ; B 117 117 117 117 -C 181 ; WX 180 ; N periodcentered ; B 118 118 118 118 -C 183 ; WX 182 ; N paragraph ; B 119 119 119 119 -C 184 ; WX 183 ; N bullet ; B 120 120 120 120 -C 185 ; WX 184 ; N quotesinglbase ; B 121 121 121 121 -C 186 ; WX 185 ; N quotedblbase ; B 122 122 122 122 -C 187 ; WX 186 ; N quotedblright ; B 123 123 123 123 -C 188 ; WX 187 ; N guillemotright ; B 124 124 124 124 -C 189 ; WX 188 ; N ellipsis ; B 125 125 125 125 -C 190 ; WX 189 ; N perthousand ; B 126 126 126 126 -C 192 ; WX 191 ; N questiondown ; B 127 127 127 127 -C 194 ; WX 193 ; N grave ; B 128 128 128 128 -C 195 ; WX 194 ; N acute ; B 129 129 129 129 -C 196 ; WX 195 ; N circumflex ; B 130 130 130 130 -C 197 ; WX 196 ; N tilde ; B 131 131 131 131 -C 198 ; WX 197 ; N macron ; B 132 132 132 132 -C 198 ; WX 197 ; N macron ; B 133 133 133 133 -C 199 ; WX 198 ; N breve ; B 134 134 134 134 -C 200 ; WX 199 ; N dotaccent ; B 135 135 135 135 -C 201 ; WX 200 ; N dieresis ; B 136 136 136 136 -C 203 ; WX 202 ; N ring ; B 137 137 137 137 -C 204 ; WX 203 ; N cedilla ; B 138 138 138 138 -C 206 ; WX 205 ; N hungarumlaut ; B 139 139 139 139 -C 207 ; WX 206 ; N ogonek ; B 140 140 140 140 -C 208 ; WX 207 ; N caron ; B 141 141 141 141 -C 209 ; WX 208 ; N emdash ; B 142 142 142 142 -C 226 ; WX 225 ; N AE ; B 143 143 143 143 -C 228 ; WX 227 ; N ordfeminine ; B 144 144 144 144 -C 233 ; WX 232 ; N Lslash ; B 145 145 145 145 -C 234 ; WX 233 ; N Oslash ; B 146 146 146 146 -C 235 ; WX 234 ; N OE ; B 147 147 147 147 -C 236 ; WX 235 ; N ordmasculine ; B 148 148 148 148 -C 242 ; WX 241 ; N ae ; B 149 149 149 149 -C 246 ; WX 245 ; N dotlessi ; B 150 150 150 150 -C 249 ; WX 248 ; N lslash ; B 151 151 151 151 -C 250 ; WX 249 ; N oslash ; B 152 152 152 152 -C 251 ; WX 250 ; N oe ; B 153 153 153 153 -C 252 ; WX 251 ; N germandbls ; B 154 154 154 154 -EndCharMetrics diff --git a/test/java/org/apache/fop/fonts/type1/underline.afm b/test/java/org/apache/fop/fonts/type1/underline.afm deleted file mode 100644 index 8137b41eb..000000000 --- a/test/java/org/apache/fop/fonts/type1/underline.afm +++ /dev/null @@ -1,4 +0,0 @@ -StartFontMetrics 2.0 -UnderlinePosition -96 -UnderlineThickness 58 -EndFontMetrics diff --git a/test/java/org/apache/fop/fotreetest/DummyFOEventHandler.java b/test/java/org/apache/fop/fotreetest/DummyFOEventHandler.java deleted file mode 100644 index fcb9cfe6e..000000000 --- a/test/java/org/apache/fop/fotreetest/DummyFOEventHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.fotreetest; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fo.FOEventHandler; - -/** - * Dummy FOEventHandler implementation that does nothing. - */ -public class DummyFOEventHandler extends FOEventHandler { - - /** - * Main constructor. - * @param foUserAgent the user agent - */ - public DummyFOEventHandler(FOUserAgent foUserAgent) { - super(foUserAgent); - } - -} diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java b/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java deleted file mode 100644 index 3d58e7ef0..000000000 --- a/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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.fotreetest; - -import java.io.File; -import java.util.Collection; -import java.util.List; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLFilterImpl; - -import org.apache.fop.DebugHelper; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.FopFactoryBuilder; -import org.apache.fop.apps.FopFactoryConfig; -import org.apache.fop.apps.MutableConfig; -import org.apache.fop.fotreetest.ext.TestElementMapping; -import org.apache.fop.layoutengine.LayoutEngineTestUtils; -import org.apache.fop.layoutengine.TestFilesConfiguration; -import org.apache.fop.util.ConsoleEventListenerForTests; - -/** - * Test driver class for FO tree tests. - */ -@RunWith(Parameterized.class) -public class FOTreeTestCase { - - private static final String BASE_DIR = "test/fotree/"; - private static final String TEST_CASES = "testcases"; - - @BeforeClass - public static void registerElementListObservers() { - DebugHelper.registerStandardElementListObservers(); - } - - /** - * Gets the parameters to run the FO tree test cases. - * @return a collection of file arrays containing the test files - */ - @Parameters - public static Collection<File[]> getParameters() { - TestFilesConfiguration.Builder builder = new TestFilesConfiguration.Builder(); - builder.testDir(BASE_DIR) - .singleProperty("fop.fotree.single") - .startsWithProperty("fop.fotree.starts-with") - .suffix(".fo") - .testSet("testcases") - .disabledProperty("fop.layoutengine.disabled", "test/fotree/disabled-testcases.xml") - .privateTestsProperty("fop.fotree.private"); - - TestFilesConfiguration testConfig = builder.build(); - return LayoutEngineTestUtils.getTestFiles(testConfig); - } - - - - private final File testFile; - - /** - * Main constructor - * - * @param testFile the FO file to test - */ - public FOTreeTestCase(File testFile) { - this.testFile = testFile; - } - - /** - * Runs a test. - * @throws Exception if a test or FOP itself fails - */ - @Test - public void runTest() throws Exception { - try { - ResultCollector collector = ResultCollector.getInstance(); - collector.reset(); - - SAXParserFactory spf = SAXParserFactory.newInstance(); - spf.setNamespaceAware(true); - spf.setValidating(false); - SAXParser parser = spf.newSAXParser(); - XMLReader reader = parser.getXMLReader(); - FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI()); - // Resetting values modified by processing instructions - builder.setBreakIndentInheritanceOnReferenceAreaBoundary( - FopFactoryConfig.DEFAULT_BREAK_INDENT_INHERITANCE); - builder.setSourceResolution(FopFactoryConfig.DEFAULT_SOURCE_RESOLUTION); - - MutableConfig mutableConfig = new MutableConfig(builder); - - FopFactory fopFactory = FopFactory.newInstance(mutableConfig); - fopFactory.addElementMapping(new TestElementMapping()); - FOUserAgent ua = fopFactory.newFOUserAgent(); - ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua)); - ua.getEventBroadcaster().addEventListener( - new ConsoleEventListenerForTests(testFile.getName())); - - // Used to set values in the user agent through processing instructions - reader = new PIListener(reader, mutableConfig); - Fop fop = fopFactory.newFop(ua); - - reader.setContentHandler(fop.getDefaultHandler()); - reader.setDTDHandler(fop.getDefaultHandler()); - reader.setErrorHandler(fop.getDefaultHandler()); - reader.setEntityResolver(fop.getDefaultHandler()); - try { - reader.parse(testFile.toURI().toURL().toExternalForm()); - } catch (Exception e) { - collector.notifyError(e.getLocalizedMessage()); - throw e; - } - - List<String> results = collector.getResults(); - if (results.size() > 0) { - for (int i = 0; i < results.size(); i++) { - System.out.println(results.get(i)); - } - throw new IllegalStateException(results.get(0)); - } - } catch (Exception e) { - org.apache.commons.logging.LogFactory.getLog(this.getClass()).info( - "Error on " + testFile.getName()); - throw e; - } - } - - private static class PIListener extends XMLFilterImpl { - - private final MutableConfig fopConfig; - - public PIListener(XMLReader parent, MutableConfig fopConfig) { - super(parent); - this.fopConfig = fopConfig; - } - - /** @see org.xml.sax.helpers.XMLFilterImpl */ - public void processingInstruction(String target, String data) throws SAXException { - if ("fop-useragent-break-indent-inheritance".equals(target)) { - fopConfig.setBreakIndentInheritanceOnReferenceAreaBoundary( - Boolean.valueOf(data).booleanValue()); - } else if ("fop-source-resolution".equals(target)) { - fopConfig.setSourceResolution(Float.parseFloat(data)); - } - super.processingInstruction(target, data); - } - } -} diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java b/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java deleted file mode 100644 index 604ff6e9e..000000000 --- a/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.fotreetest; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * JUnit test suit for running layout engine test under JUnit control. - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - org.apache.fop.fo.flow.table.AllTests.class, - org.apache.fop.fo.pagination.AllTests.class, - org.apache.fop.fotreetest.FOTreeTestCase.class, - org.apache.fop.fo.properties.CommonAccessibilityHolderTestCase.class, - org.apache.fop.fo.DelegatingFOEventHandlerTestCase.class -}) -public final class FOTreeTestSuite { - -} diff --git a/test/java/org/apache/fop/fotreetest/ResultCollector.java b/test/java/org/apache/fop/fotreetest/ResultCollector.java deleted file mode 100644 index 948b856bf..000000000 --- a/test/java/org/apache/fop/fotreetest/ResultCollector.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.fotreetest; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * This class collects failures for assertions injected into the FO stream. - */ -public class ResultCollector { - - private static ResultCollector instance; - - private List<String> results = new ArrayList<String>(); - - /** @return the ResultCollector singleton */ - public static ResultCollector getInstance() { - if (instance == null) { - instance = new ResultCollector(); - } - return instance; - } - - /** Main constructor. */ - public ResultCollector() { - //nop - } - - /** - * This notifies the ResultCollector about an assertion failure. - * - * @param message the message containing the details - */ - public void notifyAssertionFailure(String message) { - System.out.println(message); - results.add(message); - } - - /** - * This notifies the ResultCollector about a testcase that ended - * with a fatal error - * - * @param message the message containing the details - */ - public void notifyError(String message) { - results.add(message); - } - - /** Resets the result list. */ - public void reset() { - results.clear(); - } - - /** @return the list of results */ - public List<String> getResults() { - return Collections.unmodifiableList(results); - } -} diff --git a/test/java/org/apache/fop/fotreetest/ext/AssertElement.java b/test/java/org/apache/fop/fotreetest/ext/AssertElement.java deleted file mode 100644 index 955644ae4..000000000 --- a/test/java/org/apache/fop/fotreetest/ext/AssertElement.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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.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; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.properties.KeepProperty; -import org.apache.fop.fo.properties.LengthPairProperty; -import org.apache.fop.fo.properties.LengthRangeProperty; -import org.apache.fop.fo.properties.PercentLength; -import org.apache.fop.fo.properties.Property; -import org.apache.fop.fo.properties.SpaceProperty; -import org.apache.fop.fotreetest.ResultCollector; - -/** - * Defines the assert element for the FOP Test extension. - */ -public class AssertElement extends TestObj { - - /** - * Creates a new AssertElement instance that is a child - * of the given {@link FONode} - * - * @param parent the parent {@link FONode} - */ - public AssertElement(FONode parent) { - super(parent); - } - - /** - * @see org.apache.fop.fo.FONode#processNode - */ - public void processNode(String elementName, - Locator locator, - Attributes attlist, - PropertyList propertyList) throws FOPException { - //super.processNode(elementName, locator, attlist, propertyList); - - ResultCollector collector = ResultCollector.getInstance(); - String propName = attlist.getValue("property"); - String expected = attlist.getValue("expected"); - String component = null; - int dotIndex = propName.indexOf('.'); - if (dotIndex >= 0) { - component = propName.substring(dotIndex + 1); - propName = propName.substring(0, dotIndex); - } - int propID = FOPropertyMapping.getPropertyId(propName); - if (propID < 0) { - collector.notifyAssertionFailure("Property not found: " + propName); - } else { - Property prop; - prop = propertyList.getParentPropertyList().get(propID); - if (component != null) { - //Access subcomponent - Property mainProp = prop; - prop = null; - LengthPairProperty lpp = mainProp.getLengthPair(); - if (lpp != null) { - prop = lpp.getComponent(FOPropertyMapping.getSubPropertyId(component)); - } - LengthRangeProperty lrp = mainProp.getLengthRange(); - if (lrp != null) { - prop = lrp.getComponent(FOPropertyMapping.getSubPropertyId(component)); - } - KeepProperty kp = mainProp.getKeep(); - if (kp != null) { - prop = kp.getComponent(FOPropertyMapping.getSubPropertyId(component)); - } - SpaceProperty sp = mainProp.getSpace(); - if (sp != null) { - prop = sp.getComponent(FOPropertyMapping.getSubPropertyId(component)); - } - } - String s; - if (prop instanceof PercentLength) { - s = prop.getString(); - } else { - s = String.valueOf(prop); - } - if (!expected.equals(s)) { - collector.notifyAssertionFailure( - locator.getSystemId() - + "\nProperty '" + propName - + "' expected to evaluate to '" + expected - + "' but got '" + s - + "'\n(test:assert in " - + propertyList.getParentFObj().getName() - + " at line #" + locator.getLineNumber() - + ", column #" + locator.getColumnNumber() + ")\n"); - } - } - - } - - /** @see org.apache.fop.fo.FONode#getLocalName() */ - public String getLocalName() { - return "assert"; - } - -} diff --git a/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java b/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java deleted file mode 100644 index b61944eae..000000000 --- a/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.fotreetest.ext; - -import org.apache.fop.fo.ElementMapping; -import org.apache.fop.fo.FONode; - -/** - * This class provides the element mapping for FOP. - */ -public class TestElementMapping extends ElementMapping { - - /** MathML Namespace */ - public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/test"; - - /** - * Main constructor - */ - public TestElementMapping() { - this.namespaceURI = NAMESPACE; - } - - /** @see org.apache.fop.fo.ElementMapping#initialize() */ - protected void initialize() { - if (foObjs == null) { - foObjs = new java.util.HashMap<String, Maker>(); - foObjs.put("assert", new AssertMaker()); - } - } - - static class AssertMaker extends ElementMapping.Maker { - public FONode make(FONode parent) { - return new AssertElement(parent); - } - } - -} diff --git a/test/java/org/apache/fop/fotreetest/ext/TestObj.java b/test/java/org/apache/fop/fotreetest/ext/TestObj.java deleted file mode 100644 index e921c8919..000000000 --- a/test/java/org/apache/fop/fotreetest/ext/TestObj.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.fotreetest.ext; - -// FOP -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FObj; - -/** - * Base class for all FOP Test objects. - */ -public abstract class TestObj extends FObj { - - /** - * @see org.apache.fop.fo.FONode#FONode(FONode) - */ - public TestObj(FONode parent) { - super(parent); - } - - /** @see org.apache.fop.fo.FONode#getNamespaceURI() */ - public String getNamespaceURI() { - return TestElementMapping.NAMESPACE; - } - -} - diff --git a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java deleted file mode 100644 index 7f3036c24..000000000 --- a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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.image.loader.batik; - -import java.awt.image.Raster; -import java.awt.image.RenderedImage; -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; -import org.apache.xmlgraphics.image.loader.ImageManager; -import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor; -import org.apache.xmlgraphics.image.loader.impl.ImageRendered; -import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; -import org.apache.xmlgraphics.image.writer.ImageWriterUtil; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.FopFactoryBuilder; - -/** - * Tests for bundled ImageLoader implementations. - */ -@Ignore("Batik fails big time") -public class ImageLoaderTestCase { - - private static final File DEBUG_TARGET_DIR = null; - - private FopFactory fopFactory; - - public ImageLoaderTestCase() { - FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI()); - builder.setSourceResolution(72); - builder.setTargetResolution(300); - fopFactory = builder.build(); - } - - @Test - public void testSVG() throws Exception { - String uri = "test/resources/images/img-w-size.svg"; - - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - - ImageManager manager = fopFactory.getImageManager(); - ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); - assertNotNull("ImageInfo must not be null", info); - - Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM, - userAgent.getImageSessionContext()); - assertNotNull("Image must not be null", img); - assertEquals(XMLNamespaceEnabledImageFlavor.SVG_DOM, img.getFlavor()); - ImageXMLDOM imgDom = (ImageXMLDOM)img; - assertNotNull(imgDom.getDocument()); - assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); - info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image - assertEquals(16000, info.getSize().getWidthMpt()); - assertEquals(16000, info.getSize().getHeightMpt()); - - img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, - userAgent.getImageSessionContext()); - assertNotNull("Image must not be null", img); - assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor()); - ImageRendered imgRed = (ImageRendered)img; - assertNotNull(imgRed.getRenderedImage()); - if (DEBUG_TARGET_DIR != null) { - ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(), - (int)userAgent.getTargetResolution(), - new File(DEBUG_TARGET_DIR, "out.svg.png")); - } - assertEquals(67, imgRed.getRenderedImage().getWidth()); - assertEquals(67, imgRed.getRenderedImage().getHeight()); - info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image - assertEquals(16000, info.getSize().getWidthMpt()); - assertEquals(16000, info.getSize().getHeightMpt()); - } - - @Test - public void testSVGNoViewbox() throws Exception { - String uri = "test/resources/images/circles.svg"; - - FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI()); - builder.setSourceResolution(96); - builder.setTargetResolution(300); - FopFactory ff = builder.build(); - - FOUserAgent userAgent = ff.newFOUserAgent(); - - ImageManager manager = ff.getImageManager(); - ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); - assertNotNull("ImageInfo must not be null", info); - - Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM, - userAgent.getImageSessionContext()); - assertNotNull("Image must not be null", img); - assertEquals(XMLNamespaceEnabledImageFlavor.SVG_DOM, img.getFlavor()); - ImageXMLDOM imgDom = (ImageXMLDOM)img; - assertNotNull(imgDom.getDocument()); - assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); - info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image - assertEquals(96, info.getSize().getDpiHorizontal(), 0); - assertEquals(340158, info.getSize().getWidthMpt()); - assertEquals(340158, info.getSize().getHeightMpt()); - assertEquals(454, info.getSize().getWidthPx()); - assertEquals(454, info.getSize().getHeightPx()); - - img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, - userAgent.getImageSessionContext()); - assertNotNull("Image must not be null", img); - assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor()); - ImageRendered imgRed = (ImageRendered)img; - assertNotNull(imgRed.getRenderedImage()); - if (DEBUG_TARGET_DIR != null) { - ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(), - (int)userAgent.getTargetResolution(), - new File(DEBUG_TARGET_DIR, "circles.svg.png")); - } - assertEquals(1418, imgRed.getRenderedImage().getWidth()); - assertEquals(1418, imgRed.getRenderedImage().getHeight()); - info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image - assertEquals(340158, info.getSize().getWidthMpt()); - assertEquals(340158, info.getSize().getHeightMpt()); - } - - @Test - public void testWMF() throws Exception { - String uri = "test/resources/images/testChart.wmf"; - - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - - ImageManager manager = fopFactory.getImageManager(); - ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); - assertNotNull("ImageInfo must not be null", info); - - Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, - userAgent.getImageSessionContext()); - assertNotNull("Image must not be null", img); - assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor()); - ImageRendered imgRed = (ImageRendered)img; - assertNotNull(imgRed.getRenderedImage()); - if (DEBUG_TARGET_DIR != null) { - ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(), - (int)userAgent.getTargetResolution(), - new File(DEBUG_TARGET_DIR, "out.wmf.png")); - } - assertEquals(3300, imgRed.getRenderedImage().getWidth()); - assertEquals(2550, imgRed.getRenderedImage().getHeight()); - info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image - assertEquals(792000, info.getSize().getWidthMpt()); - assertEquals(612000, info.getSize().getHeightMpt()); - } - - @Test - public void testSVGWithReferences() throws Exception { - String uri = "test/resources/fop/svg/images.svg"; - FopFactory ff = FopFactory.newInstance(new File(".").toURI()); - FOUserAgent userAgent = ff.newFOUserAgent(); - - ImageManager manager = ff.getImageManager(); - ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); - assertNotNull("ImageInfo must not be null", info); - - Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM, - userAgent.getImageSessionContext()); - assertNotNull("Image must not be null", img); - assertEquals(XMLNamespaceEnabledImageFlavor.SVG_DOM, img.getFlavor()); - ImageXMLDOM imgDom = (ImageXMLDOM)img; - assertNotNull(imgDom.getDocument()); - assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); - info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image - assertEquals(400000, info.getSize().getWidthMpt()); - assertEquals(400000, info.getSize().getHeightMpt()); - assertEquals(400, info.getSize().getWidthPx()); - assertEquals(400, info.getSize().getHeightPx()); - - img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, - userAgent.getImageSessionContext()); - assertNotNull("Image must not be null", img); - assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor()); - ImageRendered imgRed = (ImageRendered)img; - RenderedImage renImg = imgRed.getRenderedImage(); - assertNotNull(renImg); - if (DEBUG_TARGET_DIR != null) { - ImageWriterUtil.saveAsPNG(renImg, - (int)userAgent.getTargetResolution(), - new File(DEBUG_TARGET_DIR, "images.svg.png")); - } - assertEquals(400, renImg.getWidth()); - assertEquals(400, renImg.getHeight()); - info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image - assertEquals(400000, info.getSize().getWidthMpt()); - assertEquals(400000, info.getSize().getHeightMpt()); - Raster raster = renImg.getData(); - // This pixel is white - int[] pixel1 = raster.getPixel(1, 1, (int[])null); - // This pixel is from the embedded JPG and is not white - int[] pixel80 = raster.getPixel(80, 80, (int[]) null); - assertEquals(pixel1.length, pixel80.length); - boolean same = true; - for (int i = 0; i < pixel1.length; i++) { - same &= (pixel1[i] == pixel80[i]); - } - assertFalse("Embedding JPG into SVG failed", same); - } -} diff --git a/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java deleted file mode 100644 index 3d690b67c..000000000 --- a/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.image.loader.batik; - -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; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.FopFactoryBuilder; -import org.apache.fop.apps.MimeConstants; - -/** - * Tests for bundled image preloader implementations. - */ -public class ImagePreloaderTestCase { - - private FopFactory fopFactory; - - public ImagePreloaderTestCase() { - FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI()); - builder.setSourceResolution(72); - builder.setTargetResolution(300); - fopFactory = builder.build(); - } - - @Test - public void testSVG() throws Exception { - String uri = "test/resources/images/img-w-size.svg"; - - checkSVGFile(uri); - } - - @Test - public void testSVGZ() throws Exception { - String uri = "test/resources/images/img-w-size.svgz"; - - checkSVGFile(uri); - } - - private void checkSVGFile(String uri) throws ImageException, IOException { - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - - ImageManager manager = fopFactory.getImageManager(); - ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); - assertNotNull("ImageInfo must not be null", info); - assertEquals(MimeConstants.MIME_SVG, info.getMimeType()); - assertEquals(uri, info.getOriginalURI()); - assertEquals(16, info.getSize().getWidthPx()); - assertEquals(16, info.getSize().getHeightPx()); - assertEquals(userAgent.getSourceResolution(), info.getSize().getDpiHorizontal(), 0.1); - assertEquals(16000, info.getSize().getWidthMpt()); - assertEquals(16000, info.getSize().getHeightMpt()); - } - - @Test - public void testSVGNoSize() throws Exception { - String uri = "test/resources/images/img.svg"; - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - - ImageManager manager = fopFactory.getImageManager(); - ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); - assertNotNull("ImageInfo must not be null", info); - assertEquals(MimeConstants.MIME_SVG, info.getMimeType()); - assertEquals(uri, info.getOriginalURI()); - assertEquals(100, info.getSize().getWidthPx()); //100 = default viewport size - assertEquals(100, info.getSize().getHeightPx()); - assertEquals(userAgent.getSourceResolution(), info.getSize().getDpiHorizontal(), 0.1); - assertEquals(100000, info.getSize().getWidthMpt()); - assertEquals(100000, info.getSize().getHeightMpt()); - } - - @Test - @Ignore("Batik has not yet been handled") - public void testSVGWithDOM() throws Exception { - String uri = "my:SVGImage"; - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - - // TODO: SORT THIS OUT!! - // userAgent.setURIResolver(new URIResolver() { - // - // public Source resolve(String href, String base) throws TransformerException { - // if (href.startsWith("my:")) { - // DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); - // String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; - // Document doc = impl.createDocument(svgNS, "svg", null); - // Element element = doc.getDocumentElement(); - // element.setAttribute("viewBox", "0 0 20 20"); - // element.setAttribute("width", "20pt"); - // element.setAttribute("height", "20pt"); - // - // Element rect = doc.createElementNS(svgNS, "rect"); - // rect.setAttribute("x", "5"); - // rect.setAttribute("y", "5"); - // rect.setAttribute("width", "10"); - // rect.setAttribute("height", "10"); - // element.appendChild(rect); - // - // DOMSource src = new DOMSource(doc); - // return src; - // } else { - // return null; - // } - // } - // - // }); - - ImageManager manager = fopFactory.getImageManager(); - ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); - assertNotNull("ImageInfo must not be null", info); - assertEquals(MimeConstants.MIME_SVG, info.getMimeType()); - assertEquals(uri, info.getOriginalURI()); - assertEquals(20, info.getSize().getWidthPx()); //100 = default viewport size - assertEquals(20, info.getSize().getHeightPx()); - assertEquals(userAgent.getSourceResolution(), info.getSize().getDpiHorizontal(), 0.1); - assertEquals(20000, info.getSize().getWidthMpt()); - assertEquals(20000, info.getSize().getHeightMpt()); - } - - @Test - public void testWMF() throws Exception { - String uri = "test/resources/images/testChart.wmf"; - - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - - ImageManager manager = fopFactory.getImageManager(); - ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); - assertNotNull("ImageInfo must not be null", info); - assertEquals(ImageWMF.MIME_WMF, info.getMimeType()); - assertEquals(uri, info.getOriginalURI()); - assertEquals(27940, info.getSize().getWidthPx()); - assertEquals(21590, info.getSize().getHeightPx()); - assertEquals(2540, info.getSize().getDpiHorizontal(), 0.1); - assertEquals(792000, info.getSize().getWidthMpt()); - assertEquals(612000, info.getSize().getHeightMpt()); - } - -} diff --git a/test/java/org/apache/fop/intermediate/AbstractIFTest.java b/test/java/org/apache/fop/intermediate/AbstractIFTest.java deleted file mode 100644 index 48c3f335b..000000000 --- a/test/java/org/apache/fop/intermediate/AbstractIFTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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.intermediate; - -import java.io.File; -import java.io.IOException; - -import javax.xml.XMLConstants; -import javax.xml.transform.Result; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; -import javax.xml.validation.Schema; -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; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFSerializer; - -/** - * A common super-class for intermediate format test cases. - */ -abstract class AbstractIFTest extends AbstractIntermediateTest { - - private static final Schema IF_SCHEMA; - - static { - Schema ifSchema = null; - try { - SchemaFactory sFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - sFactory.setErrorHandler(new ErrorHandler() { - - public void error(SAXParseException exception) throws SAXException { - throw exception; - } - - public void fatalError(SAXParseException exception) throws SAXException { - throw exception; - } - - public void warning(SAXParseException exception) throws SAXException { - throw exception; - } - - }); - File ifSchemaFile = new File( - "src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd"); - ifSchema = sFactory.newSchema(ifSchemaFile); - } catch (IllegalArgumentException iae) { - System.err.println("No suitable SchemaFactory for XML Schema validation found!"); - } catch (SAXException e) { - throw new ExceptionInInitializerError(e); - } - IF_SCHEMA = ifSchema; - } - - /** - * Creates a new test case. - * - * @param testFile the file containing the document and the tests - * @throws IOException if an I/O error occurs while loading the test case - */ - public AbstractIFTest(File testFile) throws IOException { - super(testFile); - } - - @Override - protected String getIntermediateFileExtension() { - return ".if.xml"; - } - - @Override - protected Document buildIntermediateDocument(Templates templates) throws Exception { - Transformer transformer = templates.newTransformer(); - setErrorListener(transformer); - - //Set up XMLRenderer to render to a DOM - DOMResult domResult = new DOMResult(); - - FOUserAgent userAgent = createUserAgent(); - - //Create an instance of the target renderer so the XMLRenderer can use its font setup - IFDocumentHandler targetHandler = userAgent.getRendererFactory().createDocumentHandler( - userAgent, getTargetMIME()); - - //Setup painter - IFSerializer serializer = new IFSerializer(new IFContext(userAgent)); - serializer.mimicDocumentHandler(targetHandler); - serializer.setResult(domResult); - - userAgent.setDocumentHandlerOverride(serializer); - - Fop fop = fopFactory.newFop(userAgent); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(new DOMSource(testDoc), res); - - return (Document) domResult.getNode(); - } - - @Override - protected void validate(Document doc) throws SAXException, IOException { - if (IF_SCHEMA == null) { - return; //skip validation; - } - Validator validator = IF_SCHEMA.newValidator(); - validator.setErrorHandler(new ErrorHandler() { - - public void error(SAXParseException exception) throws SAXException { - throw exception; - } - - public void fatalError(SAXParseException exception) throws SAXException { - throw exception; - } - - public void warning(SAXParseException exception) throws SAXException { - //ignore - } - - }); - validator.validate(new DOMSource(doc)); - } - -} diff --git a/test/java/org/apache/fop/intermediate/AbstractIntermediateTest.java b/test/java/org/apache/fop/intermediate/AbstractIntermediateTest.java deleted file mode 100644 index 23c7c0560..000000000 --- a/test/java/org/apache/fop/intermediate/AbstractIntermediateTest.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * 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.intermediate; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import javax.xml.transform.ErrorListener; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMSource; - -import org.custommonkey.xmlunit.XMLAssert; -import org.junit.After; -import org.junit.Before; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.io.output.NullOutputStream; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.events.model.EventSeverity; -import org.apache.fop.util.ConsoleEventListenerForTests; - -/** - * Abstract base class for intermediate format tests. - */ -public abstract class AbstractIntermediateTest { - - /** the test environment */ - protected static TestAssistant testAssistant = new TestAssistant(); - - /** the FOP factory */ - protected FopFactory fopFactory; - - /** the directory containing the tests */ - protected File testDir = new File("test/layoutengine/standard-testcases"); - /** the output directory for any files generated by the tests */ - protected File outputDir; - - /** the test file */ - protected File testFile; - /** the test document as DOM */ - protected Document testDoc; - /** the intermediate format document as DOM */ - protected Document intermediate; - - /** - * Constructor for the test suite that is used for each test file. - * @param testFile the test file to run - * @throws IOException if an I/O error occurs while loading the test case - */ - public AbstractIntermediateTest(File testFile) - throws IOException { - this.testFile = testFile; - } - - @Before - public void setUp() throws Exception { - setupOutputDirectory(); - this.testDoc = testAssistant.loadTestCase(testFile); - this.fopFactory = testAssistant.getFopFactory(testDoc); - intermediate = buildIntermediateDocument(testAssistant.getTestcase2FOStylesheet()); - if (outputDir != null) { - testAssistant.saveDOM(intermediate, new File(outputDir, - testFile.getName() + ".1" + getIntermediateFileExtension())); - } - } - - @After - public void tearDown() throws Exception { - //Release memory - this.intermediate = null; - this.fopFactory = null; - this.testDoc = null; - } - - /** - * Returns the file extension for the intermediate file format. - * @return the file extension - */ - protected abstract String getIntermediateFileExtension(); - - /** - * Returns the MIME type for which to test or to mimic for the intermediate format. - * @return the MIME type - */ - protected String getTargetMIME() { - return MimeConstants.MIME_PDF; - } - - /** - * Validates the intermediate format file. - * @param doc the intermediate file - * @throws IOException if an IO error occurs while loading the schema - * @throws SAXException if a SAX-related exception (including a validation error) occurs - */ - protected void validate(Document doc) throws SAXException, IOException { - //nop by default - } - - /** - * Builds an intermediate format document from a source file. - * @param templates the (optional) stylesheet - * @return the intermediate format document as a DOM - * @throws Exception if an error occurs while processing the document - */ - protected abstract Document buildIntermediateDocument(Templates templates) throws Exception; - - /** - * Creates a new FOP user agent. - * @return the user agent - */ - protected FOUserAgent createUserAgent() { - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - userAgent.getEventBroadcaster().addEventListener( - new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.FATAL)); - return userAgent; - } - - /** - * Sets up the output directory. - */ - protected void setupOutputDirectory() { - String s = System.getProperty("fop.intermediate.outdir"); - if (s != null && s.length() > 0) { - outputDir = new File(s); - outputDir.mkdirs(); - } - } - - /** - * Tests the area tree parser by running the parsed area tree again through the area tree - * renderer. The source and result documents are compared to each other. - * @throws Exception if the test fails - */ - public void testParserToIntermediateFormat() throws Exception { - validate(intermediate); - Source src = new DOMSource(intermediate); - Document doc = parseAndRenderToIntermediateFormat(src); - if (outputDir != null) { - File tgtFile = new File(outputDir, testFile.getName() + ".2" - + getIntermediateFileExtension()); - testAssistant.saveDOM(doc, tgtFile); - } - - XMLAssert.assertXMLEqual(intermediate, doc); - } - - /** - * Parses the intermediate file and renders it back to the intermediate format. - * @param src the source for the intermediate file - * @return a DOM Document with the re-created intermediate file - * @throws Exception if an error occurs while processing the document - */ - protected abstract Document parseAndRenderToIntermediateFormat(Source src) throws Exception; - - /** - * Tests the area tree parser by sending the parsed area tree to the PDF Renderer. Some - * errors might be caught by the PDFRenderer. - * @throws Exception if the test fails - */ - public void testParserToPDF() throws Exception { - OutputStream out; - if (outputDir != null) { - File tgtFile = new File(outputDir, testFile.getName() + ".pdf"); - out = new FileOutputStream(tgtFile); - out = new BufferedOutputStream(out); - } else { - out = new NullOutputStream(); - } - try { - Source src = new DOMSource(intermediate); - parseAndRender(src, out); - } finally { - IOUtils.closeQuietly(out); - } - } - - /** - * Parses and renders an intermediate format document to a final format. - * @param src the source document - * @param out the target output stream - * @throws Exception if an error occurs while rendering the document - */ - protected abstract void parseAndRender(Source src, OutputStream out) - throws Exception; - - /** - * Run the test. - * - * @throws Exception if an error occurs during the test - */ - public abstract void runTest() throws Exception; - - /** - * Sets an error listener which doesn't swallow errors like Xalan's default one. - * @param transformer the transformer to set the error listener on - */ - protected void setErrorListener(Transformer transformer) { - transformer.setErrorListener(new ErrorListener() { - - public void error(TransformerException exception) throws TransformerException { - throw exception; - } - - public void fatalError(TransformerException exception) throws TransformerException { - throw exception; - } - - public void warning(TransformerException exception) throws TransformerException { - //ignore - } - - }); - } - -} diff --git a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java deleted file mode 100644 index ab1af4379..000000000 --- a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.intermediate; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Collection; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.TransformerHandler; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -import org.w3c.dom.Document; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.area.AreaTreeModel; -import org.apache.fop.area.AreaTreeParser; -import org.apache.fop.area.RenderPagesModel; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.layoutengine.LayoutEngineTestUtils; -import org.apache.fop.render.Renderer; -import org.apache.fop.render.xml.XMLRenderer; - -/** - * Tests the area tree parser. - */ -@RunWith(Parameterized.class) -public class AreaTreeParserTestCase extends AbstractIntermediateTest { - - /** - * Creates the parameters for this test. - * - * @return the list of file arrays populated with test files - * @throws IOException if an I/O error occurs while reading the test file - */ - @Parameters - public static Collection<File[]> getParameters() throws IOException { - return LayoutEngineTestUtils.getLayoutTestFiles(); - } - - /** - * Constructor for the test suite that is used for each test file. - * @param testFile the test file to run - * @throws IOException - * @throws IOException if an I/O error occurs while loading the test case - */ - public AreaTreeParserTestCase(File testFile) throws IOException { - super(testFile); - } - - /** {@inheritDoc} */ - protected String getIntermediateFileExtension() { - return ".at.xml"; - } - - /** {@inheritDoc} */ - protected Document buildIntermediateDocument(Templates templates) - throws Exception { - Transformer transformer = templates.newTransformer(); - setErrorListener(transformer); - - //Set up XMLRenderer to render to a DOM - TransformerHandler handler = testAssistant.getTransformerFactory().newTransformerHandler(); - DOMResult domResult = new DOMResult(); - handler.setResult(domResult); - - FOUserAgent userAgent = createUserAgent(); - - //Create an instance of the target renderer so the XMLRenderer can use its font setup - Renderer targetRenderer = userAgent.getRendererFactory().createRenderer( - userAgent, getTargetMIME()); - - XMLRenderer renderer = new XMLRenderer(userAgent); - renderer.mimicRenderer(targetRenderer); - renderer.setContentHandler(handler); - - userAgent.setRendererOverride(renderer); - - Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_AREA_TREE, userAgent); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(new DOMSource(testDoc), res); - - return (Document)domResult.getNode(); - } - - /** {@inheritDoc} */ - protected void parseAndRender(Source src, OutputStream out) throws Exception { - AreaTreeParser parser = new AreaTreeParser(); - - FOUserAgent userAgent = createUserAgent(); - FontInfo fontInfo = new FontInfo(); - AreaTreeModel treeModel = new RenderPagesModel(userAgent, - getTargetMIME(), fontInfo, out); - parser.parse(src, treeModel, userAgent); - treeModel.endDocument(); - } - - /** {@inheritDoc} */ - protected Document parseAndRenderToIntermediateFormat(Source src) throws Exception { - AreaTreeParser parser = new AreaTreeParser(); - - //Set up XMLRenderer to render to a DOM - TransformerHandler handler = testAssistant.getTransformerFactory().newTransformerHandler(); - DOMResult domResult = new DOMResult(); - handler.setResult(domResult); - FOUserAgent userAgent = createUserAgent(); - XMLRenderer renderer = new XMLRenderer(userAgent); - userAgent.setRendererOverride(renderer); - renderer.setContentHandler(handler); - - FontInfo fontInfo = new FontInfo(); - AreaTreeModel treeModel = new RenderPagesModel(userAgent, - MimeConstants.MIME_FOP_AREA_TREE, fontInfo, null); - parser.parse(src, treeModel, userAgent); - treeModel.endDocument(); - - return (Document)domResult.getNode(); - } - - @Override - @Test - public void runTest() throws Exception { - try { - testParserToIntermediateFormat(); - testParserToPDF(); - } catch (Exception e) { - org.apache.commons.logging.LogFactory.getLog(this.getClass()).error( - "Error on " + testFile.getName()); - throw e; - } - } - -} diff --git a/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java b/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java deleted file mode 100644 index 2003958c8..000000000 --- a/test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.intermediate; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * JUnit test suite for the area tree XML format - */ -@RunWith(Suite.class) -@SuiteClasses(AreaTreeParserTestCase.class) -public class AreaTreeXMLFormatTestSuite { -} diff --git a/test/java/org/apache/fop/intermediate/IFCheck.java b/test/java/org/apache/fop/intermediate/IFCheck.java deleted file mode 100644 index dfd76f3b3..000000000 --- a/test/java/org/apache/fop/intermediate/IFCheck.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.intermediate; - -import org.w3c.dom.Document; - -import org.apache.fop.check.Check; - -/** - * Check interface for intermediate format checks. - */ -public interface IFCheck extends Check { - - /** - * Called to perform the check. - * @param intermediate the intermediate format file as a DOM document - */ - void check(Document intermediate); - -} diff --git a/test/java/org/apache/fop/intermediate/IFChecksFactory.java b/test/java/org/apache/fop/intermediate/IFChecksFactory.java deleted file mode 100644 index 2eab74130..000000000 --- a/test/java/org/apache/fop/intermediate/IFChecksFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.intermediate; - -import org.w3c.dom.Element; - -import org.apache.fop.check.ChecksFactory; -import org.apache.fop.layoutengine.EvalCheck; -import org.apache.fop.layoutengine.TrueCheck; - -/** - * A factory class for creating {@link IFCheck} instances. - */ -final class IFChecksFactory extends ChecksFactory<IFCheck> { - - IFChecksFactory() { - registerCheckFactory("true", new CheckFactory<IFCheck>() { - - public IFCheck createCheck(Element element) { - return new TrueCheck(element); - } - - }); - registerCheckFactory("eval", new CheckFactory<IFCheck>() { - - public IFCheck createCheck(Element element) { - return new EvalCheck(element); - } - - }); - } -} diff --git a/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java b/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java deleted file mode 100644 index 83dd88661..000000000 --- a/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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.intermediate; - -import java.io.File; - -import javax.xml.transform.ErrorListener; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.sax.SAXResult; -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; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.events.Event; -import org.apache.fop.events.EventFormatter; -import org.apache.fop.events.EventListener; -import org.apache.fop.fonts.FontEventProducer; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFException; -import org.apache.fop.render.intermediate.IFSerializer; - -/** - * This test checks the correct mimicking of a different output format. - */ -public class IFMimickingTestCase { - - private FopFactory fopFactory; - - @Before - public void setUp() throws Exception { - File configFile = new File("test/test-no-xml-metrics.xconf"); - fopFactory = FopFactory.newInstance(configFile); - } - - /** - * Tests IF document handler mimicking with PDF output. - * @throws Exception if an error occurs - */ - @Test - public void testMimickingPDF() throws Exception { - doTestMimicking(MimeConstants.MIME_PDF); - } - - /** - * Tests IF document handler mimicking with PostScript output. - * @throws Exception if an error occurs - */ - @Test - public void testMimickingPS() throws Exception { - doTestMimicking(MimeConstants.MIME_POSTSCRIPT); - } - - /** - * Tests IF document handler mimicking with TIFF output. - * @throws Exception if an error occurs - */ - @Test - public void testMimickingTIFF() throws Exception { - doTestMimicking(MimeConstants.MIME_TIFF); - } - - private void doTestMimicking(String mime) throws FOPException, IFException, - TransformerException { - //Set up XMLRenderer to render to a DOM - DOMResult domResult = new DOMResult(); - - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - userAgent.getEventBroadcaster().addEventListener(new EventListener() { - - public void processEvent(Event event) { - if (event.getEventGroupID().equals(FontEventProducer.class.getName())) { - fail("There must be no font-related event! Got: " - + EventFormatter.format(event)); - } - } - - }); - - //Create an instance of the target renderer so the XMLRenderer can use its font setup - IFDocumentHandler targetHandler = userAgent.getRendererFactory().createDocumentHandler( - userAgent, mime); - - //Setup painter - IFSerializer serializer = new IFSerializer(new IFContext(userAgent)); - serializer.mimicDocumentHandler(targetHandler); - serializer.setResult(domResult); - - userAgent.setDocumentHandlerOverride(serializer); - - Fop fop = fopFactory.newFop(userAgent); - - //minimal-pdf-a.fo uses the Gladiator font so is an ideal FO file for this test: - StreamSource src = new StreamSource(new File("test/xml/pdf-a/minimal-pdf-a.fo")); - - TransformerFactory tFactory = TransformerFactory.newInstance(); - Transformer transformer = tFactory.newTransformer(); - setErrorListener(transformer); - - transformer.transform(src, new SAXResult(fop.getDefaultHandler())); - } - - /** - * Sets an error listener which doesn't swallow errors like Xalan's default one. - * @param transformer the transformer to set the error listener on - */ - protected void setErrorListener(Transformer transformer) { - transformer.setErrorListener(new ErrorListener() { - - public void error(TransformerException exception) throws TransformerException { - throw exception; - } - - public void fatalError(TransformerException exception) throws TransformerException { - throw exception; - } - - public void warning(TransformerException exception) throws TransformerException { - //ignore - } - - }); - } - -} diff --git a/test/java/org/apache/fop/intermediate/IFParserTestCase.java b/test/java/org/apache/fop/intermediate/IFParserTestCase.java deleted file mode 100644 index 9a08816c6..000000000 --- a/test/java/org/apache/fop/intermediate/IFParserTestCase.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.intermediate; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Collection; - -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.stream.StreamResult; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -import org.w3c.dom.Document; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.layoutengine.LayoutEngineTestUtils; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFParser; -import org.apache.fop.render.intermediate.IFSerializer; - -/** - * Tests the intermediate format parser. - */ -@RunWith(Parameterized.class) -public class IFParserTestCase extends AbstractIFTest { - - /** - * Gets the parameters for this test - * - * @return a collection of file arrays containing the test files - * @throws IOException if an error occurs when trying to read the test files - */ - @Parameters - public static Collection<File[]> getParameters() throws IOException { - return LayoutEngineTestUtils.getLayoutTestFiles(); - } - - /** - * Constructor for the test suite that is used for each test file. - * @param testFile the test file to run - * @throws IOException if an I/O error occurs while loading the test case - */ - public IFParserTestCase(File testFile) throws IOException { - super(testFile); - } - - /** {@inheritDoc} */ - @Override - protected void parseAndRender(Source src, OutputStream out) throws Exception { - IFParser parser = new IFParser(); - - FOUserAgent userAgent = createUserAgent(); - - IFDocumentHandler documentHandler = userAgent.getRendererFactory().createDocumentHandler( - userAgent, getTargetMIME()); - documentHandler.setResult(new StreamResult(out)); - documentHandler.setDefaultFontInfo(new FontInfo()); - parser.parse(src, documentHandler, userAgent); - } - - /** {@inheritDoc} */ - @Override - protected Document parseAndRenderToIntermediateFormat(Source src) throws Exception { - IFParser parser = new IFParser(); - - FOUserAgent userAgent = createUserAgent(); - - IFSerializer serializer = new IFSerializer(new IFContext(userAgent)); - DOMResult domResult = new DOMResult(); - serializer.setResult(domResult); - - parser.parse(src, serializer, userAgent); - - return (Document)domResult.getNode(); - } - - @Override - @Test - public void runTest() throws Exception { - try { - testParserToIntermediateFormat(); - testParserToPDF(); - } catch (Exception e) { - org.apache.commons.logging.LogFactory.getLog(this.getClass()).error( - "Error on " + testFile.getName()); - throw e; - } - } -} diff --git a/test/java/org/apache/fop/intermediate/IFTestCase.java b/test/java/org/apache/fop/intermediate/IFTestCase.java deleted file mode 100644 index 562302ba4..000000000 --- a/test/java/org/apache/fop/intermediate/IFTestCase.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.intermediate; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; - -import javax.xml.transform.Source; -import javax.xml.transform.TransformerFactory; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -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.NodeList; - - -/** - * Test case for the IF output. - */ -@RunWith(Parameterized.class) -public class IFTestCase extends AbstractIFTest { - - /** - * Gets the files for this test. - * - * @return a collection of file arrays containing the files to test - * @throws IOException if an error occurs when reading the test files - */ - @Parameters - public static Collection<File[]> getParameters() throws IOException { - File testDir = new File("test/intermediate"); - String[] tests = testDir.list(new FilenameFilter() { - - public boolean accept(File dir, String name) { - return name.endsWith(".xml"); - } - }); - - Collection<File[]> parameters = new ArrayList<File[]>(); - for (String test : tests) { - parameters.add(new File[] { new File(testDir, test) }); - } - return parameters; - } - - private static IFTester ifTester; - - @BeforeClass - public static void setupTestEnvironment() { - File backupDir = new File("build/test-results/intermediate"); - backupDir.mkdirs(); - ifTester = new IFTester(TransformerFactory.newInstance(), backupDir); - } - - /** - * Creates a new test case. - * - * @param test the file containing the test case - * @param ifTester the helper instance that will perform checks - * @throws IOException if an I/O error occurs while loading the test case - */ - public IFTestCase(File test) throws IOException { - super(test); - this.testDir = test.getParentFile(); - } - - @Override - @Test - public void runTest() throws Exception { - Element testRoot = testAssistant.getTestRoot(testFile); - NodeList nodes = testRoot.getElementsByTagName("if-checks"); - if (nodes.getLength() == 0) { - throw new RuntimeException("No IF check found"); - } - Element ifChecks = (Element) nodes.item(0); - - Document doc = buildIntermediateDocument(testAssistant.getTestcase2FOStylesheet()); - ifTester.doIFChecks(testFile.getName(), ifChecks, doc); - } - - @Override - protected void parseAndRender(Source src, OutputStream out) throws Exception { - throw new IllegalStateException("Not applicable to this test"); - } - - @Override - protected Document parseAndRenderToIntermediateFormat(Source src) throws Exception { - throw new IllegalStateException("Not applicable to this test"); - } - -} diff --git a/test/java/org/apache/fop/intermediate/IFTester.java b/test/java/org/apache/fop/intermediate/IFTester.java deleted file mode 100644 index 46303d874..000000000 --- a/test/java/org/apache/fop/intermediate/IFTester.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.intermediate; - -import java.io.File; -import java.util.List; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * Does tests on the intermediate format. - */ -public class IFTester { - - private final IFChecksFactory ifChecksFactory = new IFChecksFactory(); - - private final TransformerFactory tfactory; - - private File backupDir; - - /** - * Main constructor. - * - * @param transformerFactory the factory used to serialize the intermediate format files - * @param backupDir an optional directory in which to write the serialized - * IF files (may be null) - */ - public IFTester(TransformerFactory transformerFactory, File backupDir) { - this.tfactory = transformerFactory; - this.backupDir = backupDir; - } - - /** - * Runs the intermediate format checks. - * @param testName the name of the test case - * @param checksRoot the root element containing the IF checks - * @param ifDocument the IF XML - * @throws TransformerException if an error occurs while transforming the content - */ - public void doIFChecks(String testName, Element checksRoot, Document ifDocument) - throws TransformerException { - if (this.backupDir != null) { - Transformer transformer = tfactory.newTransformer(); - Source src = new DOMSource(ifDocument); - File targetFile = new File(this.backupDir, testName + ".if.xml"); - Result res = new StreamResult(targetFile); - transformer.transform(src, res); - } - List<IFCheck> checks = ifChecksFactory.createCheckList(checksRoot); - if (checks.size() == 0) { - throw new RuntimeException("No available IF check"); - } - for (IFCheck check : checks) { - check.check(ifDocument); - } - } - -} diff --git a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java b/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java deleted file mode 100644 index 71b26cb9b..000000000 --- a/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.intermediate; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * A test suite for testing the Intermediate Format output. - */ -@RunWith(Suite.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 deleted file mode 100644 index ea60f2ff4..000000000 --- a/test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.intermediate; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * JUnit test suite for the intermediate format - */ -@RunWith(Suite.class) -@SuiteClasses(IFParserTestCase.class) -public final class LayoutIFTestSuite { -} diff --git a/test/java/org/apache/fop/intermediate/TestAssistant.java b/test/java/org/apache/fop/intermediate/TestAssistant.java deleted file mode 100644 index d13f88959..000000000 --- a/test/java/org/apache/fop/intermediate/TestAssistant.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 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.intermediate; - -import java.io.File; -import java.io.IOException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import org.apache.xpath.XPathAPI; -import org.apache.xpath.objects.XObject; - -import org.apache.fop.apps.EnvironmentProfile; -import org.apache.fop.apps.EnvironmentalProfileFactory; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.FopFactoryBuilder; -import org.apache.fop.apps.io.ResourceResolverFactory; - -/** - * Helper class for running FOP tests. - */ -public class TestAssistant { - - // configure fopFactory as desired - protected final File testDir = new File("test/layoutengine/standard-testcases"); - - private SAXTransformerFactory tfactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); - - private DocumentBuilderFactory domBuilderFactory; - - private Templates testcase2fo; - private Templates testcase2checks; - - /** - * Main constructor. - */ - public TestAssistant() { - domBuilderFactory = DocumentBuilderFactory.newInstance(); - domBuilderFactory.setNamespaceAware(true); - domBuilderFactory.setValidating(false); - } - - /** - * Returns the stylesheet for convert extracting the XSL-FO part from the test case. - * @return the stylesheet - * @throws TransformerConfigurationException if an error occurs loading the stylesheet - */ - public Templates getTestcase2FOStylesheet() throws TransformerConfigurationException { - if (testcase2fo == null) { - //Load and cache stylesheet - Source src = new StreamSource(new File("test/layoutengine/testcase2fo.xsl")); - testcase2fo = tfactory.newTemplates(src); - } - return testcase2fo; - } - - /** - * Returns the stylesheet for convert extracting the checks from the test case. - * @return the stylesheet - * @throws TransformerConfigurationException if an error occurs loading the stylesheet - */ - private Templates getTestcase2ChecksStylesheet() throws TransformerConfigurationException { - if (testcase2checks == null) { - //Load and cache stylesheet - Source src = new StreamSource(new File("test/layoutengine/testcase2checks.xsl")); - testcase2checks = tfactory.newTemplates(src); - } - return testcase2checks; - } - - /** - * Returns the element from the given XML file that encloses the tests. - * - * @param testFile a test case - * @return the parent element of the group(s) of checks - * @throws TransformerException if an error occurs while extracting the test element - */ - public Element getTestRoot(File testFile) throws TransformerException { - Transformer transformer = getTestcase2ChecksStylesheet().newTransformer(); - DOMResult res = new DOMResult(); - transformer.transform(new StreamSource(testFile), res); - Document doc = (Document) res.getNode(); - return doc.getDocumentElement(); - } - - public FopFactory getFopFactory(Document testDoc) { - EnvironmentProfile envProfile = EnvironmentalProfileFactory.createRestrictedIO( - testDir.getParentFile().toURI(), - ResourceResolverFactory.createDefaultResourceResolver()); - FopFactoryBuilder builder = new FopFactoryBuilder(envProfile); - builder.setStrictFOValidation(isStrictValidation(testDoc)); - builder.getFontManager().setBase14KerningEnabled(isBase14KerningEnabled(testDoc)); - return builder.build(); - } - - private boolean isBase14KerningEnabled(Document testDoc) { - try { - XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/base14kerning"); - String s = xo.str(); - return ("true".equalsIgnoreCase(s)); - } catch (TransformerException e) { - throw new RuntimeException("Error while evaluating XPath expression", e); - } - } - - private boolean isStrictValidation(Document testDoc) { - try { - XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/strict-validation"); - return !("false".equalsIgnoreCase(xo.str())); - } catch (TransformerException e) { - throw new RuntimeException("Error while evaluating XPath expression", e); - } - } - - /** - * Loads a test case into a DOM document. - * @param testFile the test file - * @return the loaded test case - * @throws IOException if an I/O error occurs loading the test case - */ - public Document loadTestCase(File testFile) - throws IOException { - try { - DocumentBuilder builder = domBuilderFactory.newDocumentBuilder(); - Document testDoc = builder.parse(testFile); - return testDoc; - } catch (Exception e) { - throw new IOException("Error while loading test case: " + e.getMessage()); - } - } - - /** - * Serialize the DOM for later inspection. - * @param doc the DOM document - * @param target target file - * @throws TransformerException if a problem occurs during serialization - */ - public void saveDOM(Document doc, File target) throws TransformerException { - Transformer transformer = getTransformerFactory().newTransformer(); - Source src = new DOMSource(doc); - Result res = new StreamResult(target); - transformer.transform(src, res); - } - - /** - * Returns the SAXTransformerFactory. - * @return the SAXTransformerFactory - */ - public SAXTransformerFactory getTransformerFactory() { - return tfactory; - } -} diff --git a/test/java/org/apache/fop/layoutengine/ElementListCheck.java b/test/java/org/apache/fop/layoutengine/ElementListCheck.java deleted file mode 100644 index 4ac29b4cd..000000000 --- a/test/java/org/apache/fop/layoutengine/ElementListCheck.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * 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.layoutengine; - -import java.util.Iterator; -import java.util.List; - -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.KnuthGlue; -import org.apache.fop.layoutmgr.KnuthPenalty; -import org.apache.fop.layoutmgr.ListElement; - -/** - * Check implementation that checks a Knuth element list. - */ -public class ElementListCheck implements LayoutEngineCheck { - - private String category; - private String id; - private int index = -1; - private Element checkElement; - - /** - * Creates a new instance from a DOM node. - * @param node DOM node that defines this check - */ - public ElementListCheck(Node node) { - this.category = node.getAttributes().getNamedItem("category").getNodeValue(); - if (node.getAttributes().getNamedItem("id") != null) { - this.id = node.getAttributes().getNamedItem("id").getNodeValue(); - } - if (!haveID()) { - if (node.getAttributes().getNamedItem("index") != null) { - String s = node.getAttributes().getNamedItem("index").getNodeValue(); - this.index = Integer.parseInt(s); - } - } - this.checkElement = (Element)node; - } - - /** - * @see org.apache.fop.layoutengine.LayoutEngineCheck - */ - public void check(LayoutResult result) { - ElementListCollector.ElementList elementList = findElementList(result); - NodeList children = checkElement.getChildNodes(); - int pos = -1; - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - if (node instanceof Element) { - pos++; - Element domEl = (Element)node; - ListElement knuthEl = (ListElement) elementList.getElementList().get(pos); - if ("skip".equals(domEl.getLocalName())) { - pos += Integer.parseInt(getElementText(domEl)) - 1; - } else if ("box".equals(domEl.getLocalName())) { - if (!(knuthEl instanceof KnuthBox)) { - fail("Expected KnuthBox" - + " at position " + pos - + " but got: " + knuthEl.getClass().getName()); - } - KnuthBox box = (KnuthBox) knuthEl; - if (domEl.getAttribute("w").length() > 0) { - int w = Integer.parseInt(domEl.getAttribute("w")); - if (w != box.getWidth()) { - fail("Expected w=" + w - + " at position " + pos - + " but got: " + box.getWidth()); - } - } - if ("true".equals(domEl.getAttribute("aux"))) { - if (!box.isAuxiliary()) { - fail("Expected auxiliary box" - + " at position " + pos); - } - } - if ("false".equals(domEl.getAttribute("aux"))) { - if (box.isAuxiliary()) { - fail("Expected a normal, not an auxiliary box" - + " at position " + pos); - } - } - } else if ("penalty".equals(domEl.getLocalName())) { - if (!(knuthEl instanceof KnuthPenalty)) { - fail("Expected KnuthPenalty " - + " at position " + pos - + " but got: " + knuthEl.getClass().getName()); - } - KnuthPenalty pen = (KnuthPenalty)knuthEl; - if (domEl.getAttribute("w").length() > 0) { - int w = Integer.parseInt(domEl.getAttribute("w")); - if (w != pen.getWidth()) { - fail("Expected w=" + w - + " at position " + pos - + " but got: " + pen.getWidth()); - } - } - if (domEl.getAttribute("p").length() > 0) { - if ("<0".equals(domEl.getAttribute("p"))) { - if (pen.getPenalty() >= 0) { - fail("Expected p<0" - + " at position " + pos - + " but got: " + pen.getPenalty()); - } - } else if (">0".equals(domEl.getAttribute("p"))) { - if (pen.getPenalty() <= 0) { - fail("Expected p>0" - + " at position " + pos - + " but got: " + pen.getPenalty()); - } - } else { - int p; - if ("INF".equalsIgnoreCase(domEl.getAttribute("p"))) { - p = KnuthPenalty.INFINITE; - } else if ("INFINITE".equalsIgnoreCase(domEl.getAttribute("p"))) { - p = KnuthPenalty.INFINITE; - } else if ("-INF".equalsIgnoreCase(domEl.getAttribute("p"))) { - p = -KnuthPenalty.INFINITE; - } else if ("-INFINITE".equalsIgnoreCase(domEl.getAttribute("p"))) { - p = -KnuthPenalty.INFINITE; - } else { - p = Integer.parseInt(domEl.getAttribute("p")); - } - if (p != pen.getPenalty()) { - fail("Expected p=" + p - + " at position " + pos - + " but got: " + pen.getPenalty()); - } - } - } - if ("true".equals(domEl.getAttribute("flagged"))) { - if (!pen.isPenaltyFlagged()) { - fail("Expected flagged penalty" - + " at position " + pos); - } - } else if ("false".equals(domEl.getAttribute("flagged"))) { - if (pen.isPenaltyFlagged()) { - fail("Expected non-flagged penalty" - + " at position " + pos); - } - } - if ("true".equals(domEl.getAttribute("aux"))) { - if (!pen.isAuxiliary()) { - fail("Expected auxiliary penalty" - + " at position " + pos); - } - } else if ("false".equals(domEl.getAttribute("aux"))) { - if (pen.isAuxiliary()) { - fail("Expected non-auxiliary penalty" - + " at position " + pos); - } - } - } else if ("glue".equals(domEl.getLocalName())) { - if (!(knuthEl instanceof KnuthGlue)) { - fail("Expected KnuthGlue" - + " at position " + pos - + " but got: " + knuthEl.getClass().getName()); - } - KnuthGlue glue = (KnuthGlue)knuthEl; - if (domEl.getAttribute("w").length() > 0) { - int w = Integer.parseInt(domEl.getAttribute("w")); - if (w != glue.getWidth()) { - fail("Expected w=" + w - + " at position " + pos - + " but got: " + glue.getWidth()); - } - } - if (domEl.getAttribute("y").length() > 0) { - int stretch = Integer.parseInt(domEl.getAttribute("y")); - if (stretch != glue.getStretch()) { - fail("Expected y=" + stretch - + " (stretch) at position " + pos - + " but got: " + glue.getStretch()); - } - } - if (domEl.getAttribute("z").length() > 0) { - int shrink = Integer.parseInt(domEl.getAttribute("z")); - if (shrink != glue.getShrink()) { - fail("Expected z=" + shrink - + " (shrink) at position " + pos - + " but got: " + glue.getShrink()); - } - } - } else { - throw new IllegalArgumentException("Invalid child node for 'element-list': " - + domEl.getLocalName() - + " at position " + pos + " (" + this + ")"); - } - - } - } - pos++; - if (elementList.getElementList().size() > pos) { - fail("There are " - + (elementList.getElementList().size() - pos) - + " unchecked elements at the end of the list"); - } - } - - private void fail(String msg) { - throw new AssertionError(msg + " (" + this + ")"); - } - - private boolean haveID() { - return (this.id != null && this.id.length() > 0); - } - - private ElementListCollector.ElementList findElementList(LayoutResult result) { - List candidates = new java.util.ArrayList(); - Iterator iter = result.getElementListCollector().getElementLists().iterator(); - while (iter.hasNext()) { - ElementListCollector.ElementList el = (ElementListCollector.ElementList)iter.next(); - if (el.getCategory().equals(category)) { - if (haveID() && this.id.equals(el.getID())) { - candidates.add(el); - break; - } else if (!haveID()) { - candidates.add(el); - } - } - } - if (candidates.size() == 0) { - throw new ArrayIndexOutOfBoundsException("Requested element list not found"); - } else if (index >= 0) { - return (ElementListCollector.ElementList)candidates.get(index); - } else { - return (ElementListCollector.ElementList)candidates.get(0); - } - } - - private static String getElementText(Element el) { - StringBuffer sb = new StringBuffer(); - NodeList children = el.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - if (node instanceof Text) { - sb.append(((Text)node).getData()); - } else if (node instanceof CDATASection) { - sb.append(((CDATASection)node).getData()); - } - } - return sb.toString(); - } - - /** @see java.lang.Object#toString() */ - public String toString() { - StringBuffer sb = new StringBuffer("element-list"); - sb.append(" category=").append(category); - if (haveID()) { - sb.append(" id=").append(id); - } else if (index >= 0) { - sb.append(" index=").append(index); - } - return sb.toString(); - } -} diff --git a/test/java/org/apache/fop/layoutengine/ElementListCollector.java b/test/java/org/apache/fop/layoutengine/ElementListCollector.java deleted file mode 100644 index 1890ee86f..000000000 --- a/test/java/org/apache/fop/layoutengine/ElementListCollector.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.layoutengine; - -import java.util.List; - -import org.apache.fop.layoutmgr.ElementListObserver.Observer; - -/** - * This class collects element list generated during a FOP processing run. These lists are later - * used to perform automated checks. - */ -public class ElementListCollector implements Observer { - - private List elementLists = new java.util.ArrayList(); - - /** - * Resets the collector. - */ - public void reset() { - elementLists.clear(); - } - - /** - * @return the list of ElementList instances. - */ - public List getElementLists() { - return this.elementLists; - } - - /** @see org.apache.fop.layoutmgr.ElementListObserver.Observer */ - public void observe(List elementList, String category, String id) { - elementLists.add(new ElementList(elementList, category, id)); - } - - /** - * Data object representing an element list along with additional information. - */ - public static class ElementList { - - private List elementList; - private String category; - private String id; - - /** - * Creates a new ElementList instance - * @param elementList the element list - * @param category the category for the element list - * @param id an optional ID - */ - public ElementList(List elementList, String category, String id) { - this.elementList = elementList; - this.category = category; - this.id = id; - } - - /** @return the element list */ - public List getElementList() { - return elementList; - } - - /** @return the category */ - public String getCategory() { - return category; - } - - /** @return the ID, may be null */ - public String getID() { - return id; - } - } - -} diff --git a/test/java/org/apache/fop/layoutengine/EvalCheck.java b/test/java/org/apache/fop/layoutengine/EvalCheck.java deleted file mode 100644 index 2af8884dd..000000000 --- a/test/java/org/apache/fop/layoutengine/EvalCheck.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.layoutengine; - -import javax.xml.transform.TransformerException; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -import org.apache.xml.utils.PrefixResolver; -import org.apache.xml.utils.PrefixResolverDefault; -import org.apache.xpath.XPathAPI; -import org.apache.xpath.objects.XObject; - -import org.apache.fop.intermediate.IFCheck; - -/** - * Simple check that requires an XPath expression to evaluate to true. - */ -public class EvalCheck implements LayoutEngineCheck, IFCheck { - - private String expected; - private String xpath; - private double tolerance; - private PrefixResolver prefixResolver; - - /** - * Creates a new instance from a DOM node. - * @param node DOM node that defines this check - */ - public EvalCheck(Node node) { - this.expected = node.getAttributes().getNamedItem("expected").getNodeValue(); - this.xpath = node.getAttributes().getNamedItem("xpath").getNodeValue(); - Node nd = node.getAttributes().getNamedItem("tolerance"); - if (nd != null) { - this.tolerance = Double.parseDouble(nd.getNodeValue()); - } - this.prefixResolver = new PrefixResolverDefault(node); - } - - /** {@inheritDoc} */ - public void check(LayoutResult result) { - doCheck(result.getAreaTree()); - } - - /** {@inheritDoc} */ - public void check(Document intermediate) { - doCheck(intermediate); - } - - private void doCheck(Document doc) { - XObject res; - try { - res = XPathAPI.eval(doc, xpath, prefixResolver); - } catch (TransformerException e) { - throw new RuntimeException("XPath evaluation failed: " + e.getMessage()); - } - String actual = res.str(); //Second str() seems to fail. D'oh! - if (tolerance != 0) { - double v1 = Double.parseDouble(expected); - double v2 = Double.parseDouble(actual); - if (Math.abs(v1 - v2) > tolerance) { - throw new AssertionError( - "Expected XPath expression to evaluate to '" + expected + "', but got '" - + actual + "' (" + this + ", outside tolerance)"); - } - } else { - if (!expected.equals(actual)) { - throw new AssertionError( - "Expected XPath expression to evaluate to '" + expected + "', but got '" - + actual + "' (" + this + ")"); - } - } - } - - /** {@inheritDoc} */ - public String toString() { - return "XPath: " + xpath; - } - -} diff --git a/test/java/org/apache/fop/layoutengine/HyphenationLayoutTestCase.java b/test/java/org/apache/fop/layoutengine/HyphenationLayoutTestCase.java deleted file mode 100644 index 6b5ebbf71..000000000 --- a/test/java/org/apache/fop/layoutengine/HyphenationLayoutTestCase.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.layoutengine; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; - -import org.junit.runners.Parameterized.Parameters; - -/** - * Class for testing the FOP's hyphenation layout engine using testcases specified in XML - * files. - */ -public class HyphenationLayoutTestCase extends LayoutEngineTestCase { - - /** - * Creates the parameters for this test. - * - * @return the list of file arrays populated with test files - * @throws IOException if an I/O error occurs while reading the test file - */ - @Parameters - public static Collection<File[]> getParameters() throws IOException { - return LayoutEngineTestUtils.getLayoutTestFiles("hyphenation-testcases"); - } - - /** - * Constructor - * @param testFile the file to test - */ - public HyphenationLayoutTestCase(File testFile) { - super(testFile); - } - -} diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java b/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java deleted file mode 100644 index ca979efe5..000000000 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineCheck.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.layoutengine; - -import org.apache.fop.check.Check; - -/** - * Defines the interface for check operations. - */ -public interface LayoutEngineCheck extends Check { - - /** - * Called to perform the check. - * @param result the results from the processing run - */ - void check(LayoutResult result); - -} diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineChecksFactory.java b/test/java/org/apache/fop/layoutengine/LayoutEngineChecksFactory.java deleted file mode 100644 index 9883a9a74..000000000 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineChecksFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.layoutengine; - -import org.w3c.dom.Element; - -import org.apache.fop.check.ChecksFactory; - -/** - * A factory class for creating {@link LayoutEngineCheck} instances. - */ -public final class LayoutEngineChecksFactory extends ChecksFactory<LayoutEngineCheck> { - - public LayoutEngineChecksFactory() { - registerCheckFactory("true", new CheckFactory<LayoutEngineCheck>() { - - public LayoutEngineCheck createCheck(Element element) { - return new TrueCheck(element); - } - - }); - registerCheckFactory("eval", new CheckFactory<LayoutEngineCheck>() { - - public LayoutEngineCheck createCheck(Element element) { - return new EvalCheck(element); - } - - }); - registerCheckFactory("element-list", new CheckFactory<LayoutEngineCheck>() { - - public LayoutEngineCheck createCheck(Element element) { - return new ElementListCheck(element); - } - - }); - registerCheckFactory("result", new CheckFactory<LayoutEngineCheck>() { - - public LayoutEngineCheck createCheck(Element element) { - return new ResultCheck(element); - } - - }); - } - -} diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java deleted file mode 100644 index 57607e475..000000000 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * 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.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; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.TransformerHandler; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -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; -import org.apache.fop.apps.FopFactory; -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; -import org.apache.fop.intermediate.TestAssistant; -import org.apache.fop.layoutmgr.ElementListObserver; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFRenderer; -import org.apache.fop.render.intermediate.IFSerializer; -import org.apache.fop.render.xml.XMLRenderer; -import org.apache.fop.util.ConsoleEventListenerForTests; -import org.apache.fop.util.DelegatingContentHandler; - -/** - * Class for testing the FOP's layout engine using testcases specified in XML - * files. - */ -@RunWith(Parameterized.class) -public class LayoutEngineTestCase { - private static File areaTreeBackupDir; - - @BeforeClass - public static void makeDirAndRegisterDebugHelper() throws IOException { - DebugHelper.registerStandardElementListObservers(); - areaTreeBackupDir = new File("build/test-results/layoutengine"); - if (!areaTreeBackupDir.mkdirs() && !areaTreeBackupDir.exists()) { - throw new IOException("Failed to create the layout engine directory at " - + "build/test-results/layoutengine"); - } - } - - /** - * Creates the parameters for this test. - * - * @return the list of file arrays populated with test files - * @throws IOException if an I/O error occurs while reading the test file - */ - @Parameters - public static Collection<File[]> getParameters() throws IOException { - return LayoutEngineTestUtils.getLayoutTestFiles(); - } - - private TestAssistant testAssistant = new TestAssistant(); - - private LayoutEngineChecksFactory layoutEngineChecksFactory = new LayoutEngineChecksFactory(); - - private IFTester ifTester; - private File testFile; - - private TransformerFactory tfactory = TransformerFactory.newInstance(); - - /** - * Constructs a new instance. - * - * @param testFile the test file - */ - public LayoutEngineTestCase(File testFile) { - this.ifTester = new IFTester(tfactory, areaTreeBackupDir); - this.testFile = testFile; - } - - /** - * Runs a single layout engine test case. - * @throws TransformerException In case of an XSLT/JAXP problem - * @throws IOException In case of an I/O problem - * @throws SAXException In case of a problem during SAX processing - * @throws ParserConfigurationException In case of a problem with the XML parser setup - */ - @Test - public void runTest() throws TransformerException, SAXException, IOException, - ParserConfigurationException { - - DOMResult domres = new DOMResult(); - - ElementListCollector elCollector = new ElementListCollector(); - ElementListObserver.addObserver(elCollector); - - Fop fop; - FopFactory effFactory; - EventsChecker eventsChecker = new EventsChecker( - new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN)); - try { - Document testDoc = testAssistant.loadTestCase(testFile); - effFactory = testAssistant.getFopFactory(testDoc); - - //Setup Transformer to convert the testcase XML to XSL-FO - Transformer transformer = testAssistant.getTestcase2FOStylesheet().newTransformer(); - Source src = new DOMSource(testDoc); - - //Setup Transformer to convert the area tree to a DOM - TransformerHandler athandler; - athandler = testAssistant.getTransformerFactory().newTransformerHandler(); - athandler.setResult(domres); - - //Setup FOP for area tree rendering - FOUserAgent ua = effFactory.newFOUserAgent(); - ua.getEventBroadcaster().addEventListener(eventsChecker); - - XMLRenderer atrenderer = new XMLRenderer(ua); - atrenderer.setContentHandler(athandler); - ua.setRendererOverride(atrenderer); - fop = effFactory.newFop(ua); - - SAXResult fores = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, fores); - } finally { - ElementListObserver.removeObserver(elCollector); - } - - Document doc = (Document)domres.getNode(); - if (areaTreeBackupDir != null) { - testAssistant.saveDOM(doc, - new File(areaTreeBackupDir, testFile.getName() + ".at.xml")); - } - FormattingResults results = fop.getResults(); - LayoutResult result = new LayoutResult(doc, elCollector, results); - 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); - } - } - } - - /** - * Perform all checks on the area tree and, optionally, on the intermediate format. - * @param fopFactory the FOP factory - * @param testFile Test case XML file - * @param result The layout results - * @throws TransformerException if a problem occurs in XSLT/JAXP - */ - protected void checkAll(FopFactory fopFactory, File testFile, LayoutResult result, - EventsChecker eventsChecker) throws TransformerException { - Element testRoot = testAssistant.getTestRoot(testFile); - - NodeList nodes; - //AT tests only when checks are available - nodes = testRoot.getElementsByTagName("at-checks"); - if (nodes.getLength() > 0) { - Element atChecks = (Element)nodes.item(0); - doATChecks(atChecks, result); - } - - //IF tests only when checks are available - nodes = testRoot.getElementsByTagName("if-checks"); - if (nodes.getLength() > 0) { - Element ifChecks = (Element)nodes.item(0); - 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) - throws TransformerException { - try { - FOUserAgent ua = fopFactory.newFOUserAgent(); - ua.getEventBroadcaster().addEventListener( - new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN)); - - IFRenderer ifRenderer = new IFRenderer(ua); - - IFSerializer serializer = new IFSerializer(new IFContext(ua)); - DOMResult result = new DOMResult(); - serializer.setResult(result); - ifRenderer.setDocumentHandler(serializer); - - ua.setRendererOverride(ifRenderer); - FontInfo fontInfo = new FontInfo(); - //Construct the AreaTreeModel that will received the individual pages - final AreaTreeModel treeModel = new RenderPagesModel(ua, - null, fontInfo, null); - - //Iterate over all intermediate files - AreaTreeParser parser = new AreaTreeParser(); - ContentHandler handler = parser.getContentHandler(treeModel, ua); - - DelegatingContentHandler proxy = new DelegatingContentHandler() { - - public void endDocument() throws SAXException { - super.endDocument(); - //Signal the end of the processing. - //The renderer can finalize the target document. - treeModel.endDocument(); - } - - }; - proxy.setDelegateContentHandler(handler); - - Transformer transformer = tfactory.newTransformer(); - transformer.transform(new DOMSource(areaTreeXML), new SAXResult(proxy)); - - return (Document)result.getNode(); - } catch (Exception e) { - throw new TransformerException( - "Error while generating intermediate format file: " + e.getMessage(), e); - } - } - - private void doATChecks(Element checksRoot, LayoutResult result) { - List<LayoutEngineCheck> checks = layoutEngineChecksFactory.createCheckList(checksRoot); - if (checks.size() == 0) { - throw new RuntimeException("No available area tree check"); - } - for (LayoutEngineCheck check : checks) { - try { - check.check(result); - } catch (AssertionError ae) { - throw new AssertionError("Layout test (" + testFile.getName() + "): " + ae.getMessage()); - } catch (RuntimeException rte) { - throw new RuntimeException("Layout test (" + testFile.getName() + "): " + rte.getMessage()); - } - } - } - - 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 deleted file mode 100644 index 89bf28a55..000000000 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.layoutengine; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * JUnit test suit for running layout engine test under JUnit control. - */ -@RunWith(Suite.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 deleted file mode 100644 index 2649838f4..000000000 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * 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.layoutengine; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.AndFileFilter; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.NameFileFilter; -import org.apache.commons.io.filefilter.NotFileFilter; -import org.apache.commons.io.filefilter.PrefixFileFilter; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.apache.commons.io.filefilter.TrueFileFilter; - -/** - * Utility class for layout engine tests. - */ -public final class LayoutEngineTestUtils { - - /** Set this to true to get the correspondence between test number and test file. */ - private static final boolean DEBUG = false; - - private LayoutEngineTestUtils() { - } - - private static class FilenameHandler extends DefaultHandler { - private StringBuffer buffer = new StringBuffer(128); - private boolean readingFilename; - private List<String> filenames; - - public FilenameHandler(List<String> filenames) { - this.filenames = filenames; - } - - public void startElement(String namespaceURI, String localName, String qName, - Attributes atts) throws SAXException { - if (qName != null && qName.equals("file")) { - buffer.setLength(0); - readingFilename = true; - } else { - throw new RuntimeException( - "Unexpected element while reading disabled testcase file names: " + qName); - } - } - - public void endElement(String namespaceURI, String localName, String qName) - throws SAXException { - if (qName != null && qName.equals("file")) { - readingFilename = false; - filenames.add(buffer.toString()); - } else { - throw new RuntimeException( - "Unexpected element while reading disabled testcase file names: " + qName); - } - } - - public void characters(char[] ch, int start, int length) throws SAXException { - if (readingFilename) { - buffer.append(ch, start, length); - } - } - } - - /** - * Removes from {@code filter} any tests that have been disabled. - * - * @param filter the filter populated with tests - * @param disabled name of the file containing disabled test cases. If null or empty, - * no file is read - * @return {@code filter} minus any disabled tests - */ - public static IOFileFilter decorateWithDisabledList(IOFileFilter filter, String disabled) { - if (disabled != null && disabled.length() > 0) { - filter = new AndFileFilter(new NotFileFilter(new NameFileFilter( - LayoutEngineTestUtils.readDisabledTestcases(new File(disabled)))), filter); - } - return filter; - } - - private static String[] readDisabledTestcases(File f) { - List<String> lines = new ArrayList<String>(); - Source stylesheet = new StreamSource( - new File("test/layoutengine/disabled-testcase2filename.xsl")); - Source source = new StreamSource(f); - Result result = new SAXResult(new FilenameHandler(lines)); - try { - Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesheet); - transformer.transform(source, result); - } catch (TransformerConfigurationException tce) { - throw new RuntimeException(tce); - } catch (TransformerException te) { - throw new RuntimeException(te); - } - return (String[]) lines.toArray(new String[lines.size()]); - } - - /** - * Returns the test files matching the given configuration. - * - * @param testConfig the test configuration - * @return the applicable test cases - */ - public static Collection<File[]> getTestFiles(TestFilesConfiguration testConfig) { - File mainDir = testConfig.getTestDirectory(); - IOFileFilter filter; - String single = testConfig.getSingleTest(); - String startsWith = testConfig.getStartsWith(); - if (single != null) { - filter = new NameFileFilter(single); - } else if (startsWith != null) { - filter = new PrefixFileFilter(startsWith); - filter = new AndFileFilter(filter, new SuffixFileFilter(testConfig.getFileSuffix())); - filter = decorateWithDisabledList(filter, testConfig.getDisabledTests()); - } else { - filter = new SuffixFileFilter(testConfig.getFileSuffix()); - filter = decorateWithDisabledList(filter, testConfig.getDisabledTests()); - } - String testset = testConfig.getTestSet(); - - Collection<File> files = FileUtils.listFiles(new File(mainDir, testset), filter, - TrueFileFilter.INSTANCE); - if (testConfig.hasPrivateTests()) { - Collection<File> privateFiles = FileUtils.listFiles(new File(mainDir, - "private-testcases"), filter, TrueFileFilter.INSTANCE); - files.addAll(privateFiles); - } - - Collection<File[]> parametersForJUnit4 = new ArrayList<File[]>(); - int index = 0; - for (File f : files) { - parametersForJUnit4.add(new File[] {f}); - if (DEBUG) { - System.out.println(String.format("%3d %s", index++, f)); - } - } - - return parametersForJUnit4; - } - - /** - * This is a helper method that uses the standard parameters for FOP's layout engine tests and - * returns a set of test files. These pull in System parameters to configure the layout tests - * to run. - * - * @return A collection of file arrays that contain the test files - */ - public static Collection<File[]> getLayoutTestFiles() { - String testSet = System.getProperty("fop.layoutengine.testset"); - testSet = (testSet != null ? testSet : "standard") + "-testcases"; - return getLayoutTestFiles(testSet); - } - - /** - * This is a helper method that uses the standard parameters for FOP's layout engine tests, - * given a test set name returns a set of test files. - * - * @param testSetName the name of the test set - * @return A collection of file arrays that contain the test files - */ - public static Collection<File[]> getLayoutTestFiles(String testSetName) { - TestFilesConfiguration.Builder builder = new TestFilesConfiguration.Builder(); - - builder.testDir("test/layoutengine") - .singleProperty("fop.layoutengine.single") - .startsWithProperty("fop.layoutengine.starts-with") - .suffix(".xml") - .testSet(testSetName) - .disabledProperty("fop.layoutengine.disabled", - "test/layoutengine/disabled-testcases.xml") - .privateTestsProperty("fop.layoutengine.private"); - - TestFilesConfiguration testConfig = builder.build(); - return getTestFiles(testConfig); - } - -} diff --git a/test/java/org/apache/fop/layoutengine/LayoutResult.java b/test/java/org/apache/fop/layoutengine/LayoutResult.java deleted file mode 100644 index 92c459234..000000000 --- a/test/java/org/apache/fop/layoutengine/LayoutResult.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.layoutengine; - -import org.w3c.dom.Document; - -import org.apache.fop.apps.FormattingResults; - -/** - * This class holds references to all the results from the FOP processing run. - */ -public class LayoutResult { - - private Document areaTree; - private ElementListCollector elCollector; - private FormattingResults results; - - /** - * Creates a new LayoutResult instance. - * @param areaTree the area tree DOM - * @param elCollector the element list collector - * @param results the formatting results - */ - public LayoutResult(Document areaTree, ElementListCollector elCollector, - FormattingResults results) { - this.areaTree = areaTree; - this.elCollector = elCollector; - this.results = results; - } - - /** @return the generated area tree as DOM tree */ - public Document getAreaTree() { - return this.areaTree; - } - - /** @return the element list collector */ - public ElementListCollector getElementListCollector() { - return this.elCollector; - } - - /** - * @return Returns the results. - */ - public FormattingResults getResults() { - return results; - } - -} diff --git a/test/java/org/apache/fop/layoutengine/ResultCheck.java b/test/java/org/apache/fop/layoutengine/ResultCheck.java deleted file mode 100644 index 7289757fb..000000000 --- a/test/java/org/apache/fop/layoutengine/ResultCheck.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.layoutengine; - -import org.w3c.dom.Node; - -import org.apache.fop.apps.FormattingResults; - -/** - * Simple check that requires a result property to evaluate to the expected value - */ -public class ResultCheck implements LayoutEngineCheck { - - private String expected; - private String property; - - /** - * Creates a new instance from a DOM node. - * @param node DOM node that defines this check - */ - public ResultCheck(Node node) { - this.expected = node.getAttributes().getNamedItem("expected").getNodeValue(); - this.property = node.getAttributes().getNamedItem("property").getNodeValue(); - } - - /** {@inheritDoc} */ - public void check(LayoutResult result) { - FormattingResults results = result.getResults(); - String actual; - if (property.equals("pagecount")) { - actual = Integer.toString(results.getPageCount()); - } else { - throw new RuntimeException("No such property test: " + property); - } - if (!expected.equals(actual)) { - throw new AssertionError( - "Expected property to evaluate to '" + expected + "', but got '" - + actual + "' (" + this + ")"); - } - - } - - @Override - public String toString() { - return "Property: " + property; - } - -} diff --git a/test/java/org/apache/fop/layoutengine/TestFilesConfiguration.java b/test/java/org/apache/fop/layoutengine/TestFilesConfiguration.java deleted file mode 100644 index 656fc5f6f..000000000 --- a/test/java/org/apache/fop/layoutengine/TestFilesConfiguration.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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.layoutengine; - -import java.io.File; - -/** - * A class that contains the information needed to run a suite of layout engine and FO tree - * tests. - */ -public final class TestFilesConfiguration { - - private final File testDirectory; - private final String singleTest; - private final String testStartsWith; - private final String testFileSuffix; - private final String testSet; - private final String disabledTests; - private final boolean privateTests; - - private TestFilesConfiguration(Builder builder) { - this.testDirectory = new File(builder.testDirectory); - this.singleTest = builder.singleTest; - this.testStartsWith = builder.testStartsWith; - this.testFileSuffix = builder.testFileSuffix; - this.testSet = builder.testSet; - this.privateTests = builder.privateTests; - this.disabledTests = builder.disabledTests; - } - - /** - * Returns the directory of the tests. - * @return the test directory - */ - public File getTestDirectory() { - return testDirectory; - } - - /** - * Returns the name of the single test file to run. - * @return the single test file name - */ - public String getSingleTest() { - return singleTest; - } - - /** - * Returns the string that must prefix the test file names. - * @return the prefixing string - */ - public String getStartsWith() { - return testStartsWith; - } - - /** - * Returns the file suffix (i.e. ".xml" for XML files and ".fo" for FOs). - * @return the file suffix - */ - public String getFileSuffix() { - return testFileSuffix; - } - - /** - * Returns the directory set of tests to be run. - * @return the directory tests - */ - public String getTestSet() { - return testSet; - } - - /** - * Returns the name of the XML file containing the disabled tests. - * @return a file name, may be null - */ - public String getDisabledTests() { - return disabledTests; - } - - /** - * Whether any private tests should be invoked. - * @return true if private tests should be tested - */ - public boolean hasPrivateTests() { - return privateTests; - } - - /** - * A builder class that configures the data for running a suite of tests designed for the - * layout engine and FOTree. - */ - public static class Builder { - - private String testDirectory; - private String singleTest; - private String testStartsWith; - private String testFileSuffix; - private String testSet; - private String disabledTests; - private boolean privateTests; - - /** - * Configures the test directory. - * @param dir the test directory - * @return {@code this} - */ - public Builder testDir(String dir) { - testDirectory = dir; - return this; - } - - /** - * Configures the name of the single test to run. - * @param singleProperty name of the property that determines the single test case - * @return {@code this} - */ - public Builder singleProperty(String singleProperty) { - singleTest = getSystemProperty(singleProperty); - return this; - } - - /** - * Configures the prefix that all test cases must match. - * @param startsWithProperty name of the property that determines the common prefix - * @return {@code this} - */ - public Builder startsWithProperty(String startsWithProperty) { - testStartsWith = getSystemProperty(startsWithProperty); - return this; - } - - /** - * Configures the test file name suffix. - * @param suffix the suffixing string - * @return {@code this} - */ - public Builder suffix(String suffix) { - testFileSuffix = suffix; - return this; - } - - /** - * Configures the name of the directory containing the set of tests. - * @param testSet the directory of tests. If null, defaults to "standard-testcases" - * @return {@code this} - */ - public Builder testSet(String testSet) { - this.testSet = testSet != null ? testSet : "standard-testcases"; - return this; - } - - /** - * Configures whether any tests are disabled. - * @param disabledProperty name of the property that determines the file of - * disabled test cases - * @param defaultValue if the property was not defined, uses this file name - * instead - * @return {@code this} - */ - public Builder disabledProperty(String disabledProperty, String defaultValue) { - String property = getSystemProperty(disabledProperty); - disabledTests = property != null ? property : defaultValue; - return this; - } - - /** - * Configures whether private tests must be run or not. - * @param privateTestsProperty name of the property containing the boolean switch - * @return {@code this} - */ - public Builder privateTestsProperty(String privateTestsProperty) { - String property = getSystemProperty(privateTestsProperty); - this.privateTests = property != null && property.equalsIgnoreCase("true"); - return this; - } - - private String getSystemProperty(String property) { - return System.getProperty(property); - } - - /** - * Creates the configuration instance. - * @return a configuration instance configured by this builder - */ - public TestFilesConfiguration build() { - return new TestFilesConfiguration(this); - } - } -} diff --git a/test/java/org/apache/fop/layoutengine/TrueCheck.java b/test/java/org/apache/fop/layoutengine/TrueCheck.java deleted file mode 100644 index 5509d754d..000000000 --- a/test/java/org/apache/fop/layoutengine/TrueCheck.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.layoutengine; - -import javax.xml.transform.TransformerException; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -import org.apache.xml.utils.PrefixResolver; -import org.apache.xml.utils.PrefixResolverDefault; -import org.apache.xpath.XPathAPI; -import org.apache.xpath.objects.XBoolean; -import org.apache.xpath.objects.XObject; - -import org.apache.fop.intermediate.IFCheck; - -/** - * Simple check that requires an XPath expression to evaluate to true. - */ -public class TrueCheck implements LayoutEngineCheck, IFCheck { - - private String xpath; - private String failureMessage; - private PrefixResolver prefixResolver; - - /** - * Creates a new instance from a DOM node. - * @param node DOM node that defines this check - */ - public TrueCheck(Node node) { - this.xpath = node.getAttributes().getNamedItem("xpath").getNodeValue(); - Node nd = node.getAttributes().getNamedItem("fail-msg"); - if (nd != null) { - this.failureMessage = nd.getNodeValue(); - } - this.prefixResolver = new PrefixResolverDefault(node); - } - - /** {@inheritDoc} */ - public void check(LayoutResult result) { - doCheck(result.getAreaTree()); - } - - /** {@inheritDoc} */ - public void check(Document intermediate) { - doCheck(intermediate); - } - - private void doCheck(Document doc) { - XObject res; - try { - res = XPathAPI.eval(doc, xpath, prefixResolver); - } catch (TransformerException e) { - throw new RuntimeException("XPath evaluation failed: " + e.getMessage()); - } - if (!XBoolean.S_TRUE.equals(res)) { - if (failureMessage != null) { - throw new AssertionError(failureMessage); - } else { - throw new AssertionError( - "Expected XPath expression to evaluate to 'true', but got '" - + res + "' (" + this + ")"); - } - } - - } - - /** {@inheritDoc} */ - public String toString() { - return "XPath: " + xpath; - } - -} diff --git a/test/java/org/apache/fop/layoutmgr/BreakElementTestCase.java b/test/java/org/apache/fop/layoutmgr/BreakElementTestCase.java deleted file mode 100644 index c836bce7c..000000000 --- a/test/java/org/apache/fop/layoutmgr/BreakElementTestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.layoutmgr; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -import org.apache.fop.fo.Constants; - -public class BreakElementTestCase { - - /** - * Tests that the constructor sets the break class to a valid default value. - */ - @Test - public void breakClassMustBeValid() { - LayoutContext context = LayoutContext.newInstance(); - BreakElement breakElement = new BreakElement(new Position(null), 0, context); - assertEquals(Constants.EN_AUTO, breakElement.getBreakClass()); - } -} diff --git a/test/java/org/apache/fop/layoutmgr/PageSequenceLayoutManagerTestCase.java b/test/java/org/apache/fop/layoutmgr/PageSequenceLayoutManagerTestCase.java deleted file mode 100644 index e810f80c5..000000000 --- a/test/java/org/apache/fop/layoutmgr/PageSequenceLayoutManagerTestCase.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.layoutmgr; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.area.AreaTreeHandler; -import org.apache.fop.area.PageViewport; -import org.apache.fop.fo.pagination.Flow; -import org.apache.fop.fo.pagination.PageSequence; -import org.apache.fop.fo.pagination.Region; -import org.apache.fop.fo.pagination.Root; -import org.apache.fop.fo.pagination.SimplePageMaster; - -public class PageSequenceLayoutManagerTestCase { - - private static final String MAIN_FLOW_NAME = "main"; - private static final String EMPTY_FLOW_NAME = "empty"; - - /** - * Blank pages can be created from empty pages - * - * @throws Exception - */ - @Test - public void testGetNextPageBlank() throws Exception { - - final Page expectedPage = createPageForRegionName(EMPTY_FLOW_NAME); - final Page[] providedPages = new Page[]{expectedPage}; - - testGetNextPage(providedPages, expectedPage, true); - } - - /** - * Empty pages should not be provided by the PageSequenceLayoutManager - * to layout the main flow - * - * @throws Exception - */ - @Test - public void testGetNextPageFirstEmpty() throws Exception { - - final Page emptyPage = createPageForRegionName(EMPTY_FLOW_NAME); - final Page expectedPage = createPageForRegionName(MAIN_FLOW_NAME); - final Page[] providedPages = new Page[]{emptyPage, expectedPage}; - - testGetNextPage(providedPages, expectedPage, false); - } - - private void testGetNextPage(final Page[] providedPages, Page expectedPage, boolean isBlank) { - - final Flow flow = mock(Flow.class); - final PageSequence pseq = mock(PageSequence.class); - final Root root = mock(Root.class); - final AreaTreeHandler ath = mock(AreaTreeHandler.class); - - when(flow.getFlowName()).thenReturn(MAIN_FLOW_NAME); - when(pseq.getMainFlow()).thenReturn(flow); - when(pseq.getRoot()).thenReturn(root); - - PageSequenceLayoutManager sut = new PageSequenceLayoutManager(ath, pseq) { - - @Override - protected Page createPage(int i, boolean b) { - return providedPages[i - 1]; - } - - @Override - protected void finishPage() { - //nop - } - - // Expose the protected method for testing - public Page makeNewPage(boolean isBlank) { - return super.makeNewPage(isBlank); - } - }; - - assertEquals(expectedPage, sut.makeNewPage(isBlank)); - } - - - private static Page createPageForRegionName(final String regionName) { - final Page page = mock(Page.class); - final SimplePageMaster spm = mock(SimplePageMaster.class); - final PageViewport pageViewport = mock(PageViewport.class); - final Region region = mock(Region.class); - - when(page.getSimplePageMaster()).thenReturn(spm); - when(page.getPageViewport()).thenReturn(pageViewport); - when(spm.getRegion(anyInt())).thenReturn(region); - - when(region.getRegionName()).thenReturn(regionName); - - return page; - } -} diff --git a/test/java/org/apache/fop/layoutmgr/RetrieveTableMarkerLayoutManagerMakerTestCase.java b/test/java/org/apache/fop/layoutmgr/RetrieveTableMarkerLayoutManagerMakerTestCase.java deleted file mode 100644 index 6a37de33c..000000000 --- a/test/java/org/apache/fop/layoutmgr/RetrieveTableMarkerLayoutManagerMakerTestCase.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.layoutmgr; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.FObj.FObjIterator; -import org.apache.fop.fo.flow.RetrieveTableMarker; -import org.apache.fop.layoutmgr.LayoutManagerMapping.RetrieveTableMarkerLayoutManagerMaker; - -public class RetrieveTableMarkerLayoutManagerMakerTestCase { - - @Test - public void testMake() throws FOPException { - // mock - FObjIterator foi = mock(FObjIterator.class); - when(foi.hasNext()).thenReturn(true).thenReturn(false); - // mock - RetrieveTableMarker rtm = mock(RetrieveTableMarker.class); - // real RTMLMM, not mock - List l = new ArrayList(); - LayoutManagerMapping lmm = new LayoutManagerMapping(); - RetrieveTableMarkerLayoutManagerMaker rtmlmm = lmm.new RetrieveTableMarkerLayoutManagerMaker(); - // test the case rtm has no child nodes - when(rtm.getChildNodes()).thenReturn(null); - rtmlmm.make(rtm, l); - assertTrue(l.size() == 1); - assertTrue(l.get(0) instanceof RetrieveTableMarkerLayoutManager); - } - -} diff --git a/test/java/org/apache/fop/layoutmgr/RetrieveTableMarkerLayoutManagerTestCase.java b/test/java/org/apache/fop/layoutmgr/RetrieveTableMarkerLayoutManagerTestCase.java deleted file mode 100644 index fda9cbccb..000000000 --- a/test/java/org/apache/fop/layoutmgr/RetrieveTableMarkerLayoutManagerTestCase.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.layoutmgr; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.fop.fo.Constants; -import org.apache.fop.fo.flow.RetrieveTableMarker; -import org.apache.fop.fo.flow.table.Table; -import org.apache.fop.layoutmgr.inline.TextLayoutManager; -import org.apache.fop.layoutmgr.table.TableLayoutManager; - -public class RetrieveTableMarkerLayoutManagerTestCase { - - @Test - public void testGetNextKnuthElementsLayoutContextInt() { - LayoutContext lc = LayoutContext.newInstance(); - // mock - Table t = mock(Table.class); - // mock - RetrieveTableMarker rtm = mock(RetrieveTableMarker.class); - when(rtm.getRetrieveClassName()).thenReturn("A"); - when(rtm.getPosition()).thenReturn(Constants.EN_FIRST_STARTING); - when(rtm.getBoundary()).thenReturn(Constants.EN_TABLE_FRAGMENT); - // mock - TextLayoutManager tlm = mock(TextLayoutManager.class); - // mock - LayoutManagerMapping lmm = mock(LayoutManagerMapping.class); - when(lmm.makeLayoutManager(rtm)).thenReturn(tlm); - // mock - PageSequenceLayoutManager pslm = mock(PageSequenceLayoutManager.class); - when(pslm.getPSLM()).thenReturn(pslm); - when(pslm.getLayoutManagerMaker()).thenReturn(lmm); - // mock - TableLayoutManager tablelm = mock(TableLayoutManager.class); - when(tablelm.getTable()).thenReturn(t); - // mock - BlockLayoutManager blm = mock(BlockLayoutManager.class); - when(blm.getPSLM()).thenReturn(pslm); - when(blm.getParent()).thenReturn(tablelm); - // real RTMLM, not mock - RetrieveTableMarkerLayoutManager rtmlm = new RetrieveTableMarkerLayoutManager(rtm); - rtmlm.setParent(blm); - // test the case where resolution returns null - when(tablelm.resolveRetrieveTableMarker(rtm)).thenReturn(null); - assertNull(rtmlm.getNextKnuthElements(lc, 0)); - // test the case where resolution returns non null - List l = new ArrayList(); - when(tablelm.resolveRetrieveTableMarker(rtm)).thenReturn(rtm); - when(tlm.getNextKnuthElements(lc, 0)).thenReturn(l); - assertEquals(l, rtmlm.getNextKnuthElements(lc, 0)); - verify(tlm).setParent(blm); - verify(tlm).initialize(); - } - -} diff --git a/test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java b/test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java deleted file mode 100644 index 629e5f1c6..000000000 --- a/test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.layoutmgr.table; - -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; -import org.apache.fop.fo.flow.table.TableColumn; -import org.apache.fop.fo.flow.table.TableHeader; -import org.apache.fop.fo.flow.table.TableRow; -import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; -import org.apache.fop.fo.properties.CondLengthProperty; -import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.PageSequenceLayoutManager; -import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.RetrieveTableMarkerLayoutManager; - -public class TableCellLayoutManagerTestCase { - - // this test aims to check that the first call to addAreas() calls - // TLM.saveTableHeaderTableCellLayoutManagers() but the second call, through repeatAddAreas() - // does not call it again; there are a lot of mocks here, but just the necessary so that the - // addAreas() call can run to completion without NPE; also, the mocking needs to be done so - // the methods isDecendantOfTableHeaderOrFooter() and hasRetrieveTableMarker() return true. - @Test - public void testRepeatAddAreas() { - LayoutContext lc = LayoutContext.newInstance(); - // mock background - CommonBorderPaddingBackground cbpb = mock(CommonBorderPaddingBackground.class); - // mock conditional length property - CondLengthProperty clp = mock(CondLengthProperty.class); - when(clp.getLengthValue()).thenReturn(0); - // real border info - BorderInfo bi = BorderInfo.getInstance(0, clp, Color.BLACK, clp, clp); - // mock column - TableColumn tcol = mock(TableColumn.class); - when(tcol.getCommonBorderPaddingBackground()).thenReturn(cbpb); - // mock table - Table t = mock(Table.class); - when(t.getColumn(0)).thenReturn(tcol); - // mock header - TableHeader th = mock(TableHeader.class); - when(th.getCommonBorderPaddingBackground()).thenReturn(cbpb); - // mock row - TableRow tr = mock(TableRow.class); - when(tr.getParent()).thenReturn(th); - // mock cell - TableCell tc = mock(TableCell.class); - when(tc.hasRetrieveTableMarker()).thenReturn(true); - when(tc.getTable()).thenReturn(t); - when(tc.getId()).thenReturn("cellId"); - when(tc.getCommonBorderPaddingBackground()).thenReturn(cbpb); - when(tc.getParent()).thenReturn(tr); - // mock PGU - PrimaryGridUnit pgu = mock(PrimaryGridUnit.class); - when(pgu.getCell()).thenReturn(tc); - when(pgu.getColIndex()).thenReturn(0); - when(pgu.getBorderBefore(0)).thenReturn(bi); - when(pgu.getBorderAfter(0)).thenReturn(bi); - when(pgu.getBorderEnd()).thenReturn(bi); - when(pgu.getBorderStart()).thenReturn(bi); - when(pgu.getTablePart()).thenReturn(th); - // mock RTMLM - RetrieveTableMarkerLayoutManager rtmlm = mock(RetrieveTableMarkerLayoutManager.class); - when(rtmlm.isFinished()).thenReturn(true); // avoids infinite loop - // mock PSLM - PageSequenceLayoutManager pslm = mock(PageSequenceLayoutManager.class); - // mock TLM - TableLayoutManager tlm = mock(TableLayoutManager.class); - when(tlm.getPSLM()).thenReturn(pslm); - // mock PI - PositionIterator pi = mock(PositionIterator.class); - // mock RP - RowPainter rp = mock(RowPainter.class); - - // real TCLM, not a mock! - TableCellLayoutManager tclm = new TableCellLayoutManager(tc, pgu); - tclm.addChildLM(rtmlm); - tclm.setParent(tlm); - // lets call addAreas - int[] n = {}; - tclm.addAreas(pi, lc, n, 0, 0, 0, 0, true, true, rp, 0); - // check the TCLM is added to the TLM - verify(tlm).saveTableHeaderTableCellLayoutManagers(tclm); - // call the repeat - tclm.repeatAddAreas(); - // check the TCLM was not added again - verify(tlm).saveTableHeaderTableCellLayoutManagers(tclm); - } -} diff --git a/test/java/org/apache/fop/layoutmgr/table/TableContentLayoutManagerTestCase.java b/test/java/org/apache/fop/layoutmgr/table/TableContentLayoutManagerTestCase.java deleted file mode 100644 index 2bc41979c..000000000 --- a/test/java/org/apache/fop/layoutmgr/table/TableContentLayoutManagerTestCase.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.layoutmgr.table; - -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.FONode.FONodeIterator; -import org.apache.fop.fo.flow.table.Table; -import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.PositionIterator; - -public class TableContentLayoutManagerTestCase { - - @Test - public void testAddAreas() { - LayoutContext lc = LayoutContext.newInstance(); - // mock - ColumnSetup cs = mock(ColumnSetup.class); - when(cs.getColumnCount()).thenReturn(3); - // mock - FONodeIterator foni = mock(FONodeIterator.class); - when(foni.hasNext()).thenReturn(false); - // mock - Table t = mock(Table.class); - when(t.getChildNodes()).thenReturn(foni); - when(t.getMarkers()).thenReturn(null); - // mock - TableLayoutManager tlm = mock(TableLayoutManager.class); - when(tlm.getTable()).thenReturn(t); - when(tlm.getColumns()).thenReturn(cs); - // mock - PositionIterator pi = mock(PositionIterator.class); - when(pi.hasNext()).thenReturn(false); - // real TCLM, not a mock - TableContentLayoutManager tclm = new TableContentLayoutManager(tlm); - // check that addAreas() calls the clearTableFragments() on the table and the - // repeatAddAreasForSavedTableHeaderTableCellLayoutManagers on the TLM - tclm.addAreas(pi, lc); - verify(tlm).clearTableFragmentMarkers(); - verify(tlm).repeatAddAreasForSavedTableHeaderTableCellLayoutManagers(); - } - -} diff --git a/test/java/org/apache/fop/layoutmgr/table/TableHandler.java b/test/java/org/apache/fop/layoutmgr/table/TableHandler.java deleted file mode 100644 index 7d07cb227..000000000 --- a/test/java/org/apache/fop/layoutmgr/table/TableHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.layoutmgr.table; - -import java.util.LinkedList; -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 { - - /** All the tables encountered in the FO file. List of Table objects. */ - private List tables = new LinkedList(); - - TableHandler(FOUserAgent foUserAgent) { - super(foUserAgent); - } - - public void endTable(Table tbl) { - tables.add(tbl); - } - - List getTables() { - return tables; - } -} diff --git a/test/java/org/apache/fop/layoutmgr/table/TableLayoutManagerTestCase.java b/test/java/org/apache/fop/layoutmgr/table/TableLayoutManagerTestCase.java deleted file mode 100644 index 46a394eb7..000000000 --- a/test/java/org/apache/fop/layoutmgr/table/TableLayoutManagerTestCase.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.layoutmgr.table; - -import java.util.HashMap; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.fop.area.PageViewport; -import org.apache.fop.fo.Constants; -import org.apache.fop.fo.flow.Marker; -import org.apache.fop.fo.flow.RetrieveTableMarker; -import org.apache.fop.fo.flow.table.Table; -import org.apache.fop.layoutmgr.BlockLayoutManager; -import org.apache.fop.layoutmgr.Page; -import org.apache.fop.layoutmgr.PageSequenceLayoutManager; - -public class TableLayoutManagerTestCase { - - @Test - public void testSavedTableCellLayoutManagersFunctionality() { - Table t = mock(Table.class); - TableCellLayoutManager tclm1 = mock(TableCellLayoutManager.class); - TableLayoutManager tlm = new TableLayoutManager(t); - tlm.saveTableHeaderTableCellLayoutManagers(tclm1); - tlm.repeatAddAreasForSavedTableHeaderTableCellLayoutManagers(); - verify(tclm1).repeatAddAreas(); // called once - // test that after the first repeatAddAreas() call the list closes to new additions - TableCellLayoutManager tclm2 = mock(TableCellLayoutManager.class); - tlm.saveTableHeaderTableCellLayoutManagers(tclm2); - tlm.repeatAddAreasForSavedTableHeaderTableCellLayoutManagers(); - verify(tclm1, times(2)).repeatAddAreas(); // called twice - verify(tclm2, never()).repeatAddAreas(); // never called - } - - @Test - public void testResolveRetrieveTableMarker() { - // mock - Table t = mock(Table.class); - // mock - Marker m = mock(Marker.class); - // mock - RetrieveTableMarker rtm = mock(RetrieveTableMarker.class); - when(rtm.getRetrieveClassName()).thenReturn("A"); - when(rtm.getPosition()).thenReturn(Constants.EN_FIRST_STARTING); - // mock - PageViewport pv = mock(PageViewport.class); - when(pv.resolveMarker(rtm)).thenReturn(m); - // mock - Page p = mock(Page.class); - when(p.getPageViewport()).thenReturn(pv); - // mock - PageSequenceLayoutManager pslm = mock(PageSequenceLayoutManager.class); - when(pslm.getPSLM()).thenReturn(pslm); - when(pslm.getCurrentPage()).thenReturn(p); - // mock - BlockLayoutManager blm = mock(BlockLayoutManager.class); - blm.setParent(pslm); - when(blm.getPSLM()).thenReturn(pslm); - // real TLM, not mock - TableLayoutManager tlm = new TableLayoutManager(t); - tlm.setParent(blm); - // register a marker - HashMap<String, Marker> markers1 = new HashMap<String, Marker>(); - Marker m1 = mock(Marker.class); - markers1.put("A", m1); - tlm.registerMarkers(markers1, true, true, true); - tlm.registerMarkers(markers1, false, true, true); - // check that if there is a marker at table fragment level the RTM is returned - assertEquals(rtm, tlm.resolveRetrieveTableMarker(rtm)); - verify(rtm, never()).getBoundary(); - // check that if there is no marker at table fragment level and that is the boundary - // we get a null return value - when(rtm.getBoundary()).thenReturn(Constants.EN_TABLE_FRAGMENT); - when(rtm.getRetrieveClassName()).thenReturn("B"); - assertNull(tlm.resolveRetrieveTableMarker(rtm)); - verify(rtm).getBoundary(); - verify(rtm, never()).changePositionTo(Constants.EN_LAST_ENDING); - // check that if there is no marker at table fragment level and the boundary is page - // then we try to do the resolution at page level; test the case a marker is found - when(rtm.getBoundary()).thenReturn(Constants.EN_PAGE); - assertEquals(rtm, tlm.resolveRetrieveTableMarker(rtm)); - verify(rtm).changePositionTo(Constants.EN_LAST_ENDING); - verify(rtm).changePositionTo(Constants.EN_FIRST_STARTING); - verify(pv).resolveMarker(rtm); - // test the same situation but in this case the marker is not found - when(pv.resolveMarker(rtm)).thenReturn(null); - assertNull(tlm.resolveRetrieveTableMarker(rtm)); - // test the situation where the marker is not found at page level but the boundary is table - when(rtm.getBoundary()).thenReturn(Constants.EN_TABLE); - assertNull(tlm.resolveRetrieveTableMarker(rtm)); - } - -} diff --git a/test/java/org/apache/fop/logging/LoggingElementListObserver.java b/test/java/org/apache/fop/logging/LoggingElementListObserver.java deleted file mode 100644 index 7824a6b8b..000000000 --- a/test/java/org/apache/fop/logging/LoggingElementListObserver.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.logging; - -import java.util.List; -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; - -/** - * <p>Logs all observed element lists. - * </p> - * <p>You can enable/disabled individual categories separately, for example for JDK 1.4 logging: - * </p> - * <p>org.apache.fop.logging.LoggingElementListObserver.level = INFO</p> - * <p>org.apache.fop.logging.LoggingElementListObserver.table-cell.level = FINE</p> - */ -public class LoggingElementListObserver implements Observer { - - /** @see org.apache.fop.layoutmgr.ElementListObserver.Observer */ - public void observe(List elementList, String category, String id) { - Log log = LogFactory.getLog(LoggingElementListObserver.class.getName() + "." + category); - if (!log.isDebugEnabled()) { - return; - } - log.debug(" "); - int len = (elementList != null ? ElementListUtils.calcContentLength(elementList) : 0); - log.debug("ElementList: category=" + category + ", id=" + id + ", len=" + len + "mpt"); - if (elementList == null) { - log.debug("<<empty list>>"); - return; - } - ListIterator tempIter = elementList.listIterator(); - ListElement temp; - while (tempIter.hasNext()) { - temp = (ListElement) tempIter.next(); - if (temp.isBox()) { - log.debug(tempIter.previousIndex() - + ") " + temp); - } else if (temp.isGlue()) { - log.debug(tempIter.previousIndex() - + ") " + temp); - } else { - log.debug(tempIter.previousIndex() - + ") " + temp); - } - if (temp.getPosition() != null) { - log.debug(" " + temp.getPosition()); - } - } - log.debug(" "); - } - -} diff --git a/test/java/org/apache/fop/memory/MemoryEater.java b/test/java/org/apache/fop/memory/MemoryEater.java deleted file mode 100644 index efe0cc489..000000000 --- a/test/java/org/apache/fop/memory/MemoryEater.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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.memory; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.stream.StreamSource; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.io.output.NullOutputStream; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; - -/** - * Debug tool to create and process large FO files by replicating them a specified number of times. - */ -public final class MemoryEater { - - private SAXTransformerFactory tFactory - = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - private Templates replicatorTemplates; - - private Stats stats; - - private MemoryEater() throws TransformerConfigurationException, MalformedURLException { - File xsltFile = new File("test/xsl/fo-replicator.xsl"); - Source xslt = new StreamSource(xsltFile); - replicatorTemplates = tFactory.newTemplates(xslt); - } - - private void eatMemory(File foFile, int runRepeats, int replicatorRepeats) throws Exception { - stats = new Stats(); - FopFactory fopFactory = FopFactory.newInstance(foFile.getParentFile().toURI()); - for (int i = 0; i < runRepeats; i++) { - eatMemory(i, foFile, replicatorRepeats, fopFactory); - stats.progress(i, runRepeats); - } - stats.dumpFinalStats(); - System.out.println(stats.getGoogleChartURL()); - } - - private void eatMemory(int callIndex, File foFile, int replicatorRepeats, FopFactory fopFactory) - throws Exception { - Source src = new StreamSource(foFile); - - Transformer transformer = replicatorTemplates.newTransformer(); - transformer.setParameter("repeats", new Integer(replicatorRepeats)); - - OutputStream out = new NullOutputStream(); //write to /dev/nul - try { - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out); - Result res = new SAXResult(fop.getDefaultHandler()); - - transformer.transform(src, res); - - stats.notifyPagesProduced(fop.getResults().getPageCount()); - if (callIndex == 0) { - System.out.println(foFile.getName() + " generates " - + fop.getResults().getPageCount() + " pages."); - } - stats.checkStats(); - } finally { - IOUtils.closeQuietly(out); - } - } - - private static void prompt() throws IOException { - BufferedReader in = new BufferedReader(new java.io.InputStreamReader(System.in)); - System.out.print("Press return to continue..."); - in.readLine(); - } - - /** - * Main method. - * @param args the command-line arguments - */ - public static void main(String[] args) { - boolean doPrompt = true; //true if you want a chance to start the monitoring console - try { - int replicatorRepeats = 2; - int runRepeats = 1; - if (args.length > 0) { - replicatorRepeats = Integer.parseInt(args[0]); - } - if (args.length > 1) { - runRepeats = Integer.parseInt(args[1]); - } - File testFile = new File("examples/fo/basic/readme.fo"); - - System.out.println("MemoryEater! About to replicate the test file " - + replicatorRepeats + " times and run it " + runRepeats + " times..."); - if (doPrompt) { - prompt(); - } - - System.out.println("Processing..."); - long start = System.currentTimeMillis(); - - MemoryEater app = new MemoryEater(); - app.eatMemory(testFile, runRepeats, replicatorRepeats); - - long duration = System.currentTimeMillis() - start; - System.out.println("Success! Job took " + duration + " ms"); - - if (doPrompt) { - prompt(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/test/java/org/apache/fop/memory/Stats.java b/test/java/org/apache/fop/memory/Stats.java deleted file mode 100644 index 354952347..000000000 --- a/test/java/org/apache/fop/memory/Stats.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.memory; - -import java.util.Iterator; -import java.util.List; - -class Stats { - - private static final int INTERVAL = 2000; - - private long startTime = System.currentTimeMillis(); - private long lastProgressDump = startTime; - private int pagesProduced; - - private int totalPagesProduced; - - private int step; - private int stepCount; - - private List samples = new java.util.LinkedList(); - - public void checkStats() { - long now = System.currentTimeMillis(); - if (now > lastProgressDump + INTERVAL) { - dumpStats(); - reset(); - } - } - - public void notifyPagesProduced(int count) { - pagesProduced += count; - totalPagesProduced += count; - } - - public void reset() { - pagesProduced = 0; - lastProgressDump = System.currentTimeMillis(); - } - - public void dumpStats() { - long duration = System.currentTimeMillis() - lastProgressDump; - - if (stepCount != 0) { - int progress = 100 * step / stepCount; - System.out.println("Progress: " + progress + "%, " + (stepCount - step) + " left"); - } - - long ppm = 60000 * pagesProduced / duration; - System.out.println("Speed: " + ppm + "ppm"); - samples.add(new Sample((int)ppm)); - } - - public void dumpFinalStats() { - long duration = System.currentTimeMillis() - startTime; - System.out.println("Final statistics"); - System.out.println("Pages produced: " + totalPagesProduced); - long ppm = 60000 * totalPagesProduced / duration; - System.out.println("Average speed: " + ppm + "ppm"); - } - - public String getGoogleChartURL() { - StringBuffer sb = new StringBuffer("http://chart.apis.google.com/chart?"); - //http://chart.apis.google.com/chart?cht=ls&chd=t:60,40&chs=250x100&chl=Hello|World - sb.append("cht=ls"); - sb.append("&chd=t:"); - boolean first = true; - int maxY = 0; - Iterator iter = samples.iterator(); - while (iter.hasNext()) { - Sample sample = (Sample)iter.next(); - if (first) { - first = false; - } else { - sb.append(','); - } - sb.append(sample.ppm); - maxY = Math.max(maxY, sample.ppm); - } - int ceilY = ((maxY / 1000) + 1) * 1000; - sb.append("&chs=1000x300"); //image size - sb.append("&chds=0,").append(ceilY); //data scale - sb.append("&chg=0,20"); //scale steps - sb.append("&chxt=y"); - sb.append("&chxl=0:|0|" + ceilY); - return sb.toString(); - } - - private static class Sample { - - private int ppm; - - public Sample(int ppm) { - this.ppm = ppm; - } - } - - public void progress(int step, int stepCount) { - this.step = step; - this.stepCount = stepCount; - - } - -} diff --git a/test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java b/test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java deleted file mode 100644 index ae68cbeb7..000000000 --- a/test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.pdf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Test case for {@link AbstractPDFStream}. - */ -public class AbstractPDFStreamTestCase extends PDFObjectTestCase { - - private AbstractPDFStream abstractStream; - - private String textData = "This is an arbitrary string for testing."; - - private static byte[] encodedBytes; - static { - int[] encoded = { 0x78, 0x9c, 0x0b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0xc4, 0x3c, 0x85, - 0xc4, 0xa2, 0xa4, 0xcc, 0x92, 0xa2, 0xc4, 0xa2, 0x4a, 0x85, 0xe2, 0x92, 0xa2, 0xcc, - 0xbc, 0x74, 0x85, 0xb4, 0xfc, 0x22, 0x85, 0x92, 0xd4, 0xe2, 0x12, 0x20, 0x5b, 0x0f, - 0x00, 0x2d, 0x2b, 0x0e, 0xde, 0x0a }; - encodedBytes = new byte[encoded.length]; - int i = 0; - for (int in : encoded) { - encodedBytes[i++] = (byte) (in & 0xff); - } - } - private String startStream = "<< /Length 1 0 R /Filter /FlateDecode >>\n" - + "stream\n"; - - private String endStream = "endstream"; - - @Before - public void setUp() { - abstractStream = new AbstractPDFStream() { - - @Override - protected void outputRawStreamData(OutputStream out) throws IOException { - out.write(textData.getBytes()); - } - - @Override - protected int getSizeHint() throws IOException { - return textData.length(); - } - }; - abstractStream.setDocument(doc); - abstractStream.setParent(parent); - - pdfObjectUnderTest = abstractStream; - } - - /** - * Tests output() - ensure that this object is correctly formatted to the output stream. - * @throws IOException if an I/O error occurs - */ - @Test - public void testOutput() throws IOException { - // This differs from most other objects, if the object number = 0 an exception is thrown - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - abstractStream.setObjectNumber(1); - ByteArrayOutputStream expectedStream = new ByteArrayOutputStream(); - expectedStream.write(startStream.getBytes()); - expectedStream.write(encodedBytes); - expectedStream.write(endStream.getBytes()); - assertEquals(expectedStream.size(), abstractStream.output(outStream)); - assertEquals(expectedStream.toString(), outStream.toString()); - } -} diff --git a/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java b/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java deleted file mode 100644 index 3301fff9e..000000000 --- a/test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.pdf; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; - -import org.junit.Before; -import org.junit.Test; -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. - */ -@RunWith(Parameterized.class) -public class FileIDGeneratorTestCase { - - /** The generator under test. */ - protected FileIDGenerator fileIDGenerator; - - private TestGetter initializer; - - @Parameters - public static Collection<TestGetter[]> getParameters() { - ArrayList<TestGetter[]> params = new ArrayList<TestGetter[]>(); - params.add(new TestGetter[] { new RandomFileIDGeneratorTest() }); - params.add(new TestGetter[] { new DigestFileIDGeneratorTest() }); - return params; - } - - public FileIDGeneratorTestCase(TestGetter initializer) { - this.initializer = initializer; - } - - @Before - public void setUp() throws Exception { - fileIDGenerator = initializer.getSut(); - } - - /** Tests that the getOriginalFileID method generates valid output. */ - @Test - public void testOriginal() { - byte[] fileID = fileIDGenerator.getOriginalFileID(); - fileIDMustBeValid(fileID); - } - - /** Tests that the getUpdatedFileID method generates valid output. */ - @Test - public void testUpdated() { - byte[] fileID = fileIDGenerator.getUpdatedFileID(); - fileIDMustBeValid(fileID); - } - - private void fileIDMustBeValid(byte[] fileID) { - assertNotNull(fileID); - assertEquals(16, fileID.length); - } - - /** Tests that multiple calls to getOriginalFileID method always return the same value. */ - @Test - public void testOriginalMultipleCalls() { - byte[] fileID1 = fileIDGenerator.getUpdatedFileID(); - byte[] fileID2 = fileIDGenerator.getUpdatedFileID(); - assertTrue(Arrays.equals(fileID1, fileID2)); - } - - /** Tests that getUpdatedFileID returns the same value as getOriginalFileID. */ - @Test - public void testUpdateEqualsOriginal() { - byte[] originalFileID = fileIDGenerator.getOriginalFileID(); - byte[] updatedFileID = fileIDGenerator.getUpdatedFileID(); - assertTrue(Arrays.equals(originalFileID, updatedFileID)); - } - - private interface TestGetter { - FileIDGenerator getSut() throws Exception; - } - - /** - * Tests the random file ID generator. - */ - private static class RandomFileIDGeneratorTest implements TestGetter { - - public FileIDGenerator getSut() throws Exception { - return FileIDGenerator.getRandomFileIDGenerator(); - } - - } - - /** - * Tests the file ID generator based on an MD5 digest. - */ - private static class DigestFileIDGeneratorTest implements TestGetter { - - public FileIDGenerator getSut() throws Exception { - return FileIDGenerator.getDigestFileIDGenerator( - new PDFDocument("Apache FOP")); - } - - } - -} diff --git a/test/java/org/apache/fop/pdf/ObjectStreamManagerTestCase.java b/test/java/org/apache/fop/pdf/ObjectStreamManagerTestCase.java deleted file mode 100644 index fda1a006e..000000000 --- a/test/java/org/apache/fop/pdf/ObjectStreamManagerTestCase.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.pdf; - -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 { - - private List<CompressedObjectReference> compressedObjectReferences; - - private MockPdfDocument pdfDocument; - - @Test - public void add() { - final int expectedCapacity = 100; - final int numCompressedObjects = expectedCapacity * 2 + 1; - createCompressObjectReferences(numCompressedObjects); - assertEquals(numCompressedObjects, compressedObjectReferences.size()); - int objectStreamNumber1 = assertSameObjectStream(0, expectedCapacity); - int objectStreamNumber2 = assertSameObjectStream(expectedCapacity, expectedCapacity * 2); - int objectStreamNumber3 = assertSameObjectStream(expectedCapacity * 2, numCompressedObjects); - assertDifferent(objectStreamNumber1, objectStreamNumber2, objectStreamNumber3); - assertEquals(objectStreamNumber3, pdfDocument.previous.getObjectNumber().getNumber()); - } - - private void createCompressObjectReferences(int numObjects) { - pdfDocument = new MockPdfDocument(); - ObjectStreamManager sut = new ObjectStreamManager(pdfDocument); - for (int obNum = 1; obNum <= numObjects; obNum++) { - sut.add(createCompressedObject(obNum)); - } - compressedObjectReferences = sut.getCompressedObjectReferences(); - } - - private static class MockPdfDocument extends PDFDocument { - - private ObjectStream previous; - - public MockPdfDocument() { - super(""); - } - - public void assignObjectNumber(PDFObject obj) { - super.assignObjectNumber(obj); - if (obj instanceof ObjectStream) { - ObjectStream objStream = (ObjectStream) obj; - ObjectStream previous = (ObjectStream) objStream.get("Extends"); - if (previous == null) { - assertEquals(this.previous, previous); - } - this.previous = objStream; - } - } - } - - private CompressedObject createCompressedObject(final int objectNumber) { - return new CompressedObject() { - - public PDFObjectNumber getObjectNumber() { - return new PDFObjectNumber(objectNumber); - } - - public int output(OutputStream outputStream) throws IOException { - throw new UnsupportedOperationException(); - } - }; - } - - private int assertSameObjectStream(int from, int to) { - int objectStreamNumber = getObjectStreamNumber(from); - for (int i = from + 1; i < to; i++) { - assertEquals(objectStreamNumber, getObjectStreamNumber(i)); - } - return objectStreamNumber; - } - - private int getObjectStreamNumber(int index) { - return compressedObjectReferences.get(index).getObjectStreamNumber().getNumber(); - } - - private void assertDifferent(int objectStreamNumber1, int objectStreamNumber2, - int objectStreamNumber3) { - assertTrue(objectStreamNumber1 != objectStreamNumber2); - assertTrue(objectStreamNumber1 != objectStreamNumber3); - assertTrue(objectStreamNumber2 != objectStreamNumber3); - } -} diff --git a/test/java/org/apache/fop/pdf/ObjectStreamTestCase.java b/test/java/org/apache/fop/pdf/ObjectStreamTestCase.java deleted file mode 100644 index a38df70a0..000000000 --- a/test/java/org/apache/fop/pdf/ObjectStreamTestCase.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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.pdf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Arrays; -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"; - - private PDFDocument pdfDocument; - - private ObjectStream objectStream; - - private List<MockCompressedObject> compressedObjects; - - @Before - public void setUp() throws Exception { - pdfDocument = new PDFDocument("PDFObjectStreamTestCase"); - objectStream = new ObjectStream(); - pdfDocument.assignObjectNumber(objectStream); - compressedObjects = Arrays.asList(new MockCompressedObject(), new MockCompressedObject()); - } - - @Test - public void testSingleObjectStream() throws IOException { - populateObjectStream(); - testOutput(); - } - - @Test - public void testObjectStreamCollection() throws IOException { - objectStream = new ObjectStream(objectStream); - pdfDocument.assignObjectNumber(objectStream); - populateObjectStream(); - testOutput(); - } - - @Test(expected = IllegalStateException.class) - public void directObjectsAreNotAllowed() throws Exception { - objectStream.addObject(new MockCompressedObject()); - } - - @Test(expected = NullPointerException.class) - public void nullObjectsAreNotAllowed() throws Exception { - objectStream.addObject(null); - } - - private void testOutput() throws IOException { - String expected = getExpectedOutput(); - String actual = getActualOutput(); - assertEquals(expected, actual); - } - - private void populateObjectStream() { - for (MockCompressedObject obj : compressedObjects) { - pdfDocument.assignObjectNumber(obj); - objectStream.addObject(obj); - } - } - - private String getExpectedOutput() { - int numObs = compressedObjects.size(); - int objectStreamNumber = objectStream.getObjectNumber().getNumber(); - int offsetsLength = 9; - StringBuilder expected = new StringBuilder(); - expected.append("<<\n"); - ObjectStream previous = (ObjectStream) objectStream.get("Extends"); - if (previous != null) { - expected.append(" /Extends ").append(previous.getObjectNumber()).append(" 0 R\n"); - objectStreamNumber++; - } - expected.append(" /Type /ObjStm\n") - .append(" /N ").append(numObs).append("\n") - .append(" /First ").append(offsetsLength).append('\n') - .append(" /Length ").append(OBJECT_CONTENT.length() * 2 + offsetsLength).append('\n') - .append(">>\n") - .append("stream\n"); - int offset = 0; - int num = 1; - for (PDFObject ob : compressedObjects) { - expected.append(objectStreamNumber + num++).append(' ').append(offset).append('\n'); - offset += ob.toPDFString().length(); - } - for (PDFObject ob : compressedObjects) { - expected.append(ob.toPDFString()); - } - expected.append("\nendstream"); - return expected.toString(); - } - - private String getActualOutput() throws IOException { - ByteArrayOutputStream actual = new ByteArrayOutputStream(); - objectStream.getFilterList().setDisableAllFilters(true); - objectStream.output(actual); - return actual.toString("US-ASCII"); - } - - private static class MockCompressedObject extends PDFObject implements CompressedObject { - - @Override - protected String toPDFString() { - return OBJECT_CONTENT; - } - } - -} diff --git a/test/java/org/apache/fop/pdf/PDFAModeTestCase.java b/test/java/org/apache/fop/pdf/PDFAModeTestCase.java deleted file mode 100644 index 68609575a..000000000 --- a/test/java/org/apache/fop/pdf/PDFAModeTestCase.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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.pdf; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class PDFAModeTestCase { - - private static class PDFAModeChecker { - - private final PDFAMode mode; - - PDFAModeChecker(PDFAMode mode) { - this.mode = mode; - } - - PDFAModeChecker isEnabled() { - assertTrue(mode.isEnabled()); - return this; - } - - PDFAModeChecker isDisabled() { - assertFalse(mode.isEnabled()); - return this; - } - - PDFAModeChecker isPart1() { - assertEquals(1, mode.getPart()); - assertTrue(mode.isPart1()); - return this; - } - - PDFAModeChecker isNotPart1() { - assertFalse(mode.getPart() == 1); - assertFalse(mode.isPart1()); - return this; - } - - PDFAModeChecker isPart2() { - assertTrue(mode.getPart() == 1 || mode.getPart() == 2); - assertTrue(mode.isPart2()); - return this; - } - - PDFAModeChecker isNotPart2() { - assertFalse(mode.getPart() == 2); - assertFalse(mode.isPart2()); - return this; - } - - PDFAModeChecker hasConformanceLevel(char level) { - assertEquals(level, mode.getConformanceLevel()); - return this; - } - - PDFAModeChecker isLevelA() { - assertEquals('A', mode.getConformanceLevel()); - assertTrue(mode.isLevelA()); - return this; - } - - PDFAModeChecker isNotLevelA() { - assertFalse(mode.getConformanceLevel() == 'A'); - assertFalse(mode.isLevelA()); - return this; - } - } - - @Test - public void checkDisabled() { - new PDFAModeChecker(PDFAMode.DISABLED) - .isDisabled() - .isNotPart1() - .isNotPart2() - .isNotLevelA(); - } - - @Test - public void checkPDFA1a() { - new PDFAModeChecker(PDFAMode.PDFA_1A) - .isEnabled() - .isPart1() - .isPart2() - .isLevelA(); - } - - @Test - public void checkPDFA1b() { - new PDFAModeChecker(PDFAMode.PDFA_1B) - .isEnabled() - .isPart1() - .isPart2() - .isNotLevelA(); - } - - @Test - public void checkPDFA2a() { - new PDFAModeChecker(PDFAMode.PDFA_2A) - .isEnabled() - .isNotPart1() - .isPart2() - .isLevelA(); - } - - @Test - public void checkPDFA2b() { - new PDFAModeChecker(PDFAMode.PDFA_2B) - .isEnabled() - .isNotPart1() - .isPart2() - .isNotLevelA(); - } - - @Test - public void checkPDFA2u() { - new PDFAModeChecker(PDFAMode.PDFA_2U) - .isEnabled() - .isNotPart1() - .isPart2() - .isNotLevelA() - .hasConformanceLevel('U'); - } - -} diff --git a/test/java/org/apache/fop/pdf/PDFArrayTestCase.java b/test/java/org/apache/fop/pdf/PDFArrayTestCase.java deleted file mode 100644 index 53e9bdba0..000000000 --- a/test/java/org/apache/fop/pdf/PDFArrayTestCase.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * 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.pdf; - -import java.io.IOException; -import java.util.ArrayList; -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 static org.junit.Assert.fail; - -/** - * Test case for {@link PDFArray}. - */ -public class PDFArrayTestCase extends PDFObjectTestCase { - private PDFArray intArray; - private String intArrayOutput; - private PDFArray doubleArray; - private String doubleArrayOutput; - private PDFArray collectionArray; - private String collectionArrayOutput; - private PDFArray objArray; - private String objArrayOutput; - - /** A PDF object used solely for testing */ - private PDFNumber num; - - @Before - public void setUp() { - intArray = new PDFArray(parent, new int[] {1, 2, 3, 4, 5}); - intArrayOutput = "[1 2 3 4 5]"; - - doubleArray = new PDFArray(parent, new double[] {1.1, 2.2, 3.3, 4.4, 5.5}); - doubleArrayOutput = "[1.1 2.2 3.3 4.4 5.5]"; - - List<Object> strList = new ArrayList<Object>(); - strList.add("one"); - strList.add("two"); - strList.add("three"); - collectionArray = new PDFArray(parent, strList); - collectionArrayOutput = "[(one) (two) (three)]"; - - // Set arbitrary values here - num = new PDFNumber(); - num.setNumber(20); - num.setObjectNumber(4); - objArray = new PDFArray(parent, new Object[] {"one", 2, 3.0f, num}); - objArrayOutput = "[(one) 2 3 4 0 R]"; - - // set the document - intArray.setDocument(doc); - doubleArray.setDocument(doc); - collectionArray.setDocument(doc); - objArray.setDocument(doc); - - // Test the progenitor in the inheritance stack - objArray.setParent(parent); - pdfObjectUnderTest = objArray; - } - - private void intArrayContainsTests() { - for (int i = 1; i <= 5; i++) { - assertTrue(intArray.contains(i)); - } - assertFalse(intArray.contains(6)); - assertFalse(intArray.contains(0)); - } - - private void doubleArrayContainsTests() { - assertTrue(doubleArray.contains(1.1)); - assertTrue(doubleArray.contains(2.2)); - assertTrue(doubleArray.contains(3.3)); - assertTrue(doubleArray.contains(4.4)); - assertTrue(doubleArray.contains(5.5)); - assertFalse(doubleArray.contains(10.0)); - assertFalse(doubleArray.contains(0.0)); - } - - private void collectionArrayContainsTests() { - assertTrue(collectionArray.contains("one")); - assertTrue(collectionArray.contains("two")); - assertTrue(collectionArray.contains("three")); - assertFalse(collectionArray.contains("zero")); - assertFalse(collectionArray.contains("four")); - } - - private void objectArrayContainsTests() { - assertTrue(objArray.contains("one")); - assertTrue(objArray.contains(2)); - assertTrue(objArray.contains(3.0f)); - assertTrue(objArray.contains(num)); - assertFalse(objArray.contains("four")); - assertFalse(objArray.contains(0.0)); - } - - /** - * Test contains() - test whether this PDFArray contains an object. - */ - @Test - public void testContains() { - // Test some arbitrary values - intArrayContainsTests(); - doubleArrayContainsTests(); - collectionArrayContainsTests(); - objectArrayContainsTests(); - } - - /** - * Test length() - tests the length of an array. - */ - @Test - public void testLength() { - assertEquals(5, intArray.length()); - assertEquals(5, doubleArray.length()); - assertEquals(3, collectionArray.length()); - assertEquals(4, objArray.length()); - - // Test the count is incremented when an object is added (this only - // needs to be tested once) - intArray.add(6); - assertEquals(6, intArray.length()); - } - - /** - * Test set() - tests that a particular point has been properly set. - */ - @Test - public void testSet() { - PDFName name = new PDFName("zero test"); - objArray.set(0, name); - assertEquals(name, objArray.get(0)); - - objArray.set(1, "test"); - assertEquals("test", objArray.get(1)); - // This goes through the set(int, double) code path rather than set(int, Object) - objArray.set(2, 5); - assertEquals(5.0, objArray.get(2)); - try { - objArray.set(4, 2); - fail("out of bounds"); - } catch (IndexOutOfBoundsException e) { - // Pass - } - } - - /** - * Test get() - gets the object stored at a given index. - */ - @Test - public void testGet() { - // Test some arbitrary values - for (int i = 1; i <= 5; i++) { - assertEquals(i, intArray.get(i - 1)); - } - - assertEquals(1.1, doubleArray.get(0)); - assertEquals(2.2, doubleArray.get(1)); - assertEquals(3.3, doubleArray.get(2)); - assertEquals(4.4, doubleArray.get(3)); - assertEquals(5.5, doubleArray.get(4)); - - assertEquals("one", collectionArray.get(0)); - assertEquals("two", collectionArray.get(1)); - assertEquals("three", collectionArray.get(2)); - - assertEquals("one", objArray.get(0)); - assertEquals(2, objArray.get(1)); - assertEquals(0, Double.compare(3.0, (Float) objArray.get(2))); - assertEquals(num, objArray.get(3)); - } - - /** - * Tests add() - tests that objects are appended to the end of the array as expected. - */ - @Test - public void testAdd() { - intArray.add(new Integer(6)); - doubleArray.add(6.6); - // Test some arbitrary values - for (int i = 1; i <= 6; i++) { - assertEquals(i, intArray.get(i - 1)); - } - - assertEquals(1.1, doubleArray.get(0)); - assertEquals(2.2, doubleArray.get(1)); - assertEquals(3.3, doubleArray.get(2)); - assertEquals(4.4, doubleArray.get(3)); - assertEquals(5.5, doubleArray.get(4)); - assertEquals(6.6, doubleArray.get(5)); - - collectionArray.add(1); - assertEquals("one", collectionArray.get(0)); - assertEquals("two", collectionArray.get(1)); - assertEquals("three", collectionArray.get(2)); - assertEquals(1.0, collectionArray.get(3)); - - objArray.add("four"); - assertEquals("one", objArray.get(0)); - assertEquals(2, objArray.get(1)); - assertEquals(0, Double.compare(3.0, (Float) objArray.get(2))); - assertEquals("four", objArray.get(4)); - } - - /** - * Tests output() - tests that this object is properly streamed to the PDF document. - * @throws IOException error caused by I/O - */ - @Test - public void testOutput() throws IOException { - testOutputStreams(intArrayOutput, intArray); - testOutputStreams(doubleArrayOutput, doubleArray); - testOutputStreams(collectionArrayOutput, collectionArray); - testOutputStreams(objArrayOutput, objArray); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFAttachmentTestCase.java b/test/java/org/apache/fop/pdf/PDFAttachmentTestCase.java deleted file mode 100644 index 8915ba934..000000000 --- a/test/java/org/apache/fop/pdf/PDFAttachmentTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.pdf; - -import java.awt.Dimension; -import java.awt.Rectangle; -import java.io.ByteArrayOutputStream; -import java.io.File; - -import javax.xml.transform.stream.StreamResult; - -import org.junit.Test; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFException; -import org.apache.fop.render.intermediate.extensions.Link; -import org.apache.fop.render.intermediate.extensions.URIAction; -import org.apache.fop.render.pdf.PDFDocumentHandler; -import org.apache.fop.render.pdf.extensions.PDFEmbeddedFileAttachment; - -import junit.framework.Assert; - -public class PDFAttachmentTestCase { - private FOUserAgent ua = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); - - @Test - public void testAddEmbeddedFile() throws IFException { - PDFDocumentHandler docHandler = new PDFDocumentHandler(new IFContext(ua)); - docHandler.setFontInfo(new FontInfo()); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - docHandler.setResult(new StreamResult(out)); - docHandler.startDocument(); - docHandler.startPage(0, "", "", new Dimension()); - docHandler.handleExtensionObject(new PDFEmbeddedFileAttachment("filename", "src", "desc")); - docHandler.getDocumentNavigationHandler().renderLink(new Link( - new URIAction("embedded-file:filename", false), new Rectangle())); - docHandler.endDocument(); - Assert.assertTrue(out.toString().contains("<<\n /Type /Filespec\n /F (filename)")); - Assert.assertTrue(out.toString().contains("<<\n/S /JavaScript\n" - + "/JS (this.exportDataObject({cName:\"filename\", nLaunch:2});)\n>>")); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFDestsTestCase.java b/test/java/org/apache/fop/pdf/PDFDestsTestCase.java deleted file mode 100644 index 4655b258d..000000000 --- a/test/java/org/apache/fop/pdf/PDFDestsTestCase.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.pdf; - -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}. - */ -public class PDFDestsTestCase extends PDFObjectTestCase { - - private PDFDests dests = new PDFDests(); - private String expectedString = "<< /Names [(number) 10 (name) /Test#20name] >>"; - - @Before - public void setUp() { - List<PDFDestination> destinations = new ArrayList<PDFDestination>(); - PDFNumber number = new PDFNumber(); - number.setNumber(10); - PDFDestination testNumber = new PDFDestination("number", number); - testNumber.setDocument(doc); - destinations.add(testNumber); - PDFDestination testName = new PDFDestination("name", new PDFName("Test name")); - testName.setDocument(doc); - destinations.add(testName); - - dests = new PDFDests(destinations); - dests.setDocument(doc); - dests.setParent(parent); - pdfObjectUnderTest = dests; - } - - /** - * Populate the object with some arbitrary values and ensure they are wrapped properly. - * @throws IOException if an I/O error occurs - */ - @Test - public void testConstructor() throws IOException { - // Seems the only way to test this is by testing the output - testOutputStreams(expectedString, dests); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFDictionaryTestCase.java b/test/java/org/apache/fop/pdf/PDFDictionaryTestCase.java deleted file mode 100644 index cc2352300..000000000 --- a/test/java/org/apache/fop/pdf/PDFDictionaryTestCase.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.pdf; - -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.assertNull; -import static org.junit.Assert.fail; - -import org.apache.commons.io.output.CountingOutputStream; - -/** - * Test case for {@link PDFDictionary}. - */ -public class PDFDictionaryTestCase extends PDFObjectTestCase { - /** The test subject */ - private PDFDictionary pdfDictUnderTest; - private PDFArray testArray; - private PDFNumber testNumber; - /** The order in which these objects are put into the dictionary MUST be maintained. */ - private String expectedOutput = "<<\n" - + " /String (TestValue)\n" - + " /int 10\n" - + " /double 3.1\n" - + " /array [1 (two) 20]\n" - + " /number 20\n" - + " /null null\n" - + ">>"; - - @Before - public void setUp() { - // A PDFNumber for testing, this DOES have a parent - testNumber = new PDFNumber(); - testNumber.setParent(parent); - testNumber.setNumber(20); - // An array for testing, this DOES NOT have a parent - testArray = new PDFArray(); - testArray.add(1); - testArray.add("two"); - testArray.add(testNumber); - // Populating the dictionary with a parent, document and the various objects - pdfDictUnderTest = new PDFDictionary(parent); - pdfDictUnderTest.setDocument(doc); - pdfDictUnderTest.put("String", "TestValue"); - pdfDictUnderTest.put("int", 10); - pdfDictUnderTest.put("double", Double.valueOf(3.1)); - pdfDictUnderTest.put("array", testArray); - pdfDictUnderTest.put("number", testNumber); - // null is a valid PDF object - pdfDictUnderTest.put("null", null); - // test that the interface is maintained - pdfObjectUnderTest = pdfDictUnderTest; - } - - /** - * Tests put() - tests that the object is put into the dictionary and it is handled if it is a - * {@link PDFObject}. - */ - @Test - public void testPut() { - // The "put()" commands have already been done in setUp(), so just test them. - assertEquals("TestValue", pdfDictUnderTest.get("String")); - assertEquals(10, pdfDictUnderTest.get("int")); - assertEquals(3.1, pdfDictUnderTest.get("double")); - // With PDFObjects, if they DO NOT have a parent, the dict becomes their parent. - assertEquals(testArray, pdfDictUnderTest.get("array")); - assertEquals(pdfDictUnderTest, testArray.getParent()); - // With PDFObjects, if they DO have a parent, the dict DOES NOT change the parent object. - assertEquals(testNumber, pdfDictUnderTest.get("number")); - // Test it doesn't explode when we try to get a non-existent entry - assertNull(pdfDictUnderTest.get("Not in dictionary")); - // Tests that we can over-write objects - pdfDictUnderTest.put("array", 10); - assertEquals(10, pdfDictUnderTest.get("array")); - // Test that nulls are handled appropriately - assertNull(pdfDictUnderTest.get("null")); - } - - /** - * Tests get() - tests that objects can be properly retrieved from the dictionary. - */ - @Test - public void testGet() { - // Tested fairly comprehensively in testPut(). - } - - /** - * Tests writeDictionary() - tests that the dictionary is properly written to the output-stream. - */ - @Test - public void testWriteDictionary() { - // Ensure that the objects stored in the dictionary are streamed in the correct format. - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - CountingOutputStream cout = new CountingOutputStream(outStream); - StringBuilder textBuffer = new StringBuilder(); - try { - pdfDictUnderTest.writeDictionary(cout, textBuffer); - PDFDocument.flushTextBuffer(textBuffer, cout); - assertEquals(expectedOutput, outStream.toString()); - } catch (IOException e) { - fail("IOException: " + e.getMessage()); - } - } - - /** - * Tests output() - test that this object can write itself to an output stream. - * @throws IOException error caused by I/O - */ - @Test - public void testOutput() throws IOException { - testOutputStreams(expectedOutput, pdfDictUnderTest); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java b/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java deleted file mode 100644 index fd6d8b94b..000000000 --- a/test/java/org/apache/fop/pdf/PDFDocumentGraphics2DTestCase.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.pdf; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -import org.apache.commons.io.output.ByteArrayOutputStream; - -import org.apache.xmlgraphics.util.UnitConv; - -import org.apache.fop.svg.PDFDocumentGraphics2D; - -/** - * Tests for {@link PDFDocumentGraphics2D}. - */ -public class PDFDocumentGraphics2DTestCase { - - /** - * Does a smoke test on PDFDocumentGraphics2D making sure that nobody accidentally broke - * anything serious. It does not check the correctness of the produced PDF. - * @throws Exception if an error occurs - */ - @Test - public void smokeTest() throws Exception { - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - PDFDocumentGraphics2D g2d = new PDFDocumentGraphics2D(false); - g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - - //Set up the document size - Dimension pageSize = new Dimension( - (int)Math.ceil(UnitConv.mm2pt(210)), - (int)Math.ceil(UnitConv.mm2pt(297))); //page size A4 (in pt) - g2d.setupDocument(baout, pageSize.width, pageSize.height); - - //A few rectangles rotated and with different color - Graphics2D copy = (Graphics2D)g2d.create(); - int c = 12; - for (int i = 0; i < c; i++) { - float f = ((i + 1) / (float)c); - Color col = new Color(0.0f, 1 - f, 0.0f); - copy.setColor(col); - copy.fillRect(70, 90, 50, 50); - copy.rotate(-2 * Math.PI / c, 70, 90); - } - copy.dispose(); - - //Some text - g2d.rotate(-0.25); - g2d.setColor(Color.RED); - g2d.setFont(new Font("sans-serif", Font.PLAIN, 36)); - g2d.drawString("Hello world!", 140, 140); - g2d.setColor(Color.RED.darker()); - g2d.setFont(new Font("serif", Font.PLAIN, 36)); - g2d.drawString("Hello world!", 140, 180); - - g2d.nextPage(); //Move to next page - - g2d.setFont(new Font("sans-serif", Font.PLAIN, 36)); - g2d.drawString("Welcome to page 2!", 140, 140); - - //Cleanup - g2d.finish(); - - String pdfString = baout.toString("ISO-8859-1"); - assertEquals("%%EOF not found", - pdfString.substring(pdfString.length() - 6), "%%EOF\n"); - } - -} diff --git a/test/java/org/apache/fop/pdf/PDFDocumentTestCase.java b/test/java/org/apache/fop/pdf/PDFDocumentTestCase.java deleted file mode 100644 index e58201f13..000000000 --- a/test/java/org/apache/fop/pdf/PDFDocumentTestCase.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.pdf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Test case for {@link PDFDocument} - */ -public class PDFDocumentTestCase { - - /** - * Test flushTextBuffer() - ensure that the text given will stream to the PDF document as - * expected. - * @throws IOException when an I/O error occurs - */ - @Test - public void testFlushTextBuffer() throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - StringBuilder textBuffer = new StringBuilder(); - String testString = "This is a test string, just some arbitrary data."; - textBuffer.append(testString); - - PDFDocument.flushTextBuffer(textBuffer, out); - assertEquals(testString, out.toString()); - - // Should reset the textBuffer - assertEquals(0, textBuffer.length()); - assertEquals("", textBuffer.toString()); - out.reset(); - - String[] strArray = { "Try ", "with ", "multiple ", "strings." }; - for (String str : strArray) { - textBuffer.append(str); - } - String fullString = textBuffer.toString(); - PDFDocument.flushTextBuffer(textBuffer, out); - assertEquals(fullString, out.toString()); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFEncodingTestCase.java b/test/java/org/apache/fop/pdf/PDFEncodingTestCase.java deleted file mode 100644 index 2f80b077c..000000000 --- a/test/java/org/apache/fop/pdf/PDFEncodingTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.pdf; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -import org.apache.fop.fonts.CodePointMapping; - -public class PDFEncodingTestCase { - - /** - * Tests the createPDFEncoding method to ensure a null encoding type - * is handled correctly. - */ - @Test - public void testCreatePDFEncodingForNull() { - Object encoding = PDFEncoding.createPDFEncoding(null, "Test"); - assertEquals(encoding, null); - } - - /** - * Tests that when a PDFEncoding object is created, if the encoding type is - * that of StandardEncoding, the baseEncoding tag is omitted. - */ - @Test - public void testStandardEncodingDiffs() { - Object encoding = PDFEncoding.createPDFEncoding(CodePointMapping.getMapping( - CodePointMapping.SYMBOL_ENCODING), "Test"); - if (encoding instanceof PDFEncoding) { - PDFEncoding pdfEncoding = (PDFEncoding) encoding; - assertFalse(pdfEncoding.entries.containsKey("BaseEncoding")); - } - } - - /** - * Tests that when the StandardEncoding type is provided and there are no - * differences, the returned encoding object is null. - */ - @Test - public void testStandardEncodingNoDiff() { - Object encoding = PDFEncoding.createPDFEncoding(CodePointMapping.getMapping( - CodePointMapping.STANDARD_ENCODING), "Test"); - assertEquals(encoding, null); - } - - /** - * Tests that when the SymbolEncoding type is provided and there are no - * differences, the returned encoding string is that of SymbolEncoding. - */ - @Test - public void testCreatePDFEncodingSymbol() { - Object encoding = PDFEncoding.createPDFEncoding(CodePointMapping.getMapping( - CodePointMapping.SYMBOL_ENCODING), "Symbol"); - assert (encoding instanceof String); - String pdfEncoding = (String) encoding; - assertEquals(pdfEncoding, "SymbolEncoding"); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java b/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java deleted file mode 100644 index 18d15c384..000000000 --- a/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java +++ /dev/null @@ -1,647 +0,0 @@ -/* - * 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.pdf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.IvParameterSpec; -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. - */ -public class PDFEncryptionJCETestCase { - - private EncryptionTest test; - - private PDFEncryptionJCE encryptionObject; - - private static final class EncryptionTest { - - private int objectNumber = 1; - - private final PDFEncryptionParams encryptionParameters = new PDFEncryptionParams(); - - private byte[] data; - - private byte[] encryptedData; - - private final EncryptionDictionaryTester encryptionDictionaryTester; - - EncryptionTest() { - this(new EncryptionDictionaryTester()); - } - - EncryptionTest(EncryptionDictionaryTester encryptionDictionaryTester) { - encryptionParameters.setUserPassword("TestUserPassword"); - encryptionParameters.setOwnerPassword("TestOwnerPassword"); - setData(0x00, 0xAA, 0xFF, 0x55, 0xCC, 0x33, 0xF0); - this.encryptionDictionaryTester = encryptionDictionaryTester; - this.encryptionDictionaryTester.setLength( - encryptionParameters.getEncryptionLengthInBits()); - } - - int getObjectNumber() { - return objectNumber; - } - - EncryptionTest setObjectNumber(int objectNumber) { - this.objectNumber = objectNumber; - return this; - } - - byte[] getData() { - return data; - } - - EncryptionTest setData(int... data) { - /* - * Use an array of int to avoid having to cast some elements to byte in the - * method call. - */ - this.data = convertIntArrayToByteArray(data); - return this; - } - - byte[] getEncryptedData() { - return encryptedData; - } - - EncryptionTest setEncryptedData(int... encryptedData) { - this.encryptedData = convertIntArrayToByteArray(encryptedData); - return this; - } - - private byte[] convertIntArrayToByteArray(int[] intArray) { - byte[] byteArray = new byte[intArray.length]; - for (int i = 0; i < intArray.length; i++) { - byteArray[i] = (byte) intArray[i]; - } - return byteArray; - } - - PDFEncryptionParams getEncryptionParameters() { - return encryptionParameters; - } - - EncryptionTest setUserPassword(String userPassword) { - encryptionParameters.setUserPassword(userPassword); - return this; - } - - EncryptionTest setOwnerPassword(String ownerPassword) { - encryptionParameters.setOwnerPassword(ownerPassword); - return this; - } - - EncryptionTest setEncryptionLength(int encryptionLength) { - encryptionParameters.setEncryptionLengthInBits(encryptionLength); - encryptionDictionaryTester.setLength(encryptionLength); - return this; - } - - EncryptionTest disablePrint() { - encryptionParameters.setAllowPrint(false); - return this; - } - - EncryptionTest disableEditContent() { - encryptionParameters.setAllowEditContent(false); - return this; - } - - EncryptionTest disableCopyContent() { - encryptionParameters.setAllowCopyContent(false); - return this; - } - - EncryptionTest disableEditAnnotations() { - encryptionParameters.setAllowEditAnnotations(false); - return this; - } - - EncryptionTest disableFillInForms() { - encryptionParameters.setAllowFillInForms(false); - return this; - } - - EncryptionTest disableAccessContent() { - encryptionParameters.setAllowAccessContent(false); - return this; - } - - EncryptionTest disableAssembleDocument() { - encryptionParameters.setAllowAssembleDocument(false); - return this; - } - - EncryptionTest disablePrintHq() { - encryptionParameters.setAllowPrintHq(false); - return this; - } - - void testEncryptionDictionary(PDFEncryptionJCE encryptionObject) { - encryptionDictionaryTester.test(encryptionObject); - } - } - - private static final class EncryptionDictionaryTester { - - private int version = 2; - - private int revision = 3; - - private int length = 128; - - private int permissions = -4; - - private String ownerEntry = "D9A98017F0500EF9B69738641C9B4CBA1229EDC3F2151BC6C9C4FB07B1CB315E"; - - private String userEntry = "D3EF424BFEA2E434000E1A74941CC87300000000000000000000000000000000"; - - EncryptionDictionaryTester setVersion(int version) { - this.version = version; - return this; - } - - EncryptionDictionaryTester setRevision(int revision) { - this.revision = revision; - return this; - } - - EncryptionDictionaryTester setLength(int length) { - this.length = length; - return this; - } - - EncryptionDictionaryTester setPermissions(int permissions) { - this.permissions = permissions; - return this; - } - - EncryptionDictionaryTester setOwnerEntry(String ownerEntry) { - this.ownerEntry = ownerEntry; - return this; - } - - EncryptionDictionaryTester setUserEntry(String userEntry) { - this.userEntry = userEntry; - return this; - } - - void test(PDFEncryptionJCE encryptionObject) { - byte[] encryptionDictionary = encryptionObject.toPDF(); - RegexTestedCharSequence dictionary = new RegexTestedCharSequence(encryptionDictionary); - - final String whitespace = "\\s+"; - final String digits = "\\d+"; - final String hexDigits = "\\p{XDigit}+"; - - dictionary.mustContain("/Filter" + whitespace + "/Standard\\b"); - - dictionary.mustContain("/V" + whitespace + "(" + digits + ")") - .withGroup1EqualTo(Integer.toString(version)); - - dictionary.mustContain("/R" + whitespace + "(" + digits + ")") - .withGroup1EqualTo(Integer.toString(revision)); - - dictionary.mustContain("/Length" + whitespace + "(" + digits + ")") - .withGroup1EqualTo(Integer.toString(length)); - - dictionary.mustContain("/P" + whitespace + "(-?" + digits + ")") - .withGroup1EqualTo(Integer.toString(permissions)); - - dictionary.mustContain("/O" + whitespace + "<(" + hexDigits + ")>") - .withGroup1EqualTo(ownerEntry); - - dictionary.mustContain("/U" + whitespace + "<(" + hexDigits + ")>") - .withGroup1EqualTo(userEntry); - } - } - - private static final class RegexTestedCharSequence { - - private final String string; - - private Matcher matcher; - - RegexTestedCharSequence(byte[] bytes) { - try { - string = new String(bytes, "US-ASCII"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - RegexTestedCharSequence mustContain(String regex) { - Pattern pattern = Pattern.compile(regex); - matcher = pattern.matcher(string); - assertTrue(matcher.find()); - return this; - } - - RegexTestedCharSequence withGroup1EqualTo(String expected) { - assertEquals(expected, matcher.group(1)); - return this; - } - } - - @Test - public final void testMake() { - PDFEncryption testEncryptionObj = createEncryptionObject(new PDFEncryptionParams()); - assertTrue(testEncryptionObj instanceof PDFEncryptionJCE); - assertEquals(1, ((PDFEncryptionJCE) testEncryptionObj).getObjectNumber().getNumber()); - } - - @Test - public void testBasic() throws IOException { - test = new EncryptionTest(); - test.setData(0x00).setEncryptedData(0x24); - runEncryptionTests(); - - test.setData(0xAA).setEncryptedData(0x8E); - runEncryptionTests(); - - test.setData(0xFF).setEncryptedData(0xDB); - runEncryptionTests(); - - test = new EncryptionTest().setEncryptedData(0x24, 0x07, 0x85, 0xF7, 0x87, 0x31, 0x90); - runEncryptionTests(); - } - - @Test - public void test128bit() throws IOException { - EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() - .setVersion(2) - .setRevision(3) - .setPermissions(-4) - .setOwnerEntry("D9A98017F0500EF9B69738641C9B4CBA1229EDC3F2151BC6C9C4FB07B1CB315E") - .setUserEntry("D3EF424BFEA2E434000E1A74941CC87300000000000000000000000000000000"); - test = new EncryptionTest(encryptionDictionaryTester) - .setObjectNumber(2) - .setEncryptionLength(128) - .setEncryptedData(0xE3, 0xCB, 0xB2, 0x55, 0xD9, 0x26, 0x55); - runEncryptionTests(); - } - - @Test - public void testDisableRev2Permissions() throws IOException { - EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() - .setVersion(1) - .setRevision(2) - .setLength(40) - .setPermissions(-64) - .setOwnerEntry("3EE8C4000CA44B2645EED029C9EA7D4FC63C6D9B89349E8FA5A40C7691AB96B5") - .setUserEntry("3E65D0090746C4C37C5EF23C1BDB6323E00C24C4B2D744DD3BFB654CD58591A1"); - test = new EncryptionTest(encryptionDictionaryTester).setObjectNumber(3).setEncryptionLength(40) - .disablePrint().disableEditContent().disableCopyContent().disableEditAnnotations() - .setEncryptedData(0x66, 0xEE, 0xA7, 0x93, 0xC4, 0xB1, 0xB4); - runEncryptionTests(); - } - - @Test - public void testDisableRev3Permissions() throws IOException { - EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() - .setVersion(2) - .setRevision(3) - .setLength(40) - .setPermissions(-3844) - .setOwnerEntry("8D4BCA4F4AB2BAB4E38F161D61F937EC50BE5EB30C2DC05EA409D252CD695E55") - .setUserEntry("0F01171E22C7FB27B079C132BA4277DE00000000000000000000000000000000"); - test = new EncryptionTest(encryptionDictionaryTester) - .setObjectNumber(4) - .setEncryptionLength(40) - .disableFillInForms() - .disableAccessContent() - .disableAssembleDocument() - .disablePrintHq() - .setEncryptedData(0x8E, 0x3C, 0xD2, 0x05, 0x50, 0x48, 0x82); - runEncryptionTests(); - } - - @Test - public void test128bitDisableSomePermissions() throws IOException { - EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() - .setVersion(2) - .setRevision(3) - .setPermissions(-1304) - .setOwnerEntry("D9A98017F0500EF9B69738641C9B4CBA1229EDC3F2151BC6C9C4FB07B1CB315E") - .setUserEntry("62F0E4D8641D482E0F8E71A89270045A00000000000000000000000000000000"); - test = new EncryptionTest(encryptionDictionaryTester) - .setObjectNumber(5) - .setEncryptionLength(128) - .disablePrint() - .disableCopyContent() - .disableFillInForms() - .disableAssembleDocument() - .setEncryptedData(0xF7, 0x85, 0x4F, 0xB0, 0x50, 0x5C, 0xDF); - runEncryptionTests(); - } - - @Test - public void testDifferentPasswords() throws IOException { - EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() - .setRevision(2) - .setVersion(1) - .setLength(40) - .setOwnerEntry("D11C233C65E9DC872E858ABBD8B62198771167ADCE7AB8DC7AE0A1A7E21A1E25") - .setUserEntry("6F449167DB8DDF0D2DF4602DDBBA97ABF9A9101F632CC16AB0BE74EB9500B469"); - test = new EncryptionTest(encryptionDictionaryTester) - .setObjectNumber(6) - .setEncryptionLength(40) - .setUserPassword("ADifferentUserPassword") - .setOwnerPassword("ADifferentOwnerPassword") - .setEncryptedData(0x27, 0xAC, 0xB1, 0x6C, 0x42, 0xE0, 0xA8); - runEncryptionTests(); - } - - @Test - public void testNoOwnerPassword() throws IOException { - EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() - .setRevision(2) - .setVersion(1) - .setLength(40) - .setOwnerEntry("5163AAF3EE74C76D7C223593A84C8702FEA8AA4493E4933FF5B5A5BBB20AE4BB") - .setUserEntry("42DDF1C1BF3AB04786D5038E7B0A723AE614D944E1DE91A922FC54F5F2345E00"); - test = new EncryptionTest(encryptionDictionaryTester) - .setObjectNumber(7) - .setEncryptionLength(40) - .setUserPassword("ADifferentUserPassword") - .setOwnerPassword("") - .setEncryptedData(0xEC, 0x2E, 0x5D, 0xC2, 0x7F, 0xAD, 0x58); - runEncryptionTests(); - } - - @Test - public void test128bitDisableSomePermissionsDifferentPasswords() throws IOException { - EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() - .setVersion(2) - .setRevision(3) - .setPermissions(-2604) - .setOwnerEntry("F83CA049FAA2F774F8541F25E746A92EE2A7F060C46C91C693E673BF18FF7B36") - .setUserEntry("88A4C58F5385B5F08FACA0636D790EDF00000000000000000000000000000000"); - test = new EncryptionTest(encryptionDictionaryTester) - .setObjectNumber(8) - .setUserPassword("ADifferentUserPassword") - .setOwnerPassword("ADifferentOwnerPassword") - .setEncryptionLength(128) - .disableEditContent() - .disableEditAnnotations() - .disableAccessContent() - .disablePrintHq() - .setEncryptedData(0x77, 0x54, 0x67, 0xA5, 0xCC, 0x73, 0xDE); - runEncryptionTests(); - } - - @Test - public void test128bitNoPermissionNoOwnerPassword() throws IOException { - EncryptionDictionaryTester encryptionDictionaryTester = new EncryptionDictionaryTester() - .setVersion(2) - .setRevision(3) - .setPermissions(-3904) - .setOwnerEntry("3EEB3FA5594CBD935BFB2F83FB184DD41FBCD7C36A04F1FFD0899B0DFFCFF96B") - .setUserEntry("D972B72DD2633F613B0DDB7511C719C500000000000000000000000000000000"); - test = new EncryptionTest(encryptionDictionaryTester) - .setObjectNumber(9) - .setUserPassword("ADifferentUserPassword") - .setOwnerPassword("") - .setEncryptionLength(128) - .disablePrint() - .disableEditContent() - .disableCopyContent() - .disableEditAnnotations() - .disableFillInForms() - .disableAccessContent() - .disableAssembleDocument() - .disablePrintHq() - .setEncryptedData(0x0C, 0xAD, 0x49, 0xC7, 0xE5, 0x05, 0xB8); - runEncryptionTests(); - } - - @Test - public void testAES256() throws UnsupportedEncodingException, NoSuchAlgorithmException, - NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, - IllegalBlockSizeException, BadPaddingException { - MessageDigest sha256 = MessageDigest.getInstance("SHA-256"); - String dataText = "Test data to encrypt."; - byte[] data = dataText.getBytes("UTF-8"); - PDFEncryptionParams params = new PDFEncryptionParams(); - params.setEncryptionLengthInBits(256); - params.setUserPassword("userpassword"); - params.setOwnerPassword("ownerpassword"); - PDFEncryptionJCE encryption = createEncryptionObject(params); - PDFText text = new PDFText(); - text.setObjectNumber(1); // obj number not used with AES 256, can be anything - String dictionary = new String(encryption.toPDF()); - byte[] encrypted = encryption.encrypt(data, text); - byte[] u = parseHexStringEntries(dictionary, "U"); - byte[] o = parseHexStringEntries(dictionary, "O"); - byte[] ue = parseHexStringEntries(dictionary, "UE"); - byte[] oe = parseHexStringEntries(dictionary, "OE"); - byte[] perms = parseHexStringEntries(dictionary, "Perms"); - // check byte arrays lengths - assertEquals(48, u.length); - assertEquals(48, o.length); - assertEquals(32, ue.length); - assertEquals(32, oe.length); - assertEquals(16, perms.length); - // check user password is valid - byte[] userValSalt = new byte[8]; - byte[] userKeySalt = new byte[8]; - System.arraycopy(u, 32, userValSalt, 0, 8); - System.arraycopy(u, 40, userKeySalt, 0, 8); - byte[] uPassBytes = params.getUserPassword().getBytes("UTF-8"); - byte[] testUPass = new byte[uPassBytes.length + 8]; - System.arraycopy(uPassBytes, 0, testUPass, 0, uPassBytes.length); - System.arraycopy(userValSalt, 0, testUPass, uPassBytes.length, 8); - sha256.reset(); - sha256.update(testUPass); - byte[] actualUPass = sha256.digest(); - byte[] expectedUPass = new byte[32]; - System.arraycopy(u, 0, expectedUPass, 0, 32); - assertArrayEquals(expectedUPass, actualUPass); - // check owner password is valid - byte[] ownerValSalt = new byte[8]; - byte[] ownerKeySalt = new byte[8]; - System.arraycopy(o, 32, ownerValSalt, 0, 8); - System.arraycopy(o, 40, ownerKeySalt, 0, 8); - byte[] oPassBytes = params.getOwnerPassword().getBytes("UTF-8"); - byte[] testOPass = new byte[oPassBytes.length + 8 + 48]; - System.arraycopy(oPassBytes, 0, testOPass, 0, oPassBytes.length); - System.arraycopy(ownerValSalt, 0, testOPass, oPassBytes.length, 8); - System.arraycopy(u, 0, testOPass, oPassBytes.length + 8, 48); - sha256.reset(); - sha256.update(testOPass); - byte[] actualOPass = sha256.digest(); - byte[] expectedOPass = new byte[32]; - System.arraycopy(o, 0, expectedOPass, 0, 32); - assertArrayEquals(expectedOPass, actualOPass); - // compute encryption key from ue - byte[] ivZero = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - IvParameterSpec ivspecZero = new IvParameterSpec(ivZero); - Cipher cipherNoPadding = Cipher.getInstance("AES/CBC/NoPadding"); - byte[] tmpUKey = new byte[uPassBytes.length + 8]; - System.arraycopy(uPassBytes, 0, tmpUKey, 0, uPassBytes.length); - System.arraycopy(userKeySalt, 0, tmpUKey, uPassBytes.length, 8); - sha256.reset(); - sha256.update(tmpUKey); - byte[] intUKey = sha256.digest(); - SecretKeySpec uSKeySpec = new SecretKeySpec(intUKey, "AES"); - cipherNoPadding.init(Cipher.DECRYPT_MODE, uSKeySpec, ivspecZero); - byte[] uFileEncryptionKey = cipherNoPadding.doFinal(ue); - // compute encryption key from oe - byte[] tmpOKey = new byte[oPassBytes.length + 8 + 48]; - System.arraycopy(oPassBytes, 0, tmpOKey, 0, oPassBytes.length); - System.arraycopy(ownerKeySalt, 0, tmpOKey, oPassBytes.length, 8); - System.arraycopy(u, 0, tmpOKey, oPassBytes.length + 8, 48); - sha256.reset(); - sha256.update(tmpOKey); - byte[] intOKey = sha256.digest(); - SecretKeySpec oSKeySpec = new SecretKeySpec(intOKey, "AES"); - cipherNoPadding.init(Cipher.DECRYPT_MODE, oSKeySpec, ivspecZero); - byte[] oFileEncryptionKey = cipherNoPadding.doFinal(oe); - // check both keys are the same - assertArrayEquals(uFileEncryptionKey, oFileEncryptionKey); - byte[] fileEncryptionKey = new byte[uFileEncryptionKey.length]; - System.arraycopy(uFileEncryptionKey, 0, fileEncryptionKey, 0, uFileEncryptionKey.length); - // decrypt perms - SecretKeySpec sKeySpec = new SecretKeySpec(fileEncryptionKey, "AES"); - cipherNoPadding.init(Cipher.DECRYPT_MODE, sKeySpec, ivspecZero); - byte[] decryptedPerms = cipherNoPadding.doFinal(perms); - assertEquals('T', decryptedPerms[8]); // metadata encrypted by default - assertEquals('a', decryptedPerms[9]); - assertEquals('d', decryptedPerms[10]); - assertEquals('b', decryptedPerms[11]); - int expectedPermissions = -4; // default if nothing set - int actualPermissions = decryptedPerms[3] << 24 | (decryptedPerms[2] & 0xFF) << 16 - | (decryptedPerms[1] & 0xFF) << 8 | (decryptedPerms[0] & 0xFF); - assertEquals(expectedPermissions, actualPermissions); - // decrypt data - byte[] iv = new byte[16]; - System.arraycopy(encrypted, 0, iv, 0, 16); - byte[] encryptedData = new byte[encrypted.length - 16]; - System.arraycopy(encrypted, 16, encryptedData, 0, encrypted.length - 16); - IvParameterSpec ivspec = new IvParameterSpec(iv); - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.DECRYPT_MODE, sKeySpec, ivspec); - byte[] decryptedData = cipher.doFinal(encryptedData); - assertArrayEquals(data, decryptedData); - } - - private byte[] parseHexStringEntries(String dictionary, String entry) throws UnsupportedEncodingException { - String token = "/" + entry + " <"; - int start = dictionary.indexOf(token) + token.length(); - int end = dictionary.indexOf(">", start); - String parsedEntry = dictionary.substring(start, end); - int length = parsedEntry.length(); - byte[] data = new byte[length / 2]; - for (int i = 0; i < length; i += 2) { - data[i / 2] = (byte) ((Character.digit(parsedEntry.charAt(i), 16) << 4) + Character.digit( - parsedEntry.charAt(i + 1), 16)); - } - return data; - } - - /** - * Creates an encryption object using a fixed file ID generator for test reproducibility. - * - * @param params the encryption parameters - * @return PDFEncryptionJCE the encryption object - */ - private PDFEncryptionJCE createEncryptionObject(PDFEncryptionParams params) { - PDFDocument doc = new PDFDocument("Apache FOP") { - - @Override - FileIDGenerator getFileIDGenerator() { - return new FileIDGenerator() { - - private final byte[] fixedFileID = new byte[] { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; - - @Override - byte[] getOriginalFileID() { - return fixedFileID; - } - - @Override - byte[] getUpdatedFileID() { - return fixedFileID; - } - - }; - } - }; - return (PDFEncryptionJCE) PDFEncryptionJCE.make(new PDFObjectNumber(1), params, doc); - } - - private void runEncryptionTests() throws IOException { - encryptionObject = createEncryptionObject(test.getEncryptionParameters()); - runEncryptTest(); - runFilterTest(); - runEncryptionDictionaryTest(); - } - - private void runEncryptTest() { - PDFText text = new PDFText(); - text.setObjectNumber(test.getObjectNumber()); - byte[] byteResult = encryptionObject.encrypt(test.getData(), text); - - assertTrue(Arrays.equals(test.getEncryptedData(), byteResult)); - } - - private void runFilterTest() throws IOException { - PDFStream stream = new PDFStream(); - stream.setDocument(encryptionObject.getDocumentSafely()); - stream.setObjectNumber(test.getObjectNumber()); - stream.setData(test.getData()); - encryptionObject.applyFilter(stream); - - StreamCache streamCache = stream.encodeStream(); - ByteArrayOutputStream testOutputStream = new ByteArrayOutputStream(); - streamCache.outputContents(testOutputStream); - - assertTrue(Arrays.equals(test.getEncryptedData(), testOutputStream.toByteArray())); - } - - private void runEncryptionDictionaryTest() { - test.testEncryptionDictionary(encryptionObject); - } - -} diff --git a/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java b/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java deleted file mode 100644 index edbc7e449..000000000 --- a/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.pdf; - -import java.io.File; -import java.net.URI; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -import org.apache.xmlgraphics.io.ResourceResolver; - -import org.apache.fop.apps.io.InternalResourceResolver; -import org.apache.fop.apps.io.ResourceResolverFactory; -import org.apache.fop.fonts.CIDSet; -import org.apache.fop.fonts.CIDSubset; -import org.apache.fop.fonts.EmbeddingMode; -import org.apache.fop.fonts.MultiByteFont; - -/** - * Test case for {@link PDFFactory}. - */ -public class PDFFactoryTestCase { - - /** - * This tests that when a font is subset embedded in a PDF, the font name is prefixed with a - * pseudo-random tag as per the PDF spec. - */ - @Test - public void testSubsetFontNamePrefix() { - class MockedFont extends MultiByteFont { - public MockedFont(InternalResourceResolver resolver) { - super(resolver, EmbeddingMode.AUTO); - } - - @Override - public int[] getWidths() { - return new int[] {0}; - } - - @Override - public CIDSet getCIDSet() { - return new CIDSubset(this); - } - } - PDFDocument doc = new PDFDocument("Test"); - PDFFactory pdfFactory = new PDFFactory(doc); - URI thisURI = new File(".").toURI(); - ResourceResolver resolver = ResourceResolverFactory.createDefaultResourceResolver(); - InternalResourceResolver resourceResolver = ResourceResolverFactory.createInternalResourceResolver( - thisURI, resolver); - MockedFont font = new MockedFont(resourceResolver); - - PDFFont pdfDejaVu = pdfFactory.makeFont("DejaVu", "DejaVu", "TTF", font, font); - assertEquals("/EAAAAA+DejaVu", pdfDejaVu.getBaseFont().toString()); - - PDFFont pdfArial = pdfFactory.makeFont("Arial", "Arial", "TTF", font, font); - assertEquals("/EAAAAB+Arial", pdfArial.getBaseFont().toString()); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFFilterListTestCase.java b/test/java/org/apache/fop/pdf/PDFFilterListTestCase.java deleted file mode 100644 index d1cc6273d..000000000 --- a/test/java/org/apache/fop/pdf/PDFFilterListTestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.pdf; - -import org.junit.Test; - -import static org.junit.Assert.assertFalse; - -public class PDFFilterListTestCase { - - @Test - public void testFilterList() { - PDFFilterList filterList = new PDFFilterList(); - assertFalse(filterList.isInitialized()); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFLibraryTestSuite.java b/test/java/org/apache/fop/pdf/PDFLibraryTestSuite.java deleted file mode 100644 index 7f408ae2c..000000000 --- a/test/java/org/apache/fop/pdf/PDFLibraryTestSuite.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.pdf; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for FOP's utility classes. - */ -@RunWith(Suite.class) -@SuiteClasses({ - PDFArrayTestCase.class, - PDFDictionaryTestCase.class, - PDFNumberTestCase.class, - PDFObjectTestCase.class, - PDFNameTestCase.class, - AbstractPDFStreamTestCase.class, - PDFDestsTestCase.class, - PDFDocumentTestCase.class, - PDFNullTestCase.class, - PDFNumsArrayTestCase.class, - PDFRectangleTestCase.class, - PDFReferenceTestCase.class, - VersionTestCase.class, - VersionControllerTestCase.class -}) -public class PDFLibraryTestSuite { -} diff --git a/test/java/org/apache/fop/pdf/PDFLinearizationTestCase.java b/test/java/org/apache/fop/pdf/PDFLinearizationTestCase.java deleted file mode 100644 index 3df497e0f..000000000 --- a/test/java/org/apache/fop/pdf/PDFLinearizationTestCase.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * 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.pdf; - -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.geom.Rectangle2D; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.transform.stream.StreamResult; - -import org.junit.Assert; -import org.junit.Test; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.pdf.PDFContentGenerator; -import org.apache.fop.render.pdf.PDFDocumentHandler; -import org.apache.fop.render.pdf.PDFPainter; - -public class PDFLinearizationTestCase { - private int objectLeast; - private int[] objects; - - @Test - public void testPDF() throws IOException { - PDFDocument doc = new PDFDocument(""); - doc.setLinearizationEnabled(true); - PDFResources resources = new PDFResources(doc); - PDFResourceContext context = new PDFResourceContext(resources); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - PDFContentGenerator gen = null; - for (int i = 0; i < 2; i++) { - gen = new PDFContentGenerator(doc, out, context); - Rectangle2D.Float f = new Rectangle2D.Float(); - PDFPage page = new PDFPage(resources, i, f, f, f, f); - doc.registerObject(page); - doc.registerObject(gen.getStream()); - page.setContents(gen.getStream()); - } - gen.flushPDFDoc(); - byte[] data = out.toByteArray(); - checkPDF(data); - } - - @Test - public void testImage() throws Exception { - String fopxconf = "<fop version=\"1.0\"><renderers>" - + "<renderer mime=\"application/pdf\">" - + "<linearization>true</linearization>" - + "</renderer></renderers></fop>"; - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI(), - new ByteArrayInputStream(fopxconf.getBytes())); - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - IFContext ifContext = new IFContext(foUserAgent); - PDFDocumentHandler documentHandler = new PDFDocumentHandler(ifContext); - documentHandler.getConfigurator().configure(documentHandler); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - documentHandler.setFontInfo(new FontInfo()); - documentHandler.setResult(new StreamResult(out)); - documentHandler.startDocument(); - documentHandler.startPage(0, "", "", new Dimension()); - PDFPainter pdfPainter = new PDFPainter(documentHandler, null); - pdfPainter.drawImage("test/resources/fop/svg/logo.jpg", new Rectangle()); - documentHandler.endPage(); - Assert.assertFalse(out.toString().contains("/Subtype /Image")); - documentHandler.endDocument(); - Assert.assertTrue(out.toString().contains("/Subtype /Image")); - } - - private void checkPDF(byte[] data) throws IOException { - checkHintTable(data); - InputStream is = new ByteArrayInputStream(data); - Map<String, StringBuilder> objs = readObjs(is); - - List<String> keys = new ArrayList<String>(objs.keySet()); - int start = keys.indexOf("1 0 obj"); - Assert.assertTrue(start > 1); - int j = 1; - for (int i = start; i < keys.size(); i++) { - Assert.assertEquals(keys.get(i), j + " 0 obj"); - j++; - } - for (int i = 0; i < start; i++) { - Assert.assertEquals(keys.get(i), j + " 0 obj"); - j++; - } - - checkFirstObj(data); - checkTrailer(data); - - String firstObj = objs.values().iterator().next().toString().replace("\n", ""); - Assert.assertTrue(firstObj.startsWith("<< /Linearized 1 /L " + data.length)); - Assert.assertTrue(firstObj.endsWith("startxref0%%EOF")); - int pageObjNumber = getValue("/O", firstObj); - Assert.assertTrue(objs.get(pageObjNumber + " 0 obj").toString().contains("/Type /Page")); - Assert.assertTrue(objs.get("5 0 obj").toString().contains("/Type /Pages")); - - int total = 0; - for (int i : objects) { - total += i; - } - Assert.assertEquals(total, objs.size() - 6); - } - - private void checkFirstObj(byte[] data) throws IOException { - int firstObjPos = getValue("/E", getFirstObj(data)); - InputStream is = new ByteArrayInputStream(data); - Assert.assertEquals(is.skip(firstObjPos), firstObjPos); - byte[] obj = new byte[10]; - Assert.assertEquals(is.read(obj), obj.length); - Assert.assertTrue(new String(obj).startsWith("1 0 obj")); - } - - private void checkTrailer(byte[] data) throws IOException { - int trailerPos = getValue("/T", getFirstObj(data)); - InputStream is = new ByteArrayInputStream(data); - Assert.assertEquals(is.skip(trailerPos), trailerPos); - byte[] obj = new byte[20]; - Assert.assertEquals(is.read(obj), obj.length); - Assert.assertTrue(new String(obj).startsWith("0000000000 65535 f")); - } - - private int getValue(String name, String firstObj) throws IOException { - String[] split = firstObj.split(" "); - for (int i = 0; i < split.length; i++) { - if (split[i].equals(name)) { - return Integer.valueOf(split[i + 1].replace(">>", "")); - } - } - throw new IOException(name + " not found " + firstObj); - } - - private int[] getArrayValue(String name, String firstObj) throws IOException { - String[] split = firstObj.split(" "); - for (int i = 0; i < split.length; i++) { - if (split[i].equals(name)) { - int[] v = new int[2]; - v[0] = Integer.valueOf(split[i + 1].replace("[", "")); - v[1] = Integer.valueOf(split[i + 2].replace("]", "")); - return v; - } - } - throw new IOException(name + " not found " + firstObj); - } - - private String getFirstObj(byte[] out) throws IOException { - InputStream data = new ByteArrayInputStream(out); - Map<String, StringBuilder> objs = readObjs(data); - return objs.values().iterator().next().toString().replace("\n", ""); - } - - private void checkHintTable(byte[] out) throws IOException { - String firstObj = getFirstObj(out); - int hintPos = getArrayValue("/H", firstObj)[0]; - int hintLength = getArrayValue("/H", firstObj)[1]; - - InputStream data = new ByteArrayInputStream(out); - Assert.assertEquals(data.skip(hintPos), hintPos); - - byte[] hintTable = new byte[hintLength]; - Assert.assertEquals(data.read(hintTable), hintLength); - String hintTableStr = new String(hintTable); - - Assert.assertTrue(hintTableStr.contains("/S ")); - Assert.assertTrue(hintTableStr.contains("/C ")); - Assert.assertTrue(hintTableStr.contains("/E ")); - Assert.assertTrue(hintTableStr.contains("/L ")); - Assert.assertTrue(hintTableStr.contains("/V ")); - Assert.assertTrue(hintTableStr.contains("/O ")); - Assert.assertTrue(hintTableStr.contains("/I ")); - Assert.assertTrue(hintTableStr.contains("/Length ")); - Assert.assertTrue(hintTableStr.contains("stream")); - Assert.assertTrue(hintTableStr.contains("endstream")); - Assert.assertTrue(hintTableStr.endsWith("endobj\n")); - - data = new ByteArrayInputStream(hintTable); - readStart(data); - int pages = getValue("/N", firstObj); - readObjectsTable(data, pages); - readSharedObjectsTable(data); - Assert.assertEquals(objectLeast, 1); - } - - private void readObjectsTable(InputStream data, int pages) - throws IOException { - objectLeast = read32(data); - read32(data); - int bitsDiffObjects = read16(data); - read32(data); - int bitsDiffPageLength = read16(data); - read32(data); - read16(data); - read32(data); - read16(data); - read16(data); - read16(data); - read16(data); - read16(data); - - objects = new int[pages]; - for (int i = 0; i < pages; i++) { - objects[i] = objectLeast + readBits(bitsDiffObjects, data); - } - for (int i = 0; i < pages; i++) { - readBits(bitsDiffPageLength, data); - } - for (int i = 0; i < pages; i++) { - readBits(32, data); - } - } - - private void readSharedObjectsTable(InputStream str) throws IOException { - readBits(32, str); - readBits(32, str); - readBits(32, str); - int sharedGroups = readBits(32, str); - readBits(16, str); - readBits(32, str); - int bitsDiffGroupLength = readBits(16, str); - for (int i = 0; i < sharedGroups; i++) { - readBits(bitsDiffGroupLength, str); - } - } - - private int readBits(int bits, InputStream data) throws IOException { - if (bits == 32) { - return read32(data); - } - if (bits == 16) { - return read16(data); - } - throw new IOException("Wrong bits"); - } - - private int read32(InputStream data) throws IOException { - int ch1 = data.read(); - int ch2 = data.read(); - int ch3 = data.read(); - int ch4 = data.read(); - return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4)); - } - - private int read16(InputStream data) throws IOException { - int ch1 = data.read(); - int ch2 = data.read(); - return (ch1 << 8) + (ch2); - } - - private void readStart(InputStream inputStream) throws IOException { - StringBuilder sb = new StringBuilder(); - while (inputStream.available() > 0) { - int data = inputStream.read(); - if (data == '\n') { - if (sb.toString().equals("stream")) { - return; - } - sb.setLength(0); - } else { - sb.append((char)data); - } - } - } - - public static Map<String, StringBuilder> readObjs(InputStream inputStream) throws IOException { - Map<String, StringBuilder> objs = new LinkedHashMap<String, StringBuilder>(); - StringBuilder sb = new StringBuilder(); - String key = null; - while (inputStream.available() > 0) { - int data = inputStream.read(); - if (data == '\n') { - if (sb.toString().endsWith(" 0 obj")) { - key = sb.toString().trim(); - objs.put(key, new StringBuilder()); - } else if (key != null) { - objs.get(key).append(sb).append("\n"); - } - sb.setLength(0); - } else { - sb.append((char)data); - } - } - return objs; - } -} diff --git a/test/java/org/apache/fop/pdf/PDFNameTestCase.java b/test/java/org/apache/fop/pdf/PDFNameTestCase.java deleted file mode 100644 index 8d7321496..000000000 --- a/test/java/org/apache/fop/pdf/PDFNameTestCase.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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.pdf; - -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.fail; - -import org.apache.commons.io.output.CountingOutputStream; - -/** - * Test class for {@link PDFName}. - */ -public class PDFNameTestCase extends PDFObjectTestCase { - private PDFName pdfName; - - /** - * Sets up the local variables - */ - @Before - public void setUp() { - pdfName = new PDFName("TestName"); - pdfName.setParent(parent); - pdfName.setDocument(doc); - - pdfObjectUnderTest = pdfName; - } - - /** - * Tests escapeName() - tests that this method escapes the necessary characters. - */ - @Test - public void testEscapeName() { - try { - // Test for null, this is a programming error thus the NPE - PDFName.escapeName(null); - fail("NPE not thrown when null object given to escapeName()"); - } catch (NullPointerException e) { - // PASS - } - // All names are prefixed by "/", check the PDF spec for further details. - assertEquals("/Test", PDFName.escapeName("Test")); - // Check that if the name is already prefixed with "/" it doens't do it twice - assertEquals("/Test", PDFName.escapeName("/Test")); - // Test with a space in the middle - assertEquals("/Test#20test", PDFName.escapeName("Test test")); - // Test that all chars apart from ASCII '!' --> '~' are escaped - nonEscapedCharactersTests(); - escapedCharactersTests(); - } - - private void escapedCharactersTests() { - for (char i = 0; i < '!'; i++) { - String str = Integer.toHexString(i >>> 4 & 0x0f).toUpperCase(); - str += Integer.toHexString(i & 0x0f).toUpperCase(); - assertEquals("/#" + str, PDFName.escapeName(String.valueOf(i))); - } - for (char i = '~' + 1; i < 256; i++) { - String str = Integer.toHexString(i >>> 4 & 0x0f).toUpperCase(); - str += Integer.toHexString(i & 0x0f).toUpperCase(); - assertEquals("/#" + str, PDFName.escapeName(String.valueOf(i))); - } - checkCharacterIsEscaped('#'); - checkCharacterIsEscaped('%'); - checkCharacterIsEscaped('('); - checkCharacterIsEscaped(')'); - checkCharacterIsEscaped('<'); - checkCharacterIsEscaped('>'); - checkCharacterIsEscaped('['); - checkCharacterIsEscaped(']'); - checkCharacterIsEscaped('>'); - } - - private void checkCharacterIsEscaped(char c) { - String str = Integer.toHexString(c >>> 4 & 0x0f).toUpperCase(); - str += Integer.toHexString(c & 0x0f).toUpperCase(); - assertEquals("/#" + str, PDFName.escapeName(String.valueOf(c))); - } - - private void nonEscapedCharactersTests() { - charactersNotEscapedBetween('!', '"'); - charactersNotEscapedBetween('*', ';'); - charactersNotEscapedBetween('?', 'Z'); - charactersNotEscapedBetween('^', '~'); - } - - private void charactersNotEscapedBetween(char c1, char c2) { - for (char i = c1; i <= c2; i++) { - String str = String.valueOf(i); - String expected = !str.equals("/") ? "/" + str : str; - assertEquals(expected, PDFName.escapeName(str)); - } - } - - /** - * Tests toString() - this has been overridden to return the String that PDFName wraps. - */ - @Test - public void testToString() { - // The escape characters have already been tested in testEscapeName() so this doesn't need - // to be done twice. - PDFName test1 = new PDFName("test1"); - assertEquals("/test1", test1.toString()); - PDFName test2 = new PDFName("another test"); - assertEquals("/another#20test", test2.toString()); - try { - new PDFName(null); - fail("NPE not thrown when null passed to constructor"); - } catch (NullPointerException e) { - // PASS - } - } - - /** - * Tests output() - check that this object can stream itself in the correct format. - * @throws IOException error caused by I/O - */ - @Test - public void testOutput() throws IOException { - testOutputStreams("/TestName", pdfName); - testOutputStreams("/test#20test", new PDFName("test test")); - } - - /** - * Test outputInline() - this writes the object reference if it is a direct object (has an - * object number), or writes the String representation if there is no object number. - */ - @Test - public void testOutputInline() { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - CountingOutputStream cout = new CountingOutputStream(outStream); - StringBuilder textBuffer = new StringBuilder(); - try { - // test with no object number set. - pdfName.outputInline(outStream, textBuffer); - PDFDocument.flushTextBuffer(textBuffer, cout); - assertEquals("/TestName", outStream.toString()); - - outStream.reset(); - // test with object number set - pdfName.setObjectNumber(1); - pdfName.outputInline(outStream, textBuffer); - PDFDocument.flushTextBuffer(textBuffer, cout); - assertEquals("1 0 R", outStream.toString()); - } catch (IOException e) { - fail("IOException: " + e.getMessage()); - } - } -} diff --git a/test/java/org/apache/fop/pdf/PDFNullTestCase.java b/test/java/org/apache/fop/pdf/PDFNullTestCase.java deleted file mode 100644 index 87dacc7f6..000000000 --- a/test/java/org/apache/fop/pdf/PDFNullTestCase.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.pdf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Test case for {@link PDFNull}. - */ -public class PDFNullTestCase extends PDFObjectTestCase { - - /** - * Test outputInline() - test that "null" is printed to the output stream. - */ - @Test - public void testOutputInline() throws IOException { - PDFNull obj = PDFNull.INSTANCE; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - StringBuilder text = new StringBuilder(); - obj.outputInline(out, text); - assertEquals("null", text.toString()); - - // Ensure previously written text is not discarded - obj.outputInline(out, text); - assertEquals("nullnull", text.toString()); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFNumberTestCase.java b/test/java/org/apache/fop/pdf/PDFNumberTestCase.java deleted file mode 100644 index 65f484dc7..000000000 --- a/test/java/org/apache/fop/pdf/PDFNumberTestCase.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.pdf; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -/** - * This test tests PDFNumber's doubleOut() methods. - */ -public class PDFNumberTestCase extends PDFObjectTestCase { - /** - * Sets up the local variables, most of these are inherited from PDFObjectTestCase - */ - @Before - public void setUp() { - pdfObjectUnderTest = new PDFNumber(); - pdfObjectUnderTest.setParent(parent); - pdfObjectUnderTest.setDocument(doc); - } - - /** - * Tests PDFNumber.doubleOut(). - * @throws Exception if the test fails - */ - @Test - public void testDoubleOut1() throws Exception { - //Default is 6 decimal digits - assertEquals("0", PDFNumber.doubleOut(0.0f)); - assertEquals("0", PDFNumber.doubleOut(0.0000000000000000000123f)); - assertEquals("0.1", PDFNumber.doubleOut(0.1f)); - assertEquals("100", PDFNumber.doubleOut(100.0f)); - assertEquals("100", PDFNumber.doubleOut(99.99999999999999999999999f)); - - //You'd expect 100.123456 here but DecimalFormat uses the BigDecimal.ROUND_HALF_EVEN - //strategy. I don't know if that's a problem. The strange thing testDoubleOut2 - //seems to return the normally expected value. Weird. - assertEquals("100.123459", PDFNumber.doubleOut(100.12345611111111f)); - assertEquals("-100.123459", PDFNumber.doubleOut(-100.12345611111111f)); - } - - /** - * Tests PDFNumber.doubleOut(). - * @throws Exception if the test fails - */ - public void testDoubleOut2() throws Exception { - //4 decimal digits in this case - assertEquals("0", PDFNumber.doubleOut(0.0f, 4)); - assertEquals("0", PDFNumber.doubleOut(0.0000000000000000000123f, 4)); - assertEquals("0.1", PDFNumber.doubleOut(0.1f, 4)); - assertEquals("100", PDFNumber.doubleOut(100.0f, 4)); - assertEquals("100", PDFNumber.doubleOut(99.99999999999999999999999f, 4)); - assertEquals("100.1234", PDFNumber.doubleOut(100.12341111111111f, 4)); - assertEquals("-100.1234", PDFNumber.doubleOut(-100.12341111111111f, 4)); - } - - /** - * Tests PDFNumber.doubleOut(). - * @throws Exception if the test fails - */ - public void testDoubleOut3() throws Exception { - //0 decimal digits in this case - assertEquals("0", PDFNumber.doubleOut(0.0f, 0)); - assertEquals("0", PDFNumber.doubleOut(0.1f, 0)); - assertEquals("1", PDFNumber.doubleOut(0.6f, 0)); - assertEquals("100", PDFNumber.doubleOut(100.1234f, 0)); - assertEquals("-100", PDFNumber.doubleOut(-100.1234f, 0)); - } - - /** - * Tests PDFNumber.doubleOut(). Special cases (former bugs). - * @throws Exception if the test fails - */ - public void testDoubleOut4() throws Exception { - double d = Double.parseDouble("5.7220458984375E-6"); - assertEquals("0.000006", PDFNumber.doubleOut(d)); - assertEquals("0", PDFNumber.doubleOut(d, 4)); - assertEquals("0.00000572", PDFNumber.doubleOut(d, 8)); - } - - /** - * Tests PDFNumber.doubleOut(). Tests for wrong parameters. - * @throws Exception if the test fails - */ - public void testDoubleOutWrongParameters() throws Exception { - try { - PDFNumber.doubleOut(0.1f, -1); - fail("IllegalArgument expected!"); - } catch (IllegalArgumentException iae) { - //we want that - } - try { - PDFNumber.doubleOut(0.1f, 17); //We support max 16 decimal digits - fail("IllegalArgument expected!"); - } catch (IllegalArgumentException iae) { - //we want that - } - try { - PDFNumber.doubleOut(0.1f, 98274659); - fail("IllegalArgument expected!"); - } catch (IllegalArgumentException iae) { - //we want that - } - try { - PDFNumber.doubleOut(null); - fail("NullPointer expected!"); - } catch (NullPointerException e) { - // PASS - } - } - - /** - * Tests both getNumber() and setNumber() - basic getter/setter methods... Why there isn't a - * constructor is beyond me... - */ - public void testGetSetNumber() { - PDFNumber pdfNum = new PDFNumber(); - // Check with a floating point number - pdfNum.setNumber(1.111f); - assertEquals(1.111f, pdfNum.getNumber()); - // try with an int - pdfNum.setNumber(2); - assertEquals(2, pdfNum.getNumber()); - // See what happens with a null... make sure it doesn't explode - pdfNum.setNumber(null); - assertEquals(null, pdfNum.getNumber()); - } - - /** - * Tests toPDFString() - this serializes PDFNumber to PDF format. - * @throws IOException error caused by I/O - */ - public void testToPDFString() throws IOException { - PDFNumber testSubject = new PDFNumber(); - testSubject.setNumber(1.0001); - testOutputStreams("1.0001", testSubject); - testSubject.setNumber(999); - testOutputStreams("999", testSubject); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFNumsArrayTestCase.java b/test/java/org/apache/fop/pdf/PDFNumsArrayTestCase.java deleted file mode 100644 index d36775cda..000000000 --- a/test/java/org/apache/fop/pdf/PDFNumsArrayTestCase.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.pdf; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; - -/** - * Test case for {@link PDFNumsArray}. - */ -public class PDFNumsArrayTestCase extends PDFObjectTestCase { - private PDFNumsArray numsArray; - private String expectedString = "[0 /Test#20name 1 10]"; - - @Before - public void setUp() { - numsArray = new PDFNumsArray(parent); - numsArray.put(0, new PDFName("Test name")); - PDFNumber num = new PDFNumber(); - num.setNumber(10); - numsArray.put(1, num); - numsArray.setDocument(doc); - - pdfObjectUnderTest = numsArray; - } - - /** - * Test output() - ensure that this object is properly outputted to the PDF document. - * @throws IOException if an I/O error occurs - */ - @Test - public void testOutput() throws IOException { - testOutputStreams(expectedString, numsArray); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java deleted file mode 100644 index 544352438..000000000 --- a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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.pdf; - -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. - */ -public class PDFObjectTestCase { - /** The document behind this object */ - protected final PDFDocument doc = new PDFDocument("test"); - /** The parent of this object */ - protected final PDFObject parent = new DummyPDFObject(); - /** The test subject */ - protected PDFObject pdfObjectUnderTest; - - private static class DummyPDFObject extends PDFObject { - - }; - - @Before - public void setUp() { - pdfObjectUnderTest = new DummyPDFObject(); - pdfObjectUnderTest.setDocument(doc); - pdfObjectUnderTest.setParent(parent); - } - - /** - * Tests setObjectNumber() - */ - @Test - public void testSetObjectNumber() { - pdfObjectUnderTest.setObjectNumber(1); - assertEquals(1, pdfObjectUnderTest.getObjectNumber().getNumber()); - - pdfObjectUnderTest.setObjectNumber(5); - assertEquals(5, pdfObjectUnderTest.getObjectNumber().getNumber()); - } - - /** - * Tests hasObjectNumber() - returns the object number of the underlying PDF object. - */ - @Test - public void testHasObjectNumber() { - assertFalse(pdfObjectUnderTest.hasObjectNumber()); - - pdfObjectUnderTest.setObjectNumber(1); - assertTrue(pdfObjectUnderTest.hasObjectNumber()); - } - - /** - * Tests getGeneration() - returns the generation number of the underlying PDF object. - */ - @Test - public void testGetGeneration() { - // Default should be 0 - assertEquals(0, pdfObjectUnderTest.getGeneration()); - // apparently there is no way to set this to anything other than 0 - } - - /** - * Tests setDocument() - returns the document to which this object is bound. - */ - @Test - public void testSetDocument() { - assertEquals(doc, pdfObjectUnderTest.getDocument()); - // assign a different document to the object and test (this should be immutable but isn't) - PDFDocument anotherDoc = new PDFDocument("another test"); - pdfObjectUnderTest.setDocument(anotherDoc); - assertEquals(anotherDoc, pdfObjectUnderTest.getDocument()); - } - - /** - * Tests setParent() - assigns the object a parent. - */ - @Test - public void testSetParent() { - assertEquals(parent, pdfObjectUnderTest.getParent()); - // assign another parent (this probably shouldn't me mutable) - DummyPDFObject anotherParent = new DummyPDFObject(); - pdfObjectUnderTest.setParent(anotherParent); - assertEquals(anotherParent, pdfObjectUnderTest.getParent()); - } - - /** - * Test getObjectID() - returns the PDF object ID. - */ - @Test - public void testGetObjectID() { - pdfObjectUnderTest.setObjectNumber(10); - // String is of the format "<object#> <generation#> obj\n" - assertEquals("10 0 obj\n", pdfObjectUnderTest.getObjectID()); - } - - /** - * Test referencePDF() - returns a {@link String} in PDF format to reference this object. - */ - @Test - public void testReferencePDF() { - try { - pdfObjectUnderTest.referencePDF(); - fail("The object number is not set, an exception should be thrown"); - } catch (IllegalArgumentException e) { - // PASS - } - pdfObjectUnderTest.setObjectNumber(10); - // Referencing this object is in the format "<obj#> <gen#> R" - assertEquals("10 0 R", pdfObjectUnderTest.referencePDF()); - } - - /** - * Test makeReference() - returns this object represented as a {@link PDFReference}. - */ - @Test - public void testMakeReference() { - // Not very intelligent but, there's not much to test here - pdfObjectUnderTest.setObjectNumber(10); - PDFReference ref = pdfObjectUnderTest.makeReference(); - assertEquals(pdfObjectUnderTest.getObjectNumber(), ref.getObjectNumber()); - assertEquals(pdfObjectUnderTest, ref.getObject()); - assertEquals(pdfObjectUnderTest.referencePDF(), ref.toString()); - } - - /** - * Tests PDF object references. - * @throws Exception if an error occurs - */ - @Test - public void testReference() throws Exception { - PDFDictionary dict = new PDFDictionary(); - dict.setObjectNumber(7); - PDFReference ref = dict.makeReference(); - assertEquals(ref.getObjectNumber().getNumber(), 7); - assertEquals(ref.getGeneration(), 0); - assertEquals(ref.toString(), "7 0 R"); - - ref = new PDFReference("8 0 R"); - assertEquals(ref.getObjectNumber().getNumber(), 8); - assertEquals(ref.getGeneration(), 0); - assertEquals(ref.toString(), "8 0 R"); - } - - /** - * A generic method to test output() for sub-classes of (@link PDFObject}. The expected String - * should be formatted such that the object number and object descriptor aren't printed i.e. - * for a simple integer object in PDF: - * <pre> - * 1 0 obj ** ommited from expectedString - * 10 - * endobj ** ommited from expectedString - * </pre> - * Thus the expected string would be "10". - * @param expectedString the string that is expected. - * @param object the object being tested - * @throws IOException error with I/O - */ - protected void testOutputStreams(String expectedString, PDFObject object) throws IOException { - // Test both with and without object numbers - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - // Ensure that - object.setObjectNumber(0); - assertEquals(expectedString.length(), object.output(outStream)); - assertEquals(expectedString, outStream.toString()); - outStream.reset(); - object.setObjectNumber(1); - // Test the length of the output string is returned correctly. - assertEquals(expectedString.length(), object.output(outStream)); - assertEquals(expectedString, outStream.toString()); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFPageLabelsTestCase.java b/test/java/org/apache/fop/pdf/PDFPageLabelsTestCase.java deleted file mode 100644 index a8be7ee74..000000000 --- a/test/java/org/apache/fop/pdf/PDFPageLabelsTestCase.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.pdf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -public class PDFPageLabelsTestCase { - - @Test - public void testAddPageLabel() throws IOException { - PDFDocument pdfDoc = mock(PDFDocument.class); - PDFPageLabels pageLabels = new PDFPageLabels(); - pageLabels.setDocument(pdfDoc); - int index = 0; - StringBuilder expected = new StringBuilder(); - expected.append("["); - expected.append(index + " << /S /r >>"); - pageLabels.addPageLabel(index++, "i"); - pageLabels.addPageLabel(index++, "ii"); - pageLabels.addPageLabel(index++, "iii"); - expected.append(" " + index + " << /S /D >>"); - pageLabels.addPageLabel(index++, "1"); - pageLabels.addPageLabel(index++, "2"); - pageLabels.addPageLabel(index++, "3"); - pageLabels.addPageLabel(index++, "4"); - pageLabels.addPageLabel(index++, "5"); - pageLabels.addPageLabel(index++, "6"); - pageLabels.addPageLabel(index++, "7"); - pageLabels.addPageLabel(index++, "8"); - pageLabels.addPageLabel(index++, "9"); - pageLabels.addPageLabel(index++, "10"); - expected.append(" " + index + " << /S /A >>"); - pageLabels.addPageLabel(index++, "A"); - pageLabels.addPageLabel(index++, "B"); - expected.append(" " + index + " << /S /R /St 100 >>"); - pageLabels.addPageLabel(index++, "C"); - expected.append(" " + index + " << /S /R /St 500 >>"); - pageLabels.addPageLabel(index++, "D"); - expected.append(" " + index + " << /S /A /St 5 >>"); - pageLabels.addPageLabel(index++, "E"); - pageLabels.addPageLabel(index++, "F"); - pageLabels.addPageLabel(index++, "G"); - expected.append(" " + index + " << /P (aa) >>"); - pageLabels.addPageLabel(index++, "aa"); - expected.append(" " + index + " << /P (ab) >>"); - pageLabels.addPageLabel(index++, "ab"); - expected.append(" " + index + " << /P (ac) >>"); - pageLabels.addPageLabel(index++, "ac"); - expected.append(" " + index + " << /S /a >>"); - pageLabels.addPageLabel(index++, "a"); - pageLabels.addPageLabel(index++, "b"); - expected.append(" " + index + " << /S /R /St 2 >>"); - pageLabels.addPageLabel(index++, "II"); - expected.append(" " + index + " << /S /R /St 12 >>"); - pageLabels.addPageLabel(index++, "XII"); - expected.append(" " + index + " <<\n /P (00)\n /S /D\n /St 9\n>>"); - pageLabels.addPageLabel(index++, "009"); - expected.append(" " + index + " <<\n /P (0)\n /S /D\n /St 10\n>>"); - pageLabels.addPageLabel(index++, "010"); - pageLabels.addPageLabel(index++, "011"); - expected.append("]"); - - PDFNumsArray nums = pageLabels.getNums(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - nums.output(baos); - assertEquals(expected.toString(), baos.toString()); - baos.close(); - } - -} diff --git a/test/java/org/apache/fop/pdf/PDFPagePieceTestCase.java b/test/java/org/apache/fop/pdf/PDFPagePieceTestCase.java deleted file mode 100644 index 4ee98b665..000000000 --- a/test/java/org/apache/fop/pdf/PDFPagePieceTestCase.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.pdf; - -import java.awt.Dimension; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.util.Arrays; - -import javax.xml.transform.stream.StreamResult; - -import org.junit.Test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFException; -import org.apache.fop.render.pdf.PDFDocumentHandler; -import org.apache.fop.render.pdf.extensions.PDFCollectionEntryExtension; -import org.apache.fop.render.pdf.extensions.PDFDictionaryAttachment; -import org.apache.fop.render.pdf.extensions.PDFDictionaryExtension; -import org.apache.fop.render.pdf.extensions.PDFDictionaryType; - -import junit.framework.Assert; - -public class PDFPagePieceTestCase { - @Test - public void testPDF() throws IFException { - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - PDFDocumentHandler documentHandler = new PDFDocumentHandler(new IFContext(userAgent)); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - documentHandler.setResult(new StreamResult(bos)); - documentHandler.startDocument(); - documentHandler.startPage(0, "", "", new Dimension()); - - PDFDictionaryExtension dictionaryExtension = mock(PDFDictionaryExtension.class); - when(dictionaryExtension.getDictionaryType()).thenReturn(PDFDictionaryType.PagePiece); - - PDFDictionaryExtension child = mock(PDFDictionaryExtension.class); - when(child.getKey()).thenReturn("a"); - when(dictionaryExtension.getEntries()).thenReturn(Arrays.<PDFCollectionEntryExtension>asList(child)); - documentHandler.handleExtensionObject(new PDFDictionaryAttachment(dictionaryExtension)); - - documentHandler.endPage(); - Assert.assertTrue(bos.toString(), bos.toString().contains("/PieceInfo << /a << >> /LastModified (D:")); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFParentTreeTestCase.java b/test/java/org/apache/fop/pdf/PDFParentTreeTestCase.java deleted file mode 100644 index 6fa5d6a42..000000000 --- a/test/java/org/apache/fop/pdf/PDFParentTreeTestCase.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.pdf; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -/** - * Tests that the nums array in the ParentTree dictionary is correctly being split into - * separate arrays if the elements number exceeds the set limit. - */ -public class PDFParentTreeTestCase { - - private PDFParentTree parentTree; - - @Before - public void initializeStructureTree() { - parentTree = new PDFParentTree(); - PDFDocument pdfDocument = new PDFDocument("test"); - pdfDocument.makeStructTreeRoot(parentTree); - } - - /** - * Adds less structured items than the imposed limit which should result - * in only one nums array being created. - * @throws Exception - */ - @Test - public void testNoSplit() throws Exception { - assertEquals(getArrayNumber(45), 1); - } - - /** - * Adds more than the imposed array limit to test that it splits the - * nums array into two objects. - * @throws Exception - */ - @Test - public void testSingleSplit() throws Exception { - assertEquals(getArrayNumber(70), 2); - } - - /** - * Adds items to the nums array to cause and test that multiple splits occur - * @throws Exception - */ - @Test - public void testMultipleSplit() throws Exception { - assertEquals(getArrayNumber(165), 4); - } - - /** - * Ensures that items added out of order get added to the correct nums array - * @throws Exception - */ - @Test - public void testOutOfOrderSplit() throws Exception { - PDFStructElem structElem = mock(PDFStructElem.class); - for (int num = 50; num < 53; num++) { - parentTree.addToNums(num, structElem); - } - assertEquals(getArrayNumber(50), 2); - PDFNumberTreeNode treeNode = (PDFNumberTreeNode) parentTree.getKids().get(0); - for (int num = 0; num < 50; num++) { - assertTrue(treeNode.getNums().map.containsKey(num)); - } - treeNode = (PDFNumberTreeNode) parentTree.getKids().get(1); - for (int num = 50; num < 53; num++) { - assertTrue(treeNode.getNums().map.containsKey(num)); - } - } - - /** - * Gets the number of arrays created for a given number of elements - * @param elementNumber The number of elements to be added to the nums array - * @return Returns the number of array objects - * @throws Exception - */ - private int getArrayNumber(int elementNumber) throws Exception { - PDFStructElem structElem = mock(PDFStructElem.class); - for (int structParent = 0; structParent < elementNumber; structParent++) { - parentTree.addToNums(structParent, structElem); - } - return parentTree.getKids().length(); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFRectangleTestCase.java b/test/java/org/apache/fop/pdf/PDFRectangleTestCase.java deleted file mode 100644 index ed87cd23e..000000000 --- a/test/java/org/apache/fop/pdf/PDFRectangleTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.pdf; - -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}. - */ -public class PDFRectangleTestCase { - - /** - * Test outputInline() - ensure properly formatted co-ords are printed to the output stream. - * @throws IOException if an I/O error occurs - */ - @Test - public void testOutputInline() throws IOException { - OutputStream out = new ByteArrayOutputStream(); - // These are arbitrary values thus have no meaning - PDFRectangle rect = new PDFRectangle(1, 2, 3, 4); - - StringBuilder textBuffer = new StringBuilder(); - // Ensure text before the outputInline() is maintained - textBuffer.append("Test "); - - rect.outputInline(out, textBuffer); - assertEquals("Test [1 2 3 4]", textBuffer.toString()); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFReferenceTestCase.java b/test/java/org/apache/fop/pdf/PDFReferenceTestCase.java deleted file mode 100644 index 4e0e8814d..000000000 --- a/test/java/org/apache/fop/pdf/PDFReferenceTestCase.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.pdf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Test case for {@link PDFReference}. - */ -public class PDFReferenceTestCase { - - /** - * Tests outputInline() - ensure that this object is properly formatted when printed to the - * output stream. - * @throws IOException if an I/O error occurs - */ - @Test - public void testOutputInline() throws IOException { - PDFName name = new PDFName("Test name"); - name.setObjectNumber(2); - PDFReference pdfRef = new PDFReference(name); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - StringBuilder textBuffer = new StringBuilder(); - // Ensure that text before outputInline() is kept - textBuffer.append("Text "); - - pdfRef.outputInline(out, textBuffer); - assertEquals("Text 2 0 R", textBuffer.toString()); - } - - /** - * Tests toString() - since this is used quite a lot, we have to ensure the format is correct. - */ - @Test - public void testToString() { - PDFName name = new PDFName("arbitrary"); - name.setObjectNumber(10); - PDFReference ref = new PDFReference(name); - assertEquals("10 0 R", ref.toString()); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFStreamTestCase.java b/test/java/org/apache/fop/pdf/PDFStreamTestCase.java deleted file mode 100644 index b5fb66e00..000000000 --- a/test/java/org/apache/fop/pdf/PDFStreamTestCase.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.pdf; - -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; - - @Before - public void createStream() { - stream = new PDFStream(); - stream.setObjectNumber(1); - PDFDocument pdfDocument = new PDFDocument("Apache FOP"); - stream.setDocument(pdfDocument); - } - - @Test - public void testFilterSetup() { - testGetFilterList(); - testSetupFilterList(); - } - - private void testGetFilterList() { - PDFFilterList filterList = stream.getFilterList(); - assertFalse(filterList.isInitialized()); - assertEquals(0, filterList.getFilters().size()); - } - - private void testSetupFilterList() { - stream.setupFilterList(); - PDFFilterList filterList = stream.getFilterList(); - assertTrue(filterList.isInitialized()); - assertEquals(1, filterList.getFilters().size()); - PDFFilter filter = filterList.getFilters().get(0); - assertEquals("/FlateDecode", filter.getName()); - } - - @Test - public void customFilter() { - PDFFilterList filters = stream.getFilterList(); - filters.addFilter("null"); - assertTrue(filters.isInitialized()); - assertEquals(1, filters.getFilters().size()); - PDFFilter filter = filters.getFilters().get(0); - assertEquals("", filter.getName()); - } - - @Test - public void testStream() throws IOException { - PDFFilterList filters = stream.getFilterList(); - filters.addFilter("null"); - byte[] bytes = createSampleData(); - stream.setData(bytes); - ByteArrayOutputStream actual = new ByteArrayOutputStream(); - stream.outputRawStreamData(actual); - assertArrayEquals(bytes, actual.toByteArray()); - } - - @Test - public void testEncodeStream() throws IOException { - PDFFilterList filters = stream.getFilterList(); - filters.addFilter("null"); - byte[] bytes = createSampleData(); - stream.setData(bytes); - ByteArrayOutputStream actual = new ByteArrayOutputStream(); - StreamCache streamCache = stream.encodeStream(); - streamCache.outputContents(actual); - assertArrayEquals(bytes, actual.toByteArray()); - } - - @Test - public void testEncodeAndWriteStream() throws IOException { - PDFFilterList filters = stream.getFilterList(); - filters.addFilter("null"); - byte[] bytes = createSampleData(); - stream.setData(bytes); - ByteArrayOutputStream actual = new ByteArrayOutputStream(); - PDFNumber number = new PDFNumber(); - stream.encodeAndWriteStream(actual, number); - assertArrayEquals(createSampleStreamData(), actual.toByteArray()); - } - - private byte[] createSampleData() { - byte[] bytes = new byte[10]; - for (int i = 0; i < 10; i++) { - bytes[i] = (byte) i; - } - return bytes; - } - - private byte[] createSampleStreamData() throws IOException { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - stream.write("\nstream\n".getBytes("US-ASCII")); - stream.write(createSampleData()); - stream.write("\nendstream".getBytes("US-ASCII")); - return stream.toByteArray(); - } -} diff --git a/test/java/org/apache/fop/pdf/PDFUATestCase.java b/test/java/org/apache/fop/pdf/PDFUATestCase.java deleted file mode 100644 index e6d7404a2..000000000 --- a/test/java/org/apache/fop/pdf/PDFUATestCase.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.pdf; - -import java.awt.geom.Rectangle2D; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; - -import org.junit.Assert; -import org.junit.Test; - -import org.apache.xmlgraphics.util.QName; -import org.apache.xmlgraphics.xmp.Metadata; - -import org.apache.fop.render.pdf.PDFContentGenerator; - -public class PDFUATestCase { - @Test - public void testXMP() throws IOException { - PDFDocument doc = new PDFDocument(""); - doc.getProfile().setPDFUAMode(PDFUAMode.PDFUA_1); - Metadata metadata = PDFMetadata.createXMPFromPDFDocument(doc); - StringBuilder sb = new StringBuilder(); - Iterator i = metadata.iterator(); - while (i.hasNext()) { - QName k = (QName) i.next(); - sb.append(k + ": " + metadata.getProperty(k).getValue() + "\n"); - } - String s = sb.toString(); - Assert.assertTrue(s, s.contains("pdfuaid:part: 1")); - } - - @Test - public void testPDF() throws IOException { - PDFDocument doc = new PDFDocument(""); - doc.getRoot().makeTagged(); - doc.getRoot().setStructTreeRoot(new PDFStructTreeRoot(null)); - doc.getInfo().setTitle("title"); - doc.getProfile().setPDFUAMode(PDFUAMode.PDFUA_1); - PDFResources resources = new PDFResources(doc); - doc.addObject(resources); - PDFResourceContext context = new PDFResourceContext(resources); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - PDFContentGenerator gen = new PDFContentGenerator(doc, out, context); - Rectangle2D.Float f = new Rectangle2D.Float(); - PDFPage page = new PDFPage(resources, 0, f, f, f, f); - doc.addImage(context, new BitmapImage("", 1, 1, new byte[0], null)); - doc.registerObject(page); - gen.flushPDFDoc(); - doc.outputTrailer(out); - - Collection<StringBuilder> objs = PDFLinearizationTestCase.readObjs( - new ByteArrayInputStream(out.toByteArray())).values(); - Assert.assertTrue(getObj(objs, "/Type /Catalog").contains("/ViewerPreferences << /DisplayDocTitle true >>")); - } - - private String getObj(Collection<StringBuilder> objs, String x) { - for (StringBuilder s : objs) { - if (s.toString().contains(x)) { - return s.toString(); - } - } - return null; - } -} diff --git a/test/java/org/apache/fop/pdf/PDFVT.fo b/test/java/org/apache/fop/pdf/PDFVT.fo deleted file mode 100644 index 6919afcf6..000000000 --- a/test/java/org/apache/fop/pdf/PDFVT.fo +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Arial" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"> - <fo:layout-master-set> - <fo:simple-page-master master-name="simple" page-height="27.9cm" page-width="21.6cm"> - <fo:region-body /> - <pdf:vt> - <pdf:dictionary key="DPM/CIP4_Root/CIP4_Production/CIP4_Part"> - <pdf:string key="CIP4_ProductType">frontpages</pdf:string> - </pdf:dictionary> - </pdf:vt> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:declarations> - <x:xmpmeta xmlns:x="adobe:ns:meta/"> - <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> - <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <dc:title>Document title</dc:title> - <dc:creator>Document author</dc:creator> - <dc:description>Document subject</dc:description> - </rdf:Description> - </rdf:RDF> - </x:xmpmeta> - </fo:declarations> - <fo:page-sequence format="1" id="th_default_sequence1" master-reference="simple"> - <fo:flow flow-name="xsl-region-body"> - <fo:block>page 1</fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/pdf/PDFVT.xconf b/test/java/org/apache/fop/pdf/PDFVT.xconf deleted file mode 100644 index 52588f0b0..000000000 --- a/test/java/org/apache/fop/pdf/PDFVT.xconf +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<fop version="1.0"> - <renderers> - <renderer mime="application/pdf"> - <pdf-x-mode>PDF/X-4</pdf-x-mode> - <pdf-vt-mode>PDF/VT-1</pdf-vt-mode> - <output-profile>test/resources/color/ISOcoated_v2_300_bas.icc</output-profile> - <fonts> - <font kerning="yes" embed-url="test/resources/fonts/ttf/DejaVuLGCSerif.ttf"> - <font-triplet name="Arial" style="normal" weight="normal"/> - </font> - </fonts> - </renderer> - </renderers> -</fop> diff --git a/test/java/org/apache/fop/pdf/PDFVTTestCase.java b/test/java/org/apache/fop/pdf/PDFVTTestCase.java deleted file mode 100644 index a2c1a010c..000000000 --- a/test/java/org/apache/fop/pdf/PDFVTTestCase.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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.pdf; - -import java.awt.geom.Rectangle2D; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.junit.Assert; -import org.junit.Test; - -import org.xml.sax.SAXException; - -import org.apache.xmlgraphics.util.QName; -import org.apache.xmlgraphics.xmp.Metadata; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFException; -import org.apache.fop.render.intermediate.IFParser; -import org.apache.fop.render.intermediate.IFSerializer; -import org.apache.fop.render.intermediate.IFUtil; -import org.apache.fop.render.pdf.PDFContentGenerator; - -public class PDFVTTestCase { - @Test - public void testXMP() throws IOException { - PDFDocument doc = new PDFDocument(""); - doc.getProfile().setPDFXMode(PDFXMode.PDFX_4); - doc.getProfile().setPDFVTMode(PDFVTMode.PDFVT_1); - Metadata metadata = PDFMetadata.createXMPFromPDFDocument(doc); - StringBuilder sb = new StringBuilder(); - Iterator i = metadata.iterator(); - while (i.hasNext()) { - QName k = (QName) i.next(); - sb.append(k + ": " + metadata.getProperty(k).getValue() + "\n"); - } - String s = sb.toString(); - Assert.assertTrue(s.contains("pdfxid:GTS_PDFXVersion: PDF/X-4")); - Assert.assertTrue(s.contains("xmpMM:VersionID: 1")); - Assert.assertTrue(s.contains("pdf:Trapped: False")); - Assert.assertTrue(s.contains("xmpMM:RenditionClass: default")); - Assert.assertTrue(s.contains("pdf:PDFVersion: 1.4")); - Assert.assertTrue(s.contains("pdfvtid:GTS_PDFVTVersion: PDF/VT-1")); - } - - @Test - public void testPDF() throws IOException { - PDFDocument doc = new PDFDocument(""); - doc.getInfo().setTitle("title"); - doc.getProfile().setPDFXMode(PDFXMode.PDFX_4); - doc.getProfile().setPDFVTMode(PDFVTMode.PDFVT_1); - PDFResources resources = new PDFResources(doc); - doc.addObject(resources); - PDFResourceContext context = new PDFResourceContext(resources); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - PDFContentGenerator gen = new PDFContentGenerator(doc, out, context); - Rectangle2D.Float f = new Rectangle2D.Float(); - PDFPage page = new PDFPage(resources, 0, f, f, f, f); - doc.addImage(context, new BitmapImage("", 1, 1, new byte[0], null)); - doc.registerObject(page); - doc.getFactory().makeDPart(page, "master"); - gen.flushPDFDoc(); - doc.outputTrailer(out); - - Collection<StringBuilder> objs = PDFLinearizationTestCase.readObjs( - new ByteArrayInputStream(out.toByteArray())).values(); - Assert.assertTrue(getObj(objs, "/Type /Catalog").contains("/DPartRoot ")); - Assert.assertTrue(getObj(objs, "/Type /DPartRoot").contains("/NodeNameList [/root /record]")); - Assert.assertTrue( - getObj(objs, "/Subtype /Image").contains("/GTS_XID (uuid:d41d8cd9-8f00-3204-a980-0998ecf8427e)")); - } - - @Test - public void textFO() throws IOException, SAXException, TransformerException, IFException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - foToOutput(out, MimeConstants.MIME_PDF); - checkPDF(out); - } - - @Test - public void textIF() throws IOException, SAXException, TransformerException, IFException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - foToOutput(out, MimeConstants.MIME_FOP_IF); - iFToPDF(new ByteArrayInputStream(out.toByteArray())); - } - - - private void foToOutput(ByteArrayOutputStream out, String mimeFopIf) - throws IOException, SAXException, TransformerException { - FopFactory fopFactory = getFopFactory(); - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - - if (mimeFopIf.equals(MimeConstants.MIME_FOP_IF)) { - IFSerializer serializer = new IFSerializer(new IFContext(userAgent)); - IFDocumentHandler targetHandler - = userAgent.getRendererFactory().createDocumentHandler(userAgent, MimeConstants.MIME_PDF); - serializer.mimicDocumentHandler(targetHandler); - userAgent.setDocumentHandlerOverride(serializer); - } - - Fop fop = fopFactory.newFop(mimeFopIf, userAgent, out); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - Source src = new StreamSource(new FileInputStream("test/java/org/apache/fop/pdf/PDFVT.fo")); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - } - - private FopFactory getFopFactory() throws IOException, SAXException { - return FopFactory.newInstance(new File(".").toURI(), - new FileInputStream("test/java/org/apache/fop/pdf/PDFVT.xconf")); - } - - private void iFToPDF(InputStream is) throws IOException, SAXException, TransformerException, IFException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - FOUserAgent userAgent = getFopFactory().newFOUserAgent(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - Source src = new StreamSource(is); - IFDocumentHandler documentHandler - = userAgent.getRendererFactory().createDocumentHandler(userAgent, MimeConstants.MIME_PDF); - documentHandler.setResult(new StreamResult(out)); - IFUtil.setupFonts(documentHandler); - IFParser parser = new IFParser(); - Result res = new SAXResult(parser.getContentHandler(documentHandler, userAgent)); - transformer.transform(src, res); - - checkPDF(out); - } - - private void checkPDF(ByteArrayOutputStream out) throws IOException { - Map<String, StringBuilder> objs = - PDFLinearizationTestCase.readObjs(new ByteArrayInputStream(out.toByteArray())); - String dpart = getObj(objs.values(), "/DParts"); - int v = getValue("/DParts", dpart); - String dpm = objs.get(v + " 0 obj").toString(); - Assert.assertTrue(dpm.contains( - "/DPM << /CIP4_Root << /CIP4_Production << /CIP4_Part << /CIP4_ProductType (frontpages) >>")); - } - - private int getValue(String name, String firstObj) throws IOException { - String[] split = firstObj.split(" "); - for (int i = 0; i < split.length; i++) { - if (split[i].equals(name)) { - return Integer.valueOf(split[i + 1].replace("[[", "")); - } - } - throw new IOException(name + " not found " + firstObj); - } - - private String getObj(Collection<StringBuilder> objs, String x) { - for (StringBuilder s : objs) { - if (s.toString().contains(x)) { - return s.toString(); - } - } - return null; - } -} diff --git a/test/java/org/apache/fop/pdf/TableHeaderScopeTestCase.java b/test/java/org/apache/fop/pdf/TableHeaderScopeTestCase.java deleted file mode 100644 index 2fa5008ed..000000000 --- a/test/java/org/apache/fop/pdf/TableHeaderScopeTestCase.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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.pdf; - -import org.junit.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.verification.VerificationMode; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.apache.fop.pdf.StandardStructureAttributes.Table.Scope; -import org.apache.fop.pdf.StandardStructureTypes.Table; - -public class TableHeaderScopeTestCase { - - private static final String ATTRIBUTE_ENTRY = "A"; - - private VersionController controller; - - @Test - public void pdfDocumentDelegatesToVersionController() { - for (Scope scope : Scope.values()) { - testMakeStructureElementWithScope(scope); - } - } - - private void testMakeStructureElementWithScope(Scope scope) { - VersionController controller = mock(VersionController.class); - PDFDocument document = new PDFDocument("Test", controller); - document.makeStructTreeRoot(null); - PDFStructElem th = new PDFStructElem(null, Table.TH); - document.registerStructureElement(th, scope); - verify(controller).addTableHeaderScopeAttribute(any(PDFStructElem.class), eq(scope)); - } - - @Test - public void versionControllerMayDelegateToScope() { - fixedController14doesNotAddAttribute(); - fixedController15addsAttribute(); - dynamicControllerAddsAttribute(); - } - - private void fixedController14doesNotAddAttribute() { - controller = VersionController.getFixedVersionController(Version.V1_4); - scopeMustNotBeAdded(); - } - - private void fixedController15addsAttribute() { - controller = VersionController.getFixedVersionController(Version.V1_5); - scopeMustBeAdded(); - } - - private void dynamicControllerAddsAttribute() { - PDFDocument document = new PDFDocument("Test"); - controller = VersionController.getDynamicVersionController(Version.V1_4, document); - scopeMustBeAdded(); - assertEquals(Version.V1_5, controller.getPDFVersion()); - } - - private void scopeMustBeAdded() { - scopeMustBeAdded(times(1)); - } - - private void scopeMustNotBeAdded() { - scopeMustBeAdded(never()); - } - - private void scopeMustBeAdded(VerificationMode nTimes) { - PDFStructElem structElem = mock(PDFStructElem.class); - controller.addTableHeaderScopeAttribute(structElem, Scope.COLUMN); - verify(structElem, nTimes).put(eq(ATTRIBUTE_ENTRY), any()); - } - - @Test - public void scopeAddsTheAttribute() { - for (Scope scope : Scope.values()) { - scopeAttributeMustBeAdded(scope); - } - } - - private void scopeAttributeMustBeAdded(Scope scope) { - PDFStructElem structElem = mock(PDFStructElem.class); - Scope.addScopeAttribute(structElem, scope); - verify(structElem).put(eq(ATTRIBUTE_ENTRY), scopeAttribute(scope)); - } - - private PDFDictionary scopeAttribute(Scope scope) { - return argThat(new IsScopeAttribute(scope)); - } - - private static class IsScopeAttribute extends ArgumentMatcher<PDFDictionary> { - - private final Scope expectedScope; - - public IsScopeAttribute(Scope expectedScope) { - this.expectedScope = expectedScope; - } - - @Override - public boolean matches(Object argument) { - PDFDictionary attribute = (PDFDictionary) argument; - return "/Table".equals(attribute.get("O").toString()) - && expectedScope.getName().toString().equals(attribute.get("Scope").toString()); - } - - } - -} diff --git a/test/java/org/apache/fop/pdf/VersionControllerTestCase.java b/test/java/org/apache/fop/pdf/VersionControllerTestCase.java deleted file mode 100644 index 383208405..000000000 --- a/test/java/org/apache/fop/pdf/VersionControllerTestCase.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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.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; - -/** - * A test class for {@link VersionController}. - */ -public class VersionControllerTestCase { - - private PDFDocument doc; - - @Before - public void setUp() { - doc = new PDFDocument("test"); - } - - @Test - public void testGetVersion() { - // These do the same thing - for (Version version : Version.values()) { - if (version.compareTo(Version.V1_4) >= 0) { - VersionController fixedVC = VersionController.getFixedVersionController(version); - assertEquals(version, fixedVC.getPDFVersion()); - } - - VersionController dynamicVC = VersionController.getDynamicVersionController(version, - doc); - assertEquals(version, dynamicVC.getPDFVersion()); - } - } - - /** - * Tests that the setter methods work at setting the underlying version. - * Here there is a disparity between the two objects, the fixed version will - * throw an exception if the setter is invoked. The dynamic version will - * allow the version to be changed, if the new version is greater than the - * version already set. - */ - @Test - public void testSetVersion() { - // Create every type of expected PDFVersion - for (Version originalVersion : Version.values()) { - // Compare against every type of Version - for (Version setVersion : Version.values()) { - testDynamicController(originalVersion, setVersion); - testFixedController(originalVersion, setVersion); - } - - } - } - - /** - * The fixed implementation will throw an exception if an attempt is made to change its - * version. - * - * @param originalVersion the version given to the constructor when PDFVersion instantiated - * @param setVersion the version being set - */ - private void testFixedController(Version originalVersion, Version setVersion) { - if (originalVersion.compareTo(Version.V1_4) >= 0) { - VersionController fixedVC = VersionController - .getFixedVersionController(originalVersion); - try { - fixedVC.setPDFVersion(setVersion); - if (setVersion.compareTo(originalVersion) != 0) { - fail("The FixedVersionController should throw an exception if an attempt to change " - + "the version is made"); - } - } catch (IllegalStateException e) { - // PASS - } - // Changes are NOT allowed, the original version is immutable - assertEquals(originalVersion, fixedVC.getPDFVersion()); - // The document version is NEVER changed - assertEquals(Version.V1_4, doc.getPDFVersion()); - // the /Version parameter shouldn't be present in the document catalog - assertNull(doc.getRoot().get("Version")); - } else { - try { - VersionController.getFixedVersionController(originalVersion); - fail("Versions < 1.4 aren't allowed."); - } catch (IllegalArgumentException e) { - // PASS - } - } - } - - /** - * The dynamic implementation allows the version to be changed. However, the version given in - * the constructor will be the version set in the header of the PDF document. Any change to the - * version will then be made in the document catalog. - * - * @param originalVersion the version given to the constructor when PDFVersion instantiated - * @param setVersion the version being set - */ - private void testDynamicController(Version originalVersion, Version setVersion) { - VersionController testSubj = VersionController.getDynamicVersionController(originalVersion, - doc); - testSubj.setPDFVersion(setVersion); - PDFName nameVersion = new PDFName(setVersion.toString()); - - if (originalVersion.compareTo(setVersion) < 0) { - versionShouldChange(setVersion, testSubj, nameVersion); - } else { - versionShouldNotChange(originalVersion, testSubj); - } - doc.getRoot().put("Version", null); - } - - private void versionShouldNotChange(Version originalVersion, VersionController testSubj) { - assertEquals(originalVersion, testSubj.getPDFVersion()); - assertNull(doc.getRoot().get("Version")); - } - - private void versionShouldChange(Version setVersion, VersionController testSubj, - PDFName nameVersion) { - assertEquals(setVersion, testSubj.getPDFVersion()); - assertEquals(nameVersion.toString(), doc.getRoot().get("Version").toString()); - } -} diff --git a/test/java/org/apache/fop/pdf/VersionTestCase.java b/test/java/org/apache/fop/pdf/VersionTestCase.java deleted file mode 100644 index dd2731d8b..000000000 --- a/test/java/org/apache/fop/pdf/VersionTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.pdf; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * This is a test case for ({@link Version}. - */ -public class VersionTestCase { - - /** - * Test the <code>getValue()</code> method. This should return {@link Version} given a - * {@link String}. - */ - @Test - public void testGetValue() { - int index = 0; - for (Version version : Version.values()) { - assertEquals(version, Version.getValueOf("1." + index++)); - } - } - - @Test(expected = IllegalArgumentException.class) - public void testGetValueIllegalArgument() { - Version.getValueOf("blah"); - } - - /** - * Tests that the <code>toString()</method> method returns the PDF version string of the proper - * format. - */ - @Test - public void testToString() { - // Test all the normal values - int index = 0; - for (Version version : Version.values()) { - assertTrue(version.toString().equals("1." + index++)); - } - } - - /** - * Tests that the <code>compareTo()</code> contract is obeyed. - */ - @Test - public void testCompareTo() { - // Ensure that the implicit comparison contract is satisfied - Version[] expected = { - Version.V1_0, - Version.V1_1, - Version.V1_2, - Version.V1_3, - Version.V1_4, - Version.V1_5, - Version.V1_6, - Version.V1_7 - }; - - Version[] actual = Version.values(); - - for (int i = 0; i < actual.length - 1; i++) { - assertEquals(-1, actual[i].compareTo(expected[i + 1])); - - assertEquals(0, actual[i].compareTo(expected[i])); - - assertEquals(1, actual[i + 1].compareTo(expected[i])); - } - } -} diff --git a/test/java/org/apache/fop/pdf/xref/CompressedObjectReferenceTestCase.java b/test/java/org/apache/fop/pdf/xref/CompressedObjectReferenceTestCase.java deleted file mode 100644 index b58d2f93e..000000000 --- a/test/java/org/apache/fop/pdf/xref/CompressedObjectReferenceTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.pdf.xref; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; - -import org.apache.fop.pdf.PDFObjectNumber; - -public class CompressedObjectReferenceTestCase extends ObjectReferenceTest { - - @Test - public void testOutput() throws IOException { - runTest(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0), 0); - runTest(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0x1), 4); - runTest(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0xf3), 16); - runTest(Arrays.asList(0, 0, 0, 0, 0, 0, 0x5, 0xf7), 128); - runTest(Arrays.asList(0, 0, 0, 0, 0, 0x9, 0xfb, 0xd), 0xae); - runTest(Arrays.asList(0, 0, 0, 0, 0x11, 0xff, 0x15, 0xe9), 0xff); - } - - private void runTest(List<Integer> expectedObjectStreamBytes, int index) throws IOException { - int objectStreamNumber = (int) computeNumberFromBytes(expectedObjectStreamBytes); - sut = new CompressedObjectReference(new PDFObjectNumber(0), new PDFObjectNumber(objectStreamNumber), index); - byte[] expected = createExpectedOutput((byte) 2, expectedObjectStreamBytes, index); - byte[] actual = getActualOutput(); - assertArrayEquals(expected, actual); - } - -} diff --git a/test/java/org/apache/fop/pdf/xref/CrossReferenceObjectTest.java b/test/java/org/apache/fop/pdf/xref/CrossReferenceObjectTest.java deleted file mode 100644 index 513f0d754..000000000 --- a/test/java/org/apache/fop/pdf/xref/CrossReferenceObjectTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.pdf.xref; - -import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.List; -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; -import org.apache.fop.pdf.PDFRoot; - -public abstract class CrossReferenceObjectTest { - - protected static final int STARTXREF = 12345; - - protected PDFDocument pdfDocument; - - protected TrailerDictionary trailerDictionary; - - private CrossReferenceObject crossReferenceObject; - - @Before - public void setUp() throws UnsupportedEncodingException { - pdfDocument = new PDFDocument("Apache FOP"); - Map<String, List<String>> filterMap = pdfDocument.getFilterMap(); - filterMap.put("default", Arrays.asList("null")); - PDFRoot root = new PDFRoot(pdfDocument, new PDFPages(pdfDocument)); - PDFInfo info = new PDFInfo(); - info.setObjectNumber(2); - byte[] fileID = - new byte[] {0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef}; - trailerDictionary = new TrailerDictionary(pdfDocument) - .setRoot(root) - .setInfo(info) - .setFileID(fileID, fileID); - } - - protected void runTest() throws IOException { - crossReferenceObject = createCrossReferenceObject(); - byte[] expected = createExpectedCrossReferenceData(); - byte[] actual = createActualCrossReferenceData(); - assertArrayEquals(expected, actual); - } - - protected abstract CrossReferenceObject createCrossReferenceObject(); - - protected abstract byte[] createExpectedCrossReferenceData() throws IOException; - - protected byte[] createActualCrossReferenceData() throws IOException { - ByteArrayOutputStream pdf = new ByteArrayOutputStream(); - crossReferenceObject.output(pdf); - pdf.close(); - return pdf.toByteArray(); - } - - protected byte[] getBytes(StringBuilder stringBuilder) { - return getBytes(stringBuilder.toString()); - } - - protected byte[] getBytes(String string) { - try { - return string.getBytes("US-ASCII"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - /** - * Outputs the given byte array to a file with the given name. Use for debugging - * purpose. - */ - protected void streamToFile(byte[] bytes, String filename) throws IOException { - OutputStream output = new FileOutputStream(filename); - output.write(bytes); - output.close(); - } - -} diff --git a/test/java/org/apache/fop/pdf/xref/CrossReferenceStreamTestCase.java b/test/java/org/apache/fop/pdf/xref/CrossReferenceStreamTestCase.java deleted file mode 100644 index 82af9fe5b..000000000 --- a/test/java/org/apache/fop/pdf/xref/CrossReferenceStreamTestCase.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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.pdf.xref; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.Test; - -import org.apache.fop.pdf.PDFObjectNumber; - -public class CrossReferenceStreamTestCase extends CrossReferenceObjectTest { - - private List<Long> uncompressedObjectOffsets; - - private List<CompressedObjectReference> compressedObjectReferences; - - @Test - public void testWithNoOffset() throws IOException { - List<Long> emptyList = Collections.emptyList(); - test(emptyList); - } - - @Test - public void testWithOffsets() throws IOException { - test(new ArrayList<Long>(Arrays.asList(0L, 1L, 2L, 3L, 4L))); - } - - @Test - public void testWithBigOffsets() throws IOException { - test(new ArrayList<Long>(Arrays.asList(0xffL, 0xffffL, 0xffffffffL, 0xffffffffffffffffL))); - } - - @Test - public void testWithObjectStreams1() throws IOException { - List<CompressedObjectReference> compressedObjectReferences = - Arrays.asList(new CompressedObjectReference(new PDFObjectNumber(2), new PDFObjectNumber(1), 0)); - test(Arrays.asList(0L, null), compressedObjectReferences); - } - - @Test - public void testWithObjectStreams2() throws IOException { - int numIndirectObjects = 2; - int numCompressedObjects = 1; - List<Long> indirectObjectOffsets - = new ArrayList<Long>(numIndirectObjects + numCompressedObjects); - for (long i = 0; i < numIndirectObjects; i++) { - indirectObjectOffsets.add(i); - } - List<CompressedObjectReference> compressedObjectReferences - = new ArrayList<CompressedObjectReference>(); - for (int index = 0; index < numCompressedObjects; index++) { - indirectObjectOffsets.add(null); - int obNum = numIndirectObjects + index + 1; - compressedObjectReferences.add(new CompressedObjectReference(new PDFObjectNumber(obNum), - new PDFObjectNumber(numIndirectObjects), index)); - } - test(indirectObjectOffsets, compressedObjectReferences); - } - - private void test(List<Long> indirectObjectOffsets) throws IOException { - List<CompressedObjectReference> compressedObjectReferences = Collections.emptyList(); - test(indirectObjectOffsets, compressedObjectReferences); - } - - private void test(List<Long> indirectObjectOffsets, - List<CompressedObjectReference> compressedObjectReferences) throws IOException { - this.uncompressedObjectOffsets = indirectObjectOffsets; - this.compressedObjectReferences = compressedObjectReferences; - runTest(); - } - - @Override - protected CrossReferenceObject createCrossReferenceObject() { - return new CrossReferenceStream(pdfDocument, - uncompressedObjectOffsets.size() + 1, - trailerDictionary, - STARTXREF, - uncompressedObjectOffsets, - compressedObjectReferences); - } - - @Override - protected byte[] createExpectedCrossReferenceData() throws IOException { - List<ObjectReference> objectReferences - = new ArrayList<ObjectReference>(uncompressedObjectOffsets.size()); - for (Long offset : uncompressedObjectOffsets) { - objectReferences.add(offset == null ? null : new UncompressedObjectReference(offset)); - } - for (CompressedObjectReference ref : compressedObjectReferences) { - objectReferences.set(ref.getObjectNumber().getNumber() - 1, ref); - } - int maxObjectNumber = objectReferences.size() + 1; - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - StringBuilder expected = new StringBuilder(256); - expected.append(maxObjectNumber + " 0 obj\n") - .append("<<\n") - .append(" /Root 1 0 R\n") - .append(" /Info 2 0 R\n") - .append(" /ID [<0123456789ABCDEF> <0123456789ABCDEF>]\n") - .append(" /Type /XRef\n") - .append(" /Size ").append(Integer.toString(maxObjectNumber + 1)).append('\n') - .append(" /W [1 8 2]\n") - .append(" /Length ").append(Integer.toString((maxObjectNumber + 1) * 11)).append('\n') - .append(">>\n") - .append("stream\n"); - stream.write(getBytes(expected)); - DataOutputStream data = new DataOutputStream(stream); - data.write(new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 0xff, (byte) 0xff}); - for (ObjectReference objectReference : objectReferences) { - objectReference.output(data); - } - data.write(1); - data.writeLong(STARTXREF); - data.write(0); - data.write(0); - data.close(); - stream.write(getBytes("\nendstream\nendobj\n")); - return stream.toByteArray(); - } - -} diff --git a/test/java/org/apache/fop/pdf/xref/CrossReferenceTableTestCase.java b/test/java/org/apache/fop/pdf/xref/CrossReferenceTableTestCase.java deleted file mode 100644 index 1c609e30f..000000000 --- a/test/java/org/apache/fop/pdf/xref/CrossReferenceTableTestCase.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.pdf.xref; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.Test; - -public class CrossReferenceTableTestCase extends CrossReferenceObjectTest { - - private List<Long> offsets; - - @Test - public void testWithNoOffset() throws IOException { - List<Long> emptyList = Collections.emptyList(); - runTest(emptyList); - } - - @Test - public void testWithOffsets() throws IOException { - runTest(Arrays.asList(0L, 1L, 2L, 3L, 4L)); - } - - @Test - public void testWithBigOffsets() throws IOException { - runTest(Arrays.asList(0xffL, 0xffffL, 0x7fffffffL)); - } - - private void runTest(List<Long> offsets) throws IOException { - this.offsets = offsets; - runTest(); - } - - @Override - protected CrossReferenceObject createCrossReferenceObject() { - return new CrossReferenceTable(trailerDictionary, STARTXREF, offsets, 0, offsets.size(), offsets.size()); - } - - @Override - protected byte[] createExpectedCrossReferenceData() throws IOException { - StringBuilder expected = new StringBuilder(256); - expected.append("xref\n0 ") - .append(offsets.size() + 1) - .append("\n0000000000 65535 f \n"); - for (Long objectReference : offsets) { - final String padding = "0000000000"; - String s = String.valueOf(objectReference).toString(); - String loc = padding.substring(s.length()) + s; - expected.append(loc).append(" 00000 n \n"); - } - expected.append("trailer\n<<\n") - .append(" /Root 1 0 R\n") - .append(" /Info 2 0 R\n") - .append(" /ID [<0123456789ABCDEF> <0123456789ABCDEF>]\n") - .append(" /Size ").append(Integer.toString(offsets.size() + 1)).append('\n') - .append(">>"); - return getBytes(expected); - } - -} diff --git a/test/java/org/apache/fop/pdf/xref/ObjectReferenceTest.java b/test/java/org/apache/fop/pdf/xref/ObjectReferenceTest.java deleted file mode 100644 index fada2794c..000000000 --- a/test/java/org/apache/fop/pdf/xref/ObjectReferenceTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.pdf.xref; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.List; - -abstract class ObjectReferenceTest { - - protected ObjectReference sut; - - protected long computeNumberFromBytes(List<Integer> expectedOffsetBytes) { - assert expectedOffsetBytes.size() <= 8; - long offset = 0; - for (int b : expectedOffsetBytes) { - offset = offset << 8 | b; - } - return offset; - } - - protected byte[] createExpectedOutput(byte field1, List<Integer> field2, int field3) { - assert field2.size() == 8; - assert (field3 & 0xffff) == field3; - byte[] expected = new byte[11]; - int index = 0; - expected[index++] = field1; - for (Integer b : field2) { - expected[index++] = b.byteValue(); - } - expected[index++] = (byte) ((field3 & 0xff00) >> 8); - expected[index++] = (byte) (field3 & 0xff); - return expected; - } - - protected byte[] getActualOutput() throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - DataOutputStream dataOutputStream = new DataOutputStream(out); - sut.output(dataOutputStream); - dataOutputStream.close(); - return out.toByteArray(); - } - -} diff --git a/test/java/org/apache/fop/pdf/xref/UncompressedObjectReferenceTestCase.java b/test/java/org/apache/fop/pdf/xref/UncompressedObjectReferenceTestCase.java deleted file mode 100644 index a9f506aaa..000000000 --- a/test/java/org/apache/fop/pdf/xref/UncompressedObjectReferenceTestCase.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.pdf.xref; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; - -public class UncompressedObjectReferenceTestCase extends ObjectReferenceTest { - - @Test - public void test1ByteOffsets() throws IOException { - run1ByteOffsetTest(0x0); - run1ByteOffsetTest(0xf); - run1ByteOffsetTest(0x10); - run1ByteOffsetTest(0xff); - } - - private void run1ByteOffsetTest(int offset) throws IOException { - runIntegerOffsetTest(Arrays.asList(0, 0, 0, offset)); - } - - @Test - public void test2ByteOffsets() throws IOException { - runIntegerOffsetTest(Arrays.asList(0, 0, 1, 0xff)); - runIntegerOffsetTest(Arrays.asList(0, 0, 0xa0, 0xff)); - } - - @Test - public void test3ByteOffsets() throws IOException { - runIntegerOffsetTest(Arrays.asList(0, 2, 0x12, 0x34)); - runIntegerOffsetTest(Arrays.asList(0, 0xee, 0x56, 0x78)); - } - - @Test - public void test4ByteOffsets() throws IOException { - runIntegerOffsetTest(Arrays.asList(0x6, 0x12, 0x34, 0x56)); - runIntegerOffsetTest(Arrays.asList(0xf1, 0x9a, 0xbc, 0xde)); - } - - @Test - public void test5ByteOffsets() throws IOException { - runTest(Arrays.asList(0, 0, 0, 0x7, 0x78, 0x9a, 0xbc, 0xde)); - runTest(Arrays.asList(0, 0, 0, 0xbf, 0xf0, 0, 0x1, 0x2)); - } - - @Test - public void test8ByteOffsets() throws IOException { - runTest(Arrays.asList(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8)); - runTest(Arrays.asList(0xf9, 0xe8, 0xd7, 0xc6, 0xb5, 0xa4, 0x93, 0x82)); - } - - private void runIntegerOffsetTest(List<Integer> expectedOffsetBytes) throws IOException { - List<Integer> expectedLongOffset = new ArrayList<Integer>(8); - expectedLongOffset.addAll(Arrays.asList(0, 0, 0, 0)); - expectedLongOffset.addAll(expectedOffsetBytes); - runTest(expectedLongOffset); - } - - private void runTest(List<Integer> expectedOffsetBytes) throws IOException { - long offset = computeNumberFromBytes(expectedOffsetBytes); - sut = new UncompressedObjectReference(offset); - byte[] expected = createExpectedOutput((byte) 1, expectedOffsetBytes, (byte) 0); - byte[] actual = getActualOutput(); - assertArrayEquals(expected, actual); - } - -} diff --git a/test/java/org/apache/fop/render/AbstractPathOrientedRendererTestCase.java b/test/java/org/apache/fop/render/AbstractPathOrientedRendererTestCase.java deleted file mode 100644 index b7ab64fcf..000000000 --- a/test/java/org/apache/fop/render/AbstractPathOrientedRendererTestCase.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render; - -import java.awt.Color; -import java.awt.Rectangle; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.ImageSize; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.area.CTM; -import org.apache.fop.area.Trait; - -public class AbstractPathOrientedRendererTestCase { - - @Before - public void setUp() throws Exception { - } - - @Test - public void testDrawBackgroundWithTargetImageSizes() { - FOUserAgent userAgent = mock(FOUserAgent.class); - MyAPOR myAPOR = new MyAPOR(userAgent); - ImageSize imgSize = new ImageSize(300, 300, 300); - imgSize.setSizeInMillipoints(72000, 72000); - ImageInfo imgInfo = new ImageInfo(null, null); - imgInfo.setSize(imgSize); - Trait.Background background = new Trait.Background(); - background.setImageTargetWidth(300000); - background.setImageTargetHeight(300000); - background.setImageInfo(imgInfo); - myAPOR.drawBackground(0, 0, 600, 900, background, null, null, null, null); - String expected = "[x=0.0,y=0.0,w=3.0,h=3.0][x=0.0,y=3.0,w=3.0,h=3.0][x=0.0,y=6.0,w=3.0,h=3.0]" - + "[x=0.0,y=9.0,w=3.0,h=3.0][x=3.0,y=0.0,w=3.0,h=3.0][x=3.0,y=3.0,w=3.0,h=3.0]" - + "[x=3.0,y=6.0,w=3.0,h=3.0][x=3.0,y=9.0,w=3.0,h=3.0][x=6.0,y=0.0,w=3.0,h=3.0]" - + "[x=6.0,y=3.0,w=3.0,h=3.0][x=6.0,y=6.0,w=3.0,h=3.0][x=6.0,y=9.0,w=3.0,h=3.0]"; - assertEquals(expected, myAPOR.getActual().replaceAll("00000", "")); - myAPOR.resetActual(); - background.setImageTargetWidth(0); - myAPOR.drawBackground(0, 0, 600, 900, background, null, null, null, null); - assertEquals(expected, myAPOR.getActual().replaceAll("00000", "")); - myAPOR.resetActual(); - background.setImageTargetWidth(300000); - background.setImageTargetHeight(0); - myAPOR.drawBackground(0, 0, 600, 900, background, null, null, null, null); - assertEquals(expected, myAPOR.getActual().replaceAll("00000", "")); - } - - private class MyAPOR extends AbstractPathOrientedRenderer { - - private String actual = ""; - - public MyAPOR(FOUserAgent userAgent) { - super(userAgent); - } - - public String getActual() { - return actual; - } - - public void resetActual() { - actual = ""; - } - - public String getMimeType() { - return null; - } - - protected void concatenateTransformationMatrix(AffineTransform at) { - } - - protected void restoreStateStackAfterBreakOut(List breakOutList) { - } - - protected List breakOutOfStateStack() { - return null; - } - - protected void saveGraphicsState() { - } - - protected void restoreGraphicsState() { - } - - protected void beginTextObject() { - } - - protected void endTextObject() { - } - - protected void clip() { - } - - protected void clipRect(float x, float y, float width, float height) { - } - - protected void moveTo(float x, float y) { - } - - protected void lineTo(float x, float y) { - } - - protected void closePath() { - } - - protected void fillRect(float x, float y, float width, float height) { - } - - protected void updateColor(Color col, boolean fill) { - } - - protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes) { - String s = pos.toString(); - actual += s.substring(s.indexOf('[')); - } - - protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, - boolean startOrBefore, int style, Color col) { - } - - protected void startVParea(CTM ctm, Rectangle clippingRect) { - } - - protected void endVParea() { - } - - protected void startLayer(String layer) { - } - - protected void endLayer() { - } - - } -} diff --git a/test/java/org/apache/fop/render/AbstractRenderingTest.java b/test/java/org/apache/fop/render/AbstractRenderingTest.java deleted file mode 100644 index 297a9ba05..000000000 --- a/test/java/org/apache/fop/render/AbstractRenderingTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render; - -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Map; -import java.util.MissingResourceException; - -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -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; -import org.apache.fop.apps.MimeConstants; - -/** - * Abstract base class for rendering (output) verification tests. - */ -public abstract class AbstractRenderingTest { - - private static final Map<String, String> MIME_MAP = new java.util.HashMap<String, String>(); - - static { - MIME_MAP.put(MimeConstants.MIME_PDF, ".pdf"); - MIME_MAP.put(MimeConstants.MIME_POSTSCRIPT, ".ps"); - MIME_MAP.put(MimeConstants.MIME_AFP, ".afp"); - } - - /** the JAXP TransformerFactory */ - protected TransformerFactory tFactory = TransformerFactory.newInstance(); - /** the FopFactory */ - protected final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - - /** - * Renders a test file. - * @param ua the user agent (with override set!) - * @param resourceName the resource name for the FO file - * @param suffix a suffix for the output filename - * @param outputFormat MIME type of the requested output format - * @return the output file - * @throws Exception if an error occurs - */ - protected File renderFile(FOUserAgent ua, String resourceName, String suffix, - String outputFormat) throws Exception { - String extension = MIME_MAP.get(outputFormat); - assert extension != null; - File outputFile = new File("build/test-results/" + resourceName + suffix + extension); - File outputDir = outputFile.getParentFile(); - FileUtils.forceMkdir(outputDir); - - // Prepare input file - InputStream in = getClass().getResourceAsStream(resourceName); - if (in == null) { - throw new MissingResourceException(resourceName + " not found in resources", - getClass().getName(), null); - } - try { - Source src = new StreamSource(in); - - // Create output file - OutputStream out = new java.io.FileOutputStream(outputFile); - out = new java.io.BufferedOutputStream(out); - try { - Fop fop = fopFactory.newFop(outputFormat, ua, out); - SAXResult res = new SAXResult(fop.getDefaultHandler()); - - Transformer transformer = tFactory.newTransformer(); - transformer.transform(src, res); - } finally { - IOUtils.closeQuietly(out); - } - } finally { - IOUtils.closeQuietly(in); - } - return outputFile; - } - -} diff --git a/test/java/org/apache/fop/render/RawPNGTestUtil.java b/test/java/org/apache/fop/render/RawPNGTestUtil.java deleted file mode 100644 index 506556c66..000000000 --- a/test/java/org/apache/fop/render/RawPNGTestUtil.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.zip.Deflater; -import java.util.zip.DeflaterOutputStream; - -import org.apache.xmlgraphics.image.loader.ImageSize; - -public final class RawPNGTestUtil { - - private static final int NUM_ROWS = 32; - private static final int NUM_COLUMNS = 32; - private static final int DPI = 72; - - private RawPNGTestUtil() { - - } - - /** - * Builds a PNG IDAT section for a square of a given color and alpha; the filter is fixed. - * @param gray the gray color; set to -1 if using RGB - * @param red the red color; ignored if gray > -1 - * @param green the green color; ignored if gray > -1 - * @param blue the blue color; ignored if gray > -1 - * @param alpha the alpha color; set to -1 if not present - * @return the PNG IDAT byte array - * @throws IOException - */ - public static byte[] buildGRGBAData(int gray, int red, int green, int blue, int alpha) throws IOException { - // build an image, 32x32, Gray or RGB, with or without alpha, and with filter - int filter = 0; - int numRows = NUM_ROWS; - int numColumns = NUM_COLUMNS; - int numComponents = (gray > -1 ? 1 : 3) + (alpha > -1 ? 1 : 0); - int numBytesPerRow = numColumns * numComponents + 1; // 1 for filter - int numBytes = numRows * numBytesPerRow; - byte[] data = new byte[numBytes]; - for (int r = 0; r < numRows; r++) { - data[r * numBytesPerRow] = (byte) filter; - for (int c = 0; c < numColumns; c++) { - if (numComponents == 1) { - data[r * numBytesPerRow + numComponents * c + 1] = (byte) gray; - } else if (numComponents == 2) { - data[r * numBytesPerRow + numComponents * c + 1] = (byte) gray; - data[r * numBytesPerRow + numComponents * c + 2] = (byte) alpha; - } else if (numComponents == 3) { - data[r * numBytesPerRow + numComponents * c + 1] = (byte) red; - data[r * numBytesPerRow + numComponents * c + 2] = (byte) green; - data[r * numBytesPerRow + numComponents * c + 3] = (byte) blue; - } else if (numComponents == 4) { - data[r * numBytesPerRow + numComponents * c + 1] = (byte) red; - data[r * numBytesPerRow + numComponents * c + 2] = (byte) green; - data[r * numBytesPerRow + numComponents * c + 3] = (byte) blue; - data[r * numBytesPerRow + numComponents * c + 4] = (byte) alpha; - } - } - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater()); - dos.write(data); - dos.close(); - return baos.toByteArray(); - } - - /** - * - * @return a default ImageSize - */ - public static ImageSize getImageSize() { - return new ImageSize(NUM_ROWS, NUM_COLUMNS, DPI); - } -} diff --git a/test/java/org/apache/fop/render/RendererFactoryTestCase.java b/test/java/org/apache/fop/render/RendererFactoryTestCase.java deleted file mode 100644 index 1fa4ae0fa..000000000 --- a/test/java/org/apache/fop/render/RendererFactoryTestCase.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render; - -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; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.area.AreaTreeHandler; -import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFRenderer; -import org.apache.fop.render.pdf.PDFDocumentHandler; -import org.apache.fop.render.rtf.RTFHandler; - -/** - * Tests for {@link RendererFactory}. - */ -public class RendererFactoryTestCase { - - @Test - public void testDocumentHandlerLevel() throws Exception { - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - RendererFactory factory = fopFactory.getRendererFactory(); - FOUserAgent ua; - IFDocumentHandler handler; - IFDocumentHandler overrideHandler; - - ua = fopFactory.newFOUserAgent(); - handler = factory.createDocumentHandler(ua, MimeConstants.MIME_PDF); - - ua = fopFactory.newFOUserAgent(); - overrideHandler = new PDFDocumentHandler(new IFContext(ua)); - ua.setDocumentHandlerOverride(overrideHandler); - handler = factory.createDocumentHandler(ua, null); - assertTrue(handler == overrideHandler); - - ua = fopFactory.newFOUserAgent(); - try { - handler = factory.createDocumentHandler(ua, "invalid/format"); - fail("Expected UnsupportedOperationException"); - } catch (UnsupportedOperationException uoe) { - //expected - } - } - - @Test - public void testRendererLevel() throws Exception { - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - RendererFactory factory = fopFactory.getRendererFactory(); - FOUserAgent ua; - Renderer renderer; - - ua = fopFactory.newFOUserAgent(); - renderer = factory.createRenderer(ua, MimeConstants.MIME_PDF); - assertTrue(renderer instanceof IFRenderer); - - ua = fopFactory.newFOUserAgent(); - renderer = factory.createRenderer(ua, MimeConstants.MIME_FOP_IF); - assertTrue(renderer instanceof IFRenderer); - - ua = fopFactory.newFOUserAgent(); - IFDocumentHandler overrideHandler; - overrideHandler = new PDFDocumentHandler(new IFContext(ua)); - ua.setDocumentHandlerOverride(overrideHandler); - renderer = factory.createRenderer(ua, null); - assertTrue(renderer instanceof IFRenderer); - - ua = fopFactory.newFOUserAgent(); - try { - renderer = factory.createRenderer(ua, "invalid/format"); - fail("Expected UnsupportedOperationException"); - } catch (UnsupportedOperationException uoe) { - //expected - } - } - - @Test - public void testFOEventHandlerLevel() throws Exception { - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - RendererFactory factory = fopFactory.getRendererFactory(); - FOUserAgent ua; - FOEventHandler foEventHandler; - FOEventHandler overrideFOEventHandler; - - ua = fopFactory.newFOUserAgent(); - foEventHandler = factory.createFOEventHandler( - ua, MimeConstants.MIME_PDF, new NullOutputStream()); - assertTrue(foEventHandler instanceof AreaTreeHandler); - - ua = fopFactory.newFOUserAgent(); - foEventHandler = factory.createFOEventHandler( - ua, MimeConstants.MIME_RTF, new NullOutputStream()); - assertTrue(foEventHandler instanceof RTFHandler); - - ua = fopFactory.newFOUserAgent(); - try { - foEventHandler = factory.createFOEventHandler( - ua, "invalid/format", new NullOutputStream()); - fail("Expected UnsupportedOperationException"); - } catch (UnsupportedOperationException uoe) { - //expected - } - - ua = fopFactory.newFOUserAgent(); - try { - foEventHandler = factory.createFOEventHandler( - ua, MimeConstants.MIME_PDF, null); - fail("Expected FOPException because of missing OutputStream"); - } catch (FOPException fe) { - //expected - } - - ua = fopFactory.newFOUserAgent(); - overrideFOEventHandler = new RTFHandler(ua, new NullOutputStream()); - ua.setFOEventHandlerOverride(overrideFOEventHandler); - foEventHandler = factory.createFOEventHandler( - ua, null, null); - assertTrue(foEventHandler == overrideFOEventHandler); - } - -} diff --git a/test/java/org/apache/fop/render/afp/AFPBorderPainterTestCase.java b/test/java/org/apache/fop/render/afp/AFPBorderPainterTestCase.java deleted file mode 100644 index dfe956d90..000000000 --- a/test/java/org/apache/fop/render/afp/AFPBorderPainterTestCase.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.afp; - -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; -import org.apache.fop.afp.BorderPaintingInfo; -import org.apache.fop.afp.DataStream; -import org.apache.fop.afp.Factory; -import org.apache.fop.fo.Constants; - -public class AFPBorderPainterTestCase { - private ByteArrayOutputStream outStream; - private AFPBorderPainter borderPainter; - private DataStream ds; - private AFPLineDataInfo line; - - @Before - public void setUp() throws Exception { - outStream = new ByteArrayOutputStream(); - ds = new MyDataStream(new Factory(), null, outStream); - ds.startDocument(); - ds.startPage(1000, 1000, 90, 72, 72); - borderPainter = new AFPBorderPainter(new AFPPaintingState(), ds); - } - - /** - * This test will fail if either of the below statements isn't true: - * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_SPACE_RATIO = 0.5f:q - * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_LENGTH_FACTOR = 4.0f. - */ - @Test - public void testDrawBorderLine() throws Exception { - BorderPaintingInfo paintInfo = new BorderPaintingInfo(0f, 0f, 1000f, 1000f, true, - Constants.EN_DASHED, Color.BLACK); - borderPainter.paint(paintInfo); - 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/AFPPainterTestCase.java b/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java deleted file mode 100644 index fd6209bf1..000000000 --- a/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.afp; - -import java.awt.Color; -import java.awt.Rectangle; -import java.util.Map; - -import org.junit.Test; - -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.ImageManager; -import org.apache.xmlgraphics.image.loader.impl.DefaultImageContext; -import org.apache.xmlgraphics.image.loader.impl.DefaultImageSessionContext; -import org.apache.xmlgraphics.image.loader.impl.ImageBuffered; - -import org.apache.fop.afp.AFPEventProducer; -import org.apache.fop.afp.AFPPaintingState; -import org.apache.fop.afp.AFPResourceManager; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.events.EventBroadcaster; -import org.apache.fop.fo.Constants; -import org.apache.fop.render.ImageHandlerRegistry; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.traits.BorderProps; - -public class AFPPainterTestCase { - - @Test - public void testDrawBorderRect() { - // the goal of this test is to check that the drawing of rounded corners in AFP uses a bitmap of the - // rounded corners (in fact the whole rectangle with rounded corners). the check is done by verifying - // that the AFPImageHandlerRenderedImage.handleImage() method is called - // mock - AFPPaintingState afpPaintingState = mock(AFPPaintingState.class); - when(afpPaintingState.getResolution()).thenReturn(72); - // mock - EventBroadcaster eventBroadcaster = mock(EventBroadcaster.class); - // mock - DefaultImageContext defaultImageContext = mock(DefaultImageContext.class); - when(defaultImageContext.getSourceResolution()).thenReturn(72000f); - // mock - DefaultImageSessionContext defaultImageSessionContxt = mock(DefaultImageSessionContext.class); - when(defaultImageSessionContxt.getParentContext()).thenReturn(defaultImageContext); - when(defaultImageSessionContxt.getTargetResolution()).thenReturn(72000f); - // mock - ImageBuffered imageBuffered = mock(ImageBuffered.class); - // mock - ImageManager imageManager = mock(ImageManager.class); - // mock - AFPImageHandlerRenderedImage afpImageHandlerRenderedImage = mock(AFPImageHandlerRenderedImage.class); - // mock - ImageHandlerRegistry imageHandlerRegistry = mock(ImageHandlerRegistry.class); - when(imageHandlerRegistry.getHandler(any(AFPRenderingContext.class), any(Image.class))).thenReturn( - afpImageHandlerRenderedImage); - // mock - FOUserAgent foUserAgent = mock(FOUserAgent.class); - when(foUserAgent.getEventBroadcaster()).thenReturn(eventBroadcaster); - when(foUserAgent.getImageSessionContext()).thenReturn(defaultImageSessionContxt); - when(foUserAgent.getImageManager()).thenReturn(imageManager); - when(foUserAgent.getImageHandlerRegistry()).thenReturn(imageHandlerRegistry); - // mock - AFPEventProducer afpEventProducer = mock(AFPEventProducer.class); - when(AFPEventProducer.Provider.get(eventBroadcaster)).thenReturn(afpEventProducer); - // mock - AFPResourceManager afpResourceManager = mock(AFPResourceManager.class); - when(afpResourceManager.isObjectCached(null)).thenReturn(false); - // mock - IFContext ifContext = mock(IFContext.class); - when(ifContext.getUserAgent()).thenReturn(foUserAgent); - // mock - AFPDocumentHandler afpDocumentHandler = mock(AFPDocumentHandler.class); - when(afpDocumentHandler.getPaintingState()).thenReturn(afpPaintingState); - when(afpDocumentHandler.getContext()).thenReturn(ifContext); - when(afpDocumentHandler.getResourceManager()).thenReturn(afpResourceManager); - when(afpDocumentHandler.cacheRoundedCorner("a2a48964ba2d")).thenReturn("RC000000"); - // real instance, no mock - AFPPainter afpPainter = new AFPPainter(afpDocumentHandler); - // build rectangle 200 x 50 (points, which are converted to millipoints) - Rectangle rectangle = new Rectangle(0, 0, 200000, 50000); - // build border properties - int style = Constants.EN_SOLID; - BorderProps.Mode mode = BorderProps.Mode.SEPARATE; - Color color = Color.BLACK; - int borderWidth = 4000; - int radiusStart = 30000; - int radiusEnd = 30000; - BorderProps border1 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode); - BorderProps border2 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode); - BorderProps border3 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode); - BorderProps border4 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode); - try { - when(imageManager.convertImage(any(Image.class), any(ImageFlavor[].class), any(Map.class))) - .thenReturn(imageBuffered); - afpPainter.drawBorderRect(rectangle, border1, border2, border3, border4, Color.WHITE); - // note: here we would really like to verify that the second and third arguments passed to - // handleImage() are the instances ib and rect declared above but that causes mockito to throw - // an exception, probably because we cannot declare the AFPRenderingContext and are forced to - // use any(), which forces the use of any() for all arguments - verify(afpImageHandlerRenderedImage).handleImage(any(AFPRenderingContext.class), - any(Image.class), any(Rectangle.class)); - } catch (Exception e) { - fail("something broke..."); - } - } - -} diff --git a/test/java/org/apache/fop/render/afp/AFPParser.java b/test/java/org/apache/fop/render/afp/AFPParser.java deleted file mode 100644 index 9f0f92322..000000000 --- a/test/java/org/apache/fop/render/afp/AFPParser.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ -package org.apache.fop.render.afp; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -import org.apache.fop.afp.AFPConstants; -import org.apache.fop.afp.ptoca.PtocaBuilder; - -import junit.framework.Assert; - -public class AFPParser { - private boolean readText; - public AFPParser(boolean readText) { - this.readText = readText; - } - - public void read(InputStream bis, StringBuilder sb) throws IOException { - while (bis.available() > 0) { - readField(bis, sb); - } - } - - private void readField(InputStream bis, StringBuilder sb) throws IOException { - bis.read(); - int len = getLength(bis.read(), bis.read()); - byte[] field = new byte[len - 2]; - bis.read(field); - InputStream fieldStream = new ByteArrayInputStream(field); - fieldStream.read(); - byte type = (byte) fieldStream.read(); - byte category = (byte) fieldStream.read(); - fieldStream.skip(3); - String typeStr = TYPE_MAP.get(type & 0xFF); - String catStr = CATEGORY_MAP.get(category & 0xFF); - if (typeStr != null && catStr != null) { - sb.append(typeStr + " " + catStr); - if (typeStr.equals("BEGIN") || typeStr.equals("END")) { - byte[] name = new byte[8]; - fieldStream.read(name); - sb.append(" " + new String(name, AFPConstants.EBCIDIC_ENCODING)); - fieldStream.skip(2); - readTriplet(fieldStream, sb); - } else if (typeStr.equals("MAP")) { - fieldStream.skip(2); - readTriplet(fieldStream, sb); - } else if (typeStr.equals("DESCRIPTOR") && catStr.equals("OBJECT_AREA")) { - readTriplet(fieldStream, sb); - } else if (typeStr.equals("DATA") && catStr.equals("PRESENTATION_TEXT") && readText) { - readData(fieldStream, sb); - } - sb.append("\n"); - } - } - - private void readData(InputStream bis, StringBuilder sb) throws IOException { - Assert.assertEquals(bis.read(), 0x2B); - Assert.assertEquals(bis.read(), 0xD3); - while (bis.available() > 0) { - int len = bis.read(); - int functionType = bis.read(); - - sb.append(" " + PTOCA_MAP.get(functionType)); - - if ("TRN".equals(PTOCA_MAP.get(functionType))) { - byte[] data = new byte[len - 2]; - bis.read(data); - sb.append(" " + new String(data, "UTF-16BE")); - } else { - bis.skip(len - 2); - } - } - } - - private void readTriplet(InputStream des, StringBuilder sb) throws IOException { - if (des.available() > 0) { - sb.append(" Triplets: "); - } - while (des.available() > 0) { - int len2 = des.read(); - int id = des.read(); - int b = id & 0xFF; - if (TRIPLET_MAP.containsKey(b)) { - sb.append(TRIPLET_MAP.get(b) + ","); - } else { - sb.append(String.format("0x%02X,", b)); - } - des.skip(len2 - 2); - } - } - - private int getLength(int a, int b) { - return (a * 256) + b; - } - - private static final Map<Integer, String> TYPE_MAP = new HashMap<Integer, String>(); - private static final Map<Integer, String> CATEGORY_MAP = new HashMap<Integer, String>(); - private static final Map<Integer, String> TRIPLET_MAP = new HashMap<Integer, String>(); - private static final Map<Integer, String> PTOCA_MAP = new HashMap<Integer, String>(); - static { - PTOCA_MAP.put(0xC2 | PtocaBuilder.CHAIN_BIT, "SIA"); - PTOCA_MAP.put(0xC4 | PtocaBuilder.CHAIN_BIT, "SVI"); - PTOCA_MAP.put(0xC6 | PtocaBuilder.CHAIN_BIT, "AMI"); - PTOCA_MAP.put(0xC8 | PtocaBuilder.CHAIN_BIT, "RMI"); - PTOCA_MAP.put(0xD2 | PtocaBuilder.CHAIN_BIT, "AMB"); - PTOCA_MAP.put(0xDA | PtocaBuilder.CHAIN_BIT, "TRN"); - PTOCA_MAP.put(0xE4 | PtocaBuilder.CHAIN_BIT, "DIR"); - PTOCA_MAP.put(0xE6 | PtocaBuilder.CHAIN_BIT, "DBR"); - PTOCA_MAP.put(0x80 | PtocaBuilder.CHAIN_BIT, "SEC"); - PTOCA_MAP.put(0xF0 | PtocaBuilder.CHAIN_BIT, "SCFL"); - PTOCA_MAP.put(0xF6 | PtocaBuilder.CHAIN_BIT, "STO"); - PTOCA_MAP.put(0xF8 | PtocaBuilder.CHAIN_BIT, "NOP"); - - TYPE_MAP.put(0xA0, "ATTRIBUTE"); - TYPE_MAP.put(0xA2, "COPY_COUNT"); - TYPE_MAP.put(0xA6, "DESCRIPTOR"); - TYPE_MAP.put(0xA7, "CONTROL"); - TYPE_MAP.put(0xA8, "BEGIN"); - TYPE_MAP.put(0xA9, "END"); - TYPE_MAP.put(0xAB, "MAP"); - TYPE_MAP.put(0xAC, "POSITION"); - TYPE_MAP.put(0xAD, "PROCESS"); - TYPE_MAP.put(0xAF, "INCLUDE"); - TYPE_MAP.put(0xB0, "TABLE"); - TYPE_MAP.put(0xB1, "MIGRATION"); - TYPE_MAP.put(0xB2, "VARIABLE"); - TYPE_MAP.put(0xB4, "LINK"); - TYPE_MAP.put(0xEE, "DATA"); - - CATEGORY_MAP.put(0x5F, "PAGE_SEGMENT"); - CATEGORY_MAP.put(0x6B, "OBJECT_AREA"); - CATEGORY_MAP.put(0x77, "COLOR_ATTRIBUTE_TABLE"); - CATEGORY_MAP.put(0x7B, "IM_IMAGE"); - CATEGORY_MAP.put(0x88, "MEDIUM"); - CATEGORY_MAP.put(0x8A, "CODED_FONT"); - CATEGORY_MAP.put(0x90, "PROCESS_ELEMENT"); - CATEGORY_MAP.put(0x92, "OBJECT_CONTAINER"); - CATEGORY_MAP.put(0x9B, "PRESENTATION_TEXT"); - CATEGORY_MAP.put(0xA7, "INDEX"); - CATEGORY_MAP.put(0xA8, "DOCUMENT"); - CATEGORY_MAP.put(0xAD, "PAGE_GROUP"); - CATEGORY_MAP.put(0xAF, "PAGE"); - CATEGORY_MAP.put(0xBB, "GRAPHICS"); - CATEGORY_MAP.put(0xC3, "DATA_RESOURCE"); - CATEGORY_MAP.put(0xC4, "DOCUMENT_ENVIRONMENT_GROUP"); - CATEGORY_MAP.put(0xC6, "RESOURCE_GROUP"); - CATEGORY_MAP.put(0xC7, "OBJECT_ENVIRONMENT_GROUP"); - CATEGORY_MAP.put(0xC9, "ACTIVE_ENVIRONMENT_GROUP"); - CATEGORY_MAP.put(0xCC, "MEDIUM_MAP"); - CATEGORY_MAP.put(0xCD, "FORM_MAP"); - CATEGORY_MAP.put(0xCE, "NAME_RESOURCE"); - CATEGORY_MAP.put(0xD8, "PAGE_OVERLAY"); - CATEGORY_MAP.put(0xD9, "RESOURCE_ENVIROMENT_GROUP"); - CATEGORY_MAP.put(0xDF, "OVERLAY"); - CATEGORY_MAP.put(0xEA, "DATA_SUPRESSION"); - CATEGORY_MAP.put(0xEB, "BARCODE"); - CATEGORY_MAP.put(0xEE, "NO_OPERATION"); - CATEGORY_MAP.put(0xFB, "IMAGE"); - - TRIPLET_MAP.put(0x02, "FULLY_QUALIFIED_NAME"); - TRIPLET_MAP.put(0x04, "MAPPING_OPTION"); - TRIPLET_MAP.put(0x10, "OBJECT_CLASSIFICATION"); - TRIPLET_MAP.put(0x18, "MODCA_INTERCHANGE_SET"); - TRIPLET_MAP.put(0x1F, "FONT_DESCRIPTOR_SPECIFICATION"); - TRIPLET_MAP.put(0x21, "OBJECT_FUNCTION_SET_SPECIFICATION"); - TRIPLET_MAP.put(0x22, "EXTENDED_RESOURCE_LOCAL_IDENTIFIER"); - TRIPLET_MAP.put(0x24, "RESOURCE_LOCAL_IDENTIFIER"); - TRIPLET_MAP.put(0x25, "RESOURCE_SECTION_NUMBER"); - TRIPLET_MAP.put(0x26, "CHARACTER_ROTATION"); - TRIPLET_MAP.put(0x2D, "OBJECT_BYTE_OFFSET"); - TRIPLET_MAP.put(0x36, "ATTRIBUTE_VALUE"); - TRIPLET_MAP.put(0x43, "DESCRIPTOR_POSITION"); - TRIPLET_MAP.put(0x45, "MEDIA_EJECT_CONTROL"); - TRIPLET_MAP.put(0x46, "PAGE_OVERLAY_CONDITIONAL_PROCESSING"); - TRIPLET_MAP.put(0x47, "RESOURCE_USAGE_ATTRIBUTE"); - TRIPLET_MAP.put(0x4B, "MEASUREMENT_UNITS"); - TRIPLET_MAP.put(0x4C, "OBJECT_AREA_SIZE"); - TRIPLET_MAP.put(0x4D, "AREA_DEFINITION"); - TRIPLET_MAP.put(0x4E, "COLOR_SPECIFICATION"); - TRIPLET_MAP.put(0x50, "ENCODING_SCHEME_ID"); - TRIPLET_MAP.put(0x56, "MEDIUM_MAP_PAGE_NUMBER"); - TRIPLET_MAP.put(0x57, "OBJECT_BYTE_EXTENT"); - TRIPLET_MAP.put(0x58, "OBJECT_STRUCTURED_FIELD_OFFSET"); - TRIPLET_MAP.put(0x59, "OBJECT_STRUCTURED_FIELD_EXTENT"); - TRIPLET_MAP.put(0x5A, "OBJECT_OFFSET"); - TRIPLET_MAP.put(0x5D, "FONT_HORIZONTAL_SCALE_FACTOR"); - TRIPLET_MAP.put(0x5E, "OBJECT_COUNT"); - TRIPLET_MAP.put(0x62, "OBJECT_DATE_AND_TIMESTAMP"); - TRIPLET_MAP.put(0x65, "COMMENT"); - TRIPLET_MAP.put(0x68, "MEDIUM_ORIENTATION"); - TRIPLET_MAP.put(0x6C, "RESOURCE_OBJECT_INCLUDE"); - TRIPLET_MAP.put(0x70, "PRESENTATION_SPACE_RESET_MIXING"); - TRIPLET_MAP.put(0x71, "PRESENTATION_SPACE_MIXING_RULE"); - TRIPLET_MAP.put(0x72, "UNIVERSAL_DATE_AND_TIMESTAMP"); - TRIPLET_MAP.put(0x74, "TONER_SAVER"); - TRIPLET_MAP.put(0x75, "COLOR_FIDELITY"); - TRIPLET_MAP.put(0x78, "FONT_FIDELITY"); - TRIPLET_MAP.put(0x80, "ATTRIBUTE_QUALIFIER"); - TRIPLET_MAP.put(0x81, "PAGE_POSITION_INFORMATION"); - TRIPLET_MAP.put(0x82, "PARAMETER_VALUE"); - TRIPLET_MAP.put(0x83, "PRESENTATION_CONTROL"); - TRIPLET_MAP.put(0x84, "FONT_RESOLUTION_AND_METRIC_TECHNOLOGY"); - TRIPLET_MAP.put(0x85, "FINISHING_OPERATION"); - TRIPLET_MAP.put(0x86, "TEXT_FIDELITY"); - TRIPLET_MAP.put(0x87, "MEDIA_FIDELITY"); - TRIPLET_MAP.put(0x88, "FINISHING_FIDELITY"); - TRIPLET_MAP.put(0x8B, "DATA_OBJECT_FONT_DESCRIPTOR"); - TRIPLET_MAP.put(0x8C, "LOCALE_SELECTOR"); - TRIPLET_MAP.put(0x8E, "UP3I_FINISHING_OPERATION"); - TRIPLET_MAP.put(0x91, "COLOR_MANAGEMENT_RESOURCE_DESCRIPTOR"); - TRIPLET_MAP.put(0x95, "RENDERING_INTENT"); - TRIPLET_MAP.put(0x96, "CMR_TAG_FIDELITY"); - TRIPLET_MAP.put(0x97, "DEVICE_APPEARANCE"); - } -} diff --git a/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java deleted file mode 100644 index 8ed54049f..000000000 --- a/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.afp; - -import java.io.File; -import java.util.HashMap; -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; -import org.apache.fop.render.afp.AFPRendererConfig.AFPRendererConfigParser; -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; - -public class AFPRendererConfigParserTestCase - extends AbstractRendererConfigParserTester<AFPRendererConfBuilder, AFPRendererConfig> { - - public AFPRendererConfigParserTestCase() { - super(new AFPRendererConfigParser(), AFPRendererConfBuilder.class); - } - - @Test - public void testShadingMode() throws Exception { - parseConfig(); - assertEquals(AFPShadingMode.COLOR, conf.getShadingMode()); - parseConfig(createRenderer().setShading(AFPShadingMode.DITHERED)); - assertEquals(AFPShadingMode.DITHERED, conf.getShadingMode()); - } - - @Test - public void testResolution() throws Exception { - parseConfig(createRenderer()); - assertEquals(Integer.valueOf(240), conf.getResolution()); - parseConfig(createRenderer().setRenderingResolution(300)); - assertEquals(Integer.valueOf(300), conf.getResolution()); - } - - @Test - public void testLineWidthCorrection() throws Exception { - parseConfig(createRenderer()); - assertEquals(AFPConstants.LINE_WIDTH_CORRECTION, - conf.getLineWidthCorrection().floatValue(), 0.0001f); - parseConfig(createRenderer().setLineWidthCorrection(1f)); - assertEquals(Float.valueOf(1f), conf.getLineWidthCorrection()); - } - - @Test - public void testResourceGroupUri() throws Exception { - parseConfig(createRenderer()); - assertEquals(null, conf.getDefaultResourceGroupUri()); - // TODO yuck! - File file = File.createTempFile("AFPRendererConfigParserTestCase", ""); - try { - file.delete(); - parseConfig(createRenderer().setResourceGroupUri(file.toURI().toASCIIString())); - assertEquals(file.toURI(), conf.getDefaultResourceGroupUri()); - } finally { - file.delete(); - } - } - - @Test - public void testResourceLevelDefaults() throws Exception { - parseConfig(createRenderer()); - assertNull(conf.getResourceLevelDefaults()); - Map<String, String> levels = new HashMap<String, String>(); - levels.put("goca", "page"); - parseConfig(createRenderer().setDefaultResourceLevels(levels)); - assertNotNull(conf.getResourceLevelDefaults()); - } - - @Test - public void testImages() throws Exception { - parseConfig(createRenderer()); - assertEquals(false, conf.isColorImages()); - assertEquals(Integer.valueOf(8), conf.getBitsPerPixel()); - ImagesModeOptions mode = MODE_GRAYSCALE; - parseConfig(createRenderer().startImages(mode) - .setModeAttribute(mode.getModeAttribute(), String.valueOf(1)) - .endImages()); - assertEquals(false, conf.isColorImages()); - assertEquals(Integer.valueOf(1), conf.getBitsPerPixel()); - mode = MODE_COLOR; - parseConfig(createRenderer() - .startImages(mode) - .setModeAttribute(mode.getModeAttribute(), - String.valueOf(false)) - .endImages()); - assertEquals(true, conf.isColorImages()); - assertEquals(false, conf.isCmykImagesSupported()); - parseConfig(createRenderer().startImages(mode) - .setModeAttribute(mode.getModeAttribute(), String.valueOf(true)) - .endImages()); - assertEquals(true, conf.isColorImages()); - assertEquals(true, conf.isCmykImagesSupported()); - } - - @Test(expected = IllegalStateException.class) - public void testImagesException1() throws Exception { - parseConfig(createRenderer().startImages().endImages()); - conf.isCmykImagesSupported(); - } - - @Test(expected = IllegalStateException.class) - public void testImagesException2() throws Exception { - parseConfig(createRenderer().startImages(MODE_COLOR).endImages()); - conf.getBitsPerPixel(); - } - - @Test - public void testImagesNative() throws Exception { - parseConfig(createRenderer()); - assertEquals(false, conf.isNativeImagesSupported()); - parseConfig(createRenderer().startImages().setNativeImageSupport(true).endImages()); - assertEquals(true, conf.isNativeImagesSupported()); - } - - @Test - public void testDitheringQuality() throws Exception { - parseConfig(createRenderer()); - assertEquals(0.5f, conf.getDitheringQuality(), 0.001f); - parseConfig(createRenderer().startImages().setDitheringQuality("min").endImages()); - assertEquals(0.0f, conf.getDitheringQuality(), 0.001f); - parseConfig(createRenderer().startImages().setDitheringQuality("max").endImages()); - assertEquals(1.0f, conf.getDitheringQuality(), 0.001f); - parseConfig(createRenderer().startImages().setDitheringQuality(0.25f).endImages()); - assertEquals(0.25f, conf.getDitheringQuality(), 0.001f); - } - - @Test - public void testAllowJpegEmbedding() throws Exception { - parseConfig(); - assertEquals(false, conf.allowJpegEmbedding()); - - parseConfig(createRenderer().startImages().setAllowJpegEmbedding(true).endImages()); - assertEquals(true, conf.allowJpegEmbedding()); - } - - @Test - public void testBitmapEncodingQuality() throws Exception { - parseConfig(); - assertEquals(1.0f, conf.getBitmapEncodingQuality(), 0.001f); - parseConfig(createRenderer().startImages().setBitmapEncodingQuality(0.5f).endImages()); - assertEquals(0.5f, conf.getBitmapEncodingQuality(), 0.001f); - } - - @Test - public void testFS45() throws Exception { - parseConfig(); - assertEquals(false, conf.isFs45()); - parseConfig(createRenderer().startImages().setFs45(true).endImages()); - assertEquals(true, conf.isFs45()); - } - - @Test - public void tesPseg() throws Exception { - parseConfig(); - assertEquals(false, conf.isWrapPseg()); - parseConfig(createRenderer().startImages().setWrapPseg(true).endImages()); - assertEquals(true, conf.isWrapPseg()); - } - - @Test(expected = IllegalArgumentException.class) - public void testForNameException() throws Exception { - ImagesModeOptions.forName("_"); - } -} diff --git a/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java deleted file mode 100644 index 48cf89240..000000000 --- a/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.render.afp; - -import java.net.URI; -import java.util.HashMap; -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; -import org.apache.fop.apps.AFPRendererConfBuilder; -import org.apache.fop.apps.AbstractRendererConfiguratorTest; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.afp.AFPRendererConfig.AFPRendererConfigParser; -import org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions; - -public class AFPRendererConfiguratorTestCase extends - AbstractRendererConfiguratorTest<AFPRendererConfigurator, AFPRendererConfBuilder> { - - public AFPRendererConfiguratorTestCase() { - super(MimeConstants.MIME_AFP, AFPRendererConfBuilder.class, AFPDocumentHandler.class); - } - - @Override - public void setUpDocumentHandler() { - } - - @Override - protected AFPRendererConfigurator createConfigurator() { - return new AFPRendererConfigurator(userAgent, new AFPRendererConfigParser()); - } - - private AFPDocumentHandler getDocHandler() { - return (AFPDocumentHandler) docHandler; - } - - @Test - public void testColorImages() throws Exception { - parseConfig(createBuilder().startImages(ImagesModeOptions.MODE_COLOR) - .endImages()); - verify(getDocHandler()).setColorImages(true); - - parseConfig(createBuilder().startImages(ImagesModeOptions.MODE_GRAYSCALE) - .endImages()); - verify(getDocHandler()).setColorImages(false); - } - - @Test - public void testCMYKImagesSupport() throws Exception { - parseConfig(createBuilder().startImages(ImagesModeOptions.MODE_COLOR) - .setModeAttribute("cmyk", "true") - .endImages()); - verify(getDocHandler()).setCMYKImagesSupported(true); - - parseConfig(createBuilder().startImages(ImagesModeOptions.MODE_COLOR) - .setModeAttribute("cmyk", "false") - .endImages()); - verify(getDocHandler()).setCMYKImagesSupported(false); - } - - @Test - public void testBitsPerPixel() throws Exception { - for (int bpp = 0; bpp < 40; bpp += 8) { - parseConfig(createBuilder().startImages() - .setModeAttribute("bits-per-pixel", String.valueOf(bpp)) - .endImages()); - verify(getDocHandler()).setBitsPerPixel(bpp); - } - } - - @Test - public void testDitheringQuality() throws Exception { - float ditheringQuality = 100f; - parseConfig(createBuilder().startImages() - .setDitheringQuality(ditheringQuality) - .endImages()); - verify(getDocHandler()).setDitheringQuality(ditheringQuality); - - ditheringQuality = 1000f; - parseConfig(createBuilder().startImages() - .setDitheringQuality(ditheringQuality) - .endImages()); - verify(getDocHandler()).setDitheringQuality(ditheringQuality); - } - - @Test - public void testNativeImagesSupported() throws Exception { - parseConfig(createBuilder().startImages() - .setNativeImageSupport(true) - .endImages()); - verify(getDocHandler()).setNativeImagesSupported(true); - - parseConfig(createBuilder().startImages() - .setNativeImageSupport(false) - .endImages()); - verify(getDocHandler()).setNativeImagesSupported(false); - } - - @Test - public void testShadingMode() throws Exception { - for (AFPShadingMode mode : AFPShadingMode.values()) { - parseConfig(createBuilder().setShading(mode)); - verify(getDocHandler()).setShadingMode(mode); - } - } - - @Test - public void testRendererResolution() throws Exception { - for (int resolution = 0; resolution < 1000; resolution += 100) { - parseConfig(createBuilder().setRenderingResolution(resolution)); - verify(getDocHandler()).setResolution(resolution); - } - } - - @Test - public void testLineWidthCorrection() throws Exception { - for (float resolution = 0; resolution < 50; resolution += 5) { - parseConfig(createBuilder().setLineWidthCorrection(resolution)); - verify(getDocHandler()).setLineWidthCorrection(resolution); - } - } - - @Test - public void testResourceGroupURI() throws Exception { - URI uri = URI.create("test://URI/just/used/for/testing"); - parseConfig(createBuilder().setResourceGroupUri(uri.toASCIIString())); - verify(getDocHandler()).setDefaultResourceGroupUri(uri); - } - - @Test - public void testResourceLevelDefaults() throws Exception { - testResourceLevelDefault(ResourceType.DOCUMENT); - } - - private void testResourceLevelDefault(ResourceType resType) throws Exception { - Map<String, String> resourceLevels = new HashMap<String, String>(); - resourceLevels.put("goca", resType.getName()); - parseConfig(createBuilder().setDefaultResourceLevels(resourceLevels)); - ArgumentCaptor<AFPResourceLevelDefaults> argument = ArgumentCaptor.forClass(AFPResourceLevelDefaults.class); - verify(getDocHandler()).setResourceLevelDefaults(argument.capture()); - AFPResourceLevel expectedLevel = new AFPResourceLevel(resType); - assertEquals(expectedLevel, argument.getValue().getDefaultResourceLevel((byte) 3)); - } - - @Test - public void testExternalResourceDefault() throws Exception { - testResourceLevelDefault(ResourceType.EXTERNAL); - } - - @Test - public void testInlineResourceDefault() throws Exception { - testResourceLevelDefault(ResourceType.INLINE); - } - - @Test - public void testPageResourceDefault() throws Exception { - testResourceLevelDefault(ResourceType.PAGE); - } - - @Test - public void testPageGroupResourceDefault() throws Exception { - testResourceLevelDefault(ResourceType.PAGE_GROUP); - } - - @Test - public void testPrintFileResourceDefault() throws Exception { - testResourceLevelDefault(ResourceType.PRINT_FILE); - } - - @Test - public void testBitmapEncodeQuality() throws Exception { - parseConfig(createBuilder().startImages() - .setBitmapEncodingQuality(0.5f) - .endImages()); - verify(getDocHandler()).setBitmapEncodingQuality(0.5f); - } - - @Test - public void testCanEmbedJpeg() throws Exception { - parseConfig(createBuilder().startImages() - .setAllowJpegEmbedding(true) - .endImages()); - verify(getDocHandler()).canEmbedJpeg(true); - - parseConfig(createBuilder().startImages() - .setAllowJpegEmbedding(false) - .endImages()); - verify(getDocHandler()).canEmbedJpeg(false); - } - -} diff --git a/test/java/org/apache/fop/render/afp/AFPTestSuite.java b/test/java/org/apache/fop/render/afp/AFPTestSuite.java deleted file mode 100644 index 117e7efcf..000000000 --- a/test/java/org/apache/fop/render/afp/AFPTestSuite.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.afp; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for FOP's AFP output. - */ -@RunWith(Suite.class) -@SuiteClasses({ - NoOperationTestCase.class, - AFPRendererConfiguratorTestCase.class }) -public class AFPTestSuite { -} diff --git a/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java b/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java deleted file mode 100644 index 333a23983..000000000 --- a/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ -package org.apache.fop.render.afp; - -import java.awt.Color; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import org.junit.Test; - -import org.xml.sax.SAXException; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.xmlgraphics.io.Resource; -import org.apache.xmlgraphics.io.ResourceResolver; - -import org.apache.fop.afp.AFPPaintingState; -import org.apache.fop.afp.AFPResourceManager; -import org.apache.fop.afp.DataStream; -import org.apache.fop.afp.Factory; -import org.apache.fop.afp.fonts.FopCharacterSet; -import org.apache.fop.afp.modca.PageObject; -import org.apache.fop.apps.EnvironmentalProfileFactory; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopConfParser; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.FopFactoryBuilder; -import org.apache.fop.apps.io.ResourceResolverFactory; -import org.apache.fop.fonts.EmbeddingMode; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontTriplet; -import org.apache.fop.fonts.MultiByteFont; -import org.apache.fop.render.intermediate.IFException; - -import junit.framework.Assert; - -public class AFPTrueTypeTestCase { - private String font; - - @Test - public void testAFPTrueType() throws IOException, SAXException, TransformerException, URISyntaxException { - String fopxconf = "<fop version=\"1.0\">\n" - + " <renderers>\n" - + " <renderer mime=\"application/x-afp\">\n" - + " <fonts>\n" - + " <font name=\"Univers\" embed-url=\"test/resources/fonts/ttf/DejaVuLGCSerif.ttf\">\n" - + " <font-triplet name=\"Univers\" style=\"normal\" weight=\"normal\"/>\n" - + " <font-triplet name=\"any\" style=\"normal\" weight=\"normal\"/>\n" - + " </font>\n" - + " </fonts>\n" - + " </renderer>\n" - + " </renderers>\n" - + "</fop>"; - String fo = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n" - + " <fo:layout-master-set>\n" - + " <fo:simple-page-master master-name=\"simple\">\n" - + " <fo:region-body />\n" - + " </fo:simple-page-master>\n" - + " </fo:layout-master-set>\n" - + " <fo:page-sequence master-reference=\"simple\">\n" - + " <fo:flow flow-name=\"xsl-region-body\">\n" - + " <fo:block font-family=\"Univers\">Univers</fo:block>\n" - + " </fo:flow>\n" - + " </fo:page-sequence>\n" - + "</fo:root>"; - - FopFactoryBuilder confBuilder = new FopConfParser( - new ByteArrayInputStream(fopxconf.getBytes()), - EnvironmentalProfileFactory.createRestrictedIO(new URI("."), - new MyResourceResolver())).getFopFactoryBuilder(); - FopFactory fopFactory = confBuilder.build(); - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - Fop fop = fopFactory.newFop("application/x-afp", foUserAgent, bos); - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); - Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes())); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - bos.close(); - - StringBuilder sb = new StringBuilder(); - InputStream bis = new ByteArrayInputStream(bos.toByteArray()); - new AFPParser(false).read(bis, sb); - - String format = "BEGIN RESOURCE_GROUP RG000001\n" - + "BEGIN NAME_RESOURCE RES00001 Triplets: OBJECT_FUNCTION_SET_SPECIFICATION" - + ",OBJECT_CLASSIFICATION,0x01,FULLY_QUALIFIED_NAME,\n" - + "BEGIN OBJECT_CONTAINER OC000001 Triplets: 0x41,0x00,0x00,\n"; - for (int i = 0; i < 29; i++) { - format += "DATA OBJECT_CONTAINER\n"; - } - format += "END OBJECT_CONTAINER OC000001\n" - + "END NAME_RESOURCE RES00001\n" - + "END RESOURCE_GROUP RG000001\n" - + "BEGIN DOCUMENT DOC00001\n" - + "BEGIN PAGE_GROUP PGP00001\n" - + "BEGIN PAGE PGN00001\n" - + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" - + "MAP DATA_RESOURCE Triplets: 0x01,FULLY_QUALIFIED_NAME,FULLY_QUALIFIED_NAME" - + ",OBJECT_CLASSIFICATION,DATA_OBJECT_FONT_DESCRIPTOR,\n" - + "DESCRIPTOR PAGE\n" - + "MIGRATION PRESENTATION_TEXT\n" - + "END ACTIVE_ENVIRONMENT_GROUP AEG00001\n" - + "BEGIN PRESENTATION_TEXT PT000001\n" - + "DATA PRESENTATION_TEXT\n" - + "END PRESENTATION_TEXT PT000001\n" - + "END PAGE PGN00001\n" - + "END PAGE_GROUP PGP00001\n" - + "END DOCUMENT DOC00001\n"; - - Assert.assertEquals(sb.toString(), format); - Assert.assertEquals("test/resources/fonts/ttf/DejaVuLGCSerif.ttf", font); - } - - class MyResourceResolver implements ResourceResolver { - private ResourceResolver defaultResourceResolver = ResourceResolverFactory.createDefaultResourceResolver(); - public Resource getResource(URI uri) throws IOException { - if (!"tmp".equals(uri.getScheme())) { - font = uri.getPath(); - uri = new File(".", uri.getPath()).toURI(); - } - return defaultResourceResolver.getResource(uri); - } - - public OutputStream getOutputStream(URI uri) throws IOException { - return defaultResourceResolver.getOutputStream(uri); - } - } - - @Test - public void testAFPPainter() throws IFException, IOException { - AFPDocumentHandler afpDocumentHandler = mock(AFPDocumentHandler.class); - when(afpDocumentHandler.getPaintingState()).thenReturn(new AFPPaintingState()); - when(afpDocumentHandler.getResourceManager()).thenReturn(new AFPResourceManager(null)); - - DataStream ds = mock(DataStream.class); - when(afpDocumentHandler.getDataStream()).thenReturn(ds); - PageObject po = new PageObject(new Factory(), "PAGE0001", 0, 0, 0, 0, 0); - when(ds.getCurrentPage()).thenReturn(po); - - AFPPainter afpPainter = new MyAFPPainter(afpDocumentHandler); - afpPainter.setFont("any", "normal", 400, null, null, Color.BLACK); - afpPainter.drawText(0, 0, 0, 0, null, "test"); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - po.writeToStream(bos); - - InputStream bis = new ByteArrayInputStream(bos.toByteArray()); - StringBuilder sb = new StringBuilder(); - new AFPParser(true).read(bis, sb); - Assert.assertTrue(sb.toString(), - sb.toString().contains("DATA PRESENTATION_TEXT AMB AMI SCFL TRN t TRN e TRN s TRN t")); - } - - class MyAFPPainter extends AFPPainter { - public MyAFPPainter(AFPDocumentHandler documentHandler) { - super(documentHandler); - } - - protected FOUserAgent getUserAgent() { - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - return fopFactory.newFOUserAgent(); - } - - protected FontInfo getFontInfo() { - FontInfo f = new FontInfo(); - f.addFontProperties("any", FontTriplet.DEFAULT_FONT_TRIPLET); - MultiByteFont font = new MultiByteFont(null, EmbeddingMode.AUTO); - font.setWidthArray(new int[100]); - f.addMetrics("any", new AFPFontConfig.AFPTrueTypeFont("", true, - new FopCharacterSet("", "UTF-16BE", "", font, null, null), null, null, null)); - return f; - } - } -} diff --git a/test/java/org/apache/fop/render/afp/AbstractAFPTest.java b/test/java/org/apache/fop/render/afp/AbstractAFPTest.java deleted file mode 100644 index 916c68395..000000000 --- a/test/java/org/apache/fop/render/afp/AbstractAFPTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.afp; - -import java.io.File; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.AbstractRenderingTest; - -/** - * Abstract base class for AFP verification tests. - */ -abstract class AbstractAFPTest extends AbstractRenderingTest { - - /** - * Renders a test file. - * @param ua the user agent (with override set!) - * @param resourceName the resource name for the FO file - * @param suffix a suffix for the output filename - * @return the output file - * @throws Exception if an error occurs - */ - protected File renderFile(FOUserAgent ua, String resourceName, String suffix) - throws Exception { - return renderFile(ua, resourceName, suffix, MimeConstants.MIME_AFP); - } - - -} diff --git a/test/java/org/apache/fop/render/afp/NoOperationTestCase.java b/test/java/org/apache/fop/render/afp/NoOperationTestCase.java deleted file mode 100644 index 9e83829f8..000000000 --- a/test/java/org/apache/fop/render/afp/NoOperationTestCase.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.afp; - -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; - -/** - * Tests generation of afp:no-operation (NOPs). - */ -public class NoOperationTestCase extends AbstractAFPTest { - - /** - * Tests afp:no-operation. - * @throws Exception if an error occurs - */ - @Test - public void testNoOperation() throws Exception { - FOUserAgent ua = fopFactory.newFOUserAgent(); - File outputFile = renderFile(ua, "nops.fo", ""); - - InputStream in = new java.io.FileInputStream(outputFile); - try { - MODCAParser parser = new MODCAParser(in); - UnparsedStructuredField field = skipTo(parser, 0xD3A8A8); //Begin Document - - //NOP in fo:declarations - field = parser.readNextStructuredField(); - assertEquals(0xD3EEEE, field.getSfTypeID()); - assertEquals("fo:declarations", getNopText(field)); - - field = parser.readNextStructuredField(); - assertEquals(0xD3A8AD, field.getSfTypeID()); //Begin Named Page Group - - //NOPs in fo:page-sequence - field = parser.readNextStructuredField(); - assertEquals(0xD3EEEE, field.getSfTypeID()); - assertEquals("fo:page-sequence: start", getNopText(field)); - field = parser.readNextStructuredField(); - assertEquals(0xD3EEEE, field.getSfTypeID()); - assertEquals("fo:page-sequence: end", getNopText(field)); - - field = parser.readNextStructuredField(); - assertEquals(0xD3A8AF, field.getSfTypeID()); //Begin Page - - field = skipTo(parser, 0xD3A9C9); //End Active Environment Group - field = parser.readNextStructuredField(); - assertEquals(0xD3EEEE, field.getSfTypeID()); - assertEquals("fo:simple-page-master: first", getNopText(field)); - - field = skipTo(parser, 0xD3A9C9); //End Active Environment Group - field = parser.readNextStructuredField(); - assertEquals(0xD3EEEE, field.getSfTypeID()); - assertEquals("fo:simple-page-master: rest", getNopText(field)); - } finally { - IOUtils.closeQuietly(in); - } - - int counter = 0; - in = new java.io.FileInputStream(outputFile); - try { - MODCAParser parser = new MODCAParser(in); - while (true) { - UnparsedStructuredField field = parser.readNextStructuredField(); - if (field == null) { - break; - } - if (field.getSfTypeID() == 0xD3EEEE) { - counter++; - } - } - } finally { - IOUtils.closeQuietly(in); - } - assertEquals(6, counter); //decl, 2 * ps, 3 * page/spm - } - - private String getNopText(UnparsedStructuredField field) throws UnsupportedEncodingException { - byte[] data = field.getData(); - String text = new String(data, AFPConstants.EBCIDIC_ENCODING); - return text; - } - - private UnparsedStructuredField skipTo(MODCAParser parser, int typeID) throws IOException { - UnparsedStructuredField field = null; - do { - field = parser.readNextStructuredField(); - if (field.getSfTypeID() == typeID) { - return field; - } - } while (field != null); - fail("Structured field not found: " + Integer.toHexString(typeID)); - return null; - } - -} diff --git a/test/java/org/apache/fop/render/afp/nops.fo b/test/java/org/apache/fop/render/afp/nops.fo deleted file mode 100644 index 96c6e0d24..000000000 --- a/test/java/org/apache/fop/render/afp/nops.fo +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp"> - <fo:layout-master-set> - <fo:simple-page-master master-name="first" page-height="10.5cm" page-width="14.85cm" margin="2cm"> - <afp:no-operation name="spm">fo:simple-page-master: first</afp:no-operation> - <fo:region-body margin-top="2em "/> - <fo:region-before extent="2em"/> - </fo:simple-page-master> - <fo:simple-page-master master-name="rest" page-height="10.5cm" page-width="14.85cm" margin="2cm"> - <afp:no-operation name="spm">fo:simple-page-master: rest</afp:no-operation> - <fo:region-body margin-top="2em "/> - <fo:region-before extent="2em"/> - </fo:simple-page-master> - <fo:page-sequence-master master-name="main"> - <fo:repeatable-page-master-alternatives> - <fo:conditional-page-master-reference master-reference="first" page-position="first"/> - <fo:conditional-page-master-reference master-reference="rest"/> - </fo:repeatable-page-master-alternatives> - </fo:page-sequence-master> - </fo:layout-master-set> - - <fo:declarations> - <afp:no-operation name="declarations">fo:declarations</afp:no-operation> - </fo:declarations> - - <fo:page-sequence master-reference="main" id="doc1"> - <afp:no-operation name="ps">fo:page-sequence: start</afp:no-operation> - <fo:flow flow-name="xsl-region-body"> - <fo:block>Page 1</fo:block> - <fo:block>Page 1</fo:block> - <fo:block break-after="page"></fo:block> - <fo:block>Page 2</fo:block> - <fo:block>Page 2</fo:block> - <fo:block break-after="page"></fo:block> - <fo:block>Page 3</fo:block> - <fo:block>Page 3</fo:block> - </fo:flow> - <afp:no-operation name="ps">fo:page-sequence: end</afp:no-operation> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java b/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java deleted file mode 100644 index cae184d51..000000000 --- a/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfigParserTester.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.bitmap; - -import java.awt.Color; -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; - -import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_BILEVEL; -import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_BINARY; -import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_GRAY; -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.JAVA2D_TRANSPARENT_PAGE_BACKGROUND; -import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_QUALITY; -import static org.apache.fop.render.bitmap.BitmapRendererOption.RENDERING_SPEED; - -public class AbstractBitmapRendererConfigParserTester - extends AbstractRendererConfigParserTester<BitmapRendererConfBuilder, BitmapRendererConfig> { - - public AbstractBitmapRendererConfigParserTester(BitmapRendererConfigParser parser) { - super(parser, BitmapRendererConfBuilder.class); - } - - @Test - public void testTransparentPageBackground() throws Exception { - parseConfig(createRenderer().setPageBackgroundTransparency(true)); - assertTrue(conf.hasTransparentBackround()); - assertNull(conf.getBackgroundColor()); - - parseConfig(createRenderer().setPageBackgroundTransparency(false)); - assertFalse(conf.hasTransparentBackround()); - assertEquals(Color.WHITE, conf.getBackgroundColor()); - - parseConfig(createRenderer()); - assertEquals(JAVA2D_TRANSPARENT_PAGE_BACKGROUND.getDefaultValue(), - conf.hasTransparentBackround()); - } - - @Test - public void testBackgroundColor() throws Exception { - parseConfig(createRenderer().setBackgroundColor("black")); - assertEquals(Color.BLACK, conf.getBackgroundColor()); - - parseConfig(createRenderer().setBackgroundColor("white")); - assertEquals(Color.WHITE, conf.getBackgroundColor()); - - parseConfig(createRenderer().setBackgroundColor("blue")); - assertEquals(Color.BLUE, conf.getBackgroundColor()); - - parseConfig(createRenderer().setBackgroundColor("blue") - .setPageBackgroundTransparency(true)); - assertTrue(conf.hasTransparentBackround()); - assertNull(conf.getBackgroundColor()); - } - - @Test - public void testAntiAliasing() throws Exception { - parseConfig(createRenderer().setAntiAliasing(true)); - assertTrue(conf.hasAntiAliasing()); - - parseConfig(createRenderer().setAntiAliasing(false)); - assertFalse(conf.hasAntiAliasing()); - } - - @Test - public void testRendererQuality() throws Exception { - parseConfig(createRenderer().setRenderingQuality(RENDERING_QUALITY.getName())); - assertTrue(conf.isRenderHighQuality()); - - parseConfig(createRenderer().setRenderingQuality(RENDERING_SPEED.getName())); - assertFalse(conf.isRenderHighQuality()); - - parseConfig(createRenderer()); - assertTrue(conf.isRenderHighQuality()); - } - - @Test - public void testColorModes() throws Exception { - parseConfig(createRenderer().setColorMode(COLOR_MODE_RGBA.getName())); - assertEquals(BufferedImage.TYPE_INT_ARGB, (int) conf.getColorMode()); - - parseConfig(createRenderer().setColorMode(COLOR_MODE_RGB.getName())); - assertEquals(BufferedImage.TYPE_INT_RGB, (int) conf.getColorMode()); - - parseConfig(createRenderer().setColorMode(COLOR_MODE_GRAY.getName())); - assertEquals(BufferedImage.TYPE_BYTE_GRAY, (int) conf.getColorMode()); - - parseConfig(createRenderer().setColorMode(COLOR_MODE_BINARY.getName())); - assertEquals(BufferedImage.TYPE_BYTE_BINARY, (int) conf.getColorMode()); - - parseConfig(createRenderer().setColorMode(COLOR_MODE_BILEVEL.getName())); - assertEquals(BufferedImage.TYPE_BYTE_BINARY, (int) conf.getColorMode()); - - parseConfig(createRenderer()); - assertEquals(BufferedImage.TYPE_INT_ARGB, (int) conf.getColorMode()); - } -} diff --git a/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfiguratorTest.java b/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfiguratorTest.java deleted file mode 100644 index dcbb27754..000000000 --- a/test/java/org/apache/fop/render/bitmap/AbstractBitmapRendererConfiguratorTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.bitmap; - -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; -import org.apache.fop.util.ColorUtil; - -import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_BILEVEL; -import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_BINARY; -import static org.apache.fop.render.bitmap.BitmapRendererOption.COLOR_MODE_GRAY; -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; - -public abstract class AbstractBitmapRendererConfiguratorTest extends - AbstractRendererConfiguratorTest<BitmapRendererConfigurator, BitmapRendererConfBuilder> { - - public AbstractBitmapRendererConfiguratorTest(String mimeType, - Class<? extends IFDocumentHandler> docHandlerClass) { - super(mimeType, BitmapRendererConfBuilder.class, docHandlerClass); - } - - BitmapRenderingSettings settings; - - @Override - public void setUpDocumentHandler() { - settings = new BitmapRenderingSettings(); - when(((AbstractBitmapDocumentHandler) docHandler).getSettings()).thenReturn(settings); - } - - @Test - public void testSetPageBackgroundColor() throws Exception { - // Try a few different colours - parseConfig(createBuilder().setBackgroundColor("Blue")); - assertEquals(ColorUtil.parseColorString(null, "Blue"), settings.getPageBackgroundColor()); - - parseConfig(createBuilder().setBackgroundColor("Black")); - assertEquals(ColorUtil.parseColorString(null, "Black"), settings.getPageBackgroundColor()); - } - - @Test - public void testAntiAliasing() throws Exception { - parseConfig(createBuilder().setAntiAliasing(true)); - assertTrue(settings.isAntiAliasingEnabled()); - - parseConfig(createBuilder().setAntiAliasing(false)); - assertFalse(settings.isAntiAliasingEnabled()); - } - - @Test - public void testTransparentBackground() throws Exception { - parseConfig(createBuilder().setPageBackgroundTransparency(true)); - assertTrue(settings.hasTransparentPageBackground()); - - parseConfig(createBuilder().setPageBackgroundTransparency(false)); - assertFalse(settings.hasTransparentPageBackground()); - } - - @Test - public void testRendererQuality() throws Exception { - parseConfig(createBuilder().setRenderingQuality(RENDERING_QUALITY.getName())); - assertTrue(settings.isQualityRenderingEnabled()); - - parseConfig(createBuilder().setRenderingQuality(RENDERING_SPEED.getName())); - assertFalse(settings.isQualityRenderingEnabled()); - - parseConfig(createBuilder()); - assertTrue(settings.isQualityRenderingEnabled()); - } - - @Test - public void testColorModes() throws Exception { - parseConfig(createBuilder().setColorMode(COLOR_MODE_RGBA.getName())); - assertEquals(BufferedImage.TYPE_INT_ARGB, settings.getBufferedImageType()); - - parseConfig(createBuilder().setColorMode(COLOR_MODE_RGB.getName())); - assertEquals(BufferedImage.TYPE_INT_RGB, settings.getBufferedImageType()); - - parseConfig(createBuilder().setColorMode(COLOR_MODE_GRAY.getName())); - assertEquals(BufferedImage.TYPE_BYTE_GRAY, settings.getBufferedImageType()); - - parseConfig(createBuilder().setColorMode(COLOR_MODE_BINARY.getName())); - assertEquals(BufferedImage.TYPE_BYTE_BINARY, settings.getBufferedImageType()); - - parseConfig(createBuilder().setColorMode(COLOR_MODE_BILEVEL.getName())); - assertEquals(BufferedImage.TYPE_BYTE_BINARY, settings.getBufferedImageType()); - - parseConfig(createBuilder()); - assertEquals(BufferedImage.TYPE_INT_ARGB, settings.getBufferedImageType()); - } -} diff --git a/test/java/org/apache/fop/render/bitmap/BitmapRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/bitmap/BitmapRendererConfigParserTestCase.java deleted file mode 100644 index 3c44bfdf7..000000000 --- a/test/java/org/apache/fop/render/bitmap/BitmapRendererConfigParserTestCase.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.bitmap; - -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.bitmap.BitmapRendererConfig.BitmapRendererConfigParser; - -public class BitmapRendererConfigParserTestCase extends AbstractBitmapRendererConfigParserTester { - - public BitmapRendererConfigParserTestCase() { - super(new BitmapRendererConfigParser(MimeConstants.MIME_BITMAP)); - } -} diff --git a/test/java/org/apache/fop/render/bitmap/BitmapRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/bitmap/BitmapRendererConfiguratorTestCase.java deleted file mode 100644 index 0d0527160..000000000 --- a/test/java/org/apache/fop/render/bitmap/BitmapRendererConfiguratorTestCase.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.bitmap; - -import org.apache.fop.apps.BitmapRendererConfBuilder; -import org.apache.fop.render.bitmap.BitmapRendererConfig.BitmapRendererConfigParser; - -public class BitmapRendererConfiguratorTestCase extends AbstractBitmapRendererConfiguratorTest { - - public BitmapRendererConfiguratorTestCase() { - super(BitmapRendererConfBuilder.getMimeType(), AbstractBitmapDocumentHandler.class); - } - - @Override - public BitmapRendererConfigurator createConfigurator() { - return new BitmapRendererConfigurator(userAgent, new BitmapRendererConfigParser(mimeType)); - } -} diff --git a/test/java/org/apache/fop/render/bitmap/TIFFCompressionValueTestCase.java b/test/java/org/apache/fop/render/bitmap/TIFFCompressionValueTestCase.java deleted file mode 100644 index c4285f034..000000000 --- a/test/java/org/apache/fop/render/bitmap/TIFFCompressionValueTestCase.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.render.bitmap; - -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.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T4; -import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T6; -import static org.apache.fop.render.bitmap.TIFFCompressionValue.DEFLATE; -import static org.apache.fop.render.bitmap.TIFFCompressionValue.JPEG; -import static org.apache.fop.render.bitmap.TIFFCompressionValue.LZW; -import static org.apache.fop.render.bitmap.TIFFCompressionValue.NONE; -import static org.apache.fop.render.bitmap.TIFFCompressionValue.PACKBITS; -import static org.apache.fop.render.bitmap.TIFFCompressionValue.ZLIB; - -public class TIFFCompressionValueTestCase { - - @Test - public void testGetName() { - testCompressionName("NONE", NONE); - testCompressionName("JPEG", JPEG); - testCompressionName("PackBits", PACKBITS); - testCompressionName("Deflate", DEFLATE); - testCompressionName("LZW", LZW); - testCompressionName("ZLib", ZLIB); - testCompressionName("CCITT T.4", CCITT_T4); - testCompressionName("CCITT T.6", CCITT_T6); - } - - private void testCompressionName(String name, TIFFCompressionValue expected) { - assertEquals(name, expected.getName()); - assertEquals(expected, TIFFCompressionValue.getType(name)); - } - - @Test - public void testGetImageType() { - for (TIFFCompressionValue value : TIFFCompressionValue.values()) { - if (value == CCITT_T4 || value == CCITT_T6) { - assertEquals(BufferedImage.TYPE_BYTE_BINARY, value.getImageType()); - } else { - assertEquals(BufferedImage.TYPE_INT_ARGB, value.getImageType()); - } - } - } - - @Test - public void testHasCCITTCompression() { - for (TIFFCompressionValue value : TIFFCompressionValue.values()) { - if (value == CCITT_T4 || value == CCITT_T6) { - assertTrue(value.hasCCITTCompression()); - } else { - assertFalse(value.hasCCITTCompression()); - } - } - } -} diff --git a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java deleted file mode 100644 index 8a5c2a72d..000000000 --- a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfigParserTestCase.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.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; - -public class TIFFRendererConfigParserTestCase -extends AbstractBitmapRendererConfigParserTester { - - public TIFFRendererConfigParserTestCase() { - super(new TIFFRendererConfigParser()); - } - - @Override - protected TIFFRendererConfBuilder createRenderer() { - builder = new FopConfBuilder().setStrictValidation(true).startRendererConfig( - TIFFRendererConfBuilder.class); - return (TIFFRendererConfBuilder) builder; - } - - private TIFFRendererConfig getConfig() { - return (TIFFRendererConfig) conf; - } - - @Test - public void testCompression() throws Exception { - for (TIFFCompressionValue value : TIFFCompressionValue.values()) { - parseConfig(createRenderer().setCompressionMode(value.getName())); - assertEquals(value, getConfig().getCompressionType()); - } - } - - @Test - public void testSingleStrip() throws Exception { - parseConfig(createRenderer().setSingleStrip(true)); - assertTrue(getConfig().isSingleStrip()); - parseConfig(createRenderer().setSingleStrip(false)); - assertFalse(getConfig().isSingleStrip()); - } - - @Test - public void testEndianness() throws Exception { - for (Endianness value : Endianness.values()) { - parseConfig(createRenderer().setEndianness(value.toString())); - assertEquals(value, getConfig().getEndianness()); - } - } -} diff --git a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java deleted file mode 100644 index e340830f4..000000000 --- a/test/java/org/apache/fop/render/bitmap/TIFFRendererConfiguratorTestCase.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.bitmap; - -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; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.apps.TIFFRendererConfBuilder; -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; - -public class TIFFRendererConfiguratorTestCase extends AbstractBitmapRendererConfiguratorTest { - - public TIFFRendererConfiguratorTestCase() { - super(MimeConstants.MIME_TIFF, TIFFDocumentHandler.class); - } - - @Override - public TIFFRendererConfigurator createConfigurator() { - return new TIFFRendererConfigurator(userAgent, new TIFFRendererConfigParser()); - } - - @Override - protected TIFFRendererConfBuilder createBuilder() { - return new FopConfBuilder().startRendererConfig(TIFFRendererConfBuilder.class); - } - - @Test - @Override - public void testColorModes() throws Exception { - for (TIFFCompressionValue value : TIFFCompressionValue.values()) { - parseConfig(createBuilder().setCompressionMode(value.getName())); - if (value == CCITT_T6 || value == CCITT_T4) { - assertEquals(BufferedImage.TYPE_BYTE_BINARY, settings.getBufferedImageType()); - } else { - assertEquals(BufferedImage.TYPE_INT_ARGB, settings.getBufferedImageType()); - } - } - } - - @Test - public void testSingleStrip() throws Exception { - parseConfig(createBuilder().setSingleStrip(true)); - assertTrue(settings.getWriterParams().isSingleStrip()); - parseConfig(createBuilder().setSingleStrip(false)); - assertFalse(settings.getWriterParams().isSingleStrip()); - } - - @Test - public void testEndianness() throws Exception { - for (Endianness value : Endianness.values()) { - parseConfig(createBuilder().setEndianness(value.toString())); - assertEquals(value, settings.getWriterParams().getEndianness()); - } - } - -} diff --git a/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTestCase.java b/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTestCase.java deleted file mode 100644 index e3f892e7c..000000000 --- a/test/java/org/apache/fop/render/extensions/prepress/PageBoundariesTestCase.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.extensions.prepress; - -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. - */ -public class PageBoundariesTestCase { - - private static final Dimension TEST_AREA_SIZE = new Dimension(20000, 15000); - - private static final Rectangle TEST_AREA = new Rectangle(TEST_AREA_SIZE); - - private static final String BLEED = "5pt"; - - private static final String CROP_OFFSET = "8pt"; - - /** Test for page boundaries. */ - @Test - public void testBoundaries1() { - PageBoundaries boundaries = new PageBoundaries(TEST_AREA_SIZE, BLEED, CROP_OFFSET, null); - assertEquals(TEST_AREA, boundaries.getTrimBox()); - - Rectangle bleedBox = boundaries.getBleedBox(); - assertNotNull("Expected not null object", bleedBox); - assertEquals(-5000, bleedBox.x); - assertEquals(-5000, bleedBox.y); - assertEquals(30000, bleedBox.width); - assertEquals(25000, bleedBox.height); - - Rectangle mediaBox = boundaries.getMediaBox(); - assertNotNull("Expected not null object", mediaBox); - assertEquals(-8000, mediaBox.x); - assertEquals(-8000, mediaBox.y); - assertEquals(36000, mediaBox.width); - assertEquals(31000, mediaBox.height); - } - - /** Test for page boundaries. */ - @Test - public void testBoundaries2() { - PageBoundaries boundaries = new PageBoundaries( - TEST_AREA_SIZE, BLEED, null, null); - Rectangle bleedBox = boundaries.getBleedBox(); - assertNotNull("Expected not null object", bleedBox); - assertEquals(-5000, bleedBox.x); - assertEquals(-5000, bleedBox.y); - assertEquals(30000, bleedBox.width); - assertEquals(25000, bleedBox.height); - assertEquals(bleedBox, boundaries.getMediaBox()); - } - - /** Two values for the properties. */ - @Test - public void testBoundaries2Values() { - PageBoundaries boundaries = new PageBoundaries( - TEST_AREA_SIZE, "5pt 10pt", "6pt \t 12pt", null); - Rectangle bleedBox = boundaries.getBleedBox(); - assertEquals(-10000, bleedBox.x); - assertEquals(-5000, bleedBox.y); - assertEquals(40000, bleedBox.width); - assertEquals(25000, bleedBox.height); - - Rectangle mediaBox = boundaries.getMediaBox(); - assertEquals(-12000, mediaBox.x); - assertEquals(-6000, mediaBox.y); - assertEquals(44000, mediaBox.width); - assertEquals(27000, mediaBox.height); - } - - /** Three values for the properties. */ - @Test - public void testBoundaries3Values() { - PageBoundaries boundaries = new PageBoundaries( - TEST_AREA_SIZE, "5pt 10pt 7pt", "6pt \t 12pt 14pt", null); - Rectangle bleedBox = boundaries.getBleedBox(); - assertEquals(-10000, bleedBox.x); - assertEquals(-5000, bleedBox.y); - assertEquals(40000, bleedBox.width); - assertEquals(27000, bleedBox.height); - - Rectangle mediaBox = boundaries.getMediaBox(); - assertEquals(-12000, mediaBox.x); - assertEquals(-6000, mediaBox.y); - assertEquals(44000, mediaBox.width); - assertEquals(35000, mediaBox.height); - } - - /** Four values for the properties. */ - @Test - public void testBoundaries4Values() { - PageBoundaries boundaries = new PageBoundaries( - TEST_AREA_SIZE, "5pt 6pt 7pt 8pt", "9pt 10pt 11pt 12pt", null); - Rectangle bleedBox = boundaries.getBleedBox(); - assertEquals(-8000, bleedBox.x); - assertEquals(-5000, bleedBox.y); - assertEquals(34000, bleedBox.width); - assertEquals(27000, bleedBox.height); - - Rectangle mediaBox = boundaries.getMediaBox(); - assertEquals(-12000, mediaBox.x); - assertEquals(-9000, mediaBox.y); - assertEquals(42000, mediaBox.width); - assertEquals(35000, mediaBox.height); - } - - /** Test for the different values of crop-box. */ - @Test - public void testCropBox() { - PageBoundaries boundaries = new PageBoundaries(TEST_AREA_SIZE, BLEED, CROP_OFFSET, null); - assertEquals(boundaries.getMediaBox(), boundaries.getCropBox()); - - boundaries = new PageBoundaries(TEST_AREA_SIZE, BLEED, CROP_OFFSET, ""); - assertEquals(boundaries.getMediaBox(), boundaries.getCropBox()); - - boundaries = new PageBoundaries(TEST_AREA_SIZE, BLEED, CROP_OFFSET, "trim-box"); - assertEquals(TEST_AREA, boundaries.getCropBox()); - - boundaries = new PageBoundaries(TEST_AREA_SIZE, BLEED, CROP_OFFSET, "bleed-box"); - assertEquals(boundaries.getBleedBox(), boundaries.getCropBox()); - - boundaries = new PageBoundaries(TEST_AREA_SIZE, BLEED, CROP_OFFSET, "media-box"); - assertEquals(boundaries.getMediaBox(), boundaries.getCropBox()); - } - - /** Test for default values returned when properties are null. */ - @Test - public void testBoundariesNull() { - PageBoundaries b = new PageBoundaries(TEST_AREA_SIZE, null, null, null); - - assertEquals("Result should be the same as TEST_AREA object", b.getTrimBox(), TEST_AREA); - assertEquals("Result should be the same as TEST_AREA object", b.getBleedBox(), TEST_AREA); - assertEquals("Result should be the same as TEST_AREA object", b.getMediaBox(), TEST_AREA); - assertEquals("Result should be the same as TEST_AREA object", b.getCropBox(), TEST_AREA); - } - - /** Units must be specified. */ - @Test - public void testBoundariesFail() { - try { - new PageBoundaries(TEST_AREA_SIZE, "0", null, null); - fail("Expected IllegalArgumentException. Box should have units"); - } catch (IllegalArgumentException iae) { - // Good! - } - } -} diff --git a/test/java/org/apache/fop/render/extensions/prepress/PageScaleTestCase.java b/test/java/org/apache/fop/render/extensions/prepress/PageScaleTestCase.java deleted file mode 100644 index 9de045cf7..000000000 --- a/test/java/org/apache/fop/render/extensions/prepress/PageScaleTestCase.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.extensions.prepress; - -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. - */ -public class PageScaleTestCase { - - /** 1 value is used for both x and y. */ - @Test - public void testScale1() { - Point2D res = PageScale.getScale(".5"); - assertEquals(0.5, res.getX(), 0.0); - assertEquals(0.5, res.getY(), 0.0); - } - - /** Two values, used resp. for x and y. */ - @Test - public void testScale2() { - Point2D res = PageScale.getScale("1. \t \n 1.2"); - assertEquals(1.0, res.getX(), 0.0); - assertEquals(1.2, res.getY(), 0.0); - } - - /** Scale must not contain units. */ - @Test - public void testScaleFail() { - try { - PageScale.getScale("0.5mm 0.5cm"); - fail("Expected IllegalArgumentException. Scale shouldn't contain units"); - } catch (IllegalArgumentException iae) { - // Good! - } - } - - /** @{code null} is returned when scale is unspecified. */ - @Test - public void testScaleNull() { - Point2D res = PageScale.getScale(null); - assertNull("Result should be null", res); - res = PageScale.getScale(""); - assertNull("Result should be null", res); - } - -} diff --git a/test/java/org/apache/fop/render/gradient/GradientTestCase.java b/test/java/org/apache/fop/render/gradient/GradientTestCase.java deleted file mode 100644 index 51a9c6c37..000000000 --- a/test/java/org/apache/fop/render/gradient/GradientTestCase.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.gradient; - -import java.awt.Color; -import java.awt.geom.AffineTransform; - -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; - -import org.apache.batik.ext.awt.LinearGradientPaint; -import org.apache.batik.ext.awt.RadialGradientPaint; - -public class GradientTestCase { - - private static class PatternChecker { - - private final Pattern pattern; - - PatternChecker(Pattern pattern) { - this.pattern = pattern; - } - - public PatternChecker type(int expectedType) { - assertEquals(expectedType, pattern.getPatternType()); - return this; - } - - public PatternChecker matrix(Double... expectedMatrix) { - assertArrayEquals(expectedMatrix, pattern.getMatrix().toArray()); - return this; - } - - public ShadingChecker shading() { - return new ShadingChecker(pattern.getShading()); - } - } - - private static class ShadingChecker { - - private final Shading shading; - - ShadingChecker(Shading shading) { - this.shading = shading; - } - - ShadingChecker shadingType(int expectedShadingType) { - assertEquals(expectedShadingType, shading.getShadingType()); - return this; - } - - ShadingChecker coords(double... expectedCoords) { - double[] coords = new double[shading.getCoords().size()]; - int index = 0; - for (Double d : shading.getCoords()) { - coords[index++] = d; - } - assertArrayEquals(expectedCoords, coords, 0.0001); - return this; - } - - ShadingChecker extend(Boolean... expectedExtend) { - assertArrayEquals(expectedExtend, shading.getExtend().toArray()); - return this; - } - - FunctionChecker function() { - return new FunctionChecker(shading.getFunction()); - } - } - - private static class FunctionChecker { - - private final Function function; - - FunctionChecker(Function function) { - this.function = function; - } - - FunctionChecker functionType(int expectedFunctionType) { - assertEquals(expectedFunctionType, function.getFunctionType()); - return this; - } - - FunctionChecker domain(Double... expectedDomain) { - assertArrayEquals(expectedDomain, function.getDomain().toArray()); - return this; - } - - FunctionChecker bounds(Float... expectedBounds) { - assertArrayEquals(expectedBounds, function.getBounds().toArray()); - return this; - } - - FunctionChecker encode(Double... expectedEncode) { - assertArrayEquals(expectedEncode, function.getEncode().toArray()); - return this; - } - - FunctionChecker cZero(float... expectedCZero) { - assertArrayEquals(expectedCZero, function.getCZero(), 0f); - return this; - } - - FunctionChecker cOne(float... expectedCOne) { - assertArrayEquals(expectedCOne, function.getCOne(), 0f); - return this; - } - - FunctionChecker functions(int expectedFunctionCount) { - assertEquals(expectedFunctionCount, function.getFunctions().size()); - return this; - } - - FunctionChecker function(int index) { - return new FunctionChecker(function.getFunctions().get(index)); - } - } - - @Test - public void simpleLinearGradient() { - LinearGradientPaint gradient = new LinearGradientPaint(0f, 0f, 100f, 100f, - fractions(0f, 1f), colors(Color.BLUE, Color.RED)); - Pattern pattern = GradientMaker.makeLinearGradient(gradient, - AffineTransform.getTranslateInstance(10.0, 20.0), - AffineTransform.getScaleInstance(100.0, 1000.0)); - PatternChecker patternChecker = new PatternChecker(pattern) - .type(2) - .matrix(100.0, 0.0, 0.0, 1000.0, 10.0, 20.0); - ShadingChecker shadingChecker = patternChecker.shading() - .shadingType(2) - .coords(0.0, 0.0, 100.0, 100.0) - .extend(true, true); - FunctionChecker functionChecker = shadingChecker.function() - .functionType(3) - .domain(0.0, 1.0) - .bounds() - .encode(0.0, 1.0) - .functions(1); - functionChecker.function(0) - .functionType(2) - .domain(0.0, 1.0) - .cZero(0f, 0f, 1f) - .cOne(1f, 0f, 0f) - .functions(0); - } - - @Test - public void simpleRadialGradient() { - RadialGradientPaint gradient = new RadialGradientPaint(100, 200, 50, - fractions(0f, 1f), colors(Color.BLUE, Color.RED)); - Pattern pattern = GradientMaker.makeRadialGradient(gradient, new AffineTransform(), new AffineTransform()); - PatternChecker patternChecker = new PatternChecker(pattern).type(2); - ShadingChecker shadingChecker = patternChecker.shading() - .shadingType(3) - .coords(100.0, 200.0, 0.0, 100.0, 200.0, 50.0) - .extend(true, true); - FunctionChecker functionChecker = shadingChecker.function() - .functionType(3) - .domain(0.0, 1.0) - .bounds() - .encode(0.0, 1.0) - .functions(1); - functionChecker.function(0) - .functionType(2) - .domain(0.0, 1.0) - .cZero(0f, 0f, 1f) - .cOne(1f, 0f, 0f) - .functions(0); - } - - @Test - public void threeColorLinearGradient() { - LinearGradientPaint gradient = new LinearGradientPaint(0f, 10f, 20f, 30f, - fractions(0f, 0.5f, 1f), colors(Color.BLUE, Color.RED, Color.GREEN)); - Pattern pattern = GradientMaker.makeLinearGradient(gradient, new AffineTransform(), new AffineTransform()); - PatternChecker patternChecker = new PatternChecker(pattern) - .type(2) - .matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); - ShadingChecker shadingChecker = patternChecker.shading() - .shadingType(2) - .coords(0.0, 10.0, 20.0, 30.0) - .extend(true, true); - FunctionChecker functionChecker = shadingChecker.function() - .functionType(3) - .domain(0.0, 1.0) - .bounds(0.5f) - .encode(0.0, 1.0, 0.0, 1.0) - .functions(2); - functionChecker.function(0) - .functionType(2) - .domain(0.0, 1.0) - .cZero(0f, 0f, 1f) - .cOne(1f, 0f, 0f) - .functions(0); - functionChecker.function(1) - .functionType(2) - .domain(0.0, 1.0) - .cZero(1f, 0f, 0f) - .cOne(0f, 1f, 0f) - .functions(0); - } - - @Test - public void fourColorRadialGradientNonZeroFirstStop() { - RadialGradientPaint gradient = new RadialGradientPaint(100, 200, 50, 110, 220, - fractions(0.2f, 0.5f, 0.7f, 1f), colors(Color.BLUE, Color.RED, Color.GREEN, Color.WHITE)); - Pattern pattern = GradientMaker.makeRadialGradient(gradient, new AffineTransform(), new AffineTransform()); - ShadingChecker shadingChecker = new PatternChecker(pattern).shading() - .coords(110.0, 220.0, 0.0, 100.0, 200.0, 50.0); - FunctionChecker functionChecker = shadingChecker.function() - .functionType(3) - .bounds(0.2f, 0.5f, 0.7f) - .encode(0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0) - .functions(4); - functionChecker.function(0) - .functionType(2) - .cZero(0f, 0f, 1f) - .cOne(0f, 0f, 1f); - functionChecker.function(1) - .functionType(2) - .cZero(0f, 0f, 1f) - .cOne(1f, 0f, 0f); - functionChecker.function(2) - .functionType(2) - .cZero(1f, 0f, 0f) - .cOne(0f, 1f, 0f); - functionChecker.function(3) - .functionType(2) - .cZero(0f, 1f, 0f) - .cOne(1f, 1f, 1f); - } - - @Test - public void fourColorRadialGradientNonZeroLastStopFocalOut() { - RadialGradientPaint gradient = new RadialGradientPaint(0, 0, 100, 100, 100, - fractions(0f, 0.3f, 0.6f, 0.9f), colors(Color.WHITE, Color.RED, Color.GREEN, Color.BLUE)); - Pattern pattern = GradientMaker.makeRadialGradient(gradient, new AffineTransform(), new AffineTransform()); - ShadingChecker shadingChecker = new PatternChecker(pattern).shading() - .coords(70.7036, 70.7036, 0.0, 0.0, 0.0, 100.0); - FunctionChecker functionChecker = shadingChecker.function() - .functionType(3) - .bounds(0.3f, 0.6f, 0.9f) - .encode(0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0) - .functions(4); - functionChecker.function(0) - .functionType(2) - .cZero(1f, 1f, 1f) - .cOne(1f, 0f, 0f); - functionChecker.function(1) - .functionType(2) - .cZero(1f, 0f, 0f) - .cOne(0f, 1f, 0f); - functionChecker.function(2) - .functionType(2) - .cZero(0f, 1f, 0f) - .cOne(0f, 0f, 1f); - functionChecker.function(3) - .functionType(2) - .cZero(0f, 0f, 1f) - .cOne(0f, 0f, 1f); - } - - private float[] fractions(float... fractions) { - return fractions; - } - - private Color[] colors(Color... colors) { - return colors; - } - -} diff --git a/test/java/org/apache/fop/render/intermediate/AbstractIFPainterTestCase.java b/test/java/org/apache/fop/render/intermediate/AbstractIFPainterTestCase.java deleted file mode 100644 index ec0f35737..000000000 --- a/test/java/org/apache/fop/render/intermediate/AbstractIFPainterTestCase.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.render.intermediate; - -import java.awt.Dimension; -import java.awt.Paint; -import java.awt.Rectangle; -import java.awt.geom.AffineTransform; - -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; - -public class AbstractIFPainterTestCase { - - private AbstractIFPainter<?> sut; - private IFDocumentHandler handler; - - @Before - public void setUp() { - handler = mock(IFDocumentHandler.class); - sut = new AbstractIFPainter<IFDocumentHandler>(handler) { - public void startViewport(AffineTransform transform, Dimension size, Rectangle clipRect) - throws IFException { - } - - public void endViewport() throws IFException { - } - - public void startGroup(AffineTransform transform, String layer) throws IFException { - } - - public void endGroup() throws IFException { - } - - public void clipRect(Rectangle rect) throws IFException { - } - - public void clipBackground(Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, - BorderProps bpsStart, BorderProps bpsEnd) throws IFException { - } - - public void fillRect(Rectangle rect, Paint fill) throws IFException { - } - - public void drawImage(String uri, Rectangle rect) throws IFException { - } - - public void drawImage(Document doc, Rectangle rect) throws IFException { - } - - @Override - protected RenderingContext createRenderingContext() { - return null; - } - - public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[][] dp, - String text) throws IFException { - } - - }; - FontInfo fontInfo = mock(FontInfo.class); - when(handler.getFontInfo()).thenReturn(fontInfo); - } - - @Test - public void testGetFontKey() throws IFException { - String expected = "the expected string"; - FontTriplet triplet = mock(FontTriplet.class); - FontInfo fontInfo = handler.getFontInfo(); - when(fontInfo.getInternalFontKey(triplet)).thenReturn(expected); - assertEquals(expected, sut.getFontKey(triplet)); - } - - @Test(expected = IFException.class) - public void testGetFontKeyMissingFont() throws IFException { - FontTriplet triplet = mock(FontTriplet.class); - when(handler.getFontInfo().getInternalFontKey(triplet)).thenReturn(null); - sut.getFontKey(triplet); - } -} diff --git a/test/java/org/apache/fop/render/intermediate/ArcToBezierCurveTransformerTestCase.java b/test/java/org/apache/fop/render/intermediate/ArcToBezierCurveTransformerTestCase.java deleted file mode 100644 index 039ddcf90..000000000 --- a/test/java/org/apache/fop/render/intermediate/ArcToBezierCurveTransformerTestCase.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.render.intermediate; - -import java.io.IOException; - -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class ArcToBezierCurveTransformerTestCase { - - @Test - public void arcTo() throws Exception { - testArcTo(Math.PI / 3, Math.PI / 2, 100, 200, 1000, 1000); - } - - private void testArcTo(double startAngle, double endAngle, int xCenter, int yCenter, int width, - int height) throws IOException { - assertAngleWithinFirstQuadrant(startAngle); - assertAngleWithinFirstQuadrant(endAngle); - BezierCurvePainter bezierCurvePainter = mock(BezierCurvePainter.class); - ArcToBezierCurveTransformer sut = new ArcToBezierCurveTransformer(bezierCurvePainter); - sut.arcTo(startAngle, endAngle, xCenter, yCenter, width, height); - double tan1 = Math.tan(startAngle); - double tan2 = Math.tan(endAngle); - double lambda1 = Math.atan(height * tan1 / width); - double lambda2 = Math.atan(height * tan2 / width); - double xStart = width * Math.cos(lambda1) + xCenter; - double yStart = height * Math.sin(lambda1) + yCenter; - double xEnd = width * Math.cos(lambda2) + xCenter; - double yEnd = height * Math.sin(lambda2) + yCenter; - ArgumentCaptor<Integer> xP1Captor = ArgumentCaptor.forClass(Integer.class); - ArgumentCaptor<Integer> yP1Captor = ArgumentCaptor.forClass(Integer.class); - ArgumentCaptor<Integer> xP2Captor = ArgumentCaptor.forClass(Integer.class); - ArgumentCaptor<Integer> yP2Captor = ArgumentCaptor.forClass(Integer.class); - ArgumentCaptor<Integer> xP3Captor = ArgumentCaptor.forClass(Integer.class); - ArgumentCaptor<Integer> yP3Captor = ArgumentCaptor.forClass(Integer.class); - verify(bezierCurvePainter).cubicBezierTo(xP1Captor.capture(), yP1Captor.capture(), - xP2Captor.capture(), yP2Captor.capture(), xP3Captor.capture(), yP3Captor.capture()); - int xP1 = xP1Captor.getValue(); - int yP1 = yP1Captor.getValue(); - int xP2 = xP2Captor.getValue(); - int yP2 = yP2Captor.getValue(); - int xP3 = xP3Captor.getValue(); - int yP3 = yP3Captor.getValue(); - // TODO do more than check the direction of the tangents at the end - // points - assertEquals((yP1 - yStart) / (xP1 - xStart), -width * width / height / height / tan1, 0.01); - assertEquals((yP2 - yEnd) / (xP2 - xEnd), -width * width / height / height / tan2, 0.01); - assertEquals((int) xEnd, xP3); - assertEquals((int) yEnd, yP3); - } - - private void assertAngleWithinFirstQuadrant(double angle) { - if (angle <= 0 || angle > Math.PI / 2) { - fail("Angle " + angle + " is in (0, " + Math.PI / 2 + ")"); - } - } -} diff --git a/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java b/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java deleted file mode 100644 index 4a89b3ac6..000000000 --- a/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java +++ /dev/null @@ -1,578 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.render.intermediate; - -import java.awt.Color; -import java.awt.Rectangle; -import java.io.IOException; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; - -import org.apache.fop.fo.Constants; -import org.apache.fop.traits.BorderProps; -import org.apache.fop.traits.BorderProps.Mode; - -public class BorderPainterTestCase { - - private static final BorderProps BORDER_PROPS = new BorderProps(Constants.EN_SOLID, 10, 50, 50, - Color.BLACK, BorderProps.Mode.SEPARATE); - - @Test - public void clipBackground() throws Exception { - // Rectangular borders - test(new ClipBackgroundTester(0, 0, 10, 10)); - test(new ClipBackgroundTester(5, 10, 10, 10)); - test(new ClipBackgroundTester(0, 0, 10, 10).setBorderWidth(1)); - test(new ClipBackgroundTester(0, 0, 10, 10).beforeBorder().setWidth(10).tester()); - // Rounded corners - test(new ClipBackgroundTester(0, 0, 10, 10).setEndBefore(1, 1)); - test(new ClipBackgroundTester(0, 0, 10, 10).setEndAfter(1, 1)); - test(new ClipBackgroundTester(0, 0, 10, 10).setStartAfter(1, 1)); - test(new ClipBackgroundTester(0, 0, 10, 10).setStartBefore(1, 1)); - test(new ClipBackgroundTester(0, 0, 100, 100) - .setCornerRadii(10) - .beforeBorder().setWidth(5).tester() - .startBorder().setWidth(5).tester()); - test(new ClipBackgroundTester(0, 0, 100, 100) - .setCornerRadii(10) - .beforeBorder().setWidth(10).tester() - .startBorder().setWidth(10).tester()); - test(new ClipBackgroundTester(0, 0, 100, 100) - .setCornerRadii(10) - .beforeBorder().setWidth(5).tester()); - test(new ClipBackgroundTester(0, 0, 100, 100) - .setCornerRadii(10) - .setStartBefore(10, 10) - .beforeBorder().setWidth(10).tester()); - } - - private void test(BorderPainterTester<?> tester) throws IOException { - tester.test(); - } - - @Test (expected = IFException.class) - public void drawBordersThrowsIFException() throws Exception { - GraphicsPainter graphicsPainter = mock(GraphicsPainter.class); - doThrow(new IOException()).when(graphicsPainter).saveGraphicsState(); - new BorderPainter(graphicsPainter).drawBorders(new Rectangle(0, 0, 1000, 1000), BORDER_PROPS, - BORDER_PROPS, BORDER_PROPS, BORDER_PROPS, Color.WHITE); - } - - @Test - public void testDrawRectangularBorders() throws IOException { - test(new DrawRectangularBordersTester(0, 0, 1000, 1000).setBorderWidth(10)); - test(new DrawRectangularBordersTester(0, 0, 1000, 1000)); - test(new DrawRectangularBordersTester(0, 0, 1000, 1000).setBorderWidth(10) - .beforeBorder().setWidth(0).tester()); - } - - @Test - public void testDrawRectangularBordersWithNullBorders() throws IOException, IFException { - GraphicsPainter graphicsPainter = mock(GraphicsPainter.class); - BorderProps nullBorderProps = null; - new BorderPainter(graphicsPainter).drawRectangularBorders(new Rectangle(0, 0, 1000, 1000), - nullBorderProps, nullBorderProps, nullBorderProps, nullBorderProps); - verifyZeroInteractions(graphicsPainter); - } - - @Test - public void drawRoundedBorders() throws Exception { - test(new DrawRoundedBordersTester(0, 0, 10, 10).setBorderWidth(10)); - test(new DrawRoundedBordersTester(0, 0, 10, 10).beforeBorder().setWidth(10).tester()); - test(new DrawRoundedBordersTester(0, 0, 10, 10).setBorderWidth(10).setCornerRadii(5) - .beforeBorder().setWidth(0).tester()); - test(new DrawRoundedBordersTester(0, 0, 10, 10) - .beforeBorder().setWidth(10).tester().endBorder().setWidth(10).tester()); - test(new DrawRoundedBordersTester(0, 0, 100, 100).setBorderWidth(15).setCornerRadii(10)); - test(new DrawRoundedBordersTester(0, 0, 100, 100).setBorderWidth(15).setCornerRadii(10) - .beforeBorder().setWidth(5).tester()); - test(new DrawRoundedBordersTester(0, 0, 60, 60).setBorderWidth(4).setCornerRadii(30)); - } - - @Test - public void testDrawRoundedBordersWithNullBorders() throws IOException, IFException { - GraphicsPainter graphicsPainter = mock(GraphicsPainter.class); - BorderProps nullBorderProps = null; - new BorderPainter(graphicsPainter).drawRoundedBorders(new Rectangle(0, 0, 1000, 1000), - nullBorderProps, nullBorderProps, nullBorderProps, nullBorderProps); - verifyZeroInteractions(graphicsPainter); - } - - @Test - public void testCalculateCornerCorrectionFactor() { - calculateCornerCorrectionFactorHelper(30000, 500000); - calculateCornerCorrectionFactorHelper(30000, 10000); - } - - private void calculateCornerCorrectionFactorHelper(int radius, int rectWidth) { - BorderProps borderProps = new BorderProps(Constants.EN_SOLID, 4000, radius, radius, Color.BLACK, - BorderProps.Mode.SEPARATE); - int rectHeight = rectWidth + 100; - double expected = (2 * radius > rectWidth) ? (double) rectWidth / (2 * radius) : 1.0; - double actual = BorderPainter.calculateCornerCorrectionFactor(rectWidth, rectHeight, borderProps, - borderProps, borderProps, borderProps); - assertEquals(expected, actual, 0); - } - - private abstract static class BorderPainterTester<T extends BorderPainterTester<?>> { - - protected final Rectangle borderExtent; - - protected BorderProps before; - - protected BorderProps after; - - protected BorderProps start; - - protected BorderProps end; - - protected final GraphicsPainter graphicsPainter; - - protected final BorderPainter sut; - - private final BorderPropsBuilder<T> beforeBuilder; - - private final BorderPropsBuilder<T> afterBuilder; - - private final BorderPropsBuilder<T> startBuilder; - - private final BorderPropsBuilder<T> endBuilder; - - public BorderPainterTester(int xOrigin, int yOrigin, int width, int height) { - if (width <= 0 || height <= 0) { - throw new IllegalArgumentException("Cannot test degenerate borders"); - } - beforeBuilder = new BorderPropsBuilder<T>(getThis()); - afterBuilder = new BorderPropsBuilder<T>(getThis()); - startBuilder = new BorderPropsBuilder<T>(getThis()); - endBuilder = new BorderPropsBuilder<T>(getThis()); - this.borderExtent = new Rectangle(xOrigin, yOrigin, width, height); - this.graphicsPainter = mock(GraphicsPainter.class); - this.sut = new BorderPainter(graphicsPainter); - } - - protected abstract T getThis(); - - public BorderPropsBuilder<T> beforeBorder() { - return beforeBuilder; - } - - public BorderPropsBuilder<T> afterBorder() { - return afterBuilder; - } - - public BorderPropsBuilder<T> startBorder() { - return startBuilder; - } - - public BorderPropsBuilder<T> endBorder() { - return endBuilder; - } - - public T setBorderWidth(int width) { - beforeBuilder.setWidth(width); - endBuilder.setWidth(width); - afterBuilder.setWidth(width); - startBuilder.setWidth(width); - return getThis(); - } - - public T setCornerRadii(int radius) { - return setCornerRadii(radius, radius); - } - - public T setCornerRadii(int xRadius, int yRadius) { - setStartBefore(xRadius, yRadius); - setEndBefore(xRadius, yRadius); - setEndAfter(xRadius, yRadius); - setStartAfter(xRadius, yRadius); - return getThis(); - } - - public T setStartBefore(int xRadius, int yRadius) { - startBuilder.setRadiusStart(xRadius); - beforeBuilder.setRadiusStart(yRadius); - return getThis(); - } - - public T setEndBefore(int xRadius, int yRadius) { - endBuilder.setRadiusStart(xRadius); - beforeBuilder.setRadiusEnd(yRadius); - return getThis(); - } - - public T setEndAfter(int xRadius, int yRadius) { - endBuilder.setRadiusEnd(xRadius); - afterBuilder.setRadiusEnd(yRadius); - return getThis(); - } - - public T setStartAfter(int xRadius, int yRadius) { - startBuilder.setRadiusEnd(xRadius); - afterBuilder.setRadiusStart(yRadius); - return getThis(); - } - - public final void test() throws IOException { - before = beforeBuilder.build(); - after = afterBuilder.build(); - end = endBuilder.build(); - start = startBuilder.build(); - testMethod(); - } - - protected abstract void testMethod() throws IOException; - - protected static int numberOfNonZeroBorders(BorderProps first, BorderProps... borders) { - int i = first.width == 0 ? 0 : 1; - for (BorderProps borderProp : borders) { - if (borderProp.width > 0) { - i++; - } - } - return i; - } - - protected int numberOfNonZeroBorders() { - return numberOfNonZeroBorders(before, end, after, start); - } - - } - - private static class BorderPropsBuilder<T extends BorderPainterTester<?>> { - - private final int style = 0; - - private final Color color = null; - - private final Mode mode = BorderProps.Mode.SEPARATE; - - private int width; - - private int radiusStart; - - private int radiusEnd; - - private final T tester; - - public BorderPropsBuilder(T tester) { - this.tester = tester; - } - - public T tester() { - return tester; - } - - public BorderPropsBuilder<T> setWidth(int width) { - this.width = width; - return this; - } - - public BorderPropsBuilder<T> setRadiusStart(int radiusStart) { - this.radiusStart = radiusStart; - return this; - } - - public BorderPropsBuilder<T> setRadiusEnd(int radiusEnd) { - this.radiusEnd = radiusEnd; - return this; - } - - public BorderProps build() { - return new BorderProps(style, width, radiusStart, radiusEnd, color, mode); - } - } - - private static final class DrawRectangularBordersTester - extends BorderPainterTester<DrawRectangularBordersTester> { - - public DrawRectangularBordersTester(int xOrigin, int yOrigin, int width, int height) - throws IOException { - super(xOrigin, yOrigin, width, height); - } - - public DrawRectangularBordersTester setStartBefore(int xRadius, int yRadius) { - return notSupported(); - } - - public DrawRectangularBordersTester setEndBefore(int xRadius, int yRadius) { - return notSupported(); - } - - public DrawRectangularBordersTester setEndAfter(int xRadius, int yRadius) { - return notSupported(); - } - - public DrawRectangularBordersTester setStartAfter(int xRadius, int yRadius) { - return notSupported(); - } - - private DrawRectangularBordersTester notSupported() { - throw new UnsupportedOperationException(); - } - - public void testMethod() throws IOException { - sut.drawRectangularBorders(borderExtent, before, after, start, end); - verifyDrawing(); - } - - private void verifyDrawing() throws IOException { - final int rectX = borderExtent.x; - final int rectY = borderExtent.y; - final int rectWidth = borderExtent.width; - final int rectHeight = borderExtent.height; - if (before.width > 0) { - verify(graphicsPainter).moveTo(rectX, rectY); - verify(graphicsPainter).lineTo(rectWidth, rectY); - verify(graphicsPainter, times(numberOfNonZeroBorders(before, end))) - .lineTo(rectWidth - end.width, rectY + before.width); - verify(graphicsPainter, times(numberOfNonZeroBorders(before, start))) - .lineTo(rectX + start.width, rectY + before.width); - } - if (end.width > 0) { - verify(graphicsPainter).moveTo(rectWidth, rectY); - verify(graphicsPainter).lineTo(rectWidth, rectHeight); - verify(graphicsPainter, times(numberOfNonZeroBorders(end, after))) - .lineTo(rectWidth - end.width, rectHeight - after.width); - verify(graphicsPainter, times(numberOfNonZeroBorders(end, before))) - .lineTo(rectWidth - end.width, rectY + before.width); - } - if (after.width > 0) { - verify(graphicsPainter).moveTo(rectWidth, rectHeight); - verify(graphicsPainter).lineTo(rectX, rectHeight); - verify(graphicsPainter, times(numberOfNonZeroBorders(after, end))) - .lineTo(rectX + start.width, rectHeight - after.width); - verify(graphicsPainter, times(numberOfNonZeroBorders(after, start))) - .lineTo(rectWidth - end.width, rectHeight - after.width); - } - if (start.width > 0) { - verify(graphicsPainter).moveTo(rectX, rectHeight); - verify(graphicsPainter).lineTo(rectX, rectY); - verify(graphicsPainter, times(numberOfNonZeroBorders(start, before))) - .lineTo(rectX + start.width, rectY + before.width); - verify(graphicsPainter, times(numberOfNonZeroBorders(start, after))) - .lineTo(rectX + start.width, rectHeight - after.width); - } - int numBorders = numberOfNonZeroBorders(); - verify(graphicsPainter, times(numBorders)).saveGraphicsState(); - verify(graphicsPainter, times(numBorders)).closePath(); - verify(graphicsPainter, times(numBorders)).restoreGraphicsState(); - verify(graphicsPainter, times(numBorders)).clip(); - } - - @Override - protected DrawRectangularBordersTester getThis() { - return this; - } - } - - private static final class DrawRoundedBordersTester extends BorderPainterTester<DrawRoundedBordersTester> { - - public DrawRoundedBordersTester(int xOrigin, int yOrigin, int width, int height) throws IOException { - super(xOrigin, yOrigin, width, height); - } - - public void testMethod() throws IOException { - sut.drawRoundedBorders(borderExtent, before, after, start, end); - verifyDrawing(); - } - - private void verifyDrawing() throws IOException { - int numBorders = numberOfNonZeroBorders(); - final int rectWidth = borderExtent.width; - final int rectHeight = borderExtent.height; - if (before.width > 0) { - verify(graphicsPainter, atLeastOnce()).lineTo(rectWidth - end.getRadiusStart(), 0); - verify(graphicsPainter, atLeastOnce()).lineTo(calcLineEnd(start.width, before.width, - start.getRadiusStart(), before.getRadiusStart()), before.width); - } - if (end.width > 0) { - verify(graphicsPainter, atLeastOnce()).lineTo(rectHeight - after.getRadiusEnd(), 0); - verify(graphicsPainter, atLeastOnce()).lineTo(calcLineEnd(before.width, end.width, - before.getRadiusEnd(), end.getRadiusStart()), end.width); - } - if (after.width > 0) { - verify(graphicsPainter, atLeastOnce()).lineTo(rectWidth - start.getRadiusEnd(), 0); - verify(graphicsPainter, atLeastOnce()).lineTo(calcLineEnd(start.width, after.width, - start.getRadiusEnd(), after.getRadiusStart()), after.width); - } - if (start.width > 0) { - verify(graphicsPainter, atLeastOnce()).lineTo(rectHeight - after.getRadiusStart(), 0); - verify(graphicsPainter, atLeastOnce()).lineTo(calcLineEnd(before.width, start.width, - before.getRadiusStart(), before.getRadiusStart()), start.width); - } - // verify the drawing of the symmetric rounded corners (the ones that are a quarter of a circle) - // verification is restricted to those since it is too complex in the general case - if (before.width == end.width && before.getRadiusStart() == before.getRadiusEnd() - && end.getRadiusStart() == end.getRadiusEnd() - && before.getRadiusEnd() == end.getRadiusStart() && end.getRadiusStart() > 0) { - verify(graphicsPainter, atLeastOnce()).arcTo(Math.PI * 5 / 4, Math.PI * 3 / 2, - before.getRadiusStart(), end.getRadiusEnd(), before.getRadiusStart(), - end.getRadiusEnd()); - } - if (end.width == after.width && end.getRadiusStart() == end.getRadiusEnd() - && after.getRadiusStart() == after.getRadiusEnd() - && end.getRadiusEnd() == after.getRadiusStart() && after.getRadiusStart() > 0) { - verify(graphicsPainter, atLeastOnce()).arcTo(Math.PI * 5 / 4, Math.PI * 3 / 2, - end.getRadiusStart(), after.getRadiusEnd(), end.getRadiusStart(), - after.getRadiusEnd()); - } - if (after.width == start.width && after.getRadiusStart() == after.getRadiusEnd() - && start.getRadiusStart() == start.getRadiusEnd() - && after.getRadiusEnd() == start.getRadiusStart() && start.getRadiusStart() > 0) { - verify(graphicsPainter, atLeastOnce()).arcTo(Math.PI * 5 / 4, Math.PI * 3 / 2, - after.getRadiusStart(), start.getRadiusEnd(), after.getRadiusStart(), - start.getRadiusEnd()); - } - if (start.width == before.width && start.getRadiusStart() == start.getRadiusEnd() - && before.getRadiusStart() == before.getRadiusEnd() - && start.getRadiusEnd() == before.getRadiusStart() && before.getRadiusStart() > 0) { - verify(graphicsPainter, atLeastOnce()).arcTo(Math.PI * 5 / 4, Math.PI * 3 / 2, - start.getRadiusStart(), before.getRadiusEnd(), start.getRadiusStart(), - before.getRadiusEnd()); - } - verify(graphicsPainter, times(numBorders)).saveGraphicsState(); - verify(graphicsPainter, times(numBorders)).closePath(); - verify(graphicsPainter, times(numBorders)).restoreGraphicsState(); - verify(graphicsPainter, times(numBorders)).clip(); - } - - private int calcLineEnd(int xWidth, int yWidth, int xRadius, int yRadius) { - return yWidth > yRadius ? yWidth : xWidth > 0 ? Math.max(xRadius, xWidth) : 0; - } - - @Override - protected DrawRoundedBordersTester getThis() { - return this; - } - - } - - private static final class ClipBackgroundTester extends BorderPainterTester<ClipBackgroundTester> { - - public ClipBackgroundTester(int xOrigin, int yOrigin, int width, int height) throws IOException { - super(xOrigin, yOrigin, width, height); - } - - public void testMethod() throws IOException { - sut.clipBackground(borderExtent, before, after, start, end); - verifyClipping(); - } - - private void verifyClipping() throws IOException { - int xOrigin = borderExtent.x; - int yOrigin = borderExtent.y; - int xEnd = xOrigin + borderExtent.width; - int yEnd = yOrigin + borderExtent.height; - - Corner startBeforeCorner = Corner.createStartBeforeCorner(getInnerRadiusStart(start), - getInnerRadiusStart(before)); - Corner endBeforeCorner = Corner.createEndBeforeCorner(getInnerRadiusStart(end), getRadiusEnd(before)); - Corner endAfterCorner = Corner.createEndAfterCorner(getRadiusEnd(end), getRadiusEnd(after)); - Corner startAfterCorner = Corner.createStartAfterCorner(getRadiusEnd(start), - getInnerRadiusStart(after)); - verify(graphicsPainter, times(1)).moveTo(xOrigin + startBeforeCorner.xRadius, yOrigin); - verify(graphicsPainter, times(1)).lineTo(xEnd - endBeforeCorner.xRadius, yOrigin); - endBeforeCorner.verifyCornerDrawn(graphicsPainter, xEnd - endBeforeCorner.xRadius, - yOrigin + endBeforeCorner.yRadius); - verify(graphicsPainter, times(1)).lineTo(xEnd, yEnd - endAfterCorner.yRadius); - endAfterCorner.verifyCornerDrawn(graphicsPainter, xEnd - endAfterCorner.xRadius, - yEnd - endAfterCorner.yRadius); - verify(graphicsPainter, times(1)).lineTo(xOrigin + startAfterCorner.xRadius, yEnd); - startAfterCorner.verifyCornerDrawn(graphicsPainter, xOrigin + startAfterCorner.xRadius, - yEnd - startAfterCorner.yRadius); - verify(graphicsPainter, times(1)).lineTo(xOrigin, yOrigin + startBeforeCorner.yRadius); - startBeforeCorner.verifyCornerDrawn(graphicsPainter, xOrigin + startBeforeCorner.xRadius, - yOrigin + startBeforeCorner.yRadius); - verify(graphicsPainter, times(1)).clip(); - } - - private int getInnerRadiusStart(BorderProps borderProps) { - return getInnerRadius(borderProps.getRadiusStart(), borderProps.width); - } - - private int getRadiusEnd(BorderProps borderProps) { - return getInnerRadius(borderProps.getRadiusEnd(), borderProps.width); - } - - private int getInnerRadius(int radius, int borderWidth) { - return Math.max(radius - borderWidth, 0); - } - - private static class Corner { - - public final int xRadius; - - public final int yRadius; - - private final double startAngle; - - private final double endAngle; - - public Corner(int xRadius, int yRadius, double startAngle, double endAngle) { - this.xRadius = xRadius; - this.yRadius = yRadius; - this.startAngle = startAngle; - this.endAngle = endAngle; - } - - public static Corner createStartBeforeCorner(int xRadius, int yRadius) { - return new Corner(xRadius, yRadius, Math.PI, Math.PI * 3 / 2); - } - - public static Corner createEndBeforeCorner(int xRadius, int yRadius) { - return new Corner(xRadius, yRadius, Math.PI * 3 / 2, 0); - } - - public static Corner createEndAfterCorner(int xRadius, int yRadius) { - return new Corner(xRadius, yRadius, 0, Math.PI / 2); - } - - public static Corner createStartAfterCorner(int xRadius, int yRadius) { - return new Corner(xRadius, yRadius, Math.PI / 2, Math.PI); - } - - public void verifyCornerDrawn(GraphicsPainter graphicsPainter, int xCenter, int yCenter) - throws IOException { - if (xRadius != 0 && yRadius != 0) { - verify(graphicsPainter, times(1)).arcTo(startAngle, endAngle, - xCenter, yCenter, xRadius, yRadius); - } else { - verify(graphicsPainter, never()).arcTo(startAngle, endAngle, - xCenter, yCenter, xRadius, yRadius); - } - } - } - - @Override - protected ClipBackgroundTester getThis() { - return this; - } - } - - -} diff --git a/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java b/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java deleted file mode 100644 index 0340c190e..000000000 --- a/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.intermediate; - -import java.awt.Rectangle; - -import javax.xml.transform.sax.SAXResult; - -import org.junit.Before; -import org.junit.Test; -import org.xml.sax.helpers.DefaultHandler; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.xmlgraphics.image.loader.ImageManager; -import org.apache.xmlgraphics.image.loader.ImageSessionContext; - -import org.apache.fop.apps.FOUserAgent; - -public class IFSerializerTestCase { - - private static final String IMAGE = "image.png"; - - private IFSerializer sut; - - private ImageManager imageManager; - - @Before - public void setUp() throws IFException { - imageManager = mock(ImageManager.class); - IFContext context = mockContext(); - sut = new IFSerializer(context); - } - - private IFContext mockContext() { - FOUserAgent userAgent = mock(FOUserAgent.class); - when(userAgent.getImageManager()).thenReturn(imageManager); - return new IFContext(userAgent); - } - - @Test - public void drawImageShouldCloseResources() throws IFException { - sut.setResult(new SAXResult(new DefaultHandler())); - whenDrawImageIsCalled(true); - thenImageResourcesMustBeClosed(); - } - - @Test - public void failingDrawImageShouldCloseResources() throws IFException { - // Make drawImage artificially fail by not calling setResult - whenDrawImageIsCalled(false); - thenImageResourcesMustBeClosed(); - } - - private void whenDrawImageIsCalled(boolean terminatesNormally) throws IFException { - boolean exceptionThrown = false; - try { - sut.drawImage(IMAGE, new Rectangle(10, 10)); - } catch (Exception e) { - exceptionThrown = true; - } - if (!terminatesNormally) { - assertTrue(exceptionThrown); - } - } - - private void thenImageResourcesMustBeClosed() { - verify(imageManager).closeImage(eq(IMAGE), any(ImageSessionContext.class)); - } - -} diff --git a/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java b/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java deleted file mode 100644 index 5546e5905..000000000 --- a/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.intermediate; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InOrder; -import org.xml.sax.Attributes; -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; -import org.apache.fop.util.XMLUtil; - -public class IFStructureTreeBuilderTestCase { - - private IFStructureTreeBuilder sut; - - @Before - public void setUp() { - sut = new IFStructureTreeBuilder(); - } - - @Test - public void startAndEndPageSequence() throws SAXException { - final ContentHandler handler = mock(ContentHandler.class); - - try { - sut.replayEventsForPageSequence(handler, 0); - fail("No page sequences created"); - } catch (IndexOutOfBoundsException e) { - // Expected - } - - sut.startPageSequence(null, null); - sut.endPageSequence(); - - sut.replayEventsForPageSequence(handler, 0); - - InOrder inOrder = inOrder(handler); - - inOrder.verify(handler).startPrefixMapping( - InternalElementMapping.STANDARD_PREFIX, InternalElementMapping.URI); - inOrder.verify(handler).startPrefixMapping( - ExtensionElementMapping.STANDARD_PREFIX, ExtensionElementMapping.URI); - inOrder.verify(handler).startElement(eq(IFConstants.NAMESPACE), - eq(IFConstants.EL_STRUCTURE_TREE), - eq(IFConstants.EL_STRUCTURE_TREE), - any(Attributes.class)); - inOrder.verify(handler).endElement(eq(IFConstants.NAMESPACE), - eq(IFConstants.EL_STRUCTURE_TREE), - eq(IFConstants.EL_STRUCTURE_TREE)); - inOrder.verify(handler).endPrefixMapping(ExtensionElementMapping.STANDARD_PREFIX); - inOrder.verify(handler).endPrefixMapping(InternalElementMapping.STANDARD_PREFIX); - } - - @Test - public void startNode() throws Exception { - final String[] attributes = {"struct-id", "1"}; - final String nodeName = "block"; - final ContentHandler handler = mock(ContentHandler.class); - - sut.startPageSequence(null, null); - sut.startNode(nodeName, createSimpleAttributes(attributes), null); - sut.endPageSequence(); - - sut.replayEventsForPageSequence(handler, 0); - - verify(handler).startElement(eq(FOElementMapping.URI), eq(nodeName), - eq(FOElementMapping.STANDARD_PREFIX + ":" + nodeName), - AttributesMatcher.match(createSimpleAttributes(attributes))); - } - - @Test - public void endNode() throws Exception { - final String nodeName = "block"; - final ContentHandler handler = mock(ContentHandler.class); - - sut.startPageSequence(null, null); - sut.endNode(nodeName); - sut.endPageSequence(); - - sut.replayEventsForPageSequence(handler, 0); - - verify(handler).endElement(eq(FOElementMapping.URI), eq(nodeName), - eq(FOElementMapping.STANDARD_PREFIX + ":" + nodeName)); - } - - private static Attributes createSimpleAttributes(String... attributes) { - assert (attributes.length % 2 == 0); - final AttributesImpl atts = new AttributesImpl(); - for (int i = 0; i < attributes.length; i += 2) { - String key = attributes[i]; - String value = attributes[i + 1]; - atts.addAttribute("", key, key, XMLUtil.CDATA, value); - } - return atts; - } - - private static final class AttributesMatcher extends ArgumentMatcher<Attributes> { - - private final Attributes expected; - - private AttributesMatcher(Attributes expected) { - this.expected = expected; - } - - public static Attributes match(Attributes expected) { - return argThat(new AttributesMatcher(expected)); - } - - public boolean matches(Object attributes) { - return attributesEqual(expected, (Attributes) attributes); - } - - private static boolean attributesEqual(Attributes attributes1, Attributes attributes2) { - if (attributes1.getLength() != attributes2.getLength()) { - return false; - } - for (int i = 0; i < attributes1.getLength(); i++) { - if (attributes1.getLocalName(i) != attributes2.getLocalName(i)) { - return false; - } - if (attributes1.getQName(i) != attributes2.getQName(i)) { - return false; - } - if (attributes1.getType(i) != attributes2.getType(i)) { - return false; - } - if (attributes1.getURI(i) != attributes2.getURI(i)) { - return false; - } - if (attributes1.getValue(i) != attributes2.getValue(i)) { - return false; - } - } - return true; - } - } -} diff --git a/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java b/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java deleted file mode 100644 index 757d6620b..000000000 --- a/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.intermediate; - - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; -import org.xml.sax.Attributes; -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; - -/** - * Tests {@link SAXEventRecorder}. - */ -public class SAXEventRecorderTestCase { - - private static final String URI = "http://www.example.com/"; - - private SAXEventRecorder sut; - - @Before - public void setUp() { - sut = new SAXEventRecorder(); - } - - @Test - public void testStartEvent() throws SAXException { - final String localName = "element"; - final String qName = "prefix:" + localName; - final Attributes attributes = new AttributesImpl(); - - sut.startElement(URI, localName, qName, attributes); - ContentHandler handler = mock(ContentHandler.class); - sut.replay(handler); - verify(handler).startElement(URI, localName, qName, attributes); - } - - @Test - public void testEndEvent() throws SAXException { - final String localName = "element"; - final String qName = "prefix:" + localName; - sut.endElement(URI, localName, qName); - ContentHandler handler = mock(ContentHandler.class); - sut.replay(handler); - verify(handler).endElement(URI, localName, qName); - } - - @Test - public void testStartPrefixMapping() throws SAXException { - final String prefix = "prefix"; - - sut.startPrefixMapping(URI, prefix); - ContentHandler handler = mock(ContentHandler.class); - sut.replay(handler); - verify(handler).startPrefixMapping(URI, prefix); - } - - @Test - public void testEndPrefixMapping() throws SAXException { - final String prefix = "prefix"; - - sut.endPrefixMapping(prefix); - ContentHandler handler = mock(ContentHandler.class); - sut.replay(handler); - verify(handler).endPrefixMapping(prefix); - } - - @Test - public void completeTest() throws SAXException { - final String localName1 = "element"; - final String qName1 = "prefix:" + localName1; - final Attributes attributes1 = createAttributes(URI, localName1, qName1, "value-1"); - final String localName2 = "element2"; - final String qName2 = "prefix:" + localName2; - final Attributes attributes2 = createAttributes(URI, localName2, qName2, "value-2"); - final ContentHandler handler = mock(ContentHandler.class); - final String extensionUrl = "http://www.example.com/extension"; - final String extensionPrefix = "ext"; - - sut.startPrefixMapping(extensionPrefix, extensionUrl); - sut.startElement(URI, localName1, qName1, attributes1); - sut.startElement(URI, localName2, qName2, attributes2); - sut.endElement(URI, localName2, qName2); - sut.endElement(URI, localName1, qName1); - sut.endPrefixMapping(extensionPrefix); - - sut.replay(handler); - - InOrder inOrder = inOrder(handler); - inOrder.verify(handler).startPrefixMapping(extensionPrefix, extensionUrl); - inOrder.verify(handler).startElement(URI, localName1, qName1, attributes1); - inOrder.verify(handler).startElement(URI, localName2, qName2, attributes2); - inOrder.verify(handler).endElement(URI, localName2, qName2); - inOrder.verify(handler).endElement(URI, localName1, qName1); - inOrder.verify(handler).endPrefixMapping(extensionPrefix); - } - - private static Attributes createAttributes(String uri, String localName, - String qName, String value) { - final AttributesImpl atts = new AttributesImpl(); - atts.addAttribute(uri, localName, qName, XMLUtil.CDATA, value); - return atts; - } - -} diff --git a/test/java/org/apache/fop/render/java2d/Java2DRendererConfigParserTestcase.java b/test/java/org/apache/fop/render/java2d/Java2DRendererConfigParserTestcase.java deleted file mode 100644 index e87c8713d..000000000 --- a/test/java/org/apache/fop/render/java2d/Java2DRendererConfigParserTestcase.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.java2d; - -import org.junit.Test; - -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.Java2DRendererConfBuilder; -import org.apache.fop.render.java2d.Java2DRendererConfig.Java2DRendererConfigParser; - -public class Java2DRendererConfigParserTestcase - extends AbstractRendererConfigParserTester<Java2DRendererConfBuilder, Java2DRendererConfig> { - - public Java2DRendererConfigParserTestcase() { - super(new Java2DRendererConfigParser("Java2D"), Java2DRendererConfBuilder.class); - } - - @Test - public void testPageBackgroundTransparency() throws Exception { - parseConfig(createRenderer().setPageBackgroundTransparency(true)); - assertTrue(conf.isPageBackgroundTransparent()); - - parseConfig(createRenderer().setPageBackgroundTransparency(false)); - assertFalse(conf.isPageBackgroundTransparent()); - } - - @Test - public void testNullPageBackgroundTransparency() throws Exception { - parseConfig(createRenderer()); - assertNull(conf.isPageBackgroundTransparent()); - } -} diff --git a/test/java/org/apache/fop/render/pcl/PCLPainterTestCase.java b/test/java/org/apache/fop/render/pcl/PCLPainterTestCase.java deleted file mode 100644 index 65ac6ef0b..000000000 --- a/test/java/org/apache/fop/render/pcl/PCLPainterTestCase.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ -package org.apache.fop.render.pcl; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.io.ByteArrayOutputStream; -import java.io.File; - -import javax.xml.transform.stream.StreamResult; - -import org.junit.Test; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFException; - -import junit.framework.Assert; - -public class PCLPainterTestCase { - private FOUserAgent ua = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); - - @Test - public void testFillRect() throws IFException { - Rectangle size = new Rectangle(1, 1); - PCLPageDefinition pclPageDef = new PCLPageDefinition("", 0, new Dimension(), size, true); - PCLDocumentHandler documentHandler = new PCLDocumentHandler(new IFContext(ua)); - ByteArrayOutputStream output = new ByteArrayOutputStream(); - documentHandler.setResult(new StreamResult(output)); - documentHandler.startDocument(); - PCLPainter pclPainter = new PCLPainter(documentHandler, pclPageDef); - pclPainter.fillRect(size, Color.RED); - Assert.assertTrue(output.toString().contains("*c4Q\u001B*c0.01h0.01V\u001B*c32G\u001B*c4P")); - output.reset(); - - pclPainter.getPCLUtil().setColorEnabled(true); - pclPainter.fillRect(size, Color.RED); - Assert.assertFalse(output.toString().contains("*c4P")); - Assert.assertTrue(output.toString().contains("*v255a0b0c0I\u001B*v0S\u001B*c0.01h0.01V\u001B*c0P")); - } - -} diff --git a/test/java/org/apache/fop/render/pcl/PCLRendererConfBuilder.java b/test/java/org/apache/fop/render/pcl/PCLRendererConfBuilder.java deleted file mode 100644 index 1265526a4..000000000 --- a/test/java/org/apache/fop/render/pcl/PCLRendererConfBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pcl; - - -import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; -import org.apache.fop.apps.MimeConstants; - -import static org.apache.fop.render.pcl.Java2DRendererOption.DISABLE_PJL; -import static org.apache.fop.render.pcl.Java2DRendererOption.RENDERING_MODE; -import static org.apache.fop.render.pcl.Java2DRendererOption.TEXT_RENDERING; -/** - * A config builder specific to a particular renderer for specific MIME type. - */ -public final class PCLRendererConfBuilder extends RendererConfBuilder { - - public PCLRendererConfBuilder() { - super(MimeConstants.MIME_PCL); - } - - public PCLRendererConfBuilder setRenderingMode(PCLRenderingMode mode) { - return setRenderingMode(mode.getName()); - } - - public PCLRendererConfBuilder setRenderingMode(String value) { - return createTextElement(RENDERING_MODE, value); - } - - public PCLRendererConfBuilder setTextRendering(String value) { - return createTextElement(TEXT_RENDERING, value); - } - - public PCLRendererConfBuilder setDisablePjl(boolean value) { - return createTextElement(DISABLE_PJL, String.valueOf(value)); - } - - private PCLRendererConfBuilder createTextElement(Java2DRendererOption option, String value) { - createTextElement(option.getName(), value); - return this; - } - -} diff --git a/test/java/org/apache/fop/render/pcl/PCLRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/pcl/PCLRendererConfigParserTestCase.java deleted file mode 100644 index caf534854..000000000 --- a/test/java/org/apache/fop/render/pcl/PCLRendererConfigParserTestCase.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.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; - -public class PCLRendererConfigParserTestCase - extends AbstractRendererConfigParserTester<PCLRendererConfBuilder, PCLRendererConfig> { - - public PCLRendererConfigParserTestCase() { - super(new PCLRendererConfigParser(), PCLRendererConfBuilder.class); - } - - @Test - public void testGetMimeType() throws Exception { - assertEquals(MimeConstants.MIME_PCL, new PCLRendererConfigParser().getMimeType()); - } - - @Test - public void testRenderingMode() throws Exception { - parseConfig(); - assertEquals(null, conf.getRenderingMode()); - parseConfig(createRenderer().setRenderingMode(PCLRenderingMode.QUALITY)); - assertEquals(PCLRenderingMode.QUALITY, conf.getRenderingMode()); - } - - @Test(expected = FOPException.class) - public void testRenderingModeException() throws Exception { - parseConfig(createRenderer().setRenderingMode("whatever")); - } - - @Test - public void testTextRendering() throws Exception { - parseConfig(); - assertEquals(false, conf.isTextRendering()); - parseConfig(createRenderer().setTextRendering("auto")); - assertEquals(false, conf.isTextRendering()); - parseConfig(createRenderer().setTextRendering("bitmap")); - assertEquals(true, conf.isTextRendering()); - } - - @Test(expected = FOPException.class) - public void testTextRenderingException() throws Exception { - parseConfig(createRenderer().setTextRendering("whatever")); - } - - @Test - public void testDisablePJL() throws Exception { - parseConfig(); - assertEquals(false, conf.isDisablePjl()); - parseConfig(createRenderer().setDisablePjl(true)); - assertEquals(true, conf.isDisablePjl()); - } -} diff --git a/test/java/org/apache/fop/render/pcl/PCLRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/pcl/PCLRendererConfiguratorTestCase.java deleted file mode 100644 index fc7175ad6..000000000 --- a/test/java/org/apache/fop/render/pcl/PCLRendererConfiguratorTestCase.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.render.pcl; - -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.FOPException; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.pcl.PCLRendererConfig.PCLRendererConfigParser; - -public class PCLRendererConfiguratorTestCase extends - AbstractRendererConfiguratorTest<PCLRendererConfigurator, PCLRendererConfBuilder> { - - private PCLRenderingUtil pclUtil; - - public PCLRendererConfiguratorTestCase() { - super(MimeConstants.MIME_PCL, PCLRendererConfBuilder.class, PCLDocumentHandler.class); - } - - @Override - public PCLRendererConfigurator createConfigurator() { - return new PCLRendererConfigurator(userAgent, new PCLRendererConfigParser()); - } - - @Override - public void setUpDocumentHandler() { - pclUtil = new PCLRenderingUtil(userAgent); - when(((PCLDocumentHandler) docHandler).getPCLUtil()).thenReturn(pclUtil); - } - - @Test - public void testSetRenderingMode() throws Exception { - parseConfig(createBuilder().setRenderingMode("bitmap")); - assertEquals(PCLRenderingMode.BITMAP, pclUtil.getRenderingMode()); - - parseConfig(createBuilder().setRenderingMode("quality")); - assertEquals(PCLRenderingMode.QUALITY, pclUtil.getRenderingMode()); - - parseConfig(createBuilder().setRenderingMode("speed")); - assertEquals(PCLRenderingMode.SPEED, pclUtil.getRenderingMode()); - - parseConfig(createBuilder()); - assertEquals(PCLRenderingMode.SPEED, pclUtil.getRenderingMode()); - } - - @Test(expected = FOPException.class) - public void testRenderingModeFailureCase() throws Exception { - parseConfig(createBuilder().setRenderingMode("fail")); - assertEquals(PCLRenderingMode.SPEED, pclUtil.getRenderingMode()); - } - - @Test - public void testPJLDisabled() throws Exception { - parseConfig(createBuilder().setDisablePjl(true)); - assertTrue(pclUtil.isPJLDisabled()); - - parseConfig(createBuilder().setDisablePjl(false)); - assertFalse(pclUtil.isPJLDisabled()); - - parseConfig(createBuilder()); - assertFalse(pclUtil.isPJLDisabled()); - } - - @Test - public void testSetAllTextAsBitmaps() throws Exception { - parseConfig(createBuilder().setTextRendering("bitmap")); - assertTrue(pclUtil.isAllTextAsBitmaps()); - - parseConfig(createBuilder().setTextRendering("auto")); - assertFalse(pclUtil.isAllTextAsBitmaps()); - - parseConfig(createBuilder()); - assertFalse(pclUtil.isAllTextAsBitmaps()); - } - - @Test(expected = FOPException.class) - public void testSetAllTextAsBitmapsFailureCase() throws Exception { - parseConfig(createBuilder().setTextRendering("fail")); - assertFalse(pclUtil.isAllTextAsBitmaps()); - } -} diff --git a/test/java/org/apache/fop/render/pcl/fonts/MockPCLTTFFontReader.java b/test/java/org/apache/fop/render/pcl/fonts/MockPCLTTFFontReader.java deleted file mode 100644 index a155dd43d..000000000 --- a/test/java/org/apache/fop/render/pcl/fonts/MockPCLTTFFontReader.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ -package org.apache.fop.render.pcl.fonts; - -import java.io.IOException; - -import org.apache.fop.fonts.CustomFont; -import org.apache.fop.fonts.Typeface; -import org.apache.fop.fonts.truetype.FontFileReader; -import org.apache.fop.fonts.truetype.TTFFile; -import org.apache.fop.render.java2d.CustomFontMetricsMapper; -import org.apache.fop.render.pcl.fonts.truetype.PCLTTFFontReader; - -public class MockPCLTTFFontReader extends PCLTTFFontReader { - - public MockPCLTTFFontReader(Typeface font, PCLByteWriterUtil pclByteWriter) throws IOException { - super(font, pclByteWriter); - } - - @Override - protected void loadFont() throws IOException { - if (typeface instanceof CustomFontMetricsMapper) { - CustomFontMetricsMapper fontMetrics = (CustomFontMetricsMapper) typeface; - CustomFont customFont = (CustomFont) fontMetrics.getRealFont(); - fontStream = customFont.getInputStream(); - reader = new FontFileReader(fontStream); - - ttfFont = new TTFFile(); - ttfFont.readFont(reader, customFont.getFullName()); - readFontTables(); - } else { - // TODO - Handle when typeface is not in the expected format for a PCL TrueType object - } - } -} diff --git a/test/java/org/apache/fop/render/pcl/fonts/PCLByteWriterUtilTestCase.java b/test/java/org/apache/fop/render/pcl/fonts/PCLByteWriterUtilTestCase.java deleted file mode 100644 index a21f204bf..000000000 --- a/test/java/org/apache/fop/render/pcl/fonts/PCLByteWriterUtilTestCase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ -package org.apache.fop.render.pcl.fonts; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; - -public class PCLByteWriterUtilTestCase { - private PCLByteWriterUtil byteWriter; - - @Before - public void setUp() { - byteWriter = new PCLByteWriterUtil(); - } - - @Test - public void testWriteMethods() throws IOException { - byte[] output = byteWriter.writeCommand("(s4X"); - // 27 = PCL escape character with rest in ASCII format - byte[] command = {27, 40, 115, 52, 88}; - assertArrayEquals(command, output); - - byte[] resultB = byteWriter.unsignedLongInt(102494); - byte[] compareB = {0, 1, -112, 94}; - assertArrayEquals(compareB, resultB); - - byte[] resultC = byteWriter.unsignedInt(1024); - byte[] compareC = {4, 0}; - assertArrayEquals(compareC, resultC); - } - - @Test - public void testUtilMethods() throws IOException { - byte[] anArray = {1, 2, 3, 4, 5, 9, 10}; - byte[] insertArray = {6, 7, 8}; - byte[] result = byteWriter.insertIntoArray(5, anArray, insertArray); - byte[] compareA = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - assertArrayEquals(compareA, result); - - byte[] reverse = {10, 9, 8, 7, 6}; - byteWriter.updateDataAtLocation(compareA, reverse, 5); - byte[] compareB = {1, 2, 3, 4, 5, 10, 9, 8, 7, 6}; - assertArrayEquals(compareB, compareA); - - byte[] anArrayC = {1, 2, 3, 4, 5}; - byte[] resultC = byteWriter.padBytes(anArrayC, 10); - byte[] compareC = {1, 2, 3, 4, 5, 0, 0, 0, 0, 0}; - assertArrayEquals(compareC, resultC); - - byte[] resultD = byteWriter.padBytes(anArrayC, 10, 1); - byte[] compareD = {1, 2, 3, 4, 5, 1, 1, 1, 1, 1}; - assertArrayEquals(compareD, resultD); - } -} diff --git a/test/java/org/apache/fop/render/pcl/fonts/PCLFontReaderFactoryTestCase.java b/test/java/org/apache/fop/render/pcl/fonts/PCLFontReaderFactoryTestCase.java deleted file mode 100644 index 2860afbdf..000000000 --- a/test/java/org/apache/fop/render/pcl/fonts/PCLFontReaderFactoryTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ -package org.apache.fop.render.pcl.fonts; - -import java.io.File; -import java.io.FileInputStream; -import java.net.URI; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.fonts.CustomFont; -import org.apache.fop.fonts.FontType; -import org.apache.fop.render.java2d.CustomFontMetricsMapper; -import org.apache.fop.render.pcl.fonts.truetype.PCLTTFFontReader; - -public class PCLFontReaderFactoryTestCase { - private static final String TEST_FONT_TTF = "./test/resources/fonts/ttf/DejaVuLGCSerif.ttf"; - - @Test - public void verifyTypeIdentification() throws Exception { - CustomFont sbFont = mock(CustomFont.class); - when(sbFont.getInputStream()).thenReturn(new FileInputStream(new File(TEST_FONT_TTF))); - when(sbFont.getEmbedFileURI()).thenReturn(new URI(TEST_FONT_TTF)); - CustomFontMetricsMapper customFont = new CustomFontMetricsMapper(sbFont); - when(customFont.getFontType()).thenReturn(FontType.TRUETYPE); - // Have to mock the input stream twice otherwise get a Stream is closed exception - when(((CustomFont) customFont.getRealFont()).getInputStream()).thenReturn( - new FileInputStream(new File(TEST_FONT_TTF))); - PCLFontReaderFactory fontReaderFactory = PCLFontReaderFactory.getInstance(null); - assertTrue(fontReaderFactory.createInstance(customFont) instanceof PCLTTFFontReader); - } -} diff --git a/test/java/org/apache/fop/render/pcl/fonts/PCLTTFFontReaderTestCase.java b/test/java/org/apache/fop/render/pcl/fonts/PCLTTFFontReaderTestCase.java deleted file mode 100644 index 5673efbb4..000000000 --- a/test/java/org/apache/fop/render/pcl/fonts/PCLTTFFontReaderTestCase.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ -package org.apache.fop.render.pcl.fonts; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -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.fop.fonts.CustomFont; -import org.apache.fop.fonts.SingleByteFont; -import org.apache.fop.render.java2d.CustomFontMetricsMapper; -import org.apache.fop.render.pcl.fonts.PCLFontSegment.SegmentID; -import org.apache.fop.render.pcl.fonts.truetype.PCLTTFFontReader; - -public class PCLTTFFontReaderTestCase { - - private CustomFontMetricsMapper customFont = mock(CustomFontMetricsMapper.class); - private PCLByteWriterUtil byteWriter; - private static final String TEST_FONT_A = "./test/resources/fonts/ttf/DejaVuLGCSerif.ttf"; - - @Before - public void setUp() { - byteWriter = new PCLByteWriterUtil(); - } - - @Test - public void verifyFontAData() throws Exception { - CustomFont sbFont = mock(CustomFont.class); - when(sbFont.getInputStream()).thenReturn(new FileInputStream(new File(TEST_FONT_A))); - when(customFont.getRealFont()).thenReturn(sbFont); - SingleByteFont font = mock(SingleByteFont.class); - when(font.getGIDFromChar('h')).thenReturn(104); - when(font.getGIDFromChar('e')).thenReturn(101); - when(font.getGIDFromChar('l')).thenReturn(108); - when(font.getGIDFromChar('o')).thenReturn(111); - PCLTTFFontReader reader = new MockPCLTTFFontReader(customFont, byteWriter); - reader.setFont(font); - verifyFontData(reader); - validateOffsets(reader); - validateFontSegments(reader); - } - - /** - * Compares the input font data against a sample of the data read and calculated by the reader. The assertions are - * made against data taken from the TrueType Font Analyzer tool. - * @param reader The reader - */ - private void verifyFontData(PCLTTFFontReader reader) { - assertEquals(reader.getCellWidth(), 5015); // Bounding box X2 - X1 - assertEquals(reader.getCellHeight(), 3254); // Bounding box Y2 - Y1 - assertEquals(reader.getCapHeight(), 0); // OS2Table.capHeight - assertEquals(reader.getFontName(), "DejaVu LGC Serif"); // Full name read by TTFFont object - assertEquals(reader.getFirstCode(), 32); // Always 32 for bound font - assertEquals(reader.getLastCode(), 255); // Always 255 for bound font - - // Values that require conversion tables (See PCLTTFFontReader.java) - assertEquals(reader.getStrokeWeight(), 0); // Weight Class 400 (regular) should be equivalent 0 - assertEquals(reader.getSerifStyle(), 128); // Serif Style 0 should equal 0 - assertEquals(reader.getWidthType(), 0); // Width Class 5 (regular) should be equivalent 0 - } - - private void validateOffsets(PCLTTFFontReader reader) throws IOException { - // Offsets are stored with their character ID with the array [offset, length] - Map<Integer, int[]> offsets = reader.getCharacterOffsets(); - - // Test data - int[] charC = {27644, 144}; // Char index = 99 - int[] charDollar = {16044, 264}; // Char index = 36 - int[] charOne = {17808, 176}; // Char index = 49 - int[] charUpperD = {21236, 148}; // Char index = 68 - int[] charUpperJ = {22140, 176}; // Char index = 74 - - assertArrayEquals(offsets.get(99), charC); - assertArrayEquals(offsets.get(36), charDollar); - assertArrayEquals(offsets.get(49), charOne); - assertArrayEquals(offsets.get(68), charUpperD); - assertArrayEquals(offsets.get(74), charUpperJ); - } - - /** - * Verifies the font segment data copied originally from the TrueType font. Data was verified using TrueType Font - * Analyzer and PCLParaphernalia tool. - * @param reader The reader - * @throws IOException - */ - private void validateFontSegments(PCLTTFFontReader reader) throws IOException { - HashMap<Character, Integer> mappedChars = new HashMap<Character, Integer>(); - mappedChars.put('H', 1); - mappedChars.put('e', 1); - mappedChars.put('l', 1); - mappedChars.put('o', 1); - - List<PCLFontSegment> segments = reader.getFontSegments(mappedChars); - assertEquals(segments.size(), 5); - for (PCLFontSegment segment : segments) { - if (segment.getIdentifier() == SegmentID.PA) { - // Panose - assertEquals(segment.getData().length, 10); - byte[] panose = {2, 6, 6, 3, 5, 6, 5, 2, 2, 4}; - assertArrayEquals(segment.getData(), panose); - } else if (segment.getIdentifier() == SegmentID.GT) { - verifyGlobalTrueTypeData(segment, mappedChars.size()); - } else if (segment.getIdentifier() == SegmentID.NULL) { - // Terminating segment - assertEquals(segment.getData().length, 0); - } - } - } - - private void verifyGlobalTrueTypeData(PCLFontSegment segment, int mappedCharsSize) - throws IOException { - byte[] ttfData = segment.getData(); - int currentPos = 0; - //Version - assertEquals(readInt(new byte[]{ttfData[currentPos++], ttfData[currentPos++]}), 1); - assertEquals(readInt(new byte[]{ttfData[currentPos++], ttfData[currentPos++]}), 0); - //Number of tables - int numTables = readInt(new byte[]{ttfData[currentPos++], ttfData[currentPos++]}); - assertEquals(numTables, 8); - //Search range - assertEquals(readInt(new byte[]{ttfData[currentPos++], ttfData[currentPos++]}), 128); - //Entry Selector - assertEquals(readInt(new byte[]{ttfData[currentPos++], ttfData[currentPos++]}), 3); - //Range shift - assertEquals(readInt(new byte[]{ttfData[currentPos++], ttfData[currentPos++]}), 0); - String[] validTags = {"head", "hhea", "hmtx", "maxp", "gdir"}; - int matches = 0; - for (int i = 0; i < numTables; i++) { - String tag = readTag(new byte[]{ttfData[currentPos++], ttfData[currentPos++], - ttfData[currentPos++], ttfData[currentPos++]}); - if (Arrays.asList(validTags).contains(tag)) { - matches++; - } - if (tag.equals("hmtx")) { - currentPos += 4; - int offset = readLong(new byte[]{ttfData[currentPos++], ttfData[currentPos++], - ttfData[currentPos++], ttfData[currentPos++]}); - int length = readLong(new byte[]{ttfData[currentPos++], ttfData[currentPos++], - ttfData[currentPos++], ttfData[currentPos++]}); - verifyHmtx(ttfData, offset, length, mappedCharsSize); - } else { - currentPos += 12; - } - } - assertEquals(matches, 5); - } - - private void verifyHmtx(byte[] ttfData, int offset, int length, int mappedCharsSize) - throws IOException { - ByteArrayInputStream bais = new ByteArrayInputStream(ttfData); - byte[] subsetHmtx = new byte[length]; - bais.skip(offset); - bais.read(subsetHmtx); - assertEquals(subsetHmtx.length, (mappedCharsSize + 32) * 4); - } - - private int readInt(byte[] bytes) { - return ((0xFF & bytes[0]) << 8) | (0xFF & bytes[1]); - } - - private int readLong(byte[] bytes) { - return ((0xFF & bytes[0]) << 24) | ((0xFF & bytes[1]) << 16) | ((0xFF & bytes[2]) << 8) - | (0xFF & bytes[3]); - } - - private String readTag(byte[] tag) { - return new String(tag); - } -} diff --git a/test/java/org/apache/fop/render/pcl/fonts/truetype/PCLTTFCharacterWriterTestCase.java b/test/java/org/apache/fop/render/pcl/fonts/truetype/PCLTTFCharacterWriterTestCase.java deleted file mode 100644 index 04849db87..000000000 --- a/test/java/org/apache/fop/render/pcl/fonts/truetype/PCLTTFCharacterWriterTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ -package org.apache.fop.render.pcl.fonts.truetype; - -import java.io.File; -import java.io.FileInputStream; - -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.fop.fonts.CustomFont; -import org.apache.fop.fonts.truetype.FontFileReader; -import org.apache.fop.fonts.truetype.OFFontLoader; -import org.apache.fop.fonts.truetype.TTFFile; -import org.apache.fop.render.java2d.CustomFontMetricsMapper; -import org.apache.fop.render.pcl.fonts.PCLByteWriterUtil; -import org.apache.fop.render.pcl.fonts.PCLSoftFont; - -public class PCLTTFCharacterWriterTestCase { - - private PCLTTFCharacterWriter characterWriter; - private PCLSoftFont softFont; - private CustomFontMetricsMapper customFont = mock(CustomFontMetricsMapper.class); - private static final String TEST_FONT_A = "./test/resources/fonts/ttf/DejaVuLGCSerif.ttf"; - - @Test - public void verifyCharacterDefinition() throws Exception { - CustomFont sbFont = mock(CustomFont.class); - when(customFont.getRealFont()).thenReturn(sbFont); - softFont = new PCLSoftFont(1, customFont, false); - TTFFile openFont = new TTFFile(); - FontFileReader reader = new FontFileReader(new FileInputStream(new File(TEST_FONT_A))); - String header = OFFontLoader.readHeader(reader); - openFont.readFont(reader, header); - softFont.setOpenFont(openFont); - softFont.setReader(reader); - - characterWriter = new PCLTTFCharacterWriter(softFont); - byte[] charDefinition = characterWriter.writeCharacterDefinitions("f"); - PCLByteWriterUtil pclByteWriter = new PCLByteWriterUtil(); - // Character command - byte[] command = pclByteWriter.writeCommand(String.format("*c%dE", 32)); - assertArrayEquals(getBytes(charDefinition, 0, 6), command); - // Character definition command - byte[] charDefCommand = pclByteWriter.writeCommand(String.format("(s%dW", 210)); - assertArrayEquals(getBytes(charDefinition, 6, 7), charDefCommand); - } - - private byte[] getBytes(byte[] byteArray, int offset, int length) { - byte[] result = new byte[length]; - int count = 0; - for (int i = offset; i < offset + length; i++) { - result[count++] = byteArray[i]; - } - return result; - } -} diff --git a/test/java/org/apache/fop/render/pdf/BasePDFTest.java b/test/java/org/apache/fop/render/pdf/BasePDFTest.java deleted file mode 100644 index ec536aa32..000000000 --- a/test/java/org/apache/fop/render/pdf/BasePDFTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import org.xml.sax.SAXException; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.output.ByteArrayOutputStream; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopConfParser; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; - -/** - * Base class for automated tests that create PDF files - */ -public class BasePDFTest { - - /** the FopFactory */ - protected final FopFactory fopFactory; - - /** the JAXP TransformerFactory */ - protected final TransformerFactory tFactory = TransformerFactory.newInstance(); - - public BasePDFTest(String fopConf) throws SAXException, IOException { - fopFactory = FopFactory.newInstance(new File(fopConf)); - } - - public BasePDFTest(InputStream confStream) throws SAXException, IOException { - fopFactory = new FopConfParser(confStream, new File(".").toURI()).getFopFactoryBuilder() - .build(); - } - - /** - * Convert a test FO file to PDF - * @param foFile the FO file - * @param ua the preconfigured user agent - * @param dumpPdfFile if true, dumps the generated PDF file to a file name (foFile).pdf - * @return the generated PDF data - * @throws Exception if the conversion fails - */ - protected byte[] convertFO(File foFile, FOUserAgent ua, boolean dumpPdfFile) - throws Exception { - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, ua, baout); - Transformer transformer = tFactory.newTransformer(); - Source src = new StreamSource(foFile); - SAXResult res = new SAXResult(fop.getDefaultHandler()); - try { - transformer.transform(src, res); - final byte[] result = baout.toByteArray(); - if (dumpPdfFile) { - final File outFile = new File(foFile.getParentFile(), foFile.getName() + ".pdf"); - FileUtils.writeByteArrayToFile(outFile, result); - } - return result; - } catch (TransformerException e) { - throw extractOriginalException(e); - } - } - - private static Exception extractOriginalException(Exception e) { - if (e.getCause() != null) { - return extractOriginalException((Exception)e.getCause()); - } else if (e instanceof SAXException) { - SAXException se = (SAXException)e; - if (se.getException() != null) { - return extractOriginalException(se.getException()); - } - } - return e; - } - - /** - * get FOP config File - * @return user config file to be used for testing - */ - protected static String getDefaultConfFile() { - return "test/test.xconf"; - } -} diff --git a/test/java/org/apache/fop/render/pdf/ImageRawPNGAdapterTestCase.java b/test/java/org/apache/fop/render/pdf/ImageRawPNGAdapterTestCase.java deleted file mode 100644 index 9577e2e01..000000000 --- a/test/java/org/apache/fop/render/pdf/ImageRawPNGAdapterTestCase.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import java.awt.color.ColorSpace; -import java.awt.color.ICC_Profile; -import java.awt.image.ComponentColorModel; -import java.awt.image.IndexColorModel; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.xmlgraphics.image.loader.ImageSize; -import org.apache.xmlgraphics.image.loader.impl.ImageRawPNG; -import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil; - -import org.apache.fop.pdf.FlateFilter; -import org.apache.fop.pdf.PDFAMode; -import org.apache.fop.pdf.PDFDictionary; -import org.apache.fop.pdf.PDFDocument; -import org.apache.fop.pdf.PDFICCBasedColorSpace; -import org.apache.fop.pdf.PDFICCStream; -import org.apache.fop.pdf.PDFName; -import org.apache.fop.pdf.PDFProfile; -import org.apache.fop.pdf.PDFResources; -import org.apache.fop.render.RawPNGTestUtil; - -public class ImageRawPNGAdapterTestCase { - - @Test - public void testSetupWithIndexColorModel() { - IndexColorModel cm = mock(IndexColorModel.class); - ImageRawPNG irpng = mock(ImageRawPNG.class); - PDFDocument doc = mock(PDFDocument.class); - PDFProfile profile = mock(PDFProfile.class); - ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock"); - ImageSize is = RawPNGTestUtil.getImageSize(); - - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getRenderingIntent()).thenReturn(-1); - // when(cm.hasAlpha()).thenReturn(false); - when(doc.getProfile()).thenReturn(profile); - when(profile.getPDFAMode()).thenReturn(PDFAMode.PDFA_1A); - when(irpng.getSize()).thenReturn(is); - irpnga.setup(doc); - FlateFilter filter = (FlateFilter) irpnga.getPDFFilter(); - assertEquals(1, filter.getColors()); - } - - @Test - public void testSetupWithComponentColorModel() throws IOException { - ComponentColorModel cm = mock(ComponentColorModel.class); - ImageRawPNG irpng = mock(ImageRawPNG.class); - PDFDocument doc = mock(PDFDocument.class); - PDFProfile profile = mock(PDFProfile.class); - ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock"); - ImageSize is = RawPNGTestUtil.getImageSize(); - - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getRenderingIntent()).thenReturn(-1); - when(cm.getNumComponents()).thenReturn(3); - // when(cm.hasAlpha()).thenReturn(false); - when(doc.getProfile()).thenReturn(profile); - when(profile.getPDFAMode()).thenReturn(PDFAMode.PDFA_1A); - when(irpng.getSize()).thenReturn(is); - irpnga.setup(doc); - FlateFilter filter = (FlateFilter) irpnga.getPDFFilter(); - assertEquals(3, filter.getColors()); - } - - @Test - public void testOutputContentsWithRGBPNG() throws IOException { - testOutputContentsWithGRGBAPNG(-1, 128, 128, 128, -1); - } - - @Test - public void testOutputContentsWithRGBAPNG() throws IOException { - testOutputContentsWithGRGBAPNG(-1, 128, 128, 128, 128); - } - - @Test - public void testOutputContentsWithGPNG() throws IOException { - testOutputContentsWithGRGBAPNG(128, -1, -1, -1, -1); - } - - @Test - public void testOutputContentsWithGAPNG() throws IOException { - testOutputContentsWithGRGBAPNG(128, -1, -1, -1, 128); - } - - private void testOutputContentsWithGRGBAPNG(int gray, int red, int green, int blue, int alpha) - throws IOException { - int numColorComponents = gray > -1 ? 1 : 3; - int numComponents = numColorComponents + (alpha > -1 ? 1 : 0); - ComponentColorModel cm = mock(ComponentColorModel.class); - ImageRawPNG irpng = mock(ImageRawPNG.class); - PDFDocument doc = mock(PDFDocument.class); - PDFProfile profile = mock(PDFProfile.class); - ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock"); - ImageSize is = RawPNGTestUtil.getImageSize(); - - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getRenderingIntent()).thenReturn(-1); - when(cm.getNumComponents()).thenReturn(numComponents); - // when(cm.hasAlpha()).thenReturn(false); - when(doc.getProfile()).thenReturn(profile); - when(profile.getPDFAMode()).thenReturn(PDFAMode.PDFA_1A); - when(irpng.getSize()).thenReturn(is); - irpnga.setup(doc); - FlateFilter filter = (FlateFilter) irpnga.getPDFFilter(); - assertEquals(numColorComponents, filter.getColors()); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] data = RawPNGTestUtil.buildGRGBAData(gray, red, green, blue, alpha); - ByteArrayInputStream bais = new ByteArrayInputStream(data); - when(irpng.createInputStream()).thenReturn(bais); - irpnga.outputContents(baos); - if (alpha > -1) { - byte[] expected = RawPNGTestUtil.buildGRGBAData(gray, red, green, blue, -1); - assertArrayEquals(expected, baos.toByteArray()); - } else { - assertArrayEquals(data, baos.toByteArray()); - } - } - - @Test - public void testPopulateXObjectDictionaryWithComponentColorModelAndsRGB() { - ComponentColorModel cm = mock(ComponentColorModel.class); - ImageRawPNG irpng = mock(ImageRawPNG.class); - PDFDictionary pdfDic = mock(PDFDictionary.class); - ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock"); - - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getRenderingIntent()).thenReturn(0); - irpnga.populateXObjectDictionary(pdfDic); - verify(pdfDic).put("Intent", new PDFName("Perceptual")); - when(irpng.getRenderingIntent()).thenReturn(1); - irpnga.populateXObjectDictionary(pdfDic); - verify(pdfDic).put("Intent", new PDFName("RelativeColorimetric")); - when(irpng.getRenderingIntent()).thenReturn(2); - irpnga.populateXObjectDictionary(pdfDic); - verify(pdfDic).put("Intent", new PDFName("Saturation")); - when(irpng.getRenderingIntent()).thenReturn(3); - irpnga.populateXObjectDictionary(pdfDic); - verify(pdfDic).put("Intent", new PDFName("AbsoluteColorimetric")); - } - - @Test - public void testRenderingIntentImpliessRGBColorProfile() { - ComponentColorModel cm = mock(ComponentColorModel.class); - ImageRawPNG irpng = mock(ImageRawPNG.class); - PDFDocument doc = mock(PDFDocument.class); - PDFProfile profile = mock(PDFProfile.class); - PDFResources resources = mock(PDFResources.class); - PDFICCBasedColorSpace cs = mock(PDFICCBasedColorSpace.class); - PDFICCStream stream = mock(PDFICCStream.class); - ICC_Profile iccprof = ICC_Profile.getInstance(ColorSpace.CS_sRGB); - ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock"); - ImageSize is = RawPNGTestUtil.getImageSize(); - - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getRenderingIntent()).thenReturn(0); - when(cm.getNumComponents()).thenReturn(3); - // when(cm.hasAlpha()).thenReturn(false); - when(doc.getProfile()).thenReturn(profile); - when(doc.getResources()).thenReturn(resources); - when(resources.getICCColorSpaceByProfileName("sRGB")).thenReturn(cs); - when(profile.getPDFAMode()).thenReturn(PDFAMode.PDFA_1A); - when(irpng.getSize()).thenReturn(is); - when(cs.getICCStream()).thenReturn(stream); - when(stream.getICCProfile()).thenReturn(iccprof); - - irpnga.setup(doc); - PDFICCStream iccStream = irpnga.getICCStream(); - assertTrue(ColorProfileUtil.isDefaultsRGB(iccStream.getICCProfile())); - } -} diff --git a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java deleted file mode 100644 index 752d666c5..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -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 org.apache.fop.svg.SVGEventProducer; - -/** - * Tests PDF/A-1 functionality. - */ -public class PDFAConformanceTestCase extends BasePDFTest { - - public PDFAConformanceTestCase() throws SAXException, IOException { - super(getDefaultConfFile()); - } - - private File foBaseDir = new File("test/xml/pdf-a"); - private boolean dumpPDF = Boolean.getBoolean("PDFAConformanceTestCase.dumpPDF"); - - - /** create an FOUserAgent for our tests - * @return an initialized FOUserAgent - * */ - protected FOUserAgent getUserAgent() { - final FOUserAgent userAgent = fopFactory.newFOUserAgent(); - userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); - return userAgent; - } - - /** - * Test exception when PDF/A-1 is enabled and everything is as it should. - * @throws Exception if the test fails - */ - @Test - public void testAllOk() throws Exception { - File foFile = new File(foBaseDir, "minimal-pdf-a.fo"); - convertFO(foFile, getUserAgent(), dumpPDF); - } - - /** - * Test exception when PDF/A-1 is enabled together with encryption. - * @throws Exception if the test fails - */ - @Test(expected = PDFConformanceException.class) - public void testNoEncryption() throws Exception { - final FOUserAgent ua = getUserAgent(); - ua.getRendererOptions().put("owner-password", "mypassword"); //To enabled encryption - File foFile = new File(foBaseDir, "minimal-pdf-a.fo"); - convertFO(foFile, ua, dumpPDF); - } - - /** - * Test exception when PDF/A-1 is enabled and a font is used which is not embedded. - * @throws Exception if the test fails - */ - @Test - public void testFontNotEmbedded() throws Exception { - File foFile = new File(foBaseDir, "base14-font.fo"); - try { - convertFO(foFile, getUserAgent(), dumpPDF); - fail("Expected PDFConformanceException. PDF/A-1 wants all fonts embedded."); - } catch (PDFConformanceException e) { - //Good! - } - } - - /** - * Test exception when PDF/A-1 is enabled and images. - * @throws Exception if the test fails - */ - @Test - public void testImages() throws Exception { - File foFile = new File(foBaseDir, "with-rgb-images.fo"); - convertFO(foFile, getUserAgent(), dumpPDF); - - foFile = new File(foBaseDir, "with-cmyk-images.fo"); - try { - convertFO(foFile, getUserAgent(), dumpPDF); - fail("Expected PDFConformanceException." - + " PDF/A-1 does not allow mixing DeviceRGB and DeviceCMYK."); - } catch (PDFConformanceException e) { - //Good! - } - } - - @Test - public void svgTransparency() throws Exception { - FOUserAgent ua = getUserAgent(); - EventChecker eventChecker = setupEventChecker(ua, "transparencyIgnored"); - File foFile = new File(foBaseDir, "svg-transparency.fo"); - convertFO(foFile, ua, dumpPDF); - eventChecker.end(); - } - - @Test - public void svgContainingBitmapWithTransparency() throws Exception { - FOUserAgent ua = getUserAgent(); - EventChecker eventChecker = setupEventChecker(ua, "bitmapWithTransparency"); - File foFile = new File(foBaseDir, "svg-with-transparent-image.fo"); - convertFO(foFile, ua, dumpPDF); - eventChecker.end(); - } - - private EventChecker setupEventChecker(FOUserAgent ua, String expectedEvent) { - Map<String, Object> params = new HashMap<String, Object>(); - params.put("pdfProfile", PDFAMode.PDFA_1B); - EventChecker eventChecker = new EventChecker(SVGEventProducer.class.getName() - + "." + expectedEvent, params); - ua.getEventBroadcaster().addEventListener(eventChecker); - return eventChecker; - } - -} diff --git a/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java deleted file mode 100644 index 6ff40b3c3..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import java.util.Calendar; -import java.util.TimeZone; - -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; -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.apache.fop.pdf.PDFDocument; -import org.apache.fop.pdf.PDFInfo; -import org.apache.fop.pdf.PDFMetadata; - -/** - * Test case for PDF/A metadata handling. - */ -public class PDFAMetadataTestCase { - - @Test - public void testInfoUpdate() throws Exception { - Metadata meta = new Metadata(); - DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta); - dc.setTitle("MyTitle"); - dc.setDescription(null, "MySubject"); - dc.addCreator("That's me"); - - AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta); - pdf.setKeywords("XSL-FO XML"); - pdf.setProducer("SuperFOP"); - - XMPBasicAdapter xmp = XMPBasicSchema.getAdapter(meta); - xmp.setCreatorTool("WonderFOP"); - Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich")); - cal1.set(2007, Calendar.JUNE, 5, 21, 49, 13); - cal1.set(Calendar.MILLISECOND, 0); - xmp.setCreateDate(cal1.getTime()); - Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich")); - cal2.set(2007, Calendar.JUNE, 6, 8, 15, 59); - cal2.set(Calendar.MILLISECOND, 0); - xmp.setModifyDate(cal2.getTime()); - - PDFInfo info = new PDFInfo(); - assertNull(info.getTitle()); - PDFMetadata.updateInfoFromMetadata(meta, info); - - assertEquals("MyTitle", info.getTitle()); - assertEquals("MySubject", info.getSubject()); - assertEquals("That's me", info.getAuthor()); - assertEquals("XSL-FO XML", info.getKeywords()); - assertEquals("SuperFOP", info.getProducer()); - assertEquals("WonderFOP", info.getCreator()); - assertEquals(cal1.getTime(), info.getCreationDate()); - assertEquals(cal2.getTime(), info.getModDate()); - } - - @Test - public void testXMPUpdate() throws Exception { - PDFDocument doc = new PDFDocument("SuperFOP"); - PDFInfo info = doc.getInfo(); - info.setTitle("MyTitle"); - info.setSubject("MySubject"); - info.setAuthor("That's me"); - info.setKeywords("XSL-FO XML"); - //info.setProducer("SuperFOP"); - info.setCreator("WonderFOP"); - Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich")); - cal1.set(2007, Calendar.JUNE, 5, 21, 49, 13); - cal1.set(Calendar.MILLISECOND, 0); - info.setCreationDate(cal1.getTime()); - Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich")); - cal2.set(2007, Calendar.JUNE, 6, 8, 15, 59); - cal2.set(Calendar.MILLISECOND, 0); - info.setModDate(cal2.getTime()); - - Metadata meta = PDFMetadata.createXMPFromPDFDocument(doc); - - DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta); - assertEquals("MyTitle", dc.getTitle()); - assertEquals("MySubject", dc.getDescription()); - assertEquals(1, dc.getCreators().length); - assertEquals("That's me", dc.getCreators()[0]); - AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta); - assertEquals("XSL-FO XML", pdf.getKeywords()); - assertEquals("SuperFOP", pdf.getProducer()); - XMPBasicAdapter xmp = XMPBasicSchema.getAdapter(meta); - assertEquals("WonderFOP", xmp.getCreatorTool()); - assertEquals(cal1.getTime(), xmp.getCreateDate()); - assertEquals(cal2.getTime(), xmp.getModifyDate()); - } -} diff --git a/test/java/org/apache/fop/render/pdf/PDFBorderPainterTestCase.java b/test/java/org/apache/fop/render/pdf/PDFBorderPainterTestCase.java deleted file mode 100644 index ed8156001..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFBorderPainterTestCase.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -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.fo.Constants; -import org.apache.fop.pdf.PDFDocument; - -public class PDFBorderPainterTestCase { - - private PDFContentGenerator generator; - private ByteArrayOutputStream outStream; - private PDFGraphicsPainter borderPainter; - - @Before - public void setUp() { - outStream = new ByteArrayOutputStream(); - generator = new PDFContentGenerator(new PDFDocument("test"), outStream, null); - borderPainter = new PDFGraphicsPainter(generator); - } - - /** - * This test will fail if either of the below statements isn't true: - * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_SPACE_RATIO = 0.5f - * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_LENGTH_FACTOR = 2.0f. - */ - @Test - public void testDrawBorderLine() throws Exception { - borderPainter.drawBorderLine(0, 0, 40000, 1000, true, true, - Constants.EN_DASHED, Color.BLACK); - generator.flushPDFDoc(); - OutputStream outStream = new ByteArrayOutputStream(); - outStream = generator.getStream().getBufferOutputStream(); - assertTrue(((ByteArrayOutputStream) outStream).toString().contains("[7.272727 3.636364] 0 d 1 w")); - } - - public void tearDown() { - generator = null; - outStream = null; - } -} diff --git a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java b/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java deleted file mode 100644 index bb0f2f92e..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFCMapTestCase.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import java.io.StringWriter; - -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"; - - @Test - public void testPDFCMapFillInPDF() throws Exception { - final String expected - = "%!PS-Adobe-3.0 Resource-CMap" + EOL - + "%%DocumentNeededResources: ProcSet (CIDInit)" + EOL - + "%%IncludeResource: ProcSet (CIDInit)" + EOL - + "%%BeginResource: CMap (test)" + EOL - + "%%EndComments" + EOL - + "/CIDInit /ProcSet findresource begin" + EOL - + "12 dict begin" + EOL - + "begincmap" + EOL - + "/CIDSystemInfo 3 dict dup begin" + EOL - + " /Registry (Adobe) def" + EOL - + " /Ordering (Identity) def" + EOL - + " /Supplement 0 def" + EOL - + "end def" + EOL - + "/CMapVersion 1 def" + EOL - + "/CMapType 1 def" + EOL - + "/CMapName /test def" + EOL - + "1 begincodespacerange" + EOL - + "<0000> <FFFF>" + EOL - + "endcodespacerange" + EOL - + "1 begincidrange" + EOL - + "<0000> <FFFF> 0" + EOL - + "endcidrange" + EOL - + "endcmap" + EOL - + "CMapName currentdict /CMap defineresource pop" + EOL - + "end" + EOL - + "end" + EOL - + "%%EndResource" + EOL - + "%%EOF" + EOL; - - final StringWriter w = new StringWriter(); - final CMapBuilder builder = new CMapBuilder(w, "test"); - builder.writeCMap(); - final String actual = w.getBuffer().toString(); - assertEquals("PDFCMap output matches expected PostScript code", expected, actual); - } - -} diff --git a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java deleted file mode 100644 index fc6212dcd..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import java.io.File; -import java.io.IOException; -import java.util.StringTokenizer; - -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 */ -public class PDFEncodingTestCase extends BasePDFTest { - private File foBaseDir = new File("test/xml/pdf-encoding"); - private final boolean dumpPDF = Boolean.getBoolean("PDFEncodingTestCase.dumpPDF"); - static final String INPUT_FILE = "test/xml/pdf-encoding/pdf-encoding-test.xconf"; - static final String TEST_MARKER = "PDFE_TEST_MARK_"; - - public PDFEncodingTestCase() throws SAXException, IOException { - super(INPUT_FILE); - } - - - /** - * create an FOUserAgent for our tests - * @return an initialized FOUserAgent - */ - protected FOUserAgent getUserAgent() { - final FOUserAgent a = fopFactory.newFOUserAgent(); - return a; - } - - /** - * Test using a standard FOP font - * @throws Exception checkstyle wants a comment here, even a silly one - */ - @Test - public void testPDFEncodingWithStandardFont() throws Exception { - - /* If the PDF encoding is correct, a text dump of the generated PDF file contains this (excerpts) - * ...Tm [(PDFE_TEST_MARK_2:) ( ) (This) ( ) (is) ...(acute:) ( ) (XX_\351_XX) ] TJ - * ...Tm [(PDFE_TEST_MARK_3:) ( ) (This) ( ) (is) ...(letter:) ( ) (XX_\342\352\356\364\373_XX) ] TJ - * The following array is used to look for these patterns - */ - final String[] testPatterns = { - TEST_MARKER + "1", "Standard", - TEST_MARKER + "2", "XX_\\351_XX", - TEST_MARKER + "3", "XX_\\342\\352\\356\\364\\373_XX" - }; - - runTest("test-standard-font.fo", testPatterns); - } - - /** - * TODO test disabled for now, fails due (probably) do different PDF - * encoding when custom font is used. - * TODO This should be tested using PDFBox. If PDFBox can extract the text correctly, - * everything is fine. The tests here are too unstable. - * - * @throws Exception - * checkstyle wants a comment here, even a silly one - */ - @Ignore("This should be tested using PDFBox. If PDFBox can extract the text correctly," - + "everything is fine. The tests here are too unstable.") - @Test - public void testPDFEncodingWithCustomFont() throws Exception { - - /* If the PDF encoding is correct, a text dump of the generated PDF file contains this (excerpts) - * ...Tm [(PDFE_TEST_MARK_2:) ( ) (This) ( ) (is) ...(acute:) ( ) (XX_\351_XX) ] TJ - * ...Tm [(PDFE_TEST_MARK_3:) ( ) (This) ( ) (is) ...(letter:) ( ) (XX_\342\352\356\364\373_XX) ] TJ - * The following array is used to look for these patterns - */ - final String[] testPatterns = { - TEST_MARKER + "1", "(Gladiator)", - TEST_MARKER + "2", "XX_\\351_XX", - TEST_MARKER + "3", "XX_\\342\\352\\356\\364\\373_XX" - }; - - runTest("test-custom-font.fo", testPatterns); - } - - /** Test encoding using specified input file and test patterns array */ - private void runTest(String inputFile, String[] testPatterns) - throws Exception { - File foFile = new File(foBaseDir, inputFile); - byte[] pdfData = convertFO(foFile, getUserAgent(), dumpPDF); - checkEncoding(pdfData, testPatterns); - } - - /** - * Check character encodings in the generated PDF data, by reading text - * lines identified by markers and checking their content - * - * @throws IOException - */ - private void checkEncoding(byte[] pdf, String[] testPattern) - throws IOException { - - int markersFound = 0; - final String input = new String(pdf); - int pos = 0; - if ((pos = input.indexOf(TEST_MARKER)) >= 0) { - final StringTokenizer tk = new StringTokenizer( - input.substring(pos), "\n"); - - while (tk.hasMoreTokens()) { - final String line = tk.nextToken(); - if (line.indexOf(TEST_MARKER) >= 0) { - markersFound++; - for (int i = 0; i < testPattern.length; i += 2) { - if (line.indexOf(testPattern[i]) >= 0) { - final String ref = testPattern[i + 1]; - final boolean patternFound = line.indexOf(ref) >= 0; - assertTrue("line containing '" + testPattern[i] - + "' must contain '" + ref, patternFound); - } - } - } - } - } - - final int nMarkers = testPattern.length / 2; - assertEquals(nMarkers + " " + TEST_MARKER + " markers must be found", - nMarkers, markersFound); - } -} diff --git a/test/java/org/apache/fop/render/pdf/PDFGraphicsPainterTestCase.java b/test/java/org/apache/fop/render/pdf/PDFGraphicsPainterTestCase.java deleted file mode 100644 index 3130a73e7..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFGraphicsPainterTestCase.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; - -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; - - private PDFContentGenerator generator; - - @Before - public void setup() { - generator = mock(PDFContentGenerator.class); - sut = new PDFGraphicsPainter(generator); - } - - @Test - public void moveTo() { - int x = 10; - int y = 20; - sut.moveTo(x, y); - verify(generator).add(op("m", x, y)); - } - - @Test - public void lineTo() { - int x = 10; - int y = 20; - sut.lineTo(x, y); - verify(generator).add(op("l", x, y)); - } - - @Test - public void arcTo() throws IOException { - int width = 10; - int height = 10; - int x = 0; - int y = 0; - double startAngle = 0; - double endAngle = Math.PI / 2; - sut.arcTo(startAngle, endAngle, x, y, width, height); - //TODO stricter verification - verify(generator).add(endsWith(" c ")); - } - - @Test - public void closePath() { - sut.closePath(); - verify(generator).add(op("h")); - } - - @Test - public void clip() { - sut.clip(); - verify(generator).add(opln("W\nn")); - } - - @Test - public void saveGraphicsState() { - sut.saveGraphicsState(); - verify(generator).add(opln("q")); - } - - @Test - public void restoreGraphicsState() { - sut.restoreGraphicsState(); - verify(generator).add(opln("Q")); - } - - @Test - public void rotateCoordinates() throws IOException { - double angle = 0; - float s = (float) Math.sin(angle); - float c = (float) Math.cos(angle); - sut.rotateCoordinates(angle); - testTransformCoordinatesF(c, s, -s, c, 0, 0); - } - - @Test - public void translateCoordinates() throws IOException { - int x = 10; - int y = 20; - sut.translateCoordinates(x, y); - testTransformCoordinates(1000, 0, 0, 1000, x, y); - } - - @Test - public void scaleCoordinates() throws IOException { - float xScaleFactor = 10f; - float yScaleFactor = 2f; - sut.scaleCoordinates(xScaleFactor, yScaleFactor); - testTransformCoordinatesF(xScaleFactor, 0f, 0f, yScaleFactor, 0f, 0f); - } - - @Test - public void cubicBezierTo() { - int[] args = new int[]{1, 2, 3, 4, 5, 6}; - sut.cubicBezierTo(args[0], args[1], args[2], args[3], args[4], args[5]); - verify(generator).add(op("c", args)); - } - - private void testTransformCoordinatesF(float... args) { - verify(generator).add(opf("cm", args)); - } - - private void testTransformCoordinates(int... args) { - verify(generator).add(op("cm", args)); - } - - private String opf(String op, float... args) { - return opf(op, " ", args); - } - - private String op(String op, int... args) { - return op(op, " ", args); - } - - private String opln(String op, int... args) { - return op(op, "\n", args); - } - - private String opf(String op, String ending, float... args) { - StringBuilder sb = new StringBuilder(); - for (float arg : args) { - sb.append("" + PDFNumber.doubleOut(arg) + " "); - } - return sb.append(op.trim()).append(ending).toString(); - } - - private String op(String op, String ending, int... args) { - float[] formattedArgs = new float[args.length]; - for (int i = 0; i < args.length; i++) { - formattedArgs[i] = format(args[i]); - } - return opf(op, ending, formattedArgs); - } - - private float format(int i) { - return (float) i / 1000; - } - -} diff --git a/test/java/org/apache/fop/render/pdf/PDFPainterTestCase.java b/test/java/org/apache/fop/render/pdf/PDFPainterTestCase.java deleted file mode 100644 index d70c00f9e..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFPainterTestCase.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.io.ByteArrayOutputStream; -import java.io.File; - -import javax.xml.transform.stream.StreamResult; - -import org.junit.Test; - -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.apps.FopFactory; -import org.apache.fop.fo.Constants; -import org.apache.fop.pdf.PDFDocument; -import org.apache.fop.pdf.PDFProfile; -import org.apache.fop.pdf.PDFStructElem; -import org.apache.fop.render.RenderingContext; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFException; -import org.apache.fop.traits.BorderProps; - -import junit.framework.Assert; - -public class PDFPainterTestCase { - - private FOUserAgent foUserAgent; - private PDFContentGenerator pdfContentGenerator; - private PDFDocumentHandler pdfDocumentHandler; - private PDFPainter pdfPainter; - private PDFStructElem elem = new PDFStructElem(); - - @Test - public void testDrawBorderRect() throws Exception { - // the goal of this test is to check that the drawing of rounded corners in PDF calls - // PDFGraphicsPaiter.cubicBezierTo(); the check is done by verifying that a " c " command is written - // to the PDFContentGenerator - createPDFPainter(false); - // build rectangle 200 x 50 (points, which are converted to milipoints) - Rectangle rectangle = new Rectangle(0, 0, 200000, 50000); - // build border properties: width 4pt, radius 30pt - BorderProps border = new BorderProps(Constants.EN_SOLID, 4000, 30000, 30000, Color.BLACK, - BorderProps.Mode.SEPARATE); - pdfPainter.drawBorderRect(rectangle, border, border, border, border, Color.WHITE); - // since we cannot mock the PDFContentGenerator.format() static method we have to restrict the - // verification to commands that end with " c ". - verify(pdfContentGenerator, times(16)).add(endsWith(" c ")); - } - - private void createPDFPainter(boolean value) { - mockFOUserAgent(value); - mockPDFContentGenerator(); - mockPDFDocumentHandler(); - PDFLogicalStructureHandler handler = mock(PDFLogicalStructureHandler.class); - pdfPainter = new PDFPainter(pdfDocumentHandler, handler); - } - - private void mockFOUserAgent(boolean value) { - foUserAgent = mock(FOUserAgent.class); - when(foUserAgent.isAccessibilityEnabled()).thenReturn(value); - } - - private void mockPDFContentGenerator() { - pdfContentGenerator = mock(PDFContentGenerator.class); - } - - private void mockPDFDocumentHandler() { - pdfDocumentHandler = mock(PDFDocumentHandler.class); - when(pdfDocumentHandler.getGenerator()).thenReturn(pdfContentGenerator); - IFContext ifContext = mock(IFContext.class); - when(ifContext.getUserAgent()).thenReturn(foUserAgent); - when(pdfDocumentHandler.getContext()).thenReturn(ifContext); - when(ifContext.getStructureTreeElement()).thenReturn(elem); - } - - private PDFDocument createMockPDFDocument() { - PDFDocument pdfDoc = mock(PDFDocument.class); - when(pdfContentGenerator.getDocument()).thenReturn(pdfDoc); - when(pdfDocumentHandler.getPDFDocument()).thenReturn(pdfDoc); - when(pdfDoc.getProfile()).thenReturn(new PDFProfile(pdfDoc)); - return pdfDoc; - } - - @Test - public void testPageNumber() throws IFException { - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - foUserAgent = fopFactory.newFOUserAgent(); - pdfDocumentHandler = new PDFDocumentHandler(new IFContext(foUserAgent)); - pdfDocumentHandler.setResult(new StreamResult(new ByteArrayOutputStream())); - pdfDocumentHandler.startDocument(); - pdfDocumentHandler.startPage(0, "", "", new Dimension()); - pdfDocumentHandler.getContext().setPageNumber(3); - MyPDFPainter pdfPainter = new MyPDFPainter(pdfDocumentHandler, null); - pdfPainter.drawImage("test/resources/images/cmyk.jpg", new Rectangle()); - Assert.assertEquals(pdfPainter.renderingContext.getHints().get("page-number"), 3); - } - - class MyPDFPainter extends PDFPainter { - protected RenderingContext renderingContext; - public MyPDFPainter(PDFDocumentHandler documentHandler, PDFLogicalStructureHandler logicalStructureHandler) { - super(documentHandler, logicalStructureHandler); - } - - protected RenderingContext createRenderingContext() { - renderingContext = super.createRenderingContext(); - return renderingContext; - } - } -} diff --git a/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java deleted file mode 100644 index 4dd3a6610..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -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; -import org.apache.fop.pdf.PDFXMode; -import org.apache.fop.pdf.Version; -import org.apache.fop.render.pdf.PDFRendererConfig.PDFRendererConfigParser; - -public class PDFRendererConfigParserTestCase - extends AbstractRendererConfigParserTester<PDFRendererConfBuilder, PDFRendererConfig> { - - public PDFRendererConfigParserTestCase() { - super(new PDFRendererConfigParser(), PDFRendererConfBuilder.class); - } - - @Test - public void testUserPassword() throws Exception { - String testPassword = "this is a password purely for test purposes"; - parseConfig(createRenderer() - .startEncryptionParams() - .setUserPassword(testPassword) - .endEncryptionParams()); - assertEquals(testPassword, conf.getConfigOptions().getEncryptionParameters().getUserPassword()); - } - - private void testRestrictEncryptionParameter(PDFEncryptionOption option) throws Exception { - parseConfig(createRenderer().startEncryptionParams() - .setAllowParam(option) - .endEncryptionParams()); - assertFalse(testEncryptionParameter(option)); - parseConfig(createRenderer().startEncryptionParams() - .endEncryptionParams()); - assertTrue(testEncryptionParameter(option)); - } - - public boolean testEncryptionParameter(PDFEncryptionOption option) throws Exception { - switch (option) { - case NO_PRINT: - return conf.getConfigOptions().getEncryptionParameters().isAllowPrint(); - case NO_ACCESSCONTENT: - return conf.getConfigOptions().getEncryptionParameters().isAllowAccessContent(); - case NO_ANNOTATIONS: - return conf.getConfigOptions().getEncryptionParameters().isAllowEditAnnotations(); - case NO_ASSEMBLEDOC: - return conf.getConfigOptions().getEncryptionParameters().isAllowAssembleDocument(); - case NO_COPY_CONTENT: - return conf.getConfigOptions().getEncryptionParameters().isAllowCopyContent(); - case NO_EDIT_CONTENT: - return conf.getConfigOptions().getEncryptionParameters().isAllowEditContent(); - case NO_FILLINFORMS: - return conf.getConfigOptions().getEncryptionParameters().isAllowFillInForms(); - case NO_PRINTHQ: - return conf.getConfigOptions().getEncryptionParameters().isAllowPrintHq(); - default: - throw new IllegalStateException("Wrong parameter given"); - } - - } - - @Test - public void testAllEncryptionRestrictions() throws Exception { - testRestrictEncryptionParameter(PDFEncryptionOption.NO_PRINT); - testRestrictEncryptionParameter(PDFEncryptionOption.NO_ACCESSCONTENT); - testRestrictEncryptionParameter(PDFEncryptionOption.NO_ANNOTATIONS); - testRestrictEncryptionParameter(PDFEncryptionOption.NO_ASSEMBLEDOC); - testRestrictEncryptionParameter(PDFEncryptionOption.NO_COPY_CONTENT); - testRestrictEncryptionParameter(PDFEncryptionOption.NO_EDIT_CONTENT); - testRestrictEncryptionParameter(PDFEncryptionOption.NO_FILLINFORMS); - testRestrictEncryptionParameter(PDFEncryptionOption.NO_PRINTHQ); - } - - @Test - public void testOwnerPassword() throws Exception { - String testPassword = "this is a password purely for test purposes"; - parseConfig(createRenderer() - .startEncryptionParams() - .setOwnerPassword(testPassword) - .endEncryptionParams()); - assertEquals(testPassword, conf.getConfigOptions().getEncryptionParameters().getOwnerPassword()); - } - - @Test - public void testFilterListDefaultFlate() throws Exception { - parseConfig(createRenderer().createFilterList(null, "flate")); - assertEquals("flate", conf.getConfigOptions().getFilterMap().get("default").get(0)); - } - - @Test - public void testFilterListDefaultNull() throws Exception { - parseConfig(createRenderer().createFilterList(null, "null")); - assertEquals("null", conf.getConfigOptions().getFilterMap().get("default").get(0)); - } - - @Test - public void testFilterListImage() throws Exception { - parseConfig(createRenderer().createFilterList("image", "flate", "ascii-85")); - assertEquals("flate", conf.getConfigOptions().getFilterMap().get("image").get(0)); - assertEquals("ascii-85", conf.getConfigOptions().getFilterMap().get("image").get(1)); - } - - @Test - public void testPDFAMode() throws Exception { - parseConfig(createRenderer().setPDFAMode(PDFAMode.PDFA_1A.getName())); - assertEquals(PDFAMode.PDFA_1A, conf.getConfigOptions().getPDFAMode()); - - parseConfig(createRenderer().setPDFAMode(PDFAMode.PDFA_1B.getName())); - assertEquals(PDFAMode.PDFA_1B, conf.getConfigOptions().getPDFAMode()); - - parseConfig(createRenderer().setPDFAMode(PDFAMode.DISABLED.getName())); - assertEquals(null, conf.getConfigOptions().getPDFAMode()); - } - - @Test - public void testPDFXMode() throws Exception { - parseConfig(createRenderer().setPDFXMode(PDFXMode.PDFX_3_2003.getName())); - assertEquals(PDFXMode.PDFX_3_2003, conf.getConfigOptions().getPDFXMode()); - - parseConfig(createRenderer().setPDFXMode(PDFXMode.DISABLED.getName())); - assertEquals(null, conf.getConfigOptions().getPDFXMode()); - } - - @Test - public void testEncryptionLength() throws Exception { - for (int i = 0; i <= 40; i++) { - parseConfig(createRenderer() - .startEncryptionParams() - .setEncryptionLength(i) - .endEncryptionParams()); - assertEquals(40, conf.getConfigOptions().getEncryptionParameters().getEncryptionLengthInBits()); - } - - for (int i = 40; i <= 128; i++) { - parseConfig(createRenderer() - .startEncryptionParams() - .setEncryptionLength(i) - .endEncryptionParams()); - int expectedLen = Math.round(i / 8.0f) * 8; - assertEquals(expectedLen, conf.getConfigOptions().getEncryptionParameters() - .getEncryptionLengthInBits()); - } - - for (int i = 128; i < 256; i += 10) { - parseConfig(createRenderer() - .startEncryptionParams() - .setEncryptionLength(i) - .endEncryptionParams()); - assertEquals(128, conf.getConfigOptions().getEncryptionParameters().getEncryptionLengthInBits()); - } - - for (int i = 256; i < 1000; i += 50) { - parseConfig(createRenderer() - .startEncryptionParams() - .setEncryptionLength(i) - .endEncryptionParams()); - assertEquals(256, conf.getConfigOptions().getEncryptionParameters().getEncryptionLengthInBits()); - } - } - - @Test - public void testPDFVersions() throws Exception { - for (int i = 0; i <= 7; i++) { - pdfVersionTester("1." + i); - } - } - - private void pdfVersionTester(String version) throws Exception { - parseConfig(createRenderer().setPDFVersion(version)); - assertEquals(Version.getValueOf(version), conf.getConfigOptions().getPDFVersion()); - } - - @Test(expected = IllegalArgumentException.class) - public void testErroneousPDFVersions18() throws Exception { - pdfVersionTester("1.8"); - } - - @Test(expected = IllegalArgumentException.class) - public void testErroneousPDFVersionsLessThan1() throws Exception { - pdfVersionTester("0.9"); - } - - @Test(expected = IllegalArgumentException.class) - public void testErroneousPDFVersionsNotSet() throws Exception { - pdfVersionTester(""); - } -} diff --git a/test/java/org/apache/fop/render/pdf/PDFRendererOptionsConfigTestCase.java b/test/java/org/apache/fop/render/pdf/PDFRendererOptionsConfigTestCase.java deleted file mode 100644 index 699a8a186..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFRendererOptionsConfigTestCase.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -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; -import org.apache.fop.pdf.Version; - -import static org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE; -import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST; -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; - -public class PDFRendererOptionsConfigTestCase { - - private static final Map<PDFRendererOption, Object> DEFAULT_OPTIONS; - - private static final PDFEncryptionParams DEFAULT_ENCRYPTION_PARAMS = null; - - static { - final EnumMap<PDFRendererOption, Object> props - = new EnumMap<PDFRendererOption, Object>(PDFRendererOption.class); - for (PDFRendererOption option : PDFRendererOption.values()) { - props.put(option, option.getDefaultValue()); - } - DEFAULT_OPTIONS = Collections.unmodifiableMap(props); - } - - @Test - public void testDefaults() { - assertConfigEquals(DEFAULT_OPTIONS, DEFAULT_ENCRYPTION_PARAMS, PDFRendererOptionsConfig.DEFAULT); - } - - @Test - public void testConstructor() throws URISyntaxException { - final Map<PDFRendererOption, Object> options = createNonDefaultOptions(); - final PDFEncryptionParams encryptionParams = new PDFEncryptionParams(); - assertConfigEquals(options, encryptionParams, new PDFRendererOptionsConfig(options, encryptionParams)); - } - - @Test - public void testMerge() throws URISyntaxException { - final PDFRendererOptionsConfig defaults = PDFRendererOptionsConfig.DEFAULT; - final PDFEncryptionParams encryptionParams = new PDFEncryptionParams(); - final Map<PDFRendererOption, Object> options = createNonDefaultOptions(); - final PDFRendererOptionsConfig otherConfig = new PDFRendererOptionsConfig(options, encryptionParams); - assertConfigEquals(options, encryptionParams, defaults.merge(otherConfig)); - assertEquals(defaults, defaults.merge(null)); - } - - private Map<PDFRendererOption, Object> createNonDefaultOptions() throws URISyntaxException { - final EnumMap<PDFRendererOption, Object> options - = new EnumMap<PDFRendererOption, Object>(PDFRendererOption.class); - options.put(DISABLE_SRGB_COLORSPACE, Boolean.TRUE); - options.put(FILTER_LIST, new HashMap<String, List<String>>()); - options.put(OUTPUT_PROFILE, new URI("xxx")); - options.put(PDF_A_MODE, PDFAMode.PDFA_1A); - options.put(PDF_X_MODE, PDFXMode.PDFX_3_2003); - options.put(VERSION, Version.V1_0); - return Collections.unmodifiableMap(options); - } - - private static void assertConfigEquals(Map<PDFRendererOption, Object> expectedOptions, - PDFEncryptionParams expectedEncryptionParams, PDFRendererOptionsConfig actual) { - assertEquals((Boolean) expectedOptions.get(DISABLE_SRGB_COLORSPACE), actual.getDisableSRGBColorSpace()); - assertEquals((Map) expectedOptions.get(FILTER_LIST), actual.getFilterMap()); - assertEquals((URI) expectedOptions.get(OUTPUT_PROFILE), actual.getOutputProfileURI()); - assertEquals((PDFAMode) expectedOptions.get(PDF_A_MODE), actual.getPDFAMode()); - assertEquals((PDFXMode) expectedOptions.get(PDF_X_MODE), actual.getPDFXMode()); - assertEquals((Version) expectedOptions.get(VERSION), actual.getPDFVersion()); - assertEncryptionParamsEquals(expectedEncryptionParams, actual.getEncryptionParameters()); - } - - private static void assertEncryptionParamsEquals(PDFEncryptionParams expected, - PDFEncryptionParams actual) { - assertEquals(expected == null, actual == null); - if (actual != null) { - assertEquals(expected.getEncryptionLengthInBits(), actual.getEncryptionLengthInBits()); - assertEquals(expected.getOwnerPassword(), actual.getOwnerPassword()); - assertEquals(expected.getUserPassword(), actual.getUserPassword()); - assertEquals(expected.isAllowAccessContent(), actual.isAllowAccessContent()); - assertEquals(expected.isAllowAssembleDocument(), actual.isAllowAssembleDocument()); - assertEquals(expected.isAllowCopyContent(), actual.isAllowCopyContent()); - assertEquals(expected.isAllowEditAnnotations(), actual.isAllowEditAnnotations()); - assertEquals(expected.isAllowEditContent(), actual.isAllowEditContent()); - assertEquals(expected.isAllowFillInForms(), actual.isAllowFillInForms()); - assertEquals(expected.isAllowPrint(), actual.isAllowPrint()); - assertEquals(expected.isAllowPrintHq(), actual.isAllowPrintHq()); - } - } - -} diff --git a/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java b/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java deleted file mode 100644 index 965a8e30e..000000000 --- a/test/java/org/apache/fop/render/pdf/PDFsRGBSettingsTestCase.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -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; - -/** - * Tests the disables-srgb-colorspace setting. - */ -public class PDFsRGBSettingsTestCase extends BasePDFTest { - - private File foBaseDir = new File("test/xml/pdf-a"); - - public PDFsRGBSettingsTestCase() throws SAXException, IOException { - super(getDefaultConfFile()); - } - - private FOUserAgent getUserAgent(boolean enablePDFA) { - final FOUserAgent a = fopFactory.newFOUserAgent(); - if (enablePDFA) { - a.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); - } - a.getRendererOptions().put("disable-srgb-colorspace", Boolean.TRUE); - return a; - } - - /** - * Verify that the PDFRenderer complains if PDF/A or PDF/X is used when sRGB is disabled. - * @throws Exception if the test fails - */ - @Test - public void testPDFAWithDisabledSRGB() throws Exception { - File foFile = new File(foBaseDir, "minimal-pdf-a.fo"); - try { - convertFO(foFile, getUserAgent(true), false); - fail("PDFRenderer must fail if PDF/A is active!"); - } catch (IllegalStateException e) { - //exception expected! - } - } - -} diff --git a/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java b/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java deleted file mode 100644 index ab58e9892..000000000 --- a/test/java/org/apache/fop/render/pdf/RenderPDFTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * A test suite for org.apache.fop.render.pdf.* - */ -@RunWith(Suite.class) -@SuiteClasses(PDFRendererConfigParserTestCase.class) -public final class RenderPDFTestSuite { -} diff --git a/test/java/org/apache/fop/render/pdf/extensions/PDFDocumentInformationElementTestCase.java b/test/java/org/apache/fop/render/pdf/extensions/PDFDocumentInformationElementTestCase.java deleted file mode 100644 index 939b5fb11..000000000 --- a/test/java/org/apache/fop/render/pdf/extensions/PDFDocumentInformationElementTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.pdf.extensions; - -import java.io.FileInputStream; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -import org.apache.xmlgraphics.util.QName; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.events.EventChecker; -import org.apache.fop.fo.FODocumentParser; -import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; -import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.fo.FOValidationEventProducer; -import org.apache.fop.fo.LoadingException; -import org.apache.fop.fotreetest.DummyFOEventHandler; - -public class PDFDocumentInformationElementTestCase { - - private FODocumentParser parser = FODocumentParser.newInstance(new FOEventHandlerFactory() { - - public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) { - return new DummyFOEventHandler(foUserAgent); - } - }); - - @Test(expected = LoadingException.class) - public void illegalChild() throws Exception { - Map<String, Object> expectedParams = new HashMap<String, Object>(); - expectedParams.put("offendingNode", new QName(PDFElementMapping.NAMESPACE, "dictionary")); - runTest("invalid-child.fo", FOValidationEventProducer.class.getName() + ".invalidChild", expectedParams); - } - - @Test - public void standardKeyword() throws Exception { - Map<String, Object> expectedParams = new HashMap<String, Object>(); - expectedParams.put("keyword", "Creator"); - runTest("reserved-keyword.fo", PDFExtensionEventProducer.class.getName() + ".reservedKeyword", expectedParams); - } - - private void runTest(String testCase, String expectedEventKey, Map<String, Object> expectedEventParams) - throws Exception { - EventChecker eventChecker = new EventChecker(expectedEventKey, expectedEventParams); - parser.setEventListener(eventChecker); - try { - parser.parse(new FileInputStream("test/pdf/extensions/document-information/" + testCase)); - } finally { - eventChecker.end(); - } - } -} diff --git a/test/java/org/apache/fop/render/ps/AbstractPostScriptTest.java b/test/java/org/apache/fop/render/ps/AbstractPostScriptTest.java deleted file mode 100644 index eb25c3f94..000000000 --- a/test/java/org/apache/fop/render/ps/AbstractPostScriptTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps; - -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; -import org.apache.xmlgraphics.ps.dsc.events.AbstractResourceDSCComment; -import org.apache.xmlgraphics.ps.dsc.events.DSCComment; -import org.apache.xmlgraphics.ps.dsc.events.DSCEvent; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.AbstractRenderingTest; - -/** - * Abstract base class for PostScript verification tests. - */ -public abstract class AbstractPostScriptTest extends AbstractRenderingTest { - - /** - * Renders a test file. - * @param ua the user agent (with override set!) - * @param resourceName the resource name for the FO file - * @param suffix a suffix for the output filename - * @return the output file - * @throws Exception if an error occurs - */ - protected File renderFile(FOUserAgent ua, String resourceName, String suffix) - throws Exception { - return renderFile(ua, resourceName, suffix, MimeConstants.MIME_POSTSCRIPT); - } - - /** - * Scans for a certain resource DSC comment and checks against a given resource. - * @param parser the DSC parser - * @param comment the comment to scan for - * @param resource the resource to check against - * @throws IOException if an I/O error occurs - * @throws DSCException if a DSC error occurs - */ - protected void checkResourceComment(DSCParser parser, String comment, PSResource resource) - throws IOException, DSCException { - AbstractResourceDSCComment resComment; - resComment = (AbstractResourceDSCComment)gotoDSCComment(parser, comment); - assertEquals(resource, resComment.getResource()); - } - - /** - * Advances the DSC parser to a DSC comment with the given name. - * @param parser the DSC parser - * @param name the name of the DSC comment - * @return the DSC comment - * @throws IOException if an I/O error occurs - * @throws DSCException if a DSC error occurs - */ - protected static DSCComment gotoDSCComment(DSCParser parser, String name) - throws IOException, DSCException { - while (parser.hasNext()) { - DSCEvent event = parser.nextEvent(); - if (event.isDSCComment()) { - DSCComment comment = event.asDSCComment(); - if (comment.getName().equals(name)) { - return comment; - } - } - } - return null; - } - -} diff --git a/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java b/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java deleted file mode 100644 index 53654d76a..000000000 --- a/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps; - -import java.awt.image.ComponentColorModel; -import java.awt.image.IndexColorModel; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Test; - -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 - public void testWriteToWithRGBPNG() throws IOException { - testWriteToWithGRGBAPNG(-1, 128, 128, 128, -1); - } - - @Test - public void testWriteToWithGPNG() throws IOException { - testWriteToWithGRGBAPNG(128, -1, -1, -1, -1); - } - - @Test - public void testWriteToWithRGBAPNG() throws IOException { - testWriteToWithGRGBAPNG(-1, 128, 128, 128, 128); - } - - @Test - public void testWriteToWithGAPNG() throws IOException { - testWriteToWithGRGBAPNG(128, -1, -1, -1, 128); - } - - private void testWriteToWithGRGBAPNG(int gray, int red, int green, int blue, int alpha) - throws IOException { - int numComponents = (gray > -1 ? 1 : 3) + (alpha > -1 ? 1 : 0); - ImageSize is = RawPNGTestUtil.getImageSize(); - ComponentColorModel cm = mock(ComponentColorModel.class); - when(cm.getNumComponents()).thenReturn(numComponents); - ImageRawPNG irpng = mock(ImageRawPNG.class); - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getSize()).thenReturn(is); - ImageEncoderPNG iepng = new ImageEncoderPNG(irpng); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] data = RawPNGTestUtil.buildGRGBAData(gray, red, green, blue, alpha); - ByteArrayInputStream bais = new ByteArrayInputStream(data); - when(irpng.createInputStream()).thenReturn(bais); - iepng.writeTo(baos); - if (alpha > -1) { - byte[] expected = RawPNGTestUtil.buildGRGBAData(gray, red, green, blue, -1); - assertArrayEquals(expected, baos.toByteArray()); - } else { - assertArrayEquals(data, baos.toByteArray()); - } - } - - @Test - public void testWriteToWithPalettePNG() throws IOException { - ImageSize is = RawPNGTestUtil.getImageSize(); - IndexColorModel cm = mock(IndexColorModel.class); - ImageRawPNG irpng = mock(ImageRawPNG.class); - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getSize()).thenReturn(is); - ImageEncoderPNG iepng = new ImageEncoderPNG(irpng); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] data = RawPNGTestUtil.buildGRGBAData(128, -1, -1, -1, -1); - ByteArrayInputStream bais = new ByteArrayInputStream(data); - when(irpng.createInputStream()).thenReturn(bais); - iepng.writeTo(baos); - assertArrayEquals(data, baos.toByteArray()); - } - - @Test - public void testGetImplicitFilterWithIndexColorModel() { - ImageSize is = RawPNGTestUtil.getImageSize(); - IndexColorModel cm = mock(IndexColorModel.class); - ImageRawPNG irpng = mock(ImageRawPNG.class); - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getBitDepth()).thenReturn(8); - when(irpng.getSize()).thenReturn(is); - ImageEncoderPNG iepng = new ImageEncoderPNG(irpng); - - String expectedFilter = "<< /Predictor 15 /Columns 32 /Colors 1 /BitsPerComponent 8 >> /FlateDecode"; - assertEquals(expectedFilter, iepng.getImplicitFilter()); - } - - @Test - public void testGetImplicitFilterWithComponentColorModel() { - ImageSize is = RawPNGTestUtil.getImageSize(); - ComponentColorModel cm = mock(ComponentColorModel.class); - when(cm.getNumComponents()).thenReturn(3); - ImageRawPNG irpng = mock(ImageRawPNG.class); - when(irpng.getColorModel()).thenReturn(cm); - when(irpng.getBitDepth()).thenReturn(8); - when(irpng.getSize()).thenReturn(is); - ImageEncoderPNG iepng = new ImageEncoderPNG(irpng); - - String expectedFilter = "<< /Predictor 15 /Columns 32 /Colors 3 /BitsPerComponent 8 >> /FlateDecode"; - assertEquals(expectedFilter, iepng.getImplicitFilter()); - } - -} diff --git a/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java b/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java deleted file mode 100644 index 3c05e9ad7..000000000 --- a/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps; - -import java.awt.Rectangle; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -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.batik.anim.dom.SAXSVGDocumentFactory; - -import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; -import org.apache.xmlgraphics.ps.DSCConstants; -import org.apache.xmlgraphics.ps.PSGenerator; -import org.apache.xmlgraphics.ps.PSResource; -import org.apache.xmlgraphics.ps.dsc.DSCException; -import org.apache.xmlgraphics.ps.dsc.DSCParser; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPage; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPages; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentTitle; -import org.apache.xmlgraphics.ps.dsc.events.DSCEvent; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.render.intermediate.IFContext; - -/** - * Tests the image handling in PostScript output. - */ -public class ImageHandlingTestCase extends AbstractPostScriptTest { - - /** - * Tests JPEG handling. - * @throws Exception if an error occurs - */ - @Test - public void testJPEGImageLevel3() throws Exception { - innerTestJPEGImage(3); - } - - /** - * Tests JPEG handling. - * @throws Exception if an error occurs - */ - @Test - public void testJPEGImageLevel2() throws Exception { - innerTestJPEGImage(2); - } - - private void innerTestJPEGImage(int level) throws Exception { - FOUserAgent ua = fopFactory.newFOUserAgent(); - PSDocumentHandler handler = new PSDocumentHandler(new IFContext(ua)); - PSRenderingUtil psUtil = handler.getPSUtil(); - psUtil.setLanguageLevel(level); - psUtil.setOptimizeResources(true); - ua.setDocumentHandlerOverride(handler); - - // Prepare output file - File outputFile = renderFile(ua, "ps-jpeg-image.fo", - "-if-l" + psUtil.getLanguageLevel()); - verifyPostScriptFile(outputFile, psUtil.getLanguageLevel()); - } - - private void verifyPostScriptFile(File psFile, int level) - throws IOException, DSCException { - InputStream in = new java.io.FileInputStream(psFile); - in = new java.io.BufferedInputStream(in); - try { - DSCParser parser = new DSCParser(in); - - DSCCommentPages pages = (DSCCommentPages)gotoDSCComment(parser, DSCConstants.PAGES); - assertEquals(1, pages.getPageCount()); - - //Skip procsets and encoding - gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE); - gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE); - gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE); - gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE); - - PSResource form2 = new PSResource(PSResource.TYPE_FORM, "FOPForm:2"); - checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form2); - DSCCommentTitle title = (DSCCommentTitle)parser.nextEvent().asDSCComment(); - assertEquals("image/jpeg test/resources/images/bgimg300dpi.jpg", title.getTitle()); - - String resourceContent = getResourceContent(parser); - - if (level == 3) { - assertContains(resourceContent, "/FOPForm:2"); - assertContains(resourceContent, "/DCTDecode filter"); - assertContains(resourceContent, "/ReusableStreamDecode filter"); - } else { - assertContains(resourceContent, "/FOPForm:2"); - assertContains(resourceContent, "/DCTDecode filter"); - assertAbsent(resourceContent, "/ReusableStreamDecode filter"); - } - - //---=== Page 1 ===--- - DSCCommentPage page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE); - assertEquals(1, page.getPagePosition()); - - PSResource form1 = new PSResource(PSResource.TYPE_FORM, "FOPForm:1"); - checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form1); - title = (DSCCommentTitle)parser.nextEvent().asDSCComment(); - assertEquals("image/jpeg test/resources/images/bgimg72dpi.jpg", title.getTitle()); - resourceContent = getResourceContent(parser); - - if (level == 3) { - assertContains(resourceContent, "/FOPForm:1"); - assertContains(resourceContent, "/DCTDecode filter"); - assertContains(resourceContent, "/ReusableStreamDecode filter"); - } else { - assertContains(resourceContent, "/FOPForm:1"); - assertContains(resourceContent, "/DCTDecode filter"); - assertAbsent(resourceContent, "/ReusableStreamDecode filter"); - } - - } finally { - IOUtils.closeQuietly(in); - } - } - - private void assertContains(String text, String searchString) { - assertTrue("Text doesn't contain '" + searchString + "'", text.indexOf(searchString) >= 0); - } - - private void assertAbsent(String text, String searchString) { - assertTrue("Text contains '" + searchString + "'", text.indexOf(searchString) < 0); - } - - private String getResourceContent(DSCParser parser) throws IOException, DSCException { - StringBuffer sb = new StringBuffer(); - while (parser.hasNext()) { - DSCEvent event = parser.nextEvent(); - if (event.isLine()) { - sb.append(event.asLine().getLine()).append('\n'); - } else if (event.isDSCComment()) { - if (DSCConstants.END_RESOURCE.equals(event.asDSCComment().getName())) { - break; - } - } - } - return sb.toString(); - } - - @Test - public void testPSImageHandlerSVG() throws IOException { - FOUserAgent ua = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); - String svg = "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\" " - + "width=\"210mm\" height=\"297mm\" font-size=\"20\" stroke-width=\"0.1mm\" font-family=\"Arial\">\n" - + " <filter id=\"drop-shadow-font\" width=\"150%\" height=\"150%\">\n" - + " <feGaussianBlur in=\"SourceAlpha\" result=\"blur\" stdDeviation=\"1\"/>\n" - + " <feOffset in=\"blur\" result=\"offsetBlur\" dy=\"1\" dx=\"1\"/>\n" - + " <feBlend in=\"SourceGraphic\" in2=\"offsetBlur\" mode=\"normal\"/>\n" - + " </filter>\n" - + " <text x=\"4.9mm\" filter=\"url(#drop-shadow-font)\" y=\"10.5mm\" fill=\"black\" " - + "rotate=\"30 30 0 15\">Hello SVG with FOP</text>\n" - + "</svg>"; - SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(null); - Document doc = factory.createDocument(null, IOUtils.toInputStream(svg)); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - new PSImageHandlerSVG().handleImage( - new PSRenderingContext(ua, new PSGenerator(bos), new FontInfo()), - new ImageXMLDOM(null, doc, ""), - new Rectangle()); - assertTrue(bos.toString().contains("/DataSource Data")); - } -} diff --git a/test/java/org/apache/fop/render/ps/PSBorderPainterTestCase.java b/test/java/org/apache/fop/render/ps/PSBorderPainterTestCase.java deleted file mode 100644 index 602431231..000000000 --- a/test/java/org/apache/fop/render/ps/PSBorderPainterTestCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps; - -import java.awt.Color; -import java.io.ByteArrayOutputStream; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -import org.apache.xmlgraphics.ps.PSGenerator; - -import org.apache.fop.fo.Constants; - -public class PSBorderPainterTestCase { - - private PSGenerator generator; - private ByteArrayOutputStream outStream; - private PSGraphicsPainter borderPainter; - - @Before - public void setUp() { - outStream = new ByteArrayOutputStream(); - generator = new PSGenerator(outStream); - borderPainter = new PSGraphicsPainter(generator); - } - - /** - * This test will fail if either of the below statements isn't true: - * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_SPACE_RATIO = 0.5f:q - * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_LENGTH_FACTOR = 4.0f. - */ - @Test - public void testDrawBorderLine() throws Exception { - borderPainter.drawBorderLine(0, 0, 40000, 1000, true, true, - Constants.EN_DASHED, Color.BLACK); - assertTrue(outStream.toString().contains("[7.2727275 3.6363637] 0 setdash")); - } - - public void tearDown() { - generator = null; - outStream = null; - } -} diff --git a/test/java/org/apache/fop/render/ps/PSPainterTestCase.java b/test/java/org/apache/fop/render/ps/PSPainterTestCase.java deleted file mode 100644 index 3efbb47d4..000000000 --- a/test/java/org/apache/fop/render/ps/PSPainterTestCase.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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. - */ -package org.apache.fop.render.ps; - -import java.awt.Color; -import java.awt.Rectangle; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.transform.stream.StreamResult; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.verification.VerificationMode; - -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.apache.xmlgraphics.ps.PSGenerator; -import org.apache.xmlgraphics.ps.dsc.ResourceTracker; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.fo.Constants; -import org.apache.fop.fonts.EmbeddingMode; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontTriplet; -import org.apache.fop.fonts.MultiByteFont; -import org.apache.fop.fonts.Typeface; -import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFException; -import org.apache.fop.render.intermediate.IFState; -import org.apache.fop.traits.BorderProps; - -public class PSPainterTestCase { - - private PSDocumentHandler docHandler; - private PSPainter psPainter; - private PSGenerator gen; - private IFState state; - - @Before - public void setup() { - state = IFState.create(); - FOUserAgent userAgent = mock(FOUserAgent.class); - when(userAgent.getRendererOptions()).thenReturn(Collections.EMPTY_MAP); - IFContext context = mock(IFContext.class); - when(context.getUserAgent()).thenReturn(userAgent); - docHandler = new PSDocumentHandler(context); - gen = mock(PSGenerator.class); - docHandler.gen = gen; - state = IFState.create(); - psPainter = new PSPainter(docHandler, state); - } - - @Test - public void testNonZeroFontSize() throws IOException { - testFontSize(6, times(1)); - } - - @Test - public void testZeroFontSize() throws IOException { - testFontSize(0, never()); - } - - private void testFontSize(int fontSize, VerificationMode test) throws IOException { - state.setFontSize(fontSize); - try { - psPainter.drawText(10, 10, 2, 2, null, "Test"); - } catch (Exception ex) { - //Expected - } - verify(gen, test).useColor(state.getTextColor()); - } - - @Test - public void testDrawBorderRect() { - // the goal of this test is to check that the drawing of rounded corners in PS calls - // PSGraphicsPaiter.cubicBezierTo(); the check is done by verifying that a curveto command is written - // to the PSGenerator - PSGenerator psGenerator = mock(PSGenerator.class); - when(psGenerator.formatDouble(anyFloat())).thenReturn("20.0"); // simplify! - PSRenderingUtil psRenderingUtil = mock(PSRenderingUtil.class); - PSDocumentHandler psDocumentHandler = mock(PSDocumentHandler.class); - when(psDocumentHandler.getGenerator()).thenReturn(psGenerator); - when(psDocumentHandler.getPSUtil()).thenReturn(psRenderingUtil); - PSPainter psPainter = new PSPainter(psDocumentHandler); - // build rectangle 200 x 50 (points, which are converted to milipoints) - Rectangle rectangle = new Rectangle(0, 0, 200000, 50000); - // build border properties: width 4pt, radius 30pt - BorderProps border = new BorderProps(Constants.EN_SOLID, 4000, 30000, 30000, Color.BLACK, - BorderProps.Mode.SEPARATE); - try { - psPainter.drawBorderRect(rectangle, border, border, border, border, Color.WHITE); - verify(psGenerator, times(16)).writeln("20.0 20.0 20.0 20.0 20.0 20.0 curveto "); - } catch (Exception e) { - fail("something broke..."); - } - } - - @Test - public void testDrawText() { - int fontSize = 12000; - String fontName = "MockFont"; - PSGenerator psGenerator = mock(PSGenerator.class); - PSRenderingUtil psRenderingUtil = mock(PSRenderingUtil.class); - PSDocumentHandler psDocumentHandler = mock(PSDocumentHandler.class); - FontInfo fontInfo = mock(FontInfo.class); - PSFontResource psFontResource = mock(PSFontResource.class); - MultiByteFont multiByteFont = mock(MultiByteFont.class); - Font font = mock(Font.class); - when(psDocumentHandler.getGenerator()).thenReturn(psGenerator); - when(psDocumentHandler.getPSUtil()).thenReturn(psRenderingUtil); - when(psDocumentHandler.getFontInfo()).thenReturn(fontInfo); - when(psDocumentHandler.getPSResourceForFontKey(fontName)).thenReturn(psFontResource); - when(fontInfo.getInternalFontKey(any(FontTriplet.class))).thenReturn(fontName); - when(fontInfo.getFontInstance(any(FontTriplet.class), anyInt())).thenReturn(font); - Map<String, Typeface> fonts = new HashMap<String, Typeface>(); - fonts.put(fontName, multiByteFont); - when(fontInfo.getFonts()).thenReturn(fonts); - - IFState ifState = IFState.create(); - ifState.setFontSize(fontSize); - - PSPainter psPainter = new PSPainter(psDocumentHandler, ifState); - - int x = 100000; - int y = 100000; - int letterSpacing = 0; - int wordSpacing = 0; - 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); - verify(psGenerator).writeln("1 0 0 -1 100.100 99.900 Tm"); - verify(psGenerator).writeln("[<0000> [-100 100] <00000000> [200 -200] <0000> [-300 300] " - + "<0000000000000000000000000000>] TJ"); - } catch (Exception e) { - fail("something broke..."); - } - } - - @Test - public void testOTF() throws IFException, IOException { - FOUserAgent ua = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); - final IFState state = IFState.create(); - PSDocumentHandler dh = new PSDocumentHandler(new IFContext(ua)) { - protected PSFontResource getPSResourceForFontKey(String key) { - return new PSFontResource() { - String getName() { - return state.getFontFamily(); - } - void notifyResourceUsageOnPage(ResourceTracker resourceTracker) { - } - }; - } - }; - FontInfo fi = new FontInfo(); - addFont(fi, "OTFFont", true); - addFont(fi, "TTFFont", false); - - dh.setFontInfo(fi); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - dh.setResult(new StreamResult(bos)); - dh.startDocument(); - state.setFontSize(10); - state.setTextColor(Color.BLACK); - state.setFontStyle(""); - PSPainter p = new PSPainter(dh, state) { - protected String getFontKey(FontTriplet triplet) throws IFException { - return state.getFontFamily(); - } - }; - - state.setFontFamily("TTFFont"); - p.drawText(0, 0, 0, 0, null, "test1"); - - state.setFontFamily("OTFFont"); - p.drawText(0, 0, 0, 0, null, "test2"); - p.drawText(0, 0, 0, 0, null, "test3"); - - state.setFontFamily("TTFFont"); - p.drawText(0, 0, 0, 0, null, "test4"); - - Assert.assertTrue(bos.toString(), bos.toString().endsWith("BT\n" - + "/TTFFont 0.01 F\n" - + "1 0 0 -1 0 0 Tm\n" - + "<00000000000000000000> t\n" - + "/OTFFont.0 0.01 F\n" - + "1 0 0 -1 0 0 Tm\n" - + "<FFFFFFFFFF> t\n" - + "/OTFFont.0 0.01 F\n" - + "1 0 0 -1 0 0 Tm\n" - + "<FFFFFFFFFF> t\n" - + "/TTFFont 0.01 F\n" - + "1 0 0 -1 0 0 Tm\n" - + "<00000000000000000000> t\n")); - } - - private void addFont(FontInfo fi, String name, boolean otf) { - fi.addFontProperties(name, name, "", 0); - MultiByteFont mbf = new MultiByteFont(null, EmbeddingMode.AUTO); - mbf.setWidthArray(new int[100]); - mbf.setIsOTFFile(otf); - fi.addMetrics(name, mbf); - } -} diff --git a/test/java/org/apache/fop/render/ps/PSRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/ps/PSRendererConfigParserTestCase.java deleted file mode 100644 index 45642764c..000000000 --- a/test/java/org/apache/fop/render/ps/PSRendererConfigParserTestCase.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.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; - -public class PSRendererConfigParserTestCase - extends AbstractRendererConfigParserTester<PSRendererConfBuilder, PSRendererConfig> { - - public PSRendererConfigParserTestCase() { - super(new PSRendererConfigParser(), PSRendererConfBuilder.class); - } - - @Test - public void testAutoRotateLandscape() throws Exception { - boolean defaultVal = false; - boolean configuredVal = !defaultVal; - parseConfig(createRenderer()); - assertEquals(defaultVal, conf.isAutoRotateLandscape()); - parseConfig(createRenderer().setAutoRotateLandscape(configuredVal)); - assertEquals(configuredVal, conf.isAutoRotateLandscape()); - } - - @Test - public void testSafeSetPageDevice() throws Exception { - boolean defaultVal = false; - boolean configuredVal = !defaultVal; - parseConfig(createRenderer()); - assertEquals(defaultVal, conf.isSafeSetPageDevice()); - parseConfig(createRenderer().setSafeSetPageDevice(configuredVal)); - assertEquals(configuredVal, conf.isSafeSetPageDevice()); - } - - @Test - public void testDscCompliant() throws Exception { - boolean defaultVal = true; - boolean configuredVal = !defaultVal; - parseConfig(createRenderer()); - assertEquals(defaultVal, conf.isDscComplianceEnabled()); - parseConfig(createRenderer().setDscCompliant(configuredVal)); - assertEquals(configuredVal, conf.isDscComplianceEnabled()); - } - - @Test - public void testLanguageLevel() throws Exception { - Integer defaultVal = PSGenerator.DEFAULT_LANGUAGE_LEVEL; - Integer configuredVal = defaultVal + 1; - parseConfig(createRenderer()); - assertEquals(defaultVal, conf.getLanguageLevel()); - parseConfig(createRenderer().setLanguageLevel(configuredVal)); - assertEquals(configuredVal, conf.getLanguageLevel()); - } - - @Test - public void testOptimizeResources() throws Exception { - boolean defaultVal = false; - boolean configuredVal = !defaultVal; - parseConfig(createRenderer()); - assertEquals(defaultVal, conf.isOptimizeResources()); - parseConfig(createRenderer().setOptimizeResources(configuredVal)); - assertEquals(configuredVal, conf.isOptimizeResources()); - } -} diff --git a/test/java/org/apache/fop/render/ps/PSRendererConfiguratorTestCase.java b/test/java/org/apache/fop/render/ps/PSRendererConfiguratorTestCase.java deleted file mode 100644 index 67ba24763..000000000 --- a/test/java/org/apache/fop/render/ps/PSRendererConfiguratorTestCase.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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. - */ - -package org.apache.fop.render.ps; - -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.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; - - public PSRendererConfiguratorTestCase() { - super(MimeConstants.MIME_POSTSCRIPT, PSRendererConfBuilder.class, PSDocumentHandler.class); - } - - @Override - public PSRendererConfigurator createConfigurator() { - return new PSRendererConfigurator(userAgent, new PSRendererConfigParser()); - } - - @Override - public void setUpDocumentHandler() { - psUtil = new PSRenderingUtil(userAgent); - when(((PSDocumentHandler) docHandler).getPSUtil()).thenReturn(psUtil); - } - - @Test - public void testAutoRotateLandscape() throws Exception { - parseConfig(createBuilder().setAutoRotateLandscape(true)); - assertTrue(psUtil.isAutoRotateLandscape()); - - parseConfig(createBuilder().setAutoRotateLandscape(false)); - assertFalse(psUtil.isAutoRotateLandscape()); - - parseConfig(createBuilder()); - assertFalse(psUtil.isAutoRotateLandscape()); - } - - @Test - public void testLanguageLevel() throws Exception { - parseConfig(createBuilder().setLanguageLevel(2)); - assertEquals(2, psUtil.getLanguageLevel()); - - parseConfig(createBuilder().setLanguageLevel(3)); - assertEquals(3, psUtil.getLanguageLevel()); - } - - @Test(expected = IllegalArgumentException.class) - public void testLanguageLevelTestCase() throws Exception { - parseConfig(createBuilder().setLanguageLevel(1)); - assertEquals(1, psUtil.getLanguageLevel()); - } - - @Test - public void testOptimizeResources() throws Exception { - parseConfig(createBuilder().setOptimizeResources(true)); - assertTrue(psUtil.isOptimizeResources()); - - parseConfig(createBuilder().setOptimizeResources(false)); - assertFalse(psUtil.isOptimizeResources()); - - parseConfig(createBuilder()); - assertFalse(psUtil.isOptimizeResources()); - } - - @Test - public void testSafeSetPageDevice() throws Exception { - parseConfig(createBuilder().setSafeSetPageDevice(true)); - assertTrue(psUtil.isSafeSetPageDevice()); - - parseConfig(createBuilder().setSafeSetPageDevice(false)); - assertFalse(psUtil.isSafeSetPageDevice()); - - parseConfig(createBuilder()); - assertFalse(psUtil.isSafeSetPageDevice()); - } - - @Test - public void testDscComplianceEnabled() throws Exception { - parseConfig(createBuilder().setDscCompliant(true)); - assertTrue(psUtil.isDSCComplianceEnabled()); - - parseConfig(createBuilder().setDscCompliant(false)); - assertFalse(psUtil.isDSCComplianceEnabled()); - - parseConfig(createBuilder()); - assertTrue(psUtil.isDSCComplianceEnabled()); - } -} diff --git a/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java b/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java deleted file mode 100644 index 0a2c895be..000000000 --- a/test/java/org/apache/fop/render/ps/PSRenderingUtilTestCase.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps; - -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; - -public class PSRenderingUtilTestCase { - - private final String content = "<< /MyEntry 0 >> command"; - private final PSPageTrailerCodeBefore ptcb = new PSPageTrailerCodeBefore(content); - private final PSGenerator gen = mock(PSGenerator.class); - - @Test - public void testWriteEnclosedExtensionAttachment() throws IOException { - PSRenderingUtil.writeEnclosedExtensionAttachment(gen, ptcb); - verify(gen).writeln(content); - } - -} diff --git a/test/java/org/apache/fop/render/ps/PSTestSuite.java b/test/java/org/apache/fop/render/ps/PSTestSuite.java deleted file mode 100644 index cf66d4776..000000000 --- a/test/java/org/apache/fop/render/ps/PSTestSuite.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for FOP's PostScript output. - */ -@RunWith(Suite.class) -@SuiteClasses({ - ImageHandlingTestCase.class, - ResourceOptimizationTestCase.class -}) -public class PSTestSuite { -} diff --git a/test/java/org/apache/fop/render/ps/RenderPSTestSuite.java b/test/java/org/apache/fop/render/ps/RenderPSTestSuite.java deleted file mode 100644 index 2e15bf91f..000000000 --- a/test/java/org/apache/fop/render/ps/RenderPSTestSuite.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.apache.fop.render.ps.fonts.PSTTFGeneratorTestCase; -import org.apache.fop.render.ps.fonts.PSTTFGlyphOutputStreamTestCase; -import org.apache.fop.render.ps.fonts.PSTTFOutputStreamTestCase; -import org.apache.fop.render.ps.fonts.PSTTFTableOutputStreamTestCase; - - -/** - * A test Suite for org.apache.fop.render.ps.* - */ -@RunWith(Suite.class) -@SuiteClasses({ - PSTTFGeneratorTestCase.class, - PSTTFOutputStreamTestCase.class, - PSTTFGlyphOutputStreamTestCase.class, - PSTTFTableOutputStreamTestCase.class -}) -public final class RenderPSTestSuite { -} diff --git a/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java b/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java deleted file mode 100644 index 8a548b1b5..000000000 --- a/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.Collection; -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; -import org.apache.xmlgraphics.ps.PSResource; -import org.apache.xmlgraphics.ps.dsc.DSCException; -import org.apache.xmlgraphics.ps.dsc.DSCListener; -import org.apache.xmlgraphics.ps.dsc.DSCParser; -import org.apache.xmlgraphics.ps.dsc.DefaultNestedDocumentHandler; -import org.apache.xmlgraphics.ps.dsc.events.AbstractResourcesDSCComment; -import org.apache.xmlgraphics.ps.dsc.events.DSCAtend; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBeginDocument; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentDocumentNeededResources; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentDocumentSuppliedResources; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentEndOfFile; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentIncludeResource; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPage; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPages; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.render.intermediate.IFContext; - -/** - * Tests the PostScript resource optimization (selective de-duplication of - * images that are used multiple times). - */ -public class ResourceOptimizationTestCase extends AbstractPostScriptTest { - - /** - * Tests resource optimization. - * @throws Exception if an error occurs - */ - @Test - public void testResourceOptimization() throws Exception { - FOUserAgent ua = fopFactory.newFOUserAgent(); - PSDocumentHandler handler = new PSDocumentHandler(new IFContext(ua)); - // This is the important part: we're enabling resource optimization - handler.getPSUtil().setOptimizeResources(true); - ua.setDocumentHandlerOverride(handler); - - // Prepare output file - File outputFile = renderFile(ua, "ps-resources.fo", - "-if-l" + handler.getPSUtil().getLanguageLevel()); - verifyPostScriptFile(outputFile); - } - - private void verifyPostScriptFile(File psFile) throws IOException, DSCException { - InputStream in = new java.io.FileInputStream(psFile); - in = new java.io.BufferedInputStream(in); - try { - DSCParser parser = new DSCParser(in); - parser.setCheckEOF(false); - - //The first form is for arrow_down_small.png (to be reused) - PSResource form1 = new PSResource(PSResource.TYPE_FORM, "FOPForm:1"); - PSResource helvetica = new PSResource(PSResource.TYPE_FONT, "Helvetica"); - PSResource helveticaBold = new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold"); - - PSResource res; - DSCCommentPages pages = (DSCCommentPages)gotoDSCComment(parser, DSCConstants.PAGES); - assertEquals(2, pages.getPageCount()); - - DSCCommentDocumentSuppliedResources supplied - = (DSCCommentDocumentSuppliedResources)gotoDSCComment(parser, - DSCConstants.DOCUMENT_SUPPLIED_RESOURCES); - Set resources = supplied.getResources(); - assertEquals(5, resources.size()); - assertTrue(resources.contains(form1)); - assertTrue("Expected barcode.eps as supplied resource", - resources.contains(new PSResource(PSResource.TYPE_FILE, - "test/resources/images/barcode.eps"))); - - DSCCommentDocumentNeededResources needed - = (DSCCommentDocumentNeededResources)gotoDSCComment(parser, - DSCConstants.DOCUMENT_NEEDED_RESOURCES); - resources = needed.getResources(); - assertEquals(2, resources.size()); - assertTrue("Expected Helvetica as needed resource", - resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica"))); - assertTrue("Expected Helvetica-Bold as needed resource", - resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold"))); - - //Some document structure checking - assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_DEFAULTS)); - assertNotNull(gotoDSCComment(parser, DSCConstants.END_DEFAULTS)); - assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PROLOG)); - assertNotNull(gotoDSCComment(parser, DSCConstants.END_PROLOG)); - assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_SETUP)); - - //Check includes for the two referenced base 14 fonts - DSCCommentIncludeResource include; - Collection strings = new java.util.HashSet( - Arrays.asList(new String[] {"Helvetica", "Helvetica-Bold"})); - for (int i = 0; i < 2; i++) { - include = (DSCCommentIncludeResource)gotoDSCComment( - parser, DSCConstants.INCLUDE_RESOURCE); - res = include.getResource(); - assertEquals(PSResource.TYPE_FONT, res.getType()); - strings.remove(res.getName()); - } - assertEquals(0, strings.size()); - - checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, - new PSResource(PSResource.TYPE_ENCODING, "WinAnsiEncoding")); - - //Here, we encounter form 1 again - checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form1); - - assertNotNull(gotoDSCComment(parser, DSCConstants.END_SETUP)); - //Now the actual pages begin - - //---=== Page 1 ===--- - DSCCommentPage page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE); - assertEquals(1, page.getPagePosition()); - - assertEquals(DSCAtend.class, - gotoDSCComment(parser, DSCConstants.PAGE_RESOURCES).getClass()); - assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PAGE_SETUP)); - assertNotNull(gotoDSCComment(parser, DSCConstants.END_PAGE_SETUP)); - - PSResource form2 = new PSResource(PSResource.TYPE_FORM, "FOPForm:2"); - checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form2); - assertNotNull(gotoDSCComment(parser, DSCConstants.PAGE_TRAILER)); - - AbstractResourcesDSCComment pageResources; - pageResources = (AbstractResourcesDSCComment)gotoDSCComment( - parser, DSCConstants.PAGE_RESOURCES); - resources = pageResources.getResources(); - assertEquals(5, resources.size()); - assertTrue(resources.contains(form1)); - assertTrue(resources.contains(form2)); - assertTrue(resources.contains(helvetica)); - assertTrue(resources.contains(helveticaBold)); - - //---=== Page 2 ===--- - page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE); - assertEquals(2, page.getPagePosition()); - - assertEquals(DSCAtend.class, - gotoDSCComment(parser, DSCConstants.PAGE_RESOURCES).getClass()); - assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PAGE_SETUP)); - assertNotNull(gotoDSCComment(parser, DSCConstants.END_PAGE_SETUP)); - - DSCCommentBeginDocument beginDocument; - beginDocument = (DSCCommentBeginDocument)gotoDSCComment( - parser, DSCConstants.BEGIN_DOCUMENT); - assertEquals("test/resources/images/barcode.eps", - beginDocument.getResource().getName()); - DSCListener listener = new DefaultNestedDocumentHandler(null); - listener.processEvent(beginDocument, parser); - - //And again (the barcode is generated twice) - beginDocument = (DSCCommentBeginDocument)gotoDSCComment( - parser, DSCConstants.BEGIN_DOCUMENT); - assertEquals("test/resources/images/barcode.eps", - beginDocument.getResource().getName()); - listener.processEvent(beginDocument, parser); - - assertNotNull(gotoDSCComment(parser, DSCConstants.PAGE_TRAILER)); - pageResources = (AbstractResourcesDSCComment)gotoDSCComment( - parser, DSCConstants.PAGE_RESOURCES); - resources = pageResources.getResources(); - assertEquals(6, resources.size()); - assertTrue(resources.contains(form1)); - assertFalse(resources.contains(form2)); - assertTrue(resources.contains(helvetica)); - assertTrue(resources.contains(helveticaBold)); - assertTrue(resources.contains(beginDocument.getResource())); - - assertNotNull(gotoDSCComment(parser, DSCConstants.TRAILER)); - //No headers in between, as they should have been put at the beginning of the file - assertEquals(DSCCommentEndOfFile.class, parser.nextEvent().asDSCComment().getClass()); - - } finally { - IOUtils.closeQuietly(in); - } - } - -} diff --git a/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java b/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java deleted file mode 100644 index f7f311ff8..000000000 --- a/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps.fonts; - -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.assertTrue; -import static org.junit.Assert.fail; - -import org.apache.xmlgraphics.ps.PSGenerator; - -/** - * The test class for org.apache.fop.render.ps.fonts.PSGenerator - */ -public class PSTTFGeneratorTestCase { - private PSTTFGenerator ttfGen; - private ByteArrayOutputStream out = new ByteArrayOutputStream(); - private PSGenerator gen = new PSGenerator(out); - private byte[] byteArray; - - /** - * Constructor - */ - public PSTTFGeneratorTestCase() { - byteArray = new byte[65536]; - for (int i = 0; i < 65536; i++) { - byteArray[i] = (byte) i; - } - } - - @Before - public void setUp() { - ttfGen = new PSTTFGenerator(gen); - } - - /** - * Tests startString() - starts the string in an appropriate way for a PostScript file. - * @exception IOException write error - */ - @Test - public void testStartString() throws IOException { - ttfGen.startString(); - assertEquals("<\n", out.toString()); - } - - /** - * Test streamBytes() - tests that strings are written to file in the proper format. - * @throws IOException write error. - */ - @Test - public void testStreamBytes() throws IOException { - ttfGen.streamBytes(byteArray, 0, 16); - assertEquals("000102030405060708090A0B0C0D0E0F", out.toString()); - /* - * 65520 is the closes multiple of 80 to 65535 (max string size in PS document) and since - * one byte takes up two characters, 65520 / 2 - 16 (16 bytes already written)= 32744. - */ - ttfGen.streamBytes(byteArray, 0, 32744); - // Using a regex to ensure that the format is correct - assertTrue(out.toString().matches("([0-9A-F]{80}\n){819}")); - try { - ttfGen.streamBytes(byteArray, 0, PSTTFGenerator.MAX_BUFFER_SIZE + 1); - fail("Shouldn't be able to write more than MAX_BUFFER_SIZE to a PS document"); - } catch (UnsupportedOperationException e) { - // PASS - } - } - - /** - * Test reset() - reset should reset the line counter such that when reset() is invoked the - * following string streamed to the PS document should be 80 chars long. - * @throws IOException file write error. - */ - @Test - public void testReset() throws IOException { - ttfGen.streamBytes(byteArray, 0, 40); - assertTrue(out.toString().matches("([0-9A-F]{80}\n)")); - ttfGen.streamBytes(byteArray, 0, 40); - assertTrue(out.toString().matches("([0-9A-F]{80}\n){2}")); - - } - - /** - * Test endString() - ensures strings are ended in the PostScript document in the correct - * format, a "00" needs to be appended to the end of a string. - * @throws IOException file write error - */ - @Test - public void testEndString() throws IOException { - ttfGen.endString(); - assertEquals("00\n> ", out.toString()); - out.reset(); - // we need to check that this doesn't write more than 80 chars per line - ttfGen.streamBytes(byteArray, 0, 40); - ttfGen.endString(); - assertTrue(out.toString().matches("([0-9A-F]{80}\n)00\n> ")); - } -} diff --git a/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java b/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java deleted file mode 100644 index 82b4364c3..000000000 --- a/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps.fonts; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; - -import static org.junit.Assert.fail; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -/** - * Test class for PSTTFGlyphOutputStream - */ -public class PSTTFGlyphOutputStreamTestCase { - private PSTTFGenerator mockGen; - private PSTTFGlyphOutputStream glyphOut; - - @Before - public void setUp() { - mockGen = mock(PSTTFGenerator.class); - glyphOut = new PSTTFGlyphOutputStream(mockGen); - } - - /** - * Test startGlyphStream() - test that startGlyphStream() invokes reset() and startString() in - * PSTTFGenerator. - * @exception IOException file write error - */ - @Test - public void testStartGlyphStream() throws IOException { - glyphOut.startGlyphStream(); - verify(mockGen).startString(); - } - - /** - * Test streamGlyph(byte[],int,int) - tests several paths: - * 1) strings are properly appended - * 2) when total strings size > PSTTFGenerator.MAX_BUFFER_SIZE, the strings is closed and a new - * strings is started. - * 3) if a glyph of size > PSTTFGenerator.MAX_BUFFER_SIZE is attempted, an exception is thrown. - * @throws IOException file write error. - */ - @Test - public void testStreamGlyph() throws IOException { - int byteArraySize = 10; - byte[] byteArray = new byte[byteArraySize]; - int runs = 100; - for (int i = 0; i < runs; i++) { - glyphOut.streamGlyph(byteArray, 0, byteArraySize); - } - verify(mockGen, times(runs)).streamBytes(byteArray, 0, byteArraySize); - - /* - * We want to run this for MAX_BUFFER_SIZE / byteArraySize so that go over the string - * boundary and enforce the ending and starting of a new string. Using mockito to ensure - * that this behaviour is performed in order (since this is an integral behavioural aspect) - */ - int stringLimit = PSTTFGenerator.MAX_BUFFER_SIZE / byteArraySize; - for (int i = 0; i < stringLimit; i++) { - glyphOut.streamGlyph(byteArray, 0, byteArraySize); - } - InOrder inOrder = inOrder(mockGen); - inOrder.verify(mockGen, times(stringLimit)).streamBytes(byteArray, 0, byteArraySize); - inOrder.verify(mockGen).endString(); - inOrder.verify(mockGen).startString(); - inOrder.verify(mockGen, times(runs)).streamBytes(byteArray, 0, byteArraySize); - - try { - glyphOut.streamGlyph(byteArray, 0, PSTTFGenerator.MAX_BUFFER_SIZE + 1); - fail("Shouldn't allow a length > PSTTFGenerator.MAX_BUFFER_SIZE"); - } catch (UnsupportedOperationException e) { - // PASS - } - } - - /** - * Test endGlyphStream() - tests that PSTTFGenerator.endString() is invoked when this method - * is called. - * @throws IOException file write exception - */ - @Test - public void testEndGlyphStream() throws IOException { - glyphOut.endGlyphStream(); - verify(mockGen).endString(); - } -} diff --git a/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java b/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java deleted file mode 100644 index 744f17f64..000000000 --- a/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps.fonts; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.apache.xmlgraphics.ps.PSGenerator; - -import org.apache.fop.fonts.truetype.TTFGlyphOutputStream; -import org.apache.fop.fonts.truetype.TTFTableOutputStream; - -/** - * Tests PSTTFOuputStream - */ -public class PSTTFOutputStreamTestCase { - private PSGenerator gen; - private PSTTFOutputStream out; - - /** - * Assigns an OutputStream to the PSGenerator. - */ - @Before - public void setUp() { - gen = mock(PSGenerator.class); - out = new PSTTFOutputStream(gen); - } - - /** - * Test startFontStream() - Just tests that the font is properly initiated in the PostScript - * document (in this case with "/sfnts[") - * @throws IOException write exception. - */ - @Test - public void testStartFontStream() throws IOException { - out.startFontStream(); - verify(gen).write("/sfnts["); - } - - /** - * Test getTableOutputStream() - we need to test that the inheritance model is properly obeyed. - */ - @Test - public void testGetTableOutputStream() { - TTFTableOutputStream tableOut = out.getTableOutputStream(); - assertTrue(tableOut instanceof PSTTFTableOutputStream); - } - - /** - * Test getGlyphOutputStream() - we need to test that the inheritance model is properly obeyed. - */ - @Test - public void testGetGlyphOutputStream() { - TTFGlyphOutputStream glyphOut = out.getGlyphOutputStream(); - assertTrue(glyphOut instanceof PSTTFGlyphOutputStream); - } - - /** - * Test endFontStream() - * @exception IOException write error. - */ - @Test - public void testEndFontStream() throws IOException { - out.endFontStream(); - verify(gen).writeln("] def"); - } -} diff --git a/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java b/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java deleted file mode 100644 index c20c3d8b1..000000000 --- a/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps.fonts; - -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; - -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; - -/** - * Test class for unit testing PSTTFTableOutputStream - */ -public class PSTTFTableOutputStreamTestCase { - private PSTTFGenerator mockGen; - private PSTTFTableOutputStream tableOut; - - @Before - public void setUp() { - mockGen = mock(PSTTFGenerator.class); - tableOut = new PSTTFTableOutputStream(mockGen); - } - - /** - * Test streamTable() - several paths to test (2. and 3. test corner cases): - * 1) that a table of length < PSTTFGenerator.MAX_BUFFER_SIZE invokes the correct methods in - * PSTTFGenerator. - * 2) that a table of length > PSTTFGenerator.MAX_BUFFER_SIZE and - * length == n * PSTTFGenerator.MAX_BUFFER_SIZE is split up and the methods in PSTTFGenerator - * are invoked. - * 3) that a table of length > PSTTFGenerator.MAX_BUFFER_SIZE but - * length != n * PSTTFGenerator.MAX_BUFFER_SIZE is split up and the methods in PSTTFGenerator - * are invoked. - * @throws IOException file write error. - */ - @Test - public void testStreamTable() throws IOException { - byte[] byteArray = new byte[PSTTFGenerator.MAX_BUFFER_SIZE * 3]; - tableOut.streamTable(byteArray, 0, 10); - InOrder inOrder = inOrder(mockGen); - inOrder.verify(mockGen).startString(); - inOrder.verify(mockGen).streamBytes(byteArray, 0, 10); - inOrder.verify(mockGen).endString(); - - setUp(); // reset all all the method calls - /* We're going to run this 3 times to ensure the proper method calls are invoked and all - * the bytes are streamed */ - tableOut.streamTable(byteArray, 0, byteArray.length); - inOrder = inOrder(mockGen); - for (int i = 0; i < 3; i++) { - int offset = PSTTFGenerator.MAX_BUFFER_SIZE * i; - inOrder.verify(mockGen).startString(); - inOrder.verify(mockGen).streamBytes(byteArray, offset, PSTTFGenerator.MAX_BUFFER_SIZE); - inOrder.verify(mockGen).endString(); - } - - setUp(); // reset all the method calls - tableOut.streamTable(byteArray, 0, PSTTFGenerator.MAX_BUFFER_SIZE + 1); - inOrder = inOrder(mockGen); - inOrder.verify(mockGen).startString(); - inOrder.verify(mockGen).streamBytes(byteArray, 0, PSTTFGenerator.MAX_BUFFER_SIZE); - inOrder.verify(mockGen).endString(); - inOrder.verify(mockGen).startString(); - inOrder.verify(mockGen).streamBytes(byteArray, PSTTFGenerator.MAX_BUFFER_SIZE, 1); - inOrder.verify(mockGen).endString(); - } -} diff --git a/test/java/org/apache/fop/render/ps/ps-jpeg-image.fo b/test/java/org/apache/fop/render/ps/ps-jpeg-image.fo deleted file mode 100644 index 50ed2d6e4..000000000 --- a/test/java/org/apache/fop/render/ps/ps-jpeg-image.fo +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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$ --> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> - <fo:layout-master-set> - <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm"> - <fo:region-body/> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="A4"> - <fo:flow flow-name="xsl-region-body"> - <fo:block>JPEG image:</fo:block> - <fo:block><fo:external-graphic src="test/resources/images/bgimg72dpi.jpg"/></fo:block> - <fo:block> - <fo:external-graphic src="test/resources/images/bgimg300dpi.jpg"/> - <fo:external-graphic src="test/resources/images/bgimg300dpi.jpg"/> - </fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/render/ps/ps-resources.fo b/test/java/org/apache/fop/render/ps/ps-resources.fo deleted file mode 100644 index 7982d35bd..000000000 --- a/test/java/org/apache/fop/render/ps/ps-resources.fo +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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$ --> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> - <fo:layout-master-set> - <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm"> - <fo:region-body/> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="A4"> - <fo:flow flow-name="xsl-region-body"> - <fo:block font-weight="bold">PostScript Resource Optimization Test</fo:block> - <fo:block>Used again later:</fo:block> - <fo:block><fo:external-graphic src="test/resources/images/arrow_down_small.png"/></fo:block> - <fo:block>Used only once in the whole document:</fo:block> - <fo:block><fo:external-graphic src="test/resources/images/arrow_up_small.png"/></fo:block> - </fo:flow> - </fo:page-sequence> - <fo:page-sequence master-reference="A4"> - <fo:flow flow-name="xsl-region-body"> - <fo:block font-weight="bold">PostScript Resource Optimization Test</fo:block> - <fo:block>Image already used in previous page-sequence:</fo:block> - <fo:block> - <fo:external-graphic src="test/resources/images/arrow_down_small.png" content-width="80%"/> - <fo:external-graphic src="test/resources/images/arrow_down_small.png"/> - <fo:external-graphic src="test/resources/images/arrow_down_small.png" content-width="120%"/> - </fo:block> - <fo:block>Can't currently reuse EPS images:</fo:block> - <fo:block> - <fo:external-graphic src="test/resources/images/barcode.eps"/> - <fo:external-graphic src="test/resources/images/barcode.eps"/> - </fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> diff --git a/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java b/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java deleted file mode 100644 index 908c60350..000000000 --- a/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.ps.svg; - -import java.awt.Color; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -import org.apache.commons.io.IOUtils; - -import org.apache.batik.ext.awt.LinearGradientPaint; -import org.apache.batik.ext.awt.MultipleGradientPaint; -import org.apache.batik.ext.awt.RadialGradientPaint; - -import org.apache.xmlgraphics.java2d.GraphicContext; -import org.apache.xmlgraphics.ps.PSGenerator; - -public class GradientTestCase { - - @Test - public void testLinearGradient() throws IOException { - float[] fractions = {0f, 1f}; - Color[] colors = {new Color(255, 255, 0), new Color(255, 0, 0)}; - LinearGradientPaint gradient = new LinearGradientPaint(115f, 285f, 15f, 15f, fractions, colors); - testGradientRendering(gradient, "expected-linear-gradient.ps"); - } - - @Test - public void testRadialGradient() throws IOException { - float cx = 840f; - float cy = 180f; - float r = 16f; - float[] fractions = {0.2f, 0.6f, 0.8f, 1.0f}; - Color[] colors = { - new Color(255, 255, 255), - new Color(200, 200, 200), - new Color(170, 170, 170), - new Color(140, 140, 140)}; - RadialGradientPaint gradient = new RadialGradientPaint(cx, cy, r, fractions, colors); - testGradientRendering(gradient, "expected-radial-gradient.ps"); - } - - private void testGradientRendering(MultipleGradientPaint gradient, String expectedResourceName) - throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - PSSVGGraphics2D svgGraphics2D = new PSSVGGraphics2D(false, new PSGenerator(out)); - svgGraphics2D.setGraphicContext(new GraphicContext()); - svgGraphics2D.translate(100, 100); - svgGraphics2D.applyPaint(gradient, true); - byte[] actual = out.toByteArray(); - byte[] expected = IOUtils.toByteArray(getClass().getResourceAsStream(expectedResourceName)); - assertEquals(new String(expected, "US-ASCII"), new String(actual, "US-ASCII")); - } - -} diff --git a/test/java/org/apache/fop/render/ps/svg/expected-linear-gradient.ps b/test/java/org/apache/fop/render/ps/svg/expected-linear-gradient.ps deleted file mode 100644 index 8ddc64486..000000000 --- a/test/java/org/apache/fop/render/ps/svg/expected-linear-gradient.ps +++ /dev/null @@ -1,25 +0,0 @@ -/Pattern setcolorspace -<< -/Type /Pattern -/PatternType 2 -/Shading << -/ShadingType 2 -/ColorSpace /DeviceRGB -/Coords [ 115 285 15 15 ] -/Extend [ true true ] -/Function << -/FunctionType 3 -/Domain [ 0 1 ] -/Functions [ << -/FunctionType 2 -/Domain [ 0 1 ] -/C0 [ 1 1 0 ] -/C1 [ 1 0 0 ] -/N 1 ->> ] -/Encode [ 0 1 ] -/Bounds [ ] ->> ->> ->> -[ 1 0 0 1 0 0 ] makepattern setcolor diff --git a/test/java/org/apache/fop/render/ps/svg/expected-radial-gradient.ps b/test/java/org/apache/fop/render/ps/svg/expected-radial-gradient.ps deleted file mode 100644 index 527f27965..000000000 --- a/test/java/org/apache/fop/render/ps/svg/expected-radial-gradient.ps +++ /dev/null @@ -1,43 +0,0 @@ -/Pattern setcolorspace -<< -/Type /Pattern -/PatternType 2 -/Shading << -/ShadingType 3 -/ColorSpace /DeviceRGB -/Coords [ 840 180 0 840 180 16 ] -/Extend [ true true ] -/Function << -/FunctionType 3 -/Domain [ 0 1 ] -/Functions [ << -/FunctionType 2 -/Domain [ 0 1 ] -/C0 [ 1 1 1 ] -/C1 [ 1 1 1 ] -/N 1 ->> << -/FunctionType 2 -/Domain [ 0 1 ] -/C0 [ 1 1 1 ] -/C1 [ 0.784 0.784 0.784 ] -/N 1 ->> << -/FunctionType 2 -/Domain [ 0 1 ] -/C0 [ 0.784 0.784 0.784 ] -/C1 [ 0.667 0.667 0.667 ] -/N 1 ->> << -/FunctionType 2 -/Domain [ 0 1 ] -/C0 [ 0.667 0.667 0.667 ] -/C1 [ 0.549 0.549 0.549 ] -/N 1 ->> ] -/Encode [ 0 1 0 1 0 1 0 1 ] -/Bounds [ 0.2 0.6 0.8 ] ->> ->> ->> -[ 1 0 0 1 0 0 ] makepattern setcolor diff --git a/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java b/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java deleted file mode 100644 index 4c3c8446e..000000000 --- a/test/java/org/apache/fop/render/rtf/Bug39607TestCase.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.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; - -/** - * Test for http://issues.apache.org/bugzilla/show_bug.cgi?id=39607 - */ -public class Bug39607TestCase { - - /** - * Test for the NPE describes in bug 39607 - * @throws Exception If an error occurs - */ - @Test - public void testForNPE() throws Exception { - StringWriter writer = new StringWriter(); - RtfFile f = new RtfFile(writer); - - RtfDocumentArea doc = f.startDocumentArea(); - - RtfSection section = doc.newSection(); - - RtfParagraph paragraph = section.newParagraph(); - paragraph.newText("Testing fop - rtf module - class RtfTableRow"); - paragraph.close(); - - RtfTable table = section.newTable(null); - RtfTableRow row = table.newTableRow(); - row.newTableCell(2000).newParagraph().newText("blah"); - row.newTableCell(5000).newParagraph().newText("doubleBlah"); - row.close(); - table.close(); - section.close(); - doc.close(); - f.flush(); - } - -} diff --git a/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java b/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java deleted file mode 100644 index 5b294bd9b..000000000 --- a/test/java/org/apache/fop/render/rtf/RichTextFormatTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.rtf; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite for FOP's RTF library. - */ -@RunWith(Suite.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 deleted file mode 100644 index 9df1c26ef..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.RtfHyperLink; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; - -/** - * Class <code>BasicLink</code> here. - */ - -public class BasicLink extends TestDocument { - ////////////////////////////////////////////////// - // @@ Construction - ////////////////////////////////////////////////// - - /** - * Default constructor. - */ - public BasicLink() { - } - - /** generate the body of the test document - * @param rda RtfDocumentArea - * @param sect RtfSection - * @throws IOException for I/O Errors - */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { - RtfParagraph p = sect.newParagraph(); - p.newLineBreak(); - p.newLineBreak(); - p.newLineBreak(); - p.newText("external link: "); - RtfHyperLink link = p.newHyperLink("click here to go to the hompage", null); - link.setExternalURL("http://www.skynamics.com"); - p.close(); - - p = sect.newParagraph(); - p.newLineBreak(); - p.newText("here we will demonstrate internal link to a bookmark"); - p.newLineBreak(); - p.newText("internal link: "); - link = p.newHyperLink("click here to go to the bookmark", null); - link.setInternalURL("testBookmark"); - p.close(); - - p = sect.newParagraph(); - p.newLineBreak(); - p.newLineBreak(); - p.newLineBreak(); - p.newPageBreak(); - p.newBookmark("testBookmark"); - p.newText("testBookmark"); - } -} 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 deleted file mode 100644 index 7f17514ef..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -package org.apache.fop.render.rtf.rtflib.testdocs; - -import java.io.File; -import java.io.IOException; - -/** Create test RTF documents from classes found in this package. - */ - -public class CreateTestDocuments { - - /** - * package name for the testdocs - */ - public static final String TESTDOCS_PACKAGE = "org.apache.fop.render.rtf.rtflib.testdocs"; - - /** List of all TestDocument subclasses from this package */ - private static final String [] CLASS_NAMES = { - "SimpleDocument", - "TextAttributes", - "SimpleTable", - "SimpleLists", - "ListInTable", - "Whitespace", - "MergedTableCells", - "NestedTable", - "ExternalGraphic", - "BasicLink", - "ParagraphAlignment" - }; - - CreateTestDocuments(File outDir) - throws Exception { - if (!outDir.isDirectory() || !outDir.canWrite()) { - throw new IOException("output directory (" + outDir + ") must exist and be writable"); - } - - for (int i = 0; i < CLASS_NAMES.length; i++) { - createOneTestDocument(CLASS_NAMES[i], outDir); - } - } - - /** instantiate one TestDocument and let it generate its document */ - void createOneTestDocument(String className, File outDir) - throws Exception { - className = TESTDOCS_PACKAGE + "." + className; - TestDocument td = null; - try { - td = (TestDocument)Class.forName(className).newInstance(); - } catch (Exception e) { - throw new Exception("unable to instantiate '" + className - + " as a TestDocument object: " + e); - } - td.setOutputDir(outDir); - try { - td.generateOutput(); - } catch (Exception e) { - System.err.println("Error while generating test RTF document:"); - e.printStackTrace(); - } - } - - /** execute this to create test documents from all classes listed in classNames array - * @param args String array of arguments - * @throws Exception for errors - */ - public static void main(String[] args) - throws Exception { - if (args.length < 1) { - System.err.println("usage: CreateTestDocuments <output directory>"); - System.exit(1); - } - -// System.err.println("CreateTestDocuments - using " + JForVersionInfo.getLongVersionInfo()); - System.err.println("Generates documents to test the RTF library."); - final File outDir = new File(args[0]); - new CreateTestDocuments(outDir); - System.err.println("CreateTestDocuments - all done."); - System.exit(0); - } -} 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 deleted file mode 100644 index 1af4c7bed..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -package org.apache.fop.render.rtf.rtflib.testdocs; - -import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableColumnsInfo; - -/** ITableColumnsInfo that does nothing, used in testodcs package - * 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. - */ - -class DummyTableColumnsInfo implements ITableColumnsInfo { - - public float getColumnWidth() { - return INVALID_COLUMN_WIDTH; - } - - public void selectFirstColumn() { - } - - public int getNumberOfColumns() { - return 0; - } - - public int getColumnIndex() { - return 0; - } - - public void selectNextColumn() { - } - - /* (non-Javadoc) - * @see org.apache.fop.render.rtf.rtflib.rtfdoc.ITableColumnsInfo#getFirstSpanningCol() - */ - public boolean getFirstSpanningCol() { - // TODO Auto-generated method stub - return false; - } - -} 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 deleted file mode 100644 index 1127f3e72..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.RtfExternalGraphic; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; -/** - * Generate a test document containing external graphics. - */ -class ExternalGraphic extends TestDocument { - private String file = "file:///tmp/jfor-images/logo."; - - ////////////////////////////////////////////////// - // @@ Construction - ////////////////////////////////////////////////// - - /** - * Default constructor. - */ - public ExternalGraphic() { - - } - /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { - RtfParagraph p = sect.newParagraph(); - p.newLineBreak(); - p.newLineBreak(); - p.newLineBreak(); - p.newText("EMF image with 150 % height"); - p.newLineBreak(); - RtfExternalGraphic imageA = p.newImage(); - imageA.setURL(file + "emf"); - imageA.setHeight("150%"); - p.newLineBreak(); - p.close(); - - p = sect.newParagraph(); - p.newLineBreak(); - p.newText("PNG image with 150 % width"); - p.newLineBreak(); - RtfExternalGraphic imageB = sect.newImage(); - imageB.setURL(file + "png"); - imageB.setWidth("150%"); - p.newLineBreak(); - p.close(); - - p = sect.newParagraph(); - p.newLineBreak(); - p.newLineBreak(); - p.newText("JPG image with width = 200px and height = 20 px"); - p.newLineBreak(); - RtfExternalGraphic imageC = sect.newImage(); - imageC.setURL(file + "jpg"); - imageC.setWidth("200"); - imageC.setHeight("20"); - p.newLineBreak(); - p.close(); - - p = sect.newParagraph(); - p.newLineBreak(); - p.newLineBreak(); - p.newText("GIF image with width = 200px and scaling = 'uniform', that means the image " - + "size will adjusted automatically"); - p.newLineBreak(); - RtfExternalGraphic imageD = sect.newImage(); - imageD.setURL(file + "gif"); - imageD.setWidth("200"); - imageD.setScaling("uniform"); - p.newLineBreak(); - p.close(); - - p = sect.newParagraph(); - p.newLineBreak(); - p.newLineBreak(); - p.newText("GIF image"); - p.newLineBreak(); - RtfExternalGraphic imageE = sect.newImage(); - imageE.setURL(file + "gif"); - p.newLineBreak(); - p.close(); - - } - - - -} 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 deleted file mode 100644 index 6f4e27a59..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.RtfList; -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. - */ - -class ListInTable extends TestDocument { - /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException { - sect.newParagraph().newText("There must be a table below where the " - + "second cell contains a bulleted list mixed with normal paragraphs"); - - final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); - final RtfTableRow row = tbl.newTableRow(); - row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH).newParagraph().newText("cell A, simple"); - - final RtfTableCell c = row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH); - c.newParagraph().newText("cell B, contains this paragraph followed by " - + "a list and another paragraph"); - fillList(c.newList(null), 1, 3); - c.newParagraph().newText("Normal paragraph, follows the list."); - - row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH).newParagraph().newText("cell C, simple"); - } - - private void fillList(RtfList list, int listIndex, int nItems) - throws IOException { - for (int i = 0; i < nItems; i++) { - final RtfListItem item = list.newListItem(); - for (int j = 0; j <= i; j++) { - final RtfParagraph para = item.newParagraph(); - para.newText("List " + listIndex + ", item " + i + ", paragraph " + j); - if (i == 0 && j == 0) { - final String txt = "This item takes more than one line to check word-wrapping."; - para.newText(". " + "This list must have " + nItems - + " items. " + txt + " " + txt + " " + txt); - } - } - } - } -} 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 deleted file mode 100644 index 9be5e899a..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.RtfTable; -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 - */ - -class MergedTableCells extends TestDocument { - static final int MM_TO_TWIPS = (int)(1440f / 25.4f); - - /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException { - sect.newParagraph().newText("This document contains a table with some merged cells."); - - final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); - - // first row, test horizontal merging - { - RtfTableRow r = tbl.newTableRow(); - RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS); - c.setHMerge(RtfTableCell.MERGE_START); - c.newParagraph().newText("cell 0,0, width 80mm, merge start, " - + "followed by two merged cells totalling 80mm width."); - - c = r.newTableCell(40 * MM_TO_TWIPS); - c.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS); - c.newParagraph().newText("THIS IS IN AN HMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); - - c = r.newTableCell(40 * MM_TO_TWIPS); - c.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS); - c.newParagraph().newText("THIS IS IN AN HMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); - } - - // second row, start vertical merging in column 1 - { - RtfTableRow r = tbl.newTableRow(); - RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS); - c.setVMerge(RtfTableCell.MERGE_START); - c.newParagraph().newText("cell 1,0, vertical merge start, 40mm, spans three rows."); - - r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 1,1, no merge, 80mm"); - - c = r.newTableCell(40 * MM_TO_TWIPS); - c.setVMerge(RtfTableCell.MERGE_START); - c.newParagraph().newText("cell 1,2, vertical merge start, 40mm, spans two rows."); - } - - // third row, column 1 merged with previous row - { - RtfTableRow r = tbl.newTableRow(); - RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS); - c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS); - c.newParagraph().newText("cell 2,0, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); - - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 2,1, no merge, 40mm"); - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 2,2, no merge, 40mm"); - - c = r.newTableCell(40 * MM_TO_TWIPS); - c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS); - c.newParagraph().newText("cell 2,3, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); - } - - // fourth row, column 1 merged with previous row - { - RtfTableRow r = tbl.newTableRow(); - RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS); - c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS); - c.newParagraph().newText("cell 3,0, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT"); - - r.newTableCell(10 * MM_TO_TWIPS).newParagraph().newText("cell 3,1, no merge, 10mm"); - r.newTableCell(30 * MM_TO_TWIPS).newParagraph().newText("cell 3,2, no merge, 30mm"); - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 3,3, no merge, 40mm"); - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 3,4, no merge, 40mm"); - } - - // fifth row, just one cell - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(160 * MM_TO_TWIPS).newParagraph().newText( - "cell 4,0, width 160mm, only cell in this row"); - } - } -} 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 deleted file mode 100644 index c11fbc334..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.RtfTableCell; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; - -/** Generates an RTF document to test nested tables with the jfor rtflib package. - */ - -class NestedTable extends TestDocument { - private static final int MM_TO_TWIPS = (int)(1440f / 25.4f); - - /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException { - sect.newParagraph().newText("This document demonstrates pseudo-nested " - + "tables created using merged table cells"); - - firstTestTable(sect); - RtfParagraph p = sect.newParagraph(); - p.newText("Test continues on next page."); - p.newPageBreak(); - secondTestTable(sect); - - p = sect.newParagraph(); - p.newText("Test continues on next page."); - p.newPageBreak(); - thirdTestTable(sect); - - sect.newParagraph().newText("End of nested tables test document"); - } - - private void firstTestTable(RtfSection sect) - throws IOException { - - sect.newParagraph().newText("First test: table with one nested table in cell 1,1"); - final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); - // first row, normal - { - RtfTableRow r = tbl.newTableRow(); - RtfTableCell c = r.newTableCell(160 * MM_TO_TWIPS); - c.newParagraph().newText("cell 0,0, width 160mm, only cell in this row."); - } - - // second row contains nested table - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText( - "cell 1,0, width 40mm, to the left of nested table."); - - final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS); - c.newParagraph().newText("cell 1,1, width 80mm, this text is " - + "followed by a nested table in the same cell, followed " - + "by text that says 'AFTER NESTED TABLE'."); - fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 1); - c.newParagraph().newText("AFTER NESTED TABLE"); - - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText( - "cell 1,2, width 40mm, to the right of nested table."); - } - - // third row, normal - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText( - "cell 2,0, width 80mm, this row has two cells."); - r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText( - "cell 2,1, width 80mm, last cell."); - } - - } - - private void secondTestTable(RtfSection sect) - throws IOException { - sect.newParagraph().newText("Second test: table with two nested tables in cell 1,1"); - final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); - // first row, normal - { - RtfTableRow r = tbl.newTableRow(); - RtfTableCell c = r.newTableCell(160 * MM_TO_TWIPS); - c.newParagraph().newText("second test table: cell 0,0, width 160mm, " - + "only cell in this row."); - } - - // second row contains nested table - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText( - "cell 1,0, width 40mm, to the left of nested tables."); - - final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS); - c.newParagraph().newText("cell 1,1, width 80mm, this text is " - + "followed by a nested table in the same cell, followed " - + "by text that says 'BETWEEN', then another table, then 'AFTER'."); - fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 2); - c.newParagraph().newText("BETWEEN"); - fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 3); - c.newParagraph().newText("AFTER"); - - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText( - "cell 1,2, width 40mm, to the right of nested table."); - } - - // third row, normal - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText( - "cell 2,0, width 80mm, this row has two cells."); - r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText( - "cell 2,1, width 80mm, last cell."); - } - } - - private void thirdTestTable(RtfSection sect) - throws IOException { - sect.newParagraph().newText("Third test: table with two nested tables " - + "in cell 1,1 and one nested table in cell 0,1"); - final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); - // first row, normal - { - RtfTableRow r = tbl.newTableRow(); - RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS); - c.newParagraph().newText("third test table: cell 0,0, width 40mm, " - + "the cell to its right contains a nested table with no other text."); - c = r.newTableCell(80 * MM_TO_TWIPS); - fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 4); - } - - // second row contains nested table - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText( - "cell 1,0, width 40mm, to the left of nested tables."); - - final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS); - c.newParagraph().newText("cell 1,1, width 80mm, this text is " - + "followed by a nested table in the same cell, followed " - + "by text that says 'BETWEEN', then another table, then 'AFTER'."); - fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 5); - c.newParagraph().newText("BETWEEN"); - fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 6); - c.newParagraph().newText("AFTER"); - - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText( - "cell 1,2, width 40mm, to the right of nested table."); - } - - // third row, normal - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText( - "cell 2,0, width 80mm, this row has two cells."); - r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText( - "cell 2,1, width 80mm, last cell."); - } - } - - /** fill the nested table */ - private void fillNestedTable(RtfTable tbl, int index) - throws IOException { - final String id = "TABLE " + index; - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText( - id + ":nested cell 0,0. Nested table contains 3 rows with 1,2 and 3 cells respectively" - ); - } - - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 1,0, 40mm."); - r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 1,1, 40mm."); - } - - { - RtfTableRow r = tbl.newTableRow(); - r.newTableCell(30 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 2,0, 30mm."); - r.newTableCell(30 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 2,1, 30mm."); - r.newTableCell(20 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 2,2, 20mm."); - } - } -} 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 deleted file mode 100644 index edce3264a..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.RtfParagraph; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; - -/** Generates a simple RTF test document for the jfor rtflib package. - */ -public class ParagraphAlignment extends TestDocument { - - /** - * Constructor - */ - public ParagraphAlignment() { - } - - /** - * Generate the document. - * @param rda RtfDocumentArea - * @param sect RtfSection - * @throws java.io.IOException for I/O errors - */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws java.io.IOException - { - RtfAttributes attr = new RtfAttributes(); - attr.set(RtfText.ALIGN_CENTER); - RtfParagraph p = sect.newParagraph(attr); - p.newLineBreak(); - p.newLineBreak(); - p.newText("Centered title"); - p.newLineBreak(); - p.close(); - - attr = new RtfAttributes(); - attr.set(RtfText.ALIGN_LEFT); - p = sect.newParagraph(attr); - p.newLineBreak(); - p.newText("This is the left aligned text."); - p.newLineBreak(); - p.close(); - - attr = new RtfAttributes(); - attr.set(RtfText.ALIGN_RIGHT); - p = sect.newParagraph(attr); - p.newLineBreak(); - p.newText("This is the right aligned text."); - p.newLineBreak(); - p.close(); - } -} 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 deleted file mode 100644 index ca6ce79bc..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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; - -/** Generates a simple RTF test document for the jfor rtflib package. - */ - -class SimpleDocument -extends TestDocument { - /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException { - sect.newParagraph().newText("First paragraph of the simple RTF test document."); - - final RtfParagraph para = sect.newParagraph(); - para.newText("Second paragraph of simple RTF test document.\n"); - for (int i = 0; i < 242; i++) { - para.newText("This is string " + i); - para.newLineBreak(); - } - } -} 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 deleted file mode 100644 index e817f6a13..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.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. - */ - -class SimpleLists extends TestDocument { - /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException { - sect.newParagraph().newText("First paragraph of the 'SimpleLists' RTF test document."); - sect.newParagraph().newText("First bulleted list with 5 items."); - makeList(sect, 1, 5, null); - sect.newParagraph().newText("Normal paragraph between lists 1 and 2."); - makeList(sect, 2, 3, null); - sect.newParagraph().newText("Normal paragraph after list 2."); - - sect.newParagraph().newText("Now a numbered list (4 items):"); - makeList(sect, 3, 4, new RtfListStyleNumber()); - } - - private void makeList(RtfSection sect, int listIndex, int nItems, RtfListStyle ls) - throws IOException { - final RtfList list = sect.newList(null); - if (ls != null) { - list.setRtfListStyle(ls); - } - for (int i = 0; i < nItems; i++) { - final RtfListItem item = list.newListItem(); - for (int j = 0; j <= i; j++) { - final RtfParagraph para = item.newParagraph(); - para.newText("List " + listIndex + ", item " + i + ", paragraph " + j); - if (i == 0 && j == 0) { - final String txt = "This item takes more than one line to check word-wrapping."; - para.newText(". " + "This list should have " + nItems - + " items. " + txt + " " + txt + " " + txt); - } - } - } - } -} 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 deleted file mode 100644 index 10ddc11e7..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.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. - */ -class SimpleTable extends TestDocument { - /** generate the body of the test document */ - static final int MAX_ROW = 2; - static final int MAX_COL = 3; - static final int INCH_TO_TWIPS = 1440; - static final int C1W = 4; - - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException { - final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); - tbl.newTableRow().newTableCell(C1W * INCH_TO_TWIPS).newParagraph().newText( - "Here's a table row with just one cell, width " + C1W + "''"); - - for (int row = 0; row < MAX_ROW; row++) { - final RtfTableRow r = tbl.newTableRow(); - - for (int col = 0; col < MAX_COL; col++) { - final float widthInInches = col / 2f + 1f; - final int widthInTwips = (int)(widthInInches * INCH_TO_TWIPS); - final RtfTableCell c = r.newTableCell(widthInTwips); - c.newParagraph().newText("(" + row + "," + col + "), width " - + widthInInches + "''"); - if (row == 0 && col == 1) { - for (int i = 0; i < 4; i++) { - c.newParagraph().newText("additional paragraph " + i + " of cell 0,1"); - } - } - } - } - - sect.newParagraph().newText("This paragraph follows the table."); - } -} 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 deleted file mode 100644 index 266903766..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -package org.apache.fop.render.rtf.rtflib.testdocs; - -import java.io.File; -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.RtfFile; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; - -/** Base class for generating RTF documents used to test the jfor rtflib package. - */ - -abstract class TestDocument { - private File output; - - final void setOutputDir(File outDir) - throws IOException { - output = new File(outDir, getRtfFilename()); - } - - final String getRtfFilename() { - // use class name for output filename - final String name = getClass().getName(); - final int pos = name.lastIndexOf('.'); - return name.substring(pos + 1) + ".rtf"; - } - - final void generateOutput() - throws IOException { - debugMsg("Generating document " + output + "..."); - final RtfFile f = new RtfFile(new FileWriter(output)); - final RtfDocumentArea rda = f.startDocumentArea(); - final RtfSection sect = rda.newSection(); - addIntroComments(sect); - generateDocument(rda, sect); - f.flush(); - } - - protected abstract void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException; - - void debugMsg(String msg) { - System.err.println(msg); - } - - protected void addIntroComments(RtfSection sect) throws IOException { - final RtfParagraph para = sect.newParagraph(); - - para.newText("jfor RTF library test document."); - para.newLineBreak(); -// para.newText(JForVersionInfo.getLongVersionInfo()); - para.newLineBreak(); - para.newText("generated by class " + getClass().getName()); - para.newLineBreak(); - para.newText("generated on " + new Date()); - para.close(); - } -} 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 deleted file mode 100644 index bb0614cee..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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.RtfParagraph; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; -import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; - -/** Generates a simple RTF test document for the jfor rtflib package. - */ - -class TextAttributes extends TestDocument { - /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException { - final RtfParagraph para = sect.newParagraph(); - para.newText("This is normal\n"); - para.newText("This is bold\n", new RtfAttributes().set(RtfText.ATTR_BOLD)); - para.newText("This is italic\n", new RtfAttributes().set(RtfText.ATTR_ITALIC)); - para.newText("This is underline\n", new RtfAttributes().set(RtfText.ATTR_UNDERLINE)); - - // RTF font sizes are in half-points - para.newText("This is size 48\n", new RtfAttributes().set(RtfText.ATTR_FONT_SIZE, 96)); - - para.newText( - "This is bold and italic\n", - new RtfAttributes().set(RtfText.ATTR_BOLD).set(RtfText.ATTR_ITALIC) - ); - - final RtfAttributes attr = new RtfAttributes(); - attr.set(RtfText.ATTR_BOLD).set(RtfText.ATTR_ITALIC); - attr.set(RtfText.ATTR_UNDERLINE); - attr.set(RtfText.ATTR_FONT_SIZE, 72); - para.newText("This is bold, italic, underline and size 36\n", attr); - - para.newText("This is back to normal\n"); - } -} 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 deleted file mode 100644 index a206e014f..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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$ */ - - -/* - * This file is part of the RTF library of the FOP project, which was originally - * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other - * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to - * the FOP project. - */ - -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; - -/** Generates an RTF document to test the WhitespaceCollapser - */ - -class Whitespace extends TestDocument { - /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) - throws IOException { - final RtfParagraph p1 = sect.newParagraph(); - p1.newText("\t Each word of this paragraph must be " - + "separated\tfrom\t\n\tthe next word with exactly\t \tone"); - p1.newText(" space."); - - final RtfParagraph p2 = sect.newParagraph(); - p2.newText(""); - p2.newText("In this"); - p2.newText(" paragraph "); - p2.newText("as well,"); - p2.newText(" there must\tbe \t"); - p2.newText("exactly"); - p2.newText(" one space "); - p2.newText("between each\tword and the next, and no spaces at the " - + "beginning or end of the paragraph."); - - final RtfParagraph p3 = sect.newParagraph(); - p3.newText("The word 'boomerang' must be written after this with no funny spacing: "); - p3.newText("boo"); - p3.newText("me"); - p3.newText("r"); - p3.newText("a"); - p3.newText("ng."); - } -} diff --git a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/package.html b/test/java/org/apache/fop/render/rtf/rtflib/testdocs/package.html deleted file mode 100644 index 6d6d62fdf..000000000 --- a/test/java/org/apache/fop/render/rtf/rtflib/testdocs/package.html +++ /dev/null @@ -1,7 +0,0 @@ -<HTML> -<TITLE>org.apache.fop.render.rtf.rtflib.testdocs</TITLE> -<BODY> -<P>Classes used to test/demonstrate RTFLib capabilities by generating sample -RTF documents.</P> -</BODY> -</HTML>
\ No newline at end of file diff --git a/test/java/org/apache/fop/render/txt/TxtRendererConfigParserTestCase.java b/test/java/org/apache/fop/render/txt/TxtRendererConfigParserTestCase.java deleted file mode 100644 index 30fed05ea..000000000 --- a/test/java/org/apache/fop/render/txt/TxtRendererConfigParserTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.render.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.txt.TxtRendererConfig.TxtRendererConfigParser; -import org.apache.fop.render.txt.TxtRendererConfig.TxtRendererOption; - -public class TxtRendererConfigParserTestCase - extends AbstractRendererConfigParserTester<TxtRendererConfBuilder, TxtRendererConfig> { - - public TxtRendererConfigParserTestCase() { - super(new TxtRendererConfigParser(), TxtRendererConfBuilder.class); - } - - @Test - public void testEncoding() throws Exception { - parseConfig(createRenderer().setEncoding("UTF-16")); - assertEquals("UTF-16", conf.getEncoding()); - - // Check validation isn't done at this point - parseConfig(createRenderer().setEncoding("RandomString")); - assertEquals("RandomString", conf.getEncoding()); - - // Check the default behaviour is expected - parseConfig(createRenderer()); - assertEquals(TxtRendererOption.ENCODING.getDefaultValue(), conf.getEncoding()); - } - -} diff --git a/test/java/org/apache/fop/svg/NativeTextPainterTest.java b/test/java/org/apache/fop/svg/NativeTextPainterTest.java deleted file mode 100644 index 5344e6a54..000000000 --- a/test/java/org/apache/fop/svg/NativeTextPainterTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.anim.dom.SAXSVGDocumentFactory; -import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.bridge.GVTBuilder; -import org.apache.batik.bridge.TextPainter; -import org.apache.batik.gvt.GraphicsNode; - -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 deleted file mode 100644 index e94c8e404..000000000 --- a/test/java/org/apache/fop/svg/OperatorValidator.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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/PDFGraphics2DTestCase.java b/test/java/org/apache/fop/svg/PDFGraphics2DTestCase.java deleted file mode 100644 index 3f610c56f..000000000 --- a/test/java/org/apache/fop/svg/PDFGraphics2DTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.BasicStroke; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -public class PDFGraphics2DTestCase { - - @Test - public void testApplyStrokeNullDash() { - PDFGraphics2D g2d = new PDFGraphics2D(false); - BasicStroke stroke = new BasicStroke(); - g2d.applyStroke(stroke); - assertTrue(g2d.getString().contains("[] 0 d\n")); - } - - @Test - public void testApplyStrokeNonNullDash() { - PDFGraphics2D g2d = new PDFGraphics2D(false); - float[] dashArray = {3.0f, 5.0f}; - BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, - dashArray, 0.0f); - g2d.applyStroke(stroke); - assertTrue(g2d.getString().contains("[3 5] 0 d\n")); - } - -} diff --git a/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java b/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java deleted file mode 100644 index 3e64cb58f..000000000 --- a/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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.bridge.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 deleted file mode 100644 index 2b716e348..000000000 --- a/test/java/org/apache/fop/svg/PSTextPainterTestCase.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.bridge.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 deleted file mode 100644 index 0f375b9af..000000000 --- a/test/java/org/apache/fop/svg/baseline-shift.svg +++ /dev/null @@ -1,9 +0,0 @@ -<?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 deleted file mode 100644 index cfdc2de01..000000000 --- a/test/java/org/apache/fop/svg/dx-dy.svg +++ /dev/null @@ -1,8 +0,0 @@ -<?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 deleted file mode 100644 index c6f062a84..000000000 --- a/test/java/org/apache/fop/svg/font/BasicGlyphVectorTestCase.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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 deleted file mode 100644 index d14752b90..000000000 --- a/test/java/org/apache/fop/svg/font/FOPFontFamilyResolverTestCase.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 deleted file mode 100644 index b27dac5b2..000000000 --- a/test/java/org/apache/fop/svg/font/FOPGVTFontTestCase.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0995ab4df..000000000 --- a/test/java/org/apache/fop/svg/font/FOPGVTGlyphVectorTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 deleted file mode 100644 index c9346588c..000000000 --- a/test/java/org/apache/fop/svg/font/FontInfoBuilder.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 deleted file mode 100644 index 04af70544..000000000 --- a/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.", "DFLT", "dflt"); - 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 deleted file mode 100644 index 4900a3b02..000000000 --- a/test/java/org/apache/fop/svg/glyph-orientation.svg +++ /dev/null @@ -1,10 +0,0 @@ -<?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 deleted file mode 100644 index 8b942905e..000000000 --- a/test/java/org/apache/fop/svg/rotated-glyph.svg +++ /dev/null @@ -1,5 +0,0 @@ -<?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 deleted file mode 100644 index 943ab1d04..000000000 --- a/test/java/org/apache/fop/svg/spacing.svg +++ /dev/null @@ -1,21 +0,0 @@ -<?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 deleted file mode 100644 index e4854d9a7..000000000 --- a/test/java/org/apache/fop/text/linebreak/LineBreakStatusTestCase.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * 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.text.linebreak; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * JUnit test case for the LineBreakStatus class - */ -public class LineBreakStatusTestCase { - - /* - * These symbols are used to indicate the break action returned - * by the paragraph breaking. Their meaning is as per Unicode - * <a href="http://unicode.org/reports/tr14/#PairBasedImplementation">technical - * report #14</a>. - */ - private static final String BREAK_ACTION = "_%#@^!"; - - /** - * Test of reset method, of class org.apache.commons.text.linebreak.LineBreakStatus. - */ - @Test - public void testReset() { - System.out.println("testReset"); - // TODO - } - - /** - * Test of nextChar method, of class org.apache.commons.text.linebreak.LineBreakStatus. - * Runs tests for most of the Line Breaking Properties defined in the Unicode standard. - */ - @Test - public void testNextChar() { - System.out.println("testNextChar"); - - // AL -- Ordinary Alphabetic and Symbol Characters (XP) - assertTrue(testBreak( - "Nobreak", - "^^^^^^^" - )); - - // BA -- Break Opportunity After (A) - assertTrue(testBreak( - "Thin Space" + "\u2009" + "break", - "^^^^^%^^^^" + "^" + "_^^^^" - )); - - assertTrue(testBreak( - "Shy" + "\u00AD" + "break", - "^^^" + "^" + "_^^^^" - )); - - - // BB -- Break opportunites before characters (B) - assertTrue(testBreak( - "Acute Accent" + "\u00B4" + "break", - "^^^^^^%^^^^^" + "_" + "^^^^^" - )); - - // B2 -- Break Opportunity Before and After (B/A/XP) - assertTrue(testBreak( - "Em Dash" + "\u2014" + "break", - "^^^%^^^" + "_" + "_^^^^" - )); - - assertTrue(testBreak( - "Em Dash Dash" + "\u2014" + "\u2014" + "break", - "^^^%^^^^%^^^" + "_" + "^" + "_^^^^" - )); - - // BK Mandatory Break (A) -- normative - assertTrue(testBreak( - "Form Feed" + "\u000C" + "break", - "^^^^^%^^^" + "^" + "!^^^^" - )); - - assertTrue(testBreak( - "Line Separator" + "\u2028" + "break", - "^^^^^%^^^^^^^^" + "^" + "!^^^^" - )); - - assertTrue(testBreak( - "Paragraph Separator" + "\u2029" + "break", - "^^^^^^^^^^%^^^^^^^^" + "^" + "!^^^^" - )); - - // CB Contingent Break Opportunity (B/A) -- normative - // TODO Don't know quite what to do here - - // CL -- Closing Punctuation (XB) - assertTrue(testBreak( - "Right Parenthesis ) break", - "^^^^^^%^^^^^^^^^^^^^%^^^^" - )); - - // CM -- Attached Characters and Combining Marks (XB) -- normative - assertTrue(testBreak( - "Grave Accent" + "\u0300" + " break", - "^^^^^^%^^^^^" + "^" + "^%^^^^" - )); - - // CR -- Carriage Return (A) -- normative - assertTrue(testBreak( - "CR" + "\r" + "break", - "^^" + "^" + "!^^^^" - )); - - assertTrue(testBreak( - "CRLF" + "\r\n" + "break", - "^^^^" + "^^" + "!^^^^" - )); - - // EX -- Exclamation / interrogation (XB) - assertTrue(testBreak( - "EX CL ! ) break", - "^^^%^^^^^^%^^^^" - )); - - assertTrue(testBreak( - "EX Wave Dash ! " + "\u301C" + " break", - "^^^%^^^^%^^^^^^" + "%" + "^_^^^^" - )); - - // GL -- Non-breaking ("Glue") (XB/XA) -- normative - assertTrue(testBreak( - "No" + "\u00a0" + "break", - "^^" + "^" + "^^^^^" - )); - - assertTrue(testBreak( - "Non" + "\u2011" + " Hyphen", - "^^^" + "^" + "^%^^^^^" - )); - - // H2 -- Hangul LVT Syllable (B/A) - // TODO - - // H3 -- Hangul LVT Syllable (B/A) - // TODO - - // HY -- Hyphen Minus - assertTrue(testBreak( - "Normal-Hyphen", - "^^^^^^^_^^^^^" - )); - - assertTrue(testBreak( - "Normal - Hyphen", - "^^^^^^^%^_^^^^^" - )); - - assertTrue(testBreak( - "123-456", - "^^^^^^^" - )); - - assertTrue(testBreak( - "123 - 456", - "^^^^%^%^^" - )); - - // ID -- Ideographic (B/A) - assertTrue(testBreak( - "\u4E00" + "\u3000" + "\u4E02", - "^" + "_" + "_" - )); - - // IN -- Inseperable characters (XP) - assertTrue(testBreak( - "IN " + "\u2024" + "\u2025" + "\u2026", - "^^^" + "%" + "^" + "^" - )); - - // IS -- Numeric Separator (Infix) (XB) - assertTrue(testBreak( - "123,456.00 12:59", - "^^^^^^^^^^^%^^^^" - )); - - // JL -- Hangul L Jamo (B) - // TODO - - // JT -- Hangul T Jamo (A) - // TODO - - // JV -- Hangul V Jamo (XA/XB) - // TODO - - // LF -- Line Feed (A) -- normative - assertTrue(testBreak( - "Simple" + "\n" + "\n" + "break", - "^^^^^^" + "^" + "!" + "!^^^^" - )); - - // NL -- Next Line (A) -- normative - assertTrue(testBreak( - "NL" + "\u0085" + "break", - "^^" + "^" + "!^^^^" - )); - - // NS -- Non-starters (XB) - // TODO - - // NU -- Numeric (XP) - // Tested as part of IS - - // OP -- Opening Punctuation (XA) - assertTrue(testBreak( - "[ Bracket ( Parenthesis", - "^^^^^^^^^^%^^^^^^^^^^^^" - )); - - // PO -- Postfix (Numeric) (XB) - assertTrue(testBreak( - "(12.00)%", - "^^^^^^^^" - )); - - // PR -- Prefix (Numeric) (XA) - assertTrue(testBreak( - "$1000.00", - "^^^^^^^^" - )); - - // QU -- Ambiguous Quotation (XB/XA) - assertTrue(testBreak( - "'In Quotes'", - "^^^^%^^^^^^" - )); - - assertTrue(testBreak( - "' (In Quotes) '", - "^^^^^^%^^^^^^^%" - )); - - // SA -- Complex-context Dependent Characters (South East Asian) (P) - // TODO - - // SP -- Space (A) -- normative - assertTrue(testBreak( - "Simple break", - "^^^^^^^%^^^^" - )); - - assertTrue(testBreak( - "Simple break2", - "^^^^^^^^^^%^^^^^" - )); - - // SY -- Symbols Allowing Break After (A) - assertTrue(testBreak( - "http://xmlgraphics.apache.org/fop", - "^^^^^^^_^^^^^^^^^^^^^^^^^^^^^^_^^" - )); - - assertTrue(testBreak( - "1/2 31/10/2005", - "^^^^%^^^^^^^^^" - )); - - // WJ -- Word Joiner (XA/XB) -- (normative) - assertTrue(testBreak( - "http://" + "\u2060" + "xmlgraphics.apache.org/" + "\uFEFF" + "fop", - "^^^^^^^" + "^" + "^^^^^^^^^^^^^^^^^^^^^^^" + "^" + "^^^" - )); - - assertTrue(testBreak( - "Simple " + "\u2060" + "break", - "^^^^^^^" + "^" + "^^^^^" - )); - - assertTrue(testBreak( - "Simple" + "\u200B" + "\u2060" + "break", - "^^^^^^" + "^" + "_" + "^^^^^" - )); - - // XX -- Unknown (XP) - // TODO - - // ZW -- Zero Width Space (A) -- (normative) - assertTrue(testBreak( - "Simple" + "\u200B" + "break", - "^^^^^^" + "^" + "_^^^^" - )); - - // Unassigned codepoint: should yield same result as AL - assertTrue(testBreak( - "No" + "\u1F7E" + "break", - "^^" + "^" + "^^^^^" - )); - - } - - /** - * Tests the paragraph break status (break actions) returned from calling - * LineBreakStatus.nextChar() on each character of paragraph against - * the expected break actions. There must be a positional match between - * the characters in paragraph and characters in breakAction. - * @param paragraph The text to be analysed for line breaks - * @param breakActions The symbolic representation of the break actions - * expected to be returned. - */ - private boolean testBreak(String paragraph, String breakActions) { - boolean result = true; - int length = paragraph.length(); - LineBreakStatus lbs = new LineBreakStatus(); - for (int i = 0; i < length; i++) { - byte breakAction = lbs.nextChar(paragraph.charAt(i)); - if (BREAK_ACTION.charAt(breakAction) != breakActions.charAt(i)) { - System.err.println(paragraph); - System.err.println(breakActions); - System.err.println("pos = " + i - + " expected '" + breakActions.charAt(i) - + "' got '" + BREAK_ACTION.charAt(breakAction) + "'"); - result = false; - } - } - return result; - } -} diff --git a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTestCase.java b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTestCase.java deleted file mode 100644 index 5fc5c7d50..000000000 --- a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.text.linebreak; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * TODO add javadoc - * - * - */ -public class LineBreakUtilsTestCase { - - @Test - public void testLineBreakProperty() { - assertEquals(LineBreakUtils.getLineBreakProperty('A'), LineBreakUtils.LINE_BREAK_PROPERTY_AL); - assertEquals(LineBreakUtils.getLineBreakProperty('1'), LineBreakUtils.LINE_BREAK_PROPERTY_NU); - assertEquals(LineBreakUtils.getLineBreakProperty('\n'), LineBreakUtils.LINE_BREAK_PROPERTY_LF); - assertEquals(LineBreakUtils.getLineBreakProperty('\r'), LineBreakUtils.LINE_BREAK_PROPERTY_CR); - assertEquals(LineBreakUtils.getLineBreakProperty('('), LineBreakUtils.LINE_BREAK_PROPERTY_OP); - assertEquals(LineBreakUtils.getLineBreakProperty('\u1F7E'), 0); - } - - @Test - public void testLineBreakPair() { - assertEquals( - LineBreakUtils.getLineBreakPairProperty( - LineBreakUtils.LINE_BREAK_PROPERTY_CM, - LineBreakUtils.LINE_BREAK_PROPERTY_CL), - LineBreakUtils.PROHIBITED_BREAK); - assertEquals( - LineBreakUtils.getLineBreakPairProperty( - LineBreakUtils.LINE_BREAK_PROPERTY_CL, - LineBreakUtils.LINE_BREAK_PROPERTY_CM), - LineBreakUtils.COMBINING_INDIRECT_BREAK); - assertEquals( - LineBreakUtils.getLineBreakPairProperty( - LineBreakUtils.LINE_BREAK_PROPERTY_IS, - LineBreakUtils.LINE_BREAK_PROPERTY_PR), - LineBreakUtils.DIRECT_BREAK); - assertEquals( - LineBreakUtils.getLineBreakPairProperty( - LineBreakUtils.LINE_BREAK_PROPERTY_AL, - LineBreakUtils.LINE_BREAK_PROPERTY_OP), - LineBreakUtils.INDIRECT_BREAK); - assertEquals( - LineBreakUtils.getLineBreakPairProperty( - LineBreakUtils.LINE_BREAK_PROPERTY_LF, - LineBreakUtils.LINE_BREAK_PROPERTY_CM), - 0); - } - -} diff --git a/test/java/org/apache/fop/threading/AvalonAdapter.java b/test/java/org/apache/fop/threading/AvalonAdapter.java deleted file mode 100644 index 5074d6b70..000000000 --- a/test/java/org/apache/fop/threading/AvalonAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.threading; - -import org.apache.avalon.framework.logger.Logger; - -import org.apache.fop.events.Event; -import org.apache.fop.events.EventFormatter; -import org.apache.fop.events.EventListener; -import org.apache.fop.events.model.EventSeverity; - -/** - * Redirects events to an Avalon logger. - */ -class AvalonAdapter implements EventListener { - - private final Logger logger; - private String filename; - - public AvalonAdapter(Logger logger, String filename) { - this.logger = logger; - this.filename = filename; - } - - public void processEvent(Event event) { - String msg = EventFormatter.format(event); - EventSeverity severity = event.getSeverity(); - if (severity == EventSeverity.INFO) { - //logger.info(filename + ": " + msg); - } else if (severity == EventSeverity.WARN) { - //logger.warn(filename + ": " + msg); - } else if (severity == EventSeverity.ERROR) { - logger.error(filename + ": " + msg); - } else if (severity == EventSeverity.FATAL) { - logger.fatalError(filename + ": " + msg); - } else { - assert false; - } - } - -} diff --git a/test/java/org/apache/fop/threading/FOPTestbed.java b/test/java/org/apache/fop/threading/FOPTestbed.java deleted file mode 100644 index 7b08b7cd1..000000000 --- a/test/java/org/apache/fop/threading/FOPTestbed.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * 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.threading; - -import java.io.File; -import java.io.OutputStream; -import java.text.DecimalFormat; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamSource; - -import org.apache.avalon.framework.CascadingRuntimeException; -import org.apache.avalon.framework.activity.Executable; -import org.apache.avalon.framework.activity.Initializable; -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.container.ContainerUtil; -import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.commons.io.IOUtils; -import org.apache.commons.io.output.CountingOutputStream; -import org.apache.commons.io.output.NullOutputStream; - -/** - * Testbed for multi-threading tests. The class can run a configurable set of task a number of - * times in a configurable number of threads to easily reproduce multi-threading issues. - */ -public class FOPTestbed extends AbstractLogEnabled - implements Configurable, Initializable { - - private int repeat; - private List taskList = new java.util.ArrayList(); - private int threads; - private File outputDir; - private Configuration fopCfg; - private Processor foprocessor; - private boolean writeToDevNull; - - private int counter; - - private List results = Collections.synchronizedList(new java.util.LinkedList()); - - /** {@inheritDoc} */ - public void configure(Configuration configuration) throws ConfigurationException { - this.threads = configuration.getChild("threads").getValueAsInteger(10); - this.outputDir = new File(configuration.getChild("output-dir").getValue()); - this.writeToDevNull = configuration.getChild("devnull").getValueAsBoolean(false); - Configuration tasks = configuration.getChild("tasks"); - this.repeat = tasks.getAttributeAsInteger("repeat", 1); - Configuration[] entries = tasks.getChildren("task"); - for (int i = 0; i < entries.length; i++) { - this.taskList.add(new TaskDef(entries[i])); - } - this.fopCfg = configuration.getChild("processor"); - } - - /** {@inheritDoc} */ - public void initialize() throws Exception { - this.foprocessor = createFOProcessor(); - } - - /** - * Starts the stress test. - */ - public void doStressTest() { - getLogger().info("Starting stress test..."); - long start = System.currentTimeMillis(); - this.counter = 0; - - //Initialize threads - ThreadGroup workerGroup = new ThreadGroup("FOP workers"); - List threadList = new java.util.LinkedList(); - for (int ti = 0; ti < this.threads; ti++) { - TaskRunner runner = new TaskRunner(); - ContainerUtil.enableLogging(runner, getLogger()); - Thread thread = new Thread(workerGroup, runner, "Worker- " + ti); - threadList.add(thread); - } - - //Start threads - Iterator i = threadList.iterator(); - while (i.hasNext()) { - ((Thread)i.next()).start(); - } - - //Wait for threads to end - while (threadList.size() > 0) { - Thread t = (Thread)threadList.get(0); - if (!t.isAlive()) { - threadList.remove(0); - continue; - } - try { - Thread.sleep(100); - } catch (InterruptedException ie) { - //ignore - } - } - long duration = System.currentTimeMillis() - start; - - report(duration); - } - - private void report(long duration) { - int count = this.results.size(); - int failures = 0; - long bytesWritten = 0; - System.out.println("Report on " + count + " tasks:"); - Iterator iter = this.results.iterator(); - while (iter.hasNext()) { - Result res = (Result)iter.next(); - if (res.failure != null) { - System.out.println("FAIL: " + (res.end - res.start) + " " + res.task); - System.out.println(" -> " + res.failure.getMessage()); - failures++; - } else { - System.out.println("good: " + (res.end - res.start) + " " + res.filesize - + " " + res.task); - bytesWritten += res.filesize; - } - } - System.out.println("Stress test duration: " + duration + "ms"); - if (failures > 0) { - System.out.println(failures + " failures of " + count + " documents!!!"); - } else { - float mb = 1024f * 1024f; - System.out.println("Bytes written: " + (bytesWritten / mb) + " MB, " - + (bytesWritten * 1000 / duration) + " bytes / sec"); - System.out.println("NO failures with " + count + " documents."); - } - } - - private class TaskRunner extends AbstractLogEnabled implements Runnable { - - public void run() { - try { - for (int r = 0; r < repeat; r++) { - Iterator i = taskList.iterator(); - while (i.hasNext()) { - TaskDef def = (TaskDef)i.next(); - final Task task = new Task(def, counter++, foprocessor); - ContainerUtil.enableLogging(task, getLogger()); - task.execute(); - } - } - } catch (Exception e) { - getLogger().error("Thread ended with an exception", e); - } - } - - } - - /** - * Creates a new FOProcessor. - * @return the newly created instance - */ - public Processor createFOProcessor() { - try { - Class clazz = Class.forName(this.fopCfg.getAttribute("class", - "org.apache.fop.threading.FOProcessorImpl")); - Processor fop = (Processor)clazz.newInstance(); - ContainerUtil.enableLogging(fop, getLogger()); - ContainerUtil.configure(fop, this.fopCfg); - ContainerUtil.initialize(fop); - return fop; - } catch (Exception e) { - throw new CascadingRuntimeException("Error creating FO Processor", e); - } - } - - - private class TaskDef { - private String fo; - private String xml; - private String xslt; - private Templates templates; - - public TaskDef(String fo) { - this.fo = fo; - } - - public TaskDef(Configuration cfg) throws ConfigurationException { - this.fo = cfg.getAttribute("fo", null); - if (this.fo == null) { - this.xml = cfg.getAttribute("xml"); - this.xslt = cfg.getAttribute("xslt", null); - if (this.xslt != null) { - TransformerFactory factory = TransformerFactory.newInstance(); - Source xsltSource = new StreamSource(new File(xslt)); - try { - this.templates = factory.newTemplates(xsltSource); - } catch (TransformerConfigurationException tce) { - throw new ConfigurationException("Invalid XSLT", tce); - } - } - } - } - - public String getFO() { - return this.fo; - } - - public String getXML() { - return this.xml; - } - - public Templates getTemplates() { - return this.templates; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - if (this.fo != null) { - sb.append("fo="); - sb.append(this.fo); - } else { - sb.append("xml="); - sb.append(this.xml); - sb.append(" xslt="); - sb.append(this.xslt); - } - return sb.toString(); - } - } - - - private class Task extends AbstractLogEnabled implements Executable { - - private TaskDef def; - private int num; - private Processor fop; - - public Task(TaskDef def, int num, Processor fop) { - this.def = def; - this.num = num; - this.fop = fop; - } - - - public void execute() throws Exception { - getLogger().info("Processing: " + def); - long start = System.currentTimeMillis(); - try { - DecimalFormat df = new DecimalFormat("00000"); - File outfile = new File(outputDir, df.format(num) + fop.getTargetFileExtension()); - OutputStream out; - if (writeToDevNull) { - out = new NullOutputStream(); - } else { - out = new java.io.FileOutputStream(outfile); - out = new java.io.BufferedOutputStream(out); - } - CountingOutputStream cout = new CountingOutputStream(out); - try { - Source src; - Templates templates; - - if (def.getFO() != null) { - src = new StreamSource(new File(def.getFO())); - templates = null; - } else { - src = new StreamSource(new File(def.getXML())); - templates = def.getTemplates(); - } - fop.process(src, templates, cout); - } finally { - IOUtils.closeQuietly(cout); - } - results.add(new Result(def, start, System.currentTimeMillis(), - cout.getByteCount())); - } catch (Exception e) { - results.add(new Result(def, start, System.currentTimeMillis(), e)); - throw e; - } - } - } - - private static class Result { - - private TaskDef task; - private long start; - private long end; - private long filesize; - private Throwable failure; - - public Result(TaskDef task, long start, long end, long filesize) { - this(task, start, end, null); - this.filesize = filesize; - } - - public Result(TaskDef task, long start, long end, Throwable failure) { - this.task = task; - this.start = start; - this.end = end; - this.failure = failure; - } - } - -} diff --git a/test/java/org/apache/fop/threading/FOProcessorImpl.java b/test/java/org/apache/fop/threading/FOProcessorImpl.java deleted file mode 100644 index 721830aee..000000000 --- a/test/java/org/apache/fop/threading/FOProcessorImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.threading; - -import java.io.File; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; - -import org.xml.sax.SAXException; - -import org.apache.avalon.framework.activity.Initializable; -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.commons.io.FilenameUtils; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; - -/** - * Default implementation of the {@link Processor} interface using FOP. - */ -public class FOProcessorImpl extends AbstractLogEnabled - implements Processor, Configurable, Initializable { - - private FopFactory fopFactory; - private TransformerFactory factory = TransformerFactory.newInstance(); - private URI userconfig; - private String mime; - private String fileExtension; - - /** {@inheritDoc} */ - public void configure(Configuration configuration) throws ConfigurationException { - try { - this.userconfig = new URI(configuration.getChild("userconfig").getValue(null)); - this.mime = configuration.getChild("mime").getValue(MimeConstants.MIME_PDF); - this.fileExtension = configuration.getChild("extension").getValue(".pdf"); - } catch (URISyntaxException use) { - throw new RuntimeException(use); - } - } - - public void initialize() throws Exception { - if (this.userconfig != null) { - getLogger().debug("Setting user config: " + userconfig); - fopFactory = FopFactory.newInstance(new File(userconfig)); - } else { - fopFactory = FopFactory.newInstance(new File(".").toURI()); - } - } - - /** {@inheritDoc} - * @throws URISyntaxException - * @throws SAXException */ - public void process(Source src, Templates templates, OutputStream out) - throws java.io.IOException, URISyntaxException, SAXException { - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - - try { - URL url = new URL(src.getSystemId()); - String filename = FilenameUtils.getName(url.getPath()); - foUserAgent.getEventBroadcaster().addEventListener( - new AvalonAdapter(getLogger(), filename)); - } catch (MalformedURLException mfue) { - throw new RuntimeException(mfue); - } - Fop fop = fopFactory.newFop(this.mime, foUserAgent, out); - - try { - Transformer transformer; - if (templates == null) { - transformer = factory.newTransformer(); - } else { - transformer = templates.newTransformer(); - } - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - } catch (TransformerException e) { - throw new FOPException(e); - } - } - - /** {@inheritDoc} */ - public String getTargetFileExtension() { - return this.fileExtension; - } -} diff --git a/test/java/org/apache/fop/threading/IFProcessorImpl.java b/test/java/org/apache/fop/threading/IFProcessorImpl.java deleted file mode 100644 index 0dc87fa50..000000000 --- a/test/java/org/apache/fop/threading/IFProcessorImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.threading; - -import java.io.File; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamResult; - -import org.xml.sax.ContentHandler; - -import org.apache.avalon.framework.activity.Initializable; -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.commons.io.FilenameUtils; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFException; -import org.apache.fop.render.intermediate.IFParser; -import org.apache.fop.render.intermediate.IFUtil; - -/** - * Implementation of the {@link Processor} interface that renders IF XML to a final output format. - */ -public class IFProcessorImpl extends AbstractLogEnabled - implements Processor, Configurable, Initializable { - - private FopFactory fopFactory; - private TransformerFactory factory = TransformerFactory.newInstance(); - private String userconfig; - private String mime; - private String fileExtension; - - /** {@inheritDoc} */ - public void configure(Configuration configuration) throws ConfigurationException { - this.userconfig = configuration.getChild("userconfig").getValue(null); - this.mime = configuration.getChild("mime").getValue(MimeConstants.MIME_PDF); - this.fileExtension = configuration.getChild("extension").getValue(".pdf"); - } - - /** {@inheritDoc} */ - public void initialize() throws Exception { - if (this.userconfig != null) { - getLogger().debug("Setting user config: " + userconfig); - fopFactory = FopFactory.newInstance(new File(this.userconfig)); - } else { - fopFactory = FopFactory.newInstance(new File(".").toURI()); - } - } - - /** {@inheritDoc} - * @throws IFException */ - public void process(Source src, Templates templates, OutputStream out) - throws org.apache.fop.apps.FOPException, java.io.IOException, IFException { - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - try { - URL url = new URL(src.getSystemId()); - String filename = FilenameUtils.getName(url.getPath()); - foUserAgent.getEventBroadcaster().addEventListener( - new AvalonAdapter(getLogger(), filename)); - } catch (MalformedURLException mfue) { - throw new RuntimeException(mfue); - } - - //Setup target handler - IFDocumentHandler targetHandler = fopFactory.getRendererFactory().createDocumentHandler( - foUserAgent, mime); - - //Setup fonts - IFUtil.setupFonts(targetHandler); - targetHandler.setResult(new StreamResult(out)); - - try { - Transformer transformer; - if (templates == null) { - transformer = factory.newTransformer(); - } else { - transformer = templates.newTransformer(); - } - IFParser parser = new IFParser(); - ContentHandler contentHandler = parser.getContentHandler(targetHandler, foUserAgent); - Result res = new SAXResult(contentHandler); - transformer.transform(src, res); - } catch (TransformerException e) { - throw new FOPException(e); - } - } - - /** {@inheritDoc} */ - public String getTargetFileExtension() { - return this.fileExtension; - } - -} diff --git a/test/java/org/apache/fop/threading/Main.java b/test/java/org/apache/fop/threading/Main.java deleted file mode 100644 index d18ae405a..000000000 --- a/test/java/org/apache/fop/threading/Main.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.threading; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; - -import org.apache.avalon.framework.ExceptionUtil; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; -import org.apache.avalon.framework.container.ContainerUtil; -import org.apache.avalon.framework.logger.ConsoleLogger; - -/** - * Starter class for the multi-threading testbed. - */ -public final class Main { - - private Main() { - } - - private static void prompt() throws IOException { - BufferedReader in = new BufferedReader(new java.io.InputStreamReader(System.in)); - System.out.print("Press return to continue..."); - in.readLine(); - } - - /** - * Main method. - * @param args the command-line arguments - */ - public static void main(String[] args) { - try { - //Read configuration - File cfgFile = new File(args[0]); - DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); - Configuration cfg = builder.buildFromFile(cfgFile); - - boolean doPrompt = cfg.getAttributeAsBoolean("prompt", false); - if (doPrompt) { - prompt(); - } - - //Setup testbed - FOPTestbed testbed = new FOPTestbed(); - ContainerUtil.enableLogging(testbed, new ConsoleLogger(ConsoleLogger.LEVEL_INFO)); - ContainerUtil.configure(testbed, cfg); - ContainerUtil.initialize(testbed); - - //Start tests - testbed.doStressTest(); - - System.exit(0); - } catch (Exception e) { - System.err.println(ExceptionUtil.printStackTrace(e)); - System.exit(-1); - } - } -} diff --git a/test/java/org/apache/fop/threading/Processor.java b/test/java/org/apache/fop/threading/Processor.java deleted file mode 100644 index 2f37c02a1..000000000 --- a/test/java/org/apache/fop/threading/Processor.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.threading; - -import java.io.OutputStream; - -import javax.xml.transform.Source; -import javax.xml.transform.Templates; - -/** - * Represents a processor. - */ -public interface Processor { - - /** - * Process a file. - * @param src the Source for the FO or XML file - * @param templates a JAXP Templates object for an XSLT transformation or null - * @param out the OutputStream for the target file - * @throws Exception if an error occurs - */ - void process(Source src, Templates templates, OutputStream out) - throws Exception; - - /** - * Returns the target file extension for the configured output format. - * @return the target file extension (for example ".pdf") - */ - String getTargetFileExtension(); -} diff --git a/test/java/org/apache/fop/threading/sample.cfg.xml b/test/java/org/apache/fop/threading/sample.cfg.xml deleted file mode 100644 index a4de0d754..000000000 --- a/test/java/org/apache/fop/threading/sample.cfg.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<config prompt="false"> - <threads>2</threads> - <output-dir>C:/Dev/FOP/temp/out</output-dir> - <processor class="org.apache.fop.threading.FOProcessorImpl"> - <!-- - <userconfig>C:/Dev/FOP/temp/userconfig.xml</userconfig> - --> - <mime>application/pdf</mime> - <extension>.pdf</extension> - </processor> - <tasks repeat="2"> - <task fo="C:/Dev/FOP/temp/helloworld.fo"/> - <task xml="C:/Dev/FOP/temp/page-x-of-y.xml" xslt="C:/Dev/FOP/temp/page-x-of-y.xsl"/> - </tasks> -</config> diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java deleted file mode 100644 index 692e3059f..000000000 --- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.traits; - -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; - -/** - * Tests the BorderProps class. - */ -public class BorderPropsTestCase { - - /** - * Test serialization and deserialization to/from String. - * @throws Exception if an error occurs - */ - @Test - public void testSerialization() throws Exception { - 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)); - BorderProps sut = BorderProps.makeRectangular(Constants.EN_DOUBLE, 1250, col, - BorderProps.Mode.COLLAPSE_OUTER); - testSerialization(sut); - - float[] cmyk = new float[] {1.0f, 1.0f, 0.5f, 1.0f}; - col = DeviceCMYKColorSpace.createCMYKColor(cmyk); - //Convert to sRGB with CMYK alternative as constructed by the cmyk() function - float[] rgb = col.getRGBColorComponents(null); - col = new ColorWithAlternatives(rgb[0], rgb[1], rgb[2], new Color[] {col}); - sut = BorderProps.makeRectangular(Constants.EN_INSET, 9999, col, BorderProps.Mode.SEPARATE); - testSerialization(sut); - } - - /** - * Test serialization and deserialization to/from String. - * @throws Exception if an error occurs - */ - @Test - public void testSerializationWithCornerRadii() throws Exception { - 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()) { - BorderProps sut = BorderProps.makeRectangular(Constants.EN_SOLID, 10, col, mode); - testSerialization(sut); - sut = new BorderProps(Constants.EN_SOLID, 10, 4, 3, col, mode); - testSerialization(sut); - } - } - - private void testSerialization(BorderProps borderProp) { - assertEquals(borderProp, BorderProps.valueOf(null, borderProp.toString())); - } - -} diff --git a/test/java/org/apache/fop/traits/MinOptMaxTestCase.java b/test/java/org/apache/fop/traits/MinOptMaxTestCase.java deleted file mode 100644 index ba6862785..000000000 --- a/test/java/org/apache/fop/traits/MinOptMaxTestCase.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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.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; - -/** - * Tests the {@link MinOptMax} class. - */ -public class MinOptMaxTestCase { - - /** - * Tests that the constant <code>MinOptMax.ZERO</code> is really zero. - */ - @Test - public void testZero() { - assertEquals(MinOptMax.getInstance(0), MinOptMax.ZERO); - } - - @Test - public void testNewStiffMinOptMax() { - MinOptMax value = MinOptMax.getInstance(1); - assertTrue(value.isStiff()); - assertEquals(1, value.getMin()); - assertEquals(1, value.getOpt()); - assertEquals(1, value.getMax()); - } - - @Test - public void testNewMinOptMax() { - MinOptMax value = MinOptMax.getInstance(1, 2, 3); - assertTrue(value.isElastic()); - assertEquals(1, value.getMin()); - assertEquals(2, value.getOpt()); - assertEquals(3, value.getMax()); - } - - /** - * Test that it is possible to create stiff instances with the normal factory method. - */ - @Test - public void testNewMinOptMaxStiff() { - MinOptMax value = MinOptMax.getInstance(1, 1, 1); - assertTrue(value.isStiff()); - assertEquals(1, value.getMin()); - assertEquals(1, value.getOpt()); - assertEquals(1, value.getMax()); - } - - @Test - public void testNewMinOptMaxMinGreaterOpt() { - try { - MinOptMax.getInstance(1, 0, 2); - fail(); - } catch (IllegalArgumentException e) { - assertEquals("min (1) > opt (0)", e.getMessage()); - } - } - - @Test - public void testNewMinOptMaxMaxSmallerOpt() { - try { - MinOptMax.getInstance(0, 1, 0); - fail(); - } catch (IllegalArgumentException e) { - assertEquals("max (0) < opt (1)", e.getMessage()); - } - } - - @Test - public void testShrinkablility() { - assertEquals(0, MinOptMax.getInstance(1).getShrink()); - assertEquals(1, MinOptMax.getInstance(1, 2, 2).getShrink()); - assertEquals(2, MinOptMax.getInstance(1, 3, 3).getShrink()); - } - - @Test - public void testStrechablilty() { - assertEquals(0, MinOptMax.getInstance(1).getStretch()); - assertEquals(1, MinOptMax.getInstance(1, 1, 2).getStretch()); - assertEquals(2, MinOptMax.getInstance(1, 1, 3).getStretch()); - } - - @Test - public void testPlus() { - assertEquals(MinOptMax.ZERO, - MinOptMax.ZERO.plus(MinOptMax.ZERO)); - assertEquals(MinOptMax.getInstance(1, 2, 3), - MinOptMax.ZERO.plus(MinOptMax.getInstance(1, 2, 3))); - assertEquals(MinOptMax.getInstance(2, 4, 6), - MinOptMax.getInstance(1, 2, 3).plus(MinOptMax.getInstance(1, 2, 3))); - assertEquals(MinOptMax.getInstance(4, 5, 6), MinOptMax.getInstance(1, 2, 3).plus(3)); - } - - @Test - public void testMinus() { - assertEquals(MinOptMax.ZERO, - MinOptMax.ZERO.minus(MinOptMax.ZERO)); - assertEquals(MinOptMax.getInstance(1, 2, 3), - MinOptMax.getInstance(1, 2, 3).plus(MinOptMax.ZERO)); - assertEquals(MinOptMax.getInstance(1, 2, 3), - MinOptMax.getInstance(2, 4, 6).minus(MinOptMax.getInstance(1, 2, 3))); - assertEquals(MinOptMax.getInstance(1, 2, 3), MinOptMax.getInstance(5, 6, 7).minus(4)); - } - - @Test - public void testMinusFail1() { - try { - MinOptMax.ZERO.minus(MinOptMax.getInstance(1, 2, 3)); - fail(); - } catch (ArithmeticException e) { - // Ok - } - } - - @Test - public void testMinusFail2() { - try { - MinOptMax.getInstance(1, 2, 3).minus(MinOptMax.getInstance(1, 3, 3)); - fail(); - } catch (ArithmeticException e) { - // Ok - } - } - - @Test - public void testMinusFail3() { - try { - MinOptMax.ZERO.minus(MinOptMax.getInstance(1, 1, 2)); - fail(); - } catch (ArithmeticException e) { - // Ok - } - } - - @Test - public void testMinusFail4() { - try { - MinOptMax.getInstance(1, 2, 3).minus(MinOptMax.getInstance(1, 1, 3)); - fail(); - } catch (ArithmeticException e) { - // Ok - } - } - - @Test - public void testMult() { - assertEquals(MinOptMax.ZERO, MinOptMax.ZERO.mult(0)); - assertEquals(MinOptMax.getInstance(1, 2, 3), MinOptMax.getInstance(1, 2, 3).mult(1)); - assertEquals(MinOptMax.getInstance(2, 4, 6), MinOptMax.getInstance(1, 2, 3).mult(2)); - } - - @Test - public void testMultFail() { - try { - MinOptMax.getInstance(1, 2, 3).mult(-1); - fail(); - } catch (IllegalArgumentException e) { - assertEquals("factor < 0; was: -1", e.getMessage()); - } - } - - @Test - public void testNonZero() { - assertFalse(MinOptMax.ZERO.isNonZero()); - assertTrue(MinOptMax.getInstance(1).isNonZero()); - assertTrue(MinOptMax.getInstance(1, 2, 3).isNonZero()); - } - - @Test - public void testExtendMinimum() { - assertEquals(MinOptMax.getInstance(1, 1, 1), - MinOptMax.ZERO.extendMinimum(1)); - assertEquals(MinOptMax.getInstance(1, 2, 3), - MinOptMax.getInstance(1, 2, 3).extendMinimum(1)); - assertEquals(MinOptMax.getInstance(2, 2, 3), - MinOptMax.getInstance(1, 2, 3).extendMinimum(2)); - assertEquals(MinOptMax.getInstance(3, 3, 3), - MinOptMax.getInstance(1, 2, 3).extendMinimum(3)); - assertEquals(MinOptMax.getInstance(4, 4, 4), - MinOptMax.getInstance(1, 2, 3).extendMinimum(4)); - } - - @Test - public void testEquals() { - MinOptMax number = MinOptMax.getInstance(1, 3, 5); - assertEquals(number, number); - assertEquals(number, MinOptMax.getInstance(1, 3, 5)); - assertFalse(number.equals(MinOptMax.getInstance(2, 3, 5))); - assertFalse(number.equals(MinOptMax.getInstance(1, 4, 5))); - assertFalse(number.equals(MinOptMax.getInstance(1, 3, 4))); - assertFalse(number.equals(null)); - assertFalse(number.equals(new Integer(1))); - } - - @Test - public void testHashCode() { - MinOptMax number = MinOptMax.getInstance(1, 2, 3); - assertEquals(number.hashCode(), number.hashCode()); - assertEquals(number.hashCode(), MinOptMax.getInstance(1, 2, 3).hashCode()); - } -} diff --git a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java b/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java deleted file mode 100644 index 5e75f2563..000000000 --- a/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * 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.util; - -import java.util.Map; - -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. - */ -public class AdvancedMessageFormatTestCase { - - @Test - public void testFormatting() throws Exception { - String msg; - AdvancedMessageFormat format; - - String pattern - = "Element \"{elementName}\" is missing[ required property \"{propertyName}\"]!"; - format = new AdvancedMessageFormat(pattern); - - Map params = new java.util.HashMap(); - params.put("node", new Object()); - params.put("elementName", "fo:external-graphic"); - params.put("propertyName", "src"); - - msg = format.format(params); - assertEquals("Element \"fo:external-graphic\" is missing required property \"src\"!", msg); - - params.remove("propertyName"); - msg = format.format(params); - assertEquals("Element \"fo:external-graphic\" is missing!", msg); - - pattern - = "Testing \\{escaped \\[characters\\], now a normal field {elementName}!"; - format = new AdvancedMessageFormat(pattern); - msg = format.format(params); - assertEquals("Testing {escaped [characters], now a normal field fo:external-graphic!", msg); - - pattern = "Multi-conditional: [case1: {var1}|case2: {var2}|case3: {var3}]"; - format = new AdvancedMessageFormat(pattern); - - params = new java.util.HashMap(); - msg = format.format(params); - assertEquals("Multi-conditional: ", msg); - - params.put("var3", "value3"); - msg = format.format(params); - assertEquals("Multi-conditional: case3: value3", msg); - params.put("var1", "value1"); - msg = format.format(params); - assertEquals("Multi-conditional: case1: value1", msg); - } - - @Test - public void testObjectFormatting() throws Exception { - String msg; - AdvancedMessageFormat format; - - String pattern - = "Here's a Locator: {locator}"; - format = new AdvancedMessageFormat(pattern); - - Map params = new java.util.HashMap(); - LocatorImpl loc = new LocatorImpl(); - loc.setColumnNumber(7); - loc.setLineNumber(12); - params.put("locator", loc); - - msg = format.format(params); - assertEquals("Here\'s a Locator: 12:7", msg); - } - - @Test - public void testIfFormatting() throws Exception { - String msg; - AdvancedMessageFormat format; - - format = new AdvancedMessageFormat("You are{isBad,if, not} nice!"); - - Map params = new java.util.HashMap(); - - params.put("isBad", Boolean.FALSE); - msg = format.format(params); - assertEquals("You are nice!", msg); - - params.put("isBad", Boolean.TRUE); - msg = format.format(params); - assertEquals("You are not nice!", msg); - - format = new AdvancedMessageFormat("You are{isGood,if, very, not so} nice!"); - - params = new java.util.HashMap(); - - msg = format.format(params); //isGood is missing - assertEquals("You are not so nice!", msg); - - params.put("isGood", Boolean.FALSE); - msg = format.format(params); - assertEquals("You are not so nice!", msg); - - params.put("isGood", Boolean.TRUE); - msg = format.format(params); - assertEquals("You are very nice!", msg); - - format = new AdvancedMessageFormat("You are{isGood,if, very\\, very} nice!"); - - params = new java.util.HashMap(); - - msg = format.format(params); //isGood is missing - assertEquals("You are nice!", msg); - - params.put("isGood", Boolean.FALSE); - msg = format.format(params); - assertEquals("You are nice!", msg); - - params.put("isGood", Boolean.TRUE); - msg = format.format(params); - assertEquals("You are very, very nice!", msg); - } - - @Test - public void testEqualsFormatting() throws Exception { - String msg; - AdvancedMessageFormat format; - - format = new AdvancedMessageFormat( - "Error{severity,equals,EventSeverity:FATAL,,\nSome explanation!}"); - - Map params = new java.util.HashMap(); - - params.put("severity", EventSeverity.FATAL); - msg = format.format(params); - assertEquals("Error", msg); - - params.put("severity", EventSeverity.WARN); - msg = format.format(params); - assertEquals("Error\nSome explanation!", msg); - } - - @Test - public void testChoiceFormatting() throws Exception { - String msg; - AdvancedMessageFormat format; - - format = new AdvancedMessageFormat( - "You have {amount,choice,0#nothing|0<{amount} bucks|100<more than enough}."); - - Map params = new java.util.HashMap(); - - params.put("amount", new Integer(0)); - msg = format.format(params); - assertEquals("You have nothing.", msg); - - params.put("amount", new Integer(7)); - msg = format.format(params); - assertEquals("You have 7 bucks.", msg); - - params.put("amount", new Integer(140)); - msg = format.format(params); - assertEquals("You have more than enough.", msg); - - } - -} diff --git a/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java b/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java deleted file mode 100644 index 8bda99785..000000000 --- a/test/java/org/apache/fop/util/BitmapImageUtilTestCase.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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.util; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.awt.image.RenderedImage; -import java.io.File; -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.xmlgraphics.image.writer.ImageWriterUtil; -import org.apache.xmlgraphics.util.WriterOutputStream; -import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream; - -import org.apache.fop.util.bitmap.BitmapImageUtil; -import org.apache.fop.util.bitmap.MonochromeBitmapConverter; - -/** - * Tests {@link BitmapImageUtil}. - */ -public class BitmapImageUtilTestCase { - - private static final boolean DEBUG = true; - private static final boolean TEST_PIXELS = false; - - /** - * Tests the convertTo* methods. - * @throws Exception if an error occurs - */ - @Test - public void testConvertToMono() throws Exception { - BufferedImage testImage = createTestImage(); - saveAsPNG(testImage, "test-image"); - - RenderedImage img; - Dimension scaled = new Dimension(320, 240); - - img = BitmapImageUtil.convertToGrayscale(testImage, null); - saveAsPNG(img, "out-gray"); - assertEquals(1, img.getColorModel().getNumComponents()); - assertEquals(8, img.getColorModel().getPixelSize()); - assertEquals(640, img.getWidth()); - assertEquals(480, img.getHeight()); - assertPixels("5757575757575757575757FFFFFFFFFF", img, 220, 34, 16); - - img = BitmapImageUtil.convertToGrayscale(testImage, scaled); - saveAsPNG(img, "out-gray-scaled"); - assertEquals(1, img.getColorModel().getNumComponents()); - assertEquals(8, img.getColorModel().getPixelSize()); - assertEquals(320, img.getWidth()); - assertEquals(240, img.getHeight()); - - img = BitmapImageUtil.convertToMonochrome(testImage, null); - saveAsPNG(img, "out-mono"); - assertEquals(1, img.getColorModel().getPixelSize()); - assertEquals(640, img.getWidth()); - assertEquals(480, img.getHeight()); - assertPixels("00000000000000000000000101010101", img, 220, 34, 16); - - if (isJAIAvailable()) { - img = BitmapImageUtil.convertToMonochrome(testImage, null, 0.5f); - saveAsPNG(img, "out-mono-jai-0.5"); - assertEquals(1, img.getColorModel().getPixelSize()); - assertEquals(640, img.getWidth()); - assertEquals(480, img.getHeight()); - assertPixels("00010000000100000001000101010101", img, 220, 34, 16); - - img = BitmapImageUtil.convertToMonochrome(testImage, null, 1.0f); - saveAsPNG(img, "out-mono-jai-1.0"); - assertEquals(1, img.getColorModel().getPixelSize()); - assertEquals(640, img.getWidth()); - assertEquals(480, img.getHeight()); - assertPixels("01000001000001000001000101010101", img, 220, 34, 16); - } - } - - private void assertPixels(String expected, RenderedImage img, int x, int y, int w) - throws IOException { - if (TEST_PIXELS) { - byte[] byteArray = (byte[])img.getData().getDataElements(x, y, w, 1, new byte[w]); - assertEquals(expected, toHex(byteArray)); - } - } - - private boolean isJAIAvailable() { - MonochromeBitmapConverter converter - = BitmapImageUtil.createDefaultMonochromeBitmapConverter(); - return converter.getClass().getName().contains("JAI"); - } - - private void saveAsPNG(RenderedImage img, String name) throws IOException { - if (DEBUG) { - File baseDir = new File("./build/test-results/bitmap-conversion"); - baseDir.mkdirs(); - ImageWriterUtil.saveAsPNG(img, new File(baseDir, name + ".png")); - } - } - - private String toHex(byte[] byteArray) throws IOException { - InputStream in = new java.io.ByteArrayInputStream(byteArray); - StringWriter writer = new StringWriter(); - WriterOutputStream wo = new WriterOutputStream(writer, "US-ASCII"); - ASCIIHexOutputStream hex = new ASCIIHexOutputStream(wo); - IOUtils.copyLarge(in, hex); - return writer.toString(); - } - - private BufferedImage createTestImage() { - BufferedImage buf = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB); - Graphics2D g2d = buf.createGraphics(); - g2d.setBackground(Color.WHITE); - g2d.clearRect(0, 0, buf.getWidth(), buf.getHeight()); - - //A few rectangles rotated and with different color - Graphics2D copy = (Graphics2D)g2d.create(); - copy.translate(170, 170); - int c = 12; - for (int i = 0; i < c; i++) { - float f = ((i + 1) / (float)c); - Color col = new Color(0.0f, 1 - f, 0.0f); - copy.setColor(col); - copy.fillRect(0, 0, 120, 120); - copy.rotate(-2 * Math.PI / c); - } - copy.dispose(); - - //the same in gray scales - copy = (Graphics2D)g2d.create(); - copy.translate(470, 310); - c = 12; - for (int i = 0; i < c; i++) { - float f = ((i + 1) / (float)c); - Color col = new Color(f, f, f); - copy.setColor(col); - copy.fillRect(0, 0, 120, 120); - copy.rotate(-2 * Math.PI / c); - } - copy.dispose(); - return buf; - } - -} diff --git a/test/java/org/apache/fop/util/ColorUtilTestCase.java b/test/java/org/apache/fop/util/ColorUtilTestCase.java deleted file mode 100644 index c86ebbeac..000000000 --- a/test/java/org/apache/fop/util/ColorUtilTestCase.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * 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.util; - -import java.awt.Color; -import java.awt.color.ColorSpace; -import java.io.File; -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; -import org.apache.xmlgraphics.java2d.color.RenderingIntent; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; - -/** - * Tests the ColorUtil class. - */ -public class ColorUtilTestCase { - private FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - - /** - * Test serialization to String. - * @throws Exception if an error occurs - */ - @Test - public void testSerialization() throws Exception { - Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f); - String s = ColorUtil.colorToString(col); - - //This is what the old color spit out. Now it is 80 due to rounding - //assertEquals("#ffff7f", s); - assertEquals("#ffff80", s); - - col = new Color(1.0f, 0.0f, 0.0f, 0.8f); - s = ColorUtil.colorToString(col); - assertEquals("#ff0000cc", s); - } - - /** - * Test deserialization from String. - * @throws Exception if an error occurs - */ - @Test - public void testDeserialization() throws Exception { - Color col = ColorUtil.parseColorString(null, "#ffff7f"); - assertEquals(255, col.getRed()); - assertEquals(255, col.getGreen()); - assertEquals(127, col.getBlue()); - assertEquals(255, col.getAlpha()); - - col = ColorUtil.parseColorString(null, "#ff0000cc"); - assertEquals(255, col.getRed()); - assertEquals(0, col.getGreen()); - assertEquals(0, col.getBlue()); - assertEquals(204, col.getAlpha()); - } - - /** - * Test equals(). - * @throws Exception if an error occurs - */ - @Test - public void testEquals() throws Exception { - Color col1 = ColorUtil.parseColorString(null, "#ff0000cc"); - Color col2 = ColorUtil.parseColorString(null, "#ff0000cc"); - assertEquals(col1, col2); - - col1 = ColorUtil.parseColorString(null, "fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.0,0.0,0.0,0.5)"); - /* The following doesn't work since java.awt.Color from Sun doesn't round consistently - col2 = ColorUtil.parseColorString(null, "cmyk(0.0,0.0,0.0,0.5)"); - assertEquals(col1, col2); - */ - - col2 = ColorUtil.parseColorString(null, "fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.5,0.5,0.5,0.0)"); - assertTrue(col1.equals(col2)); - assertFalse(org.apache.xmlgraphics.java2d.color.ColorUtil.isSameColor(col1, col2)); - } - - /** - * Tests the rgb() function. - * @throws Exception if an error occurs - */ - @Test - public void testRGB() throws Exception { - - FOUserAgent ua = fopFactory.newFOUserAgent(); - Color colActual; - - colActual = ColorUtil.parseColorString(ua, "rgb(255, 40, 0)"); - assertEquals(255, colActual.getRed()); - assertEquals(40, colActual.getGreen()); - assertEquals(0, colActual.getBlue()); - assertEquals(255, colActual.getAlpha()); - assertEquals(ColorSpace.getInstance(ColorSpace.CS_sRGB), colActual.getColorSpace()); - } - - /** - * Tests the fop-rgb-icc() function. - * @throws Exception if an error occurs - */ - @Test - public void testRGBICC() throws Exception { - FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); - URI sRGBLoc = new URI("src/java/org/apache/fop/pdf/sRGB%20Color%20Space%20Profile.icm"); - ColorSpace cs = fopFactory.getColorSpaceCache().get( - "sRGBAlt", sRGBLoc.toASCIIString(), RenderingIntent.AUTO); - assertNotNull("Color profile not found", cs); - - FOUserAgent ua = fopFactory.newFOUserAgent(); - ColorWithFallback colActual; - - //fop-rgb-icc() is used instead of rgb-icc() inside FOP! - String colSpec = "fop-rgb-icc(1.0,0.0,0.0,sRGBAlt," - + "\"" + sRGBLoc.toASCIIString() + "\",1.0,0.0,0.0)"; - colActual = (ColorWithFallback)ColorUtil.parseColorString(ua, colSpec); - assertEquals(cs, colActual.getColorSpace()); - assertEquals(255, colActual.getRed(), 2f); //Java 5: 253, Java 6: 255 - assertEquals(0, colActual.getGreen(), 25f); //Java 5: 25, Java 6: 0 - assertEquals(0, colActual.getBlue()); - //I don't understand the difference. Maybe Java's sRGB and HP's sRGB are somehow not - //equivalent. This is only going to be a problem if anyone actually makes use of the - //RGB fallback in any renderer. - //TODO Anyone know what's going on here? - float[] comps = colActual.getColorComponents(null); - assertEquals(3, comps.length); - assertEquals(1f, comps[0], 0); - assertEquals(0f, comps[1], 0); - assertEquals(0f, comps[2], 0); - assertEquals(0, colActual.getAlternativeColors().length); - - Color fallback = colActual.getFallbackColor(); - assertTrue(fallback.getColorSpace().isCS_sRGB()); - assertEquals(255, fallback.getRed()); - assertEquals(0, fallback.getGreen()); - assertEquals(0, fallback.getBlue()); - - assertEquals(colSpec, ColorUtil.colorToString(colActual)); - - colSpec = "fop-rgb-icc(1.0,0.5,0.0,blah," - + "\"invalid.icm\",1.0,0.5,0.0,0.15)"; - Color colFallback = ColorUtil.parseColorString(ua, colSpec); - assertEquals(new Color(1.0f, 0.5f, 0.0f), colFallback); - } - - /** - * Tests the cmyk() function. - * @throws Exception if an error occurs - */ - @Test - public void testCMYK() throws Exception { - ColorWithAlternatives colActual; - String colSpec; - - colSpec = "cmyk(0.0, 0.0, 1.0, 0.0)"; - colActual = (ColorWithAlternatives)ColorUtil.parseColorString(null, colSpec); - assertEquals(255, colActual.getRed()); - assertEquals(255, colActual.getGreen()); - assertEquals(0, colActual.getBlue()); - Color alt = colActual.getAlternativeColors()[0]; - assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), alt.getColorSpace()); - float[] comps = alt.getColorComponents(null); - assertEquals(4, comps.length); - assertEquals(0f, comps[0], 0); - assertEquals(0f, comps[1], 0); - assertEquals(1f, comps[2], 0); - assertEquals(0f, comps[3], 0); - assertEquals("fop-rgb-icc(1.0,1.0,0.0,#CMYK,,0.0,0.0,1.0,0.0)", - ColorUtil.colorToString(colActual)); - - colSpec = "cmyk(0.0274, 0.2196, 0.3216, 0.0)"; - colActual = (ColorWithAlternatives)ColorUtil.parseColorString(null, colSpec); - assertEquals(248, colActual.getRed(), 1); - assertEquals(199, colActual.getGreen(), 1); - assertEquals(172, colActual.getBlue(), 1); - alt = colActual.getAlternativeColors()[0]; - assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), alt.getColorSpace()); - comps = alt.getColorComponents(null); - assertEquals(0.0274f, comps[0], 0.001); - assertEquals(0.2196f, comps[1], 0.001); - assertEquals(0.3216f, comps[2], 0.001); - assertEquals(0f, comps[3], 0); - assertEquals("fop-rgb-icc(0.9726,0.7804,0.67840004,#CMYK,,0.0274,0.2196,0.3216,0.0)", - ColorUtil.colorToString(colActual)); - - colSpec = "fop-rgb-icc(1.0,1.0,0.0,#CMYK,,0.0,0.0,1.0,0.0)"; - colActual = (ColorWithAlternatives)ColorUtil.parseColorString(null, colSpec); - assertEquals(255, colActual.getRed()); - assertEquals(255, colActual.getGreen()); - assertEquals(0, colActual.getBlue()); - alt = colActual.getAlternativeColors()[0]; - assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), alt.getColorSpace()); - comps = alt.getColorComponents(null); - assertEquals(4, comps.length); - assertEquals(0f, comps[0], 0); - assertEquals(0f, comps[1], 0); - assertEquals(1f, comps[2], 0); - assertEquals(0f, comps[3], 0); - assertEquals("fop-rgb-icc(1.0,1.0,0.0,#CMYK,,0.0,0.0,1.0,0.0)", - ColorUtil.colorToString(colActual)); - - colSpec = "fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.0,0.0,0.0,0.5)"; - colActual = (ColorWithAlternatives)ColorUtil.parseColorString(null, colSpec); - assertEquals(127, colActual.getRed(), 1); - assertEquals(127, colActual.getGreen(), 1); - assertEquals(127, colActual.getBlue(), 1); - alt = colActual.getAlternativeColors()[0]; - assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), alt.getColorSpace()); - comps = alt.getColorComponents(null); - assertEquals(4, comps.length); - assertEquals(0f, comps[0], 0); - assertEquals(0f, comps[1], 0); - assertEquals(0f, comps[2], 0); - assertEquals(0.5f, comps[3], 0); - assertEquals("fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.0,0.0,0.0,0.5)", - ColorUtil.colorToString(colActual)); - - //Verify that the cmyk() and fop-rgb-icc(#CMYK) functions have the same results - ColorWithAlternatives colCMYK = (ColorWithAlternatives)ColorUtil.parseColorString( - null, "cmyk(0,0,0,0.5)"); - assertEquals(colCMYK.getAlternativeColors()[0], colActual.getAlternativeColors()[0]); - //The following doesn't work: - //assertEquals(colCMYK, colActual); - //java.awt.Color does not consistenly calculate the int RGB values: - //Color(ColorSpace cspace, float components[], float alpha): 0.5 --> 127 - //Color(float r, float g, float b): 0.5 --> 128 - if (!colCMYK.equals(colActual)) { - System.out.println("Info: java.awt.Color does not consistently calculate" - + " int RGB values from float RGB values."); - } - } - - /** - * Tests color for the #Separation pseudo-colorspace. - * @throws Exception if an error occurs - */ - @Test - public void testSeparationColor() throws Exception { - ColorWithFallback colActual; - String colSpec; - - colSpec = "fop-rgb-icc(1.0,0.8,0.0,#Separation,,Postgelb)"; - colActual = (ColorWithFallback)ColorUtil.parseColorString(null, colSpec); - assertEquals(255, colActual.getRed(), 5); - assertEquals(204, colActual.getGreen(), 3); - assertEquals(0, colActual.getBlue(), 12); - //sRGB results differ between JDKs - - Color fallback = colActual.getFallbackColor(); - assertEquals(255, fallback.getRed()); - assertEquals(204, fallback.getGreen()); - assertEquals(0, fallback.getBlue()); - - assertFalse(colActual.hasAlternativeColors()); - - assertTrue(colActual.getColorSpace() instanceof NamedColorSpace); - NamedColorSpace ncs; - ncs = (NamedColorSpace)colActual.getColorSpace(); - assertEquals("Postgelb", ncs.getColorName()); - float[] comps = colActual.getColorComponents(null); - assertEquals(1, comps.length); - assertEquals(1f, comps[0], 0); - assertEquals(colSpec, ColorUtil.colorToString(colActual)); - - } - - /** - * Tests the fop-rgb-named-color() function. - * @throws Exception if an error occurs - */ - @Test - public void testNamedColorProfile() throws Exception { - FopFactory fopFactory = FopFactory.newInstance(new File("./").toURI()); - URI ncpLoc = new URI("test/resources/color/ncp-example.icc"); - ColorSpace cs = fopFactory.getColorSpaceCache().get( - "NCP", ncpLoc.toASCIIString(), RenderingIntent.AUTO); - assertNotNull("Color profile not found", cs); - - FOUserAgent ua = fopFactory.newFOUserAgent(); - ColorWithFallback colActual; - - //fop-rgb-named-color() is used instead of rgb-named-color() inside FOP! - String colSpec = "fop-rgb-named-color(1.0,0.8,0.0,NCP," - + "\"" + ncpLoc.toASCIIString() + "\",Postgelb)"; - colActual = (ColorWithFallback)ColorUtil.parseColorString(ua, colSpec); - assertEquals(255, colActual.getRed(), 2); - assertEquals(193, colActual.getGreen(), 2); - assertEquals(0, colActual.getBlue()); - - Color fallback = colActual.getFallbackColor(); - assertEquals(255, fallback.getRed()); - assertEquals(204, fallback.getGreen()); - assertEquals(0, fallback.getBlue()); - assertEquals(ColorSpace.getInstance(ColorSpace.CS_sRGB), fallback.getColorSpace()); - - float[] comps = fallback.getColorComponents(null); - assertEquals(3, comps.length); - assertEquals(1f, comps[0], 0); - assertEquals(0.8f, comps[1], 0); - assertEquals(0f, comps[2], 0); - - assertTrue(colActual.getColorSpace() instanceof NamedColorSpace); - NamedColorSpace ncs; - ncs = (NamedColorSpace)colActual.getColorSpace(); - assertEquals("Postgelb", ncs.getColorName()); - comps = colActual.getColorComponents(null); - assertEquals(1, comps.length); - assertEquals(1f, comps[0], 0); - - assertEquals(colSpec, ColorUtil.colorToString(colActual)); - } -} diff --git a/test/java/org/apache/fop/util/CompareUtilTestCase.java b/test/java/org/apache/fop/util/CompareUtilTestCase.java deleted file mode 100644 index e0f769afc..000000000 --- a/test/java/org/apache/fop/util/CompareUtilTestCase.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.util; - -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; - -public class CompareUtilTestCase { - - @Test - public void testEqual() { - int numberOfParallelThreads = Runtime.getRuntime().availableProcessors(); - long numberOfEqualOperations = 100; - double probabilityOf12 = 0.5; - - ExecutorService executor = Executors.newFixedThreadPool(numberOfParallelThreads); - - final Vector object1 = new Vector(); - object1.add(new Object()); - object1.add(new Object()); - object1.add(new Object()); - object1.add(new Object()); - object1.add(new Object()); - final Vector object2 = new Vector(); - object2.add(new Object()); - object2.add(new Object()); - object2.add(new Object()); - object2.add(new Object()); - object2.add(new Object()); - object2.add(new Object()); - object2.add(new Object()); - object2.add(new Object()); - object2.add(new Object()); - object2.add(new Object()); - final boolean areEqual = object1.equals(object2); - final AtomicBoolean wrongResult = new AtomicBoolean(false); - - Runnable equal12 = new Runnable() { - public void run() { - if (areEqual != CompareUtil.equal(object1, object2)) { - wrongResult.set(true); - } - } - }; - Runnable equal21 = new Runnable() { - public void run() { - if (areEqual != CompareUtil.equal(object2, object1)) { - wrongResult.set(true); - } - } - }; - - List<Future<?>> futures = new ArrayList<Future<?>>(); - for (int i = 1; i <= numberOfEqualOperations; i++) { - Runnable randomTask = Math.random() < probabilityOf12 ? equal12 : equal21; - futures.add(executor.submit(randomTask)); - } - - Exception exception = null; - try { - for (Future<?> future : futures) { - future.get(); - } - } catch (Exception e) { - exception = e; - } - - assertNull(exception); - assertFalse(wrongResult.get()); - } -} diff --git a/test/java/org/apache/fop/util/ConsoleEventListenerForTests.java b/test/java/org/apache/fop/util/ConsoleEventListenerForTests.java deleted file mode 100644 index 24a797648..000000000 --- a/test/java/org/apache/fop/util/ConsoleEventListenerForTests.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.util; - -import org.apache.fop.events.Event; -import org.apache.fop.events.EventFormatter; -import org.apache.fop.events.EventListener; -import org.apache.fop.events.model.EventSeverity; - -/** A simple event listener that writes the events to stdout and sterr. */ -public class ConsoleEventListenerForTests implements EventListener { - - private String name; - private EventSeverity logLevel; - - /** - * Creates a new event listener with console output on severity INFO. This object will - * write out the name of the test before the first log message. - * @param name the name of the test - */ - public ConsoleEventListenerForTests(String name) { - this(name, EventSeverity.INFO); - } - - /** - * Creates a new event listener with console output. This object will - * write out the name of the test before the first log message. - * @param name the name of the test - * @param logLevel the logging level - */ - public ConsoleEventListenerForTests(String name, EventSeverity logLevel) { - this.name = name; - this.logLevel = logLevel; - } - - /** {@inheritDoc} */ - public void processEvent(Event event) { - EventSeverity severity = event.getSeverity(); - if (severity == EventSeverity.FATAL) { - log("FATAL", event); - return; - } - if (logLevel == EventSeverity.FATAL) { - return; - } - if (severity == EventSeverity.ERROR) { - log("ERROR", event); - return; - } - if (logLevel == EventSeverity.ERROR) { - return; - } - if (severity == EventSeverity.WARN) { - log("WARN ", event); - } - if (logLevel == EventSeverity.WARN) { - return; - } - if (severity == EventSeverity.INFO) { - log("INFO ", event); - } - } - - private void log(String levelString, Event event) { - if (this.name != null) { - System.out.println("Test: " + this.name); - this.name = null; - } - String msg = EventFormatter.format(event); - System.out.println(" [" + levelString + "] " + msg); - } -} diff --git a/test/java/org/apache/fop/util/DigestFilter.java b/test/java/org/apache/fop/util/DigestFilter.java deleted file mode 100644 index 9e62fdc1c..000000000 --- a/test/java/org/apache/fop/util/DigestFilter.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.util; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeMap; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.helpers.XMLFilterImpl; - -/** - * SAX filter which produces a digest over the XML elements. - * Insignificant whitespace as determined by the, comments and - * processing instructions are not part of the digest. - * If the filter is namespace aware, the URI and local name for - * each element is digested, otherwise the QName. Attributes are - * sorted before the name-value pairs are digested. - * - */ -public class DigestFilter extends XMLFilterImpl { - - private MessageDigest digest; - private byte[] value; - private boolean isNamespaceAware; - - public DigestFilter(String algorithm) throws NoSuchAlgorithmException { - digest = MessageDigest.getInstance(algorithm); - } - - public byte[] getDigestValue() { - return value; - } - - public String getDigestString() { - if (value != null) { - StringBuffer buffer = new StringBuffer(2 * value.length); - for (int i = 0; i < value.length; i++) { - int val = value[i]; - int hi = (val >> 4) & 0xF; - int lo = val & 0xF; - if (hi < 10) { - buffer.append((char) (hi + 0x30)); - } else { - buffer.append((char) (hi + 0x61 - 10)); - } - if (lo < 10) { - buffer.append((char) (lo + 0x30)); - } else { - buffer.append((char) (lo + 0x61 - 10)); - } - } - return buffer.toString(); - } else { - return null; - } - } - - /* (non-Javadoc) - * @see org.xml.sax.ContentHandler#characters(char[], int, int) - */ - public void characters(char[] chars, int start, int length) - throws SAXException { - digest.update(new String(chars, start, length).getBytes()); - super.characters(chars, start, length); - } - - /* (non-Javadoc) - * @see org.xml.sax.ContentHandler#endDocument() - */ - public void endDocument() throws SAXException { - value = digest.digest(); - super.endDocument(); - } - - public void startElement( - String url, - String localName, - String qName, - Attributes attr) - throws SAXException { - Map map = new TreeMap(); - if (isNamespaceAware) { - digest.update(url.getBytes()); - digest.update(localName.getBytes()); - for (int i = 0; i < attr.getLength(); i++) { - map.put( - attr.getLocalName(i) + attr.getURI(i), - attr.getValue(i)); - } - } else { - digest.update(qName.getBytes()); - for (int i = 0; i < attr.getLength(); i++) { - map.put(attr.getQName(i), attr.getValue(i)); - } - } - for (Iterator i = map.entrySet().iterator(); i.hasNext();) { - Map.Entry entry = (Map.Entry)i.next(); - digest.update(((String)entry.getKey()).getBytes()); - digest.update(((String)entry.getValue()).getBytes()); - } - super.startElement(url, localName, qName, attr); - } - - - /* (non-Javadoc) - * @see org.xml.sax.XMLReader#setFeature(java.lang.String, boolean) - */ - public void setFeature(String feature, boolean value) - throws SAXNotRecognizedException, SAXNotSupportedException { - if (feature.equals("http://xml.org/sax/features/namespaces")) { - isNamespaceAware = value; - } - super.setFeature(feature, value); - } - -} diff --git a/test/java/org/apache/fop/util/ElementListUtilsTestCase.java b/test/java/org/apache/fop/util/ElementListUtilsTestCase.java deleted file mode 100644 index 5e4f38b0b..000000000 --- a/test/java/org/apache/fop/util/ElementListUtilsTestCase.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.util; - -import java.util.LinkedList; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -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; - -/** - * Test class for ElementListUtils. - */ -public class ElementListUtilsTestCase { - - /** - * Tests ElementListUtils.removeLegalBreaks(). - * @throws Exception if the test fails - */ - @Test - public void testRemoveElementPenalty1() throws Exception { - LinkedList lst = new LinkedList(); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, 0, false, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, 200, false, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, 0, false, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false)); - lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false)); - lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false)); - - boolean res = ElementListUtils.removeLegalBreaks(lst, 9000); - - assertFalse(res); - - assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(1)).getPenalty()); - assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(3)).getPenalty()); - assertEquals(0, ((KnuthPenalty)lst.get(5)).getPenalty()); - } - - /** - * Tests ElementListUtils.removeLegalBreaks(). - * @throws Exception if the test fails - */ - @Test - public void testRemoveElementPenalty2() throws Exception { - LinkedList lst = new LinkedList(); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthGlue(0, 0, 0, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthGlue(0, 0, 0, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthGlue(0, 0, 0, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false)); - lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false)); - lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false)); - - boolean res = ElementListUtils.removeLegalBreaks(lst, 9000); - - assertFalse(res); - - //Must insert an INFINITE penalty - assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(1)).getPenalty()); - assertEquals(0, ((KnuthGlue)lst.get(2)).getWidth()); - assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(4)).getPenalty()); - assertEquals(0, ((KnuthGlue)lst.get(5)).getWidth()); - assertEquals(0, ((KnuthGlue)lst.get(7)).getWidth()); - } - - /** - * Tests ElementListUtils.removeLegalBreaksFromEnd(). - * @throws Exception if the test fails - */ - @Test - public void testRemoveElementFromEndPenalty1() throws Exception { - LinkedList lst = new LinkedList(); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, 0, false, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, 200, false, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, 0, false, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false)); - lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false)); - lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false)); - - boolean res = ElementListUtils.removeLegalBreaksFromEnd(lst, 9000); - - assertFalse(res); - - assertEquals(0, ((KnuthPenalty)lst.get(1)).getPenalty()); - assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(3)).getPenalty()); - assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(5)).getPenalty()); - } - - /** - * Tests ElementListUtils.removeLegalBreaksFromEnd(). - * @throws Exception if the test fails - */ - @Test - public void testRemoveElementFromEndPenalty2() throws Exception { - LinkedList lst = new LinkedList(); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, 0, false, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, 200, false, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthGlue(0, 0, 0, null, false)); - lst.add(new KnuthBox(4000, null, false)); - lst.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false)); - lst.add(new KnuthGlue(0, Integer.MAX_VALUE, 0, null, false)); - lst.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false)); - - boolean res = ElementListUtils.removeLegalBreaksFromEnd(lst, 9000); - - assertFalse(res); - - //Must insert an INFINITE penalty - assertEquals(0, ((KnuthPenalty)lst.get(1)).getPenalty()); - assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(3)).getPenalty()); - assertEquals(KnuthElement.INFINITE, ((KnuthPenalty)lst.get(5)).getPenalty()); - assertEquals(0, ((KnuthGlue)lst.get(6)).getWidth()); - } -} diff --git a/test/java/org/apache/fop/util/HexEncoderTestCase.java b/test/java/org/apache/fop/util/HexEncoderTestCase.java deleted file mode 100644 index cb366abdf..000000000 --- a/test/java/org/apache/fop/util/HexEncoderTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.util; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Test case for the conversion of characters into hex-encoded strings. - */ -public class HexEncoderTestCase { - - /** - * Tests that characters are properly encoded into hex strings. - */ - @Test - public void testEncodeChar() { - char[] digits = new char[] {'0', '0', '0', '0'}; - for (int c = 0; c <= 0xFFFF; c++) { - assertEquals(new String(digits), HexEncoder.encode((char) c)); - increment(digits); - } - } - - private static void increment(char[] digits) { - int d = 4; - do { - d--; - digits[d] = successor(digits[d]); - } while (digits[d] == '0' && d > 0); - } - - private static char successor(char d) { - if (d == '9') { - return 'A'; - } else if (d == 'F') { - return '0'; - } else { - return (char) (d + 1); - } - } - -} diff --git a/test/java/org/apache/fop/util/LanguageTagsTestCase.java b/test/java/org/apache/fop/util/LanguageTagsTestCase.java deleted file mode 100644 index 91861dcc6..000000000 --- a/test/java/org/apache/fop/util/LanguageTagsTestCase.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.util; - -import java.util.Locale; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Tests {@link LanguageTags}. - */ -public class LanguageTagsTestCase { - - @Test(expected = NullPointerException.class) - public void toLanguageTagRejectsNull() { - LanguageTags.toLanguageTag(null); - } - - @Test - public void testToLanguageTag() throws Exception { - assertEquals("", LanguageTags.toLanguageTag(new Locale(""))); - assertEquals("en", LanguageTags.toLanguageTag(new Locale("en"))); - assertEquals("en-US", LanguageTags.toLanguageTag(new Locale("en", "US"))); - assertEquals("en-US", LanguageTags.toLanguageTag(new Locale("EN", "us"))); - } - - @Test(expected = NullPointerException.class) - public void toLocaleRejectsNull() { - LanguageTags.toLocale(null); - } - - @Test - public void testRFC3066ToLocale() throws Exception { - assertEquals(new Locale(""), LanguageTags.toLocale("")); - assertEquals(new Locale("en"), LanguageTags.toLocale("en")); - assertEquals(new Locale("en", "US"), LanguageTags.toLocale("en-US")); - assertEquals(new Locale("en", "US"), LanguageTags.toLocale("EN-us")); - } -} diff --git a/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java b/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java deleted file mode 100644 index 60aa16d83..000000000 --- a/test/java/org/apache/fop/util/XMLResourceBundleTestCase.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.util; - -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. - */ -public class XMLResourceBundleTestCase { - - @Test - public void testWithValidFile() throws Exception { - ResourceBundle bundle = XMLResourceBundle.getXMLBundle( - getClass().getName(), Locale.ENGLISH, getClass().getClassLoader()); - ResourceBundle bundleDE = XMLResourceBundle.getXMLBundle( - getClass().getName(), Locale.GERMAN, getClass().getClassLoader()); - - assertEquals("", bundle.getLocale().getLanguage()); - assertEquals("de", bundleDE.getLocale().getLanguage()); - - assertEquals("Hello World!", bundle.getString("hello-world")); - assertEquals("Hallo Welt!", bundleDE.getString("hello-world")); - - //Check fallback to English - assertEquals("Untranslatable", bundle.getString("untranslatable")); - assertEquals("Untranslatable", bundleDE.getString("untranslatable")); - } - - @Test - public void testWithInvalidFile() throws Exception { - try { - ResourceBundle bundle = XMLResourceBundle.getXMLBundle( - "org.apache.fop.util.invalid-translation-file", getClass().getClassLoader()); - fail("Expected exception"); - } catch (MissingResourceException e) { - //expected - } - } - -} diff --git a/test/java/org/apache/fop/util/XMLResourceBundleTestCase.xml b/test/java/org/apache/fop/util/XMLResourceBundleTestCase.xml deleted file mode 100644 index 5cdee49ec..000000000 --- a/test/java/org/apache/fop/util/XMLResourceBundleTestCase.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<catalogue xml:lang="en"> - <message key="hello-world">Hello World!</message> - <message key="untranslatable">Untranslatable</message> -</catalogue>
\ No newline at end of file diff --git a/test/java/org/apache/fop/util/XMLResourceBundleTestCase_de.xml b/test/java/org/apache/fop/util/XMLResourceBundleTestCase_de.xml deleted file mode 100644 index 44cf5a5b4..000000000 --- a/test/java/org/apache/fop/util/XMLResourceBundleTestCase_de.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<catalogue xml:lang="de"> - <message key="hello-world">Hallo Welt!</message> -</catalogue>
\ No newline at end of file diff --git a/test/java/org/apache/fop/util/invalid-translation-file.xml b/test/java/org/apache/fop/util/invalid-translation-file.xml deleted file mode 100644 index 09306b7cc..000000000 --- a/test/java/org/apache/fop/util/invalid-translation-file.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<catalogue xml:lang="en"> - <message key1="hello-world">Hello World!</message> - <something>blah</something> -</catalogue>
\ No newline at end of file diff --git a/test/java/org/apache/fop/visual/AbstractBitmapProducer.java b/test/java/org/apache/fop/visual/AbstractBitmapProducer.java deleted file mode 100644 index fbbe1e22d..000000000 --- a/test/java/org/apache/fop/visual/AbstractBitmapProducer.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.visual; - -import java.net.URI; - -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Abstract base class for converters. - */ -public abstract class AbstractBitmapProducer implements BitmapProducer { - - /** Logger */ - protected static Log log = LogFactory.getLog(AbstractBitmapProducer.class); - final URI baseUri; - - public AbstractBitmapProducer(URI baseUri) { - this.baseUri = baseUri; - } - - /** - * Returns a new JAXP Transformer based on information in the ProducerContext. - * @param context context information for the process - * @return a new Transformer instance (identity or set up with a stylesheet) - * @throws TransformerConfigurationException in case creating the Transformer fails. - */ - protected Transformer getTransformer(ProducerContext context) - throws TransformerConfigurationException { - if (context.getTemplates() != null) { - return context.getTemplates().newTransformer(); - } else { - return context.getTransformerFactory().newTransformer(); - } - } - -} diff --git a/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java b/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java deleted file mode 100644 index 162a83756..000000000 --- a/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.visual; - -import java.awt.image.BufferedImage; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.URI; -import java.text.MessageFormat; - -import javax.xml.transform.Transformer; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.commons.io.IOUtils; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.util.DefaultErrorListener; - -/** - * BitmapProducer implementation that uses the PS or PDF renderer and an external converter - * to create bitmaps. - * <p> - * Here's what the configuration element looks like for the class: - * <p> - * <pre> - * <producer classname="<concrete class>"> - * <converter>mypdf2bmp {0} {1} {2}</converter> - * <delete-temp-files>false</delete-temp-files> - * </producer> - * </pre> - * <p> - * You will notice the three parameters in curly braces (java.util.MessageFormat style) to the - * converter call: - * <ul> - * <li>0: the input file - * <li>1: the output bitmap file - * <li>2: the requested resolution in dpi for the generated bitmap - * </ul> - * <p> - * The "delete-temp-files" element is optional and defaults to true. - */ -public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer - implements Configurable { - - // configure fopFactory as desired - private final FopFactory fopFactory; - - private String converter; - private boolean deleteTempFiles; - /** the bitmap producer's target format */ - protected String targetFormat; - - public AbstractPSPDFBitmapProducer(URI baseUri) { - super(baseUri); - fopFactory = FopFactory.newInstance(baseUri); - } - - /** {@inheritDoc} */ - public void configure(Configuration cfg) throws ConfigurationException { - this.converter = cfg.getChild("converter").getValue(); - this.deleteTempFiles = cfg.getChild("delete-temp-files").getValueAsBoolean(true); - if (cfg.getChild("target-format", false) != null) { - this.targetFormat = cfg.getChild("target-format").getValue(); - } - } - - /** - * Calls an external converter to convert the file generated by FOP to a bitmap. - * @param inFile the generated output file to be converted - * @param outFile the target filename for the bitmap - * @param context context information (required bitmap resolution etc.) - * @throws IOException in case the conversion fails - */ - public void convert(File inFile, File outFile, ProducerContext context) throws IOException { - outFile.delete(); - - //Build command-line - String cmd = MessageFormat.format(converter, - new Object[] {inFile.toString(), outFile.toString(), - Integer.toString(context.getTargetResolution())}); - ConvertUtils.convert(cmd, null, null, log); - - if (!outFile.exists()) { - throw new IOException("The target file has not been generated"); - } - } - - /** - * @return the native extension generated by the output format, ex. "ps" or "pdf". - */ - protected abstract String getTargetExtension(); - - /** - * @return the output format for the FOP renderer, i.e. a MIME type. - */ - protected String getTargetFormat() { - return this.targetFormat; - } - - /** {@inheritDoc} */ - public BufferedImage produce(File src, int index, ProducerContext context) { - try { - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - userAgent.setTargetResolution(context.getTargetResolution()); - - File tempOut = new File(context.getTargetDir(), - src.getName() + "." + index + "." + getTargetExtension()); - File tempPNG = new File(context.getTargetDir(), - src.getName() + "." + index + "." + getTargetExtension() + ".png"); - try { - OutputStream out = new FileOutputStream(tempOut); - out = new BufferedOutputStream(out); - try { - Fop fop = fopFactory.newFop(getTargetFormat(), userAgent, out); - SAXResult res = new SAXResult(fop.getDefaultHandler()); - - Transformer transformer = getTransformer(context); - transformer.setErrorListener(new DefaultErrorListener(log)); - transformer.transform(new StreamSource(src), res); - } finally { - IOUtils.closeQuietly(out); - } - - convert(tempOut, tempPNG, context); - BufferedImage img = BitmapComparator.getImage(tempPNG); - return img; - } finally { - if (deleteTempFiles) { - if (!tempOut.delete()) { - log.warn("Can't delete " + tempOut); - tempOut.deleteOnExit(); - } - if (!tempPNG.delete()) { - log.warn("Can't delete " + tempPNG); - tempPNG.deleteOnExit(); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - log.error(e); - return null; - } - } - -} diff --git a/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java b/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java deleted file mode 100644 index 344d3199e..000000000 --- a/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.visual; - -/** - * Abstract base implementation for a RedirectorLineHandler which provides empty notifyStart() - * and notifyEnd() methods. - */ -public abstract class AbstractRedirectorLineHandler - implements RedirectorLineHandler { - - /** @see org.apache.fop.visual.RedirectorLineHandler#notifyStart() */ - public void notifyStart() { - //nop - } - - /** @see org.apache.fop.visual.RedirectorLineHandler#notifyEnd() */ - public void notifyEnd() { - //nop - } - -} diff --git a/test/java/org/apache/fop/visual/BatchDiffer.java b/test/java/org/apache/fop/visual/BatchDiffer.java deleted file mode 100644 index cb78028f4..000000000 --- a/test/java/org/apache/fop/visual/BatchDiffer.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * 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.visual; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.util.Collection; - -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.stream.StreamSource; - -import org.xml.sax.SAXException; - -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; -import org.apache.avalon.framework.container.ContainerUtil; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.AndFileFilter; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.apache.commons.io.filefilter.WildcardFileFilter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.apache.xmlgraphics.image.writer.ImageWriterUtil; - -import org.apache.fop.layoutengine.LayoutEngineTestUtils; - -/** - * This class is used to visually diff bitmap images created through various sources. - * <p> - * Here's what the configuration format looks like: - * <p> - * <pre> - * <batch-diff> - * <source-directory>C:/Dev/FOP/trunk/test/layoutengine</source-directory> - * <filter-disabled>false</filter-disabled> - * <max-files>10</max-files> - * <target-directory>C:/Temp/diff-out</target-directory> - * <resolution>100</resolution> - * <stop-on-exception>false</stop-on-exception> - * <create-diffs>false</create-diffs> - * <stylesheet>C:/Dev/FOP/trunk/test/layoutengine/testcase2fo.xsl</stylesheet> - * <producers> - * <producer classname="org.apache.fop.visual.BitmapProducerJava2D"> - * <delete-temp-files>false</delete-temp-files> - * </producer> - * <producer classname="org.apache.fop.visual.ReferenceBitmapLoader"> - * <directory>C:/Temp/diff-bitmaps</directory> - * </producer> - * </producers> - * </batch-diff> - * </pre> - * <p> - * The optional "filter-disabled" element determines whether the source files should be filtered - * using the same "disabled-testcases.txt" file used for the layout engine tests. Default: true - * <p> - * The optional "max-files" element controls how many files at maximum should be processed. - * Default is to process all the files found. - * <p> - * The optional "resolution" element controls the requested bitmap resolution in dpi for the - * generated bitmaps. Defaults to 72dpi. - * <p> - * The optional "stop-on-exception" element controls whether the batch should be aborted when - * an exception is caught. Defaults to true. - * <p> - * The optional "create-diffs" element controls whether the diff images should be created. - * Defaults to true. - * <p> - * The optional "stylesheet" element allows you to supply an XSLT stylesheet to preprocess all - * source files with. Default: no stylesheet, identity transform. - * <p> - * The "producers" element contains a list of producer implementations with configuration. - * The "classname" attribute specifies the fully qualified class name for the implementation. - */ -public class BatchDiffer { - - /** Logger */ - protected static Log log = LogFactory.getLog(BatchDiffer.class); - - /** - * Prints the usage of this app to stdout. - */ - public static void printUsage() { - System.out.println("Usage:"); - System.out.println("java " + BatchDiffer.class.getName() + " <cfgfile>"); - System.out.println(); - System.out.println("<cfgfile>: Path to an XML file with the configuration" - + " for the batch run."); - } - - /** - * Runs the batch. - * @param cfgFile configuration file to use - * @throws ConfigurationException In case of a problem with the configuration - * @throws SAXException In case of a problem during SAX processing - * @throws IOException In case of a I/O problem - */ - public void runBatch(File cfgFile) - throws ConfigurationException, SAXException, IOException { - DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); - Configuration cfg = cfgBuilder.buildFromFile(cfgFile); - runBatch(cfg); - } - - /** - * Runs the batch - * @param cfg Configuration for the batch - * @throws TransformerConfigurationException - */ - public void runBatch(Configuration cfg) { - try { - ProducerContext context = new ProducerContext(); - context.setTargetResolution(cfg.getChild("resolution").getValueAsInteger(72)); - String xslt = cfg.getChild("stylesheet").getValue(null); - if (xslt != null) { - try { - context.setTemplates(context.getTransformerFactory().newTemplates( - new StreamSource(xslt))); - } catch (TransformerConfigurationException e) { - log.error("Error setting up stylesheet", e); - throw new RuntimeException("Error setting up stylesheet"); - } - } - - - //Set up directories - File srcDir = new File(cfg.getChild("source-directory").getValue()); - if (!srcDir.exists()) { - throw new RuntimeException("source-directory does not exist: " + srcDir); - } - - BitmapProducer[] producers = getProducers(cfg.getChild("producers"), srcDir); - - final File targetDir = new File(cfg.getChild("target-directory").getValue()); - if (!targetDir.mkdirs() && !targetDir.exists()) { - throw new RuntimeException("target-directory is invalid: " + targetDir); - } - context.setTargetDir(targetDir); - - boolean stopOnException = cfg.getChild("stop-on-exception").getValueAsBoolean(true); - final boolean createDiffs = cfg.getChild("create-diffs").getValueAsBoolean(true); - - //RUN! - - IOFileFilter filter = new SuffixFileFilter(new String[] {".xml", ".fo"}); - //Same filtering as in layout engine tests - if (cfg.getChild("filter-disabled").getValueAsBoolean(true)) { - String disabled = System.getProperty("fop.layoutengine.disabled"); - filter = LayoutEngineTestUtils.decorateWithDisabledList(filter, disabled); - } - String manualFilter = cfg.getChild("manual-filter").getValue(null); - if (manualFilter != null) { - if (manualFilter.indexOf('*') < 0) { - manualFilter = manualFilter + '*'; - } - filter = new AndFileFilter( - new WildcardFileFilter(manualFilter), filter); - } - - int maxfiles = cfg.getChild("max-files").getValueAsInteger(-1); - Collection<File> files = FileUtils.listFiles(srcDir, filter, null); - for (final File f : files) { - try { - log.info("---=== " + f + " ===---"); - long[] times = new long[producers.length]; - final BufferedImage[] bitmaps = new BufferedImage[producers.length]; - for (int j = 0; j < producers.length; j++) { - times[j] = System.currentTimeMillis(); - bitmaps[j] = producers[j].produce(f, j, context); - times[j] = System.currentTimeMillis() - times[j]; - } - if (log.isDebugEnabled()) { - StringBuffer sb = new StringBuffer("Bitmap production times: "); - for (int j = 0; j < producers.length; j++) { - if (j > 0) { - sb.append(", "); - } - sb.append(times[j]).append("ms"); - } - log.debug(sb.toString()); - } - //Create combined image - if (bitmaps[0] == null) { - throw new RuntimeException("First producer didn't return a bitmap for " - + f + ". Cannot continue."); - } - - Runnable runnable = new Runnable() { - public void run() { - try { - saveBitmaps(targetDir, f, createDiffs, bitmaps); - } catch (IOException e) { - log.error("IO error while saving bitmaps: " + e.getMessage()); - } - } - }; - //This speeds it up a little on multi-core CPUs (very cheap, I know) - new Thread(runnable).start(); - } catch (RuntimeException e) { - log.error("Catching RE on file " + f + ": " + e.getMessage()); - if (stopOnException) { - log.error("rethrowing..."); - throw e; - } - } - maxfiles = (maxfiles < 0 ? maxfiles : maxfiles - 1); - if (maxfiles == 0) { - break; - } - } - } catch (ConfigurationException e) { - log.error("Error while configuring BatchDiffer", e); - throw new RuntimeException("Error while configuring BatchDiffer: " + e.getMessage()); - } - } - - private void saveBitmaps(File targetDir, File srcFile, boolean createDiffs, - BufferedImage[] bitmaps) throws IOException { - BufferedImage combined = BitmapComparator.buildCompareImage(bitmaps); - - //Save combined bitmap as PNG file - File outputFile = new File(targetDir, srcFile.getName() + "._combined.png"); - ImageWriterUtil.saveAsPNG(combined, outputFile); - - if (createDiffs) { - for (int k = 1; k < bitmaps.length; k++) { - BufferedImage diff = BitmapComparator.buildDiffImage( - bitmaps[0], bitmaps[k]); - outputFile = new File(targetDir, srcFile.getName() + "._diff" + k + ".png"); - ImageWriterUtil.saveAsPNG(diff, outputFile); - } - } - } - - private BitmapProducer[] getProducers(Configuration cfg, File srcDir) { - Configuration[] children = cfg.getChildren("producer"); - BitmapProducer[] producers = new BitmapProducer[children.length]; - for (int i = 0; i < children.length; i++) { - try { - Class<?> clazz = Class.forName(children[i].getAttribute("classname")); - Object producer = clazz.getDeclaredConstructor(URI.class) - .newInstance(srcDir.toURI()); - producers[i] = (BitmapProducer) producer; - ContainerUtil.configure(producers[i], children[i]); - } catch (Exception e) { - log.error("Error setting up producers", e); - throw new RuntimeException("Error while setting up producers"); - } - } - return producers; - } - - /** - * Main method. - * @param args command-line arguments - */ - public static void main(String[] args) { - try { - if (args.length == 0) { - System.err.println("Configuration file is missing!"); - printUsage(); - System.exit(-1); - } - File cfgFile = new File(args[0]); - if (!cfgFile.exists()) { - System.err.println("Configuration file cannot be found: " + args[0]); - printUsage(); - System.exit(-1); - } - - Thread.currentThread().setPriority(Thread.MIN_PRIORITY); - BatchDiffer differ = new BatchDiffer(); - differ.runBatch(cfgFile); - - System.out.println("Regular exit..."); - } catch (Exception e) { - System.out.println("Exception caught..."); - e.printStackTrace(); - } - } - -} diff --git a/test/java/org/apache/fop/visual/BitmapComparator.java b/test/java/org/apache/fop/visual/BitmapComparator.java deleted file mode 100644 index f2157176b..000000000 --- a/test/java/org/apache/fop/visual/BitmapComparator.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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.visual; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; -import java.awt.image.RenderedImage; -import java.awt.image.WritableRaster; -import java.io.File; -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; - -/** - * Helper class to visually compare two bitmap images. - * <p> - * This class was created by extracting reusable code from - * org.apache.batik.test.util.ImageCompareText (Apache Batik) - * into this separate class. - * <p> - * TODO Move as utility class to XML Graphics Commons when possible - */ -public final class BitmapComparator { - - - private BitmapComparator() { - } - - /** - * Builds a new BufferedImage that is the difference between the two input images - * @param ref the reference bitmap - * @param gen the newly generated bitmap - * @return the diff bitmap - */ - public static BufferedImage buildDiffImage(BufferedImage ref, - BufferedImage gen) { - BufferedImage diff = new BufferedImage(ref.getWidth(), - ref.getHeight(), - BufferedImage.TYPE_INT_ARGB); - WritableRaster refWR = ref.getRaster(); - WritableRaster genWR = gen.getRaster(); - WritableRaster dstWR = diff.getRaster(); - - boolean refPre = ref.isAlphaPremultiplied(); - if (!refPre) { - ColorModel cm = ref.getColorModel(); - cm = GraphicsUtil.coerceData(refWR, cm, true); - ref = new BufferedImage(cm, refWR, true, null); - } - boolean genPre = gen.isAlphaPremultiplied(); - if (!genPre) { - ColorModel cm = gen.getColorModel(); - cm = GraphicsUtil.coerceData(genWR, cm, true); - gen = new BufferedImage(cm, genWR, true, null); - } - - - int w = ref.getWidth(); - int h = ref.getHeight(); - - int [] refPix = null; - int [] genPix = null; - 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; - int val = ((refPix[i] - genPix[i]) * 10) + 128; - if ((val & 0xFFFFFF00) != 0) { - if ((val & 0x80000000) != 0) { - val = 0; - } else { - val = 255; - } - } - genPix[i] = val; - } - dstWR.setPixels(0, y, w, 1, genPix); - } - - if (!genPre) { - ColorModel cm = gen.getColorModel(); - cm = GraphicsUtil.coerceData(genWR, cm, false); - } - - if (!refPre) { - ColorModel cm = ref.getColorModel(); - cm = GraphicsUtil.coerceData(refWR, cm, false); - } - - return diff; - } - - /** - * Builds a combined image that places a number of images next to each other for - * manual, visual comparison. - * @param images the array of bitmaps - * @return the combined image - */ - public static BufferedImage buildCompareImage(BufferedImage[] images) { - BufferedImage cmp = new BufferedImage( - images[0].getWidth() * images.length, - images[0].getHeight(), BufferedImage.TYPE_INT_ARGB); - - Graphics2D g = cmp.createGraphics(); - g.setPaint(Color.white); - g.fillRect(0, 0, cmp.getWidth(), cmp.getHeight()); - int lastWidth = 0; - for (int i = 0; i < images.length; i++) { - if (lastWidth > 0) { - g.translate(lastWidth, 0); - } - if (images[i] != null) { - g.drawImage(images[i], 0, 0, null); - lastWidth = images[i].getWidth(); - } else { - lastWidth = 20; //Maybe add a special placeholder image instead later - } - } - g.dispose(); - - return cmp; - } - - /** - * Builds a combined image that places two images next to each other for - * manual, visual comparison. - * @param ref the reference image - * @param gen the actual image - * @return the combined image - */ - public static BufferedImage buildCompareImage(BufferedImage ref, - BufferedImage gen) { - return buildCompareImage(new BufferedImage[] {ref, gen}); - } - - /** - * Loads an image from a URL - * @param url the URL to the image - * @return the bitmap as BufferedImage - * TODO This method doesn't close the InputStream opened by the URL. - */ - public static BufferedImage getImage(URL url) { - ImageTagRegistry reg = ImageTagRegistry.getRegistry(); - Filter filt = reg.readURL(new ParsedURL(url)); - if (filt == null) { - return null; - } - - RenderedImage red = filt.createDefaultRendering(); - if (red == null) { - return null; - } - - BufferedImage img = new BufferedImage(red.getWidth(), - red.getHeight(), - BufferedImage.TYPE_INT_ARGB); - red.copyData(img.getRaster()); - - return img; - } - - /** - * Loads an image from a URL - * @param bitmapFile the bitmap file - * @return the bitmap as BufferedImage - */ - public static BufferedImage getImage(File bitmapFile) { - try { - InputStream in = new java.io.FileInputStream(bitmapFile); - try { - in = new java.io.BufferedInputStream(in); - - ImageTagRegistry reg = ImageTagRegistry.getRegistry(); - Filter filt = reg.readStream(in); - if (filt == null) { - return null; - } - - RenderedImage red = filt.createDefaultRendering(); - if (red == null) { - return null; - } - - BufferedImage img = new BufferedImage(red.getWidth(), - red.getHeight(), - BufferedImage.TYPE_INT_ARGB); - red.copyData(img.getRaster()); - return img; - } finally { - IOUtils.closeQuietly(in); - } - } catch (IOException e) { - return null; - } - } - -} diff --git a/test/java/org/apache/fop/visual/BitmapProducer.java b/test/java/org/apache/fop/visual/BitmapProducer.java deleted file mode 100644 index 9326656f4..000000000 --- a/test/java/org/apache/fop/visual/BitmapProducer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.visual; - -import java.awt.image.BufferedImage; -import java.io.File; - -/** - * Interface for a converter. - */ -public interface BitmapProducer { - - /** - * Produces a BufferedImage from the source file by invoking the FO processor and - * converting the generated output file to a bitmap image if necessary. - * @param src the source FO or XML file - * @param index the index of the producer inside the test set - * @param context context information for the conversion - * @return the generated BufferedImage - */ - BufferedImage produce(File src, int index, ProducerContext context); - -} diff --git a/test/java/org/apache/fop/visual/BitmapProducerJava2D.java b/test/java/org/apache/fop/visual/BitmapProducerJava2D.java deleted file mode 100644 index c29de1e85..000000000 --- a/test/java/org/apache/fop/visual/BitmapProducerJava2D.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.visual; - -import java.awt.image.BufferedImage; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.net.URI; - -import javax.xml.transform.Transformer; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamSource; - -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.commons.io.IOUtils; - -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.util.DefaultErrorListener; - -/** - * BitmapProducer implementation that uses the Java2DRenderer to create bitmaps. - * <p> - * Here's what the configuration element looks like for the class: - * <p> - * <pre> - * <producer classname="org.apache.fop.visual.BitmapProducerJava2D"> - * <delete-temp-files>false</delete-temp-files> - * </producer> - * </pre> - * <p> - * The "delete-temp-files" element is optional and defaults to true. - */ -public class BitmapProducerJava2D extends AbstractBitmapProducer implements Configurable { - - // configure fopFactory as desired - private final FopFactory fopFactory; - - private boolean deleteTempFiles; - - public BitmapProducerJava2D(URI baseUri) { - super(baseUri); - fopFactory = FopFactory.newInstance(baseUri); - } - - /** @see org.apache.avalon.framework.configuration.Configurable */ - public void configure(Configuration cfg) throws ConfigurationException { - this.deleteTempFiles = cfg.getChild("delete-temp-files").getValueAsBoolean(true); - } - - /** @see org.apache.fop.visual.BitmapProducer */ - public BufferedImage produce(File src, int index, ProducerContext context) { - try { - FOUserAgent userAgent = fopFactory.newFOUserAgent(); - userAgent.setTargetResolution(context.getTargetResolution()); - - File outputFile = new File(context.getTargetDir(), - src.getName() + "." + index + ".java2d.png"); - OutputStream out = new FileOutputStream(outputFile); - out = new BufferedOutputStream(out); - try { - Fop fop = fopFactory.newFop(MimeConstants.MIME_PNG, userAgent, out); - SAXResult res = new SAXResult(fop.getDefaultHandler()); - - Transformer transformer = getTransformer(context); - transformer.setErrorListener(new DefaultErrorListener(log)); - transformer.transform(new StreamSource(src), res); - } finally { - IOUtils.closeQuietly(out); - } - - BufferedImage img = BitmapComparator.getImage(outputFile); - if (deleteTempFiles) { - if (!outputFile.delete()) { - log.warn("Cannot delete " + outputFile); - outputFile.deleteOnExit(); - } - } - return img; - } catch (Exception e) { - e.printStackTrace(); - log.error(e); - return null; - } - } - -} diff --git a/test/java/org/apache/fop/visual/BitmapProducerPDF.java b/test/java/org/apache/fop/visual/BitmapProducerPDF.java deleted file mode 100644 index d28ebfc2a..000000000 --- a/test/java/org/apache/fop/visual/BitmapProducerPDF.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.visual; - -import java.net.URI; - -import org.apache.fop.apps.MimeConstants; - -/** - * BitmapProducer implementation that uses the PDFRenderer and an external converter - * to create bitmaps. - * <p> - * See the superclass' javadoc for info on the configuration format. - */ -public class BitmapProducerPDF extends AbstractPSPDFBitmapProducer { - - /** - * Default constructor. - */ - public BitmapProducerPDF(URI baseUri) { - super(baseUri); - this.targetFormat = MimeConstants.MIME_PDF; - } - - /** {@inheritDoc} */ - protected String getTargetExtension() { - return "pdf"; - } - -} diff --git a/test/java/org/apache/fop/visual/BitmapProducerPS.java b/test/java/org/apache/fop/visual/BitmapProducerPS.java deleted file mode 100644 index 1bbdba891..000000000 --- a/test/java/org/apache/fop/visual/BitmapProducerPS.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.visual; - -import java.net.URI; - -import org.apache.fop.apps.MimeConstants; - -/** - * BitmapProducer implementation that uses the PSRenderer and an external converter - * to create bitmaps. - * <p> - * See the superclass' javadoc for info on the configuration format. - */ -public class BitmapProducerPS extends AbstractPSPDFBitmapProducer { - - /** - * Default constructor. - */ - public BitmapProducerPS(URI baseUri) { - super(baseUri); - this.targetFormat = MimeConstants.MIME_POSTSCRIPT; - } - - /** {@inheritDoc} */ - protected String getTargetExtension() { - return "ps"; - } - -} diff --git a/test/java/org/apache/fop/visual/ConvertUtils.java b/test/java/org/apache/fop/visual/ConvertUtils.java deleted file mode 100644 index aa4dadf47..000000000 --- a/test/java/org/apache/fop/visual/ConvertUtils.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.visual; - -import java.io.File; -import java.io.IOException; - -import org.apache.commons.logging.Log; - -/** - * Utilities for converting files with external converters. - */ -public final class ConvertUtils { - - private ConvertUtils() { - } - - /** - * Calls an external converter application (GhostScript, for example). - * @param cmd the full command - * @param envp array of strings, each element of which has environment variable settings - * in format name=value. - * @param workDir the working directory of the subprocess, or null if the subprocess should - * inherit the working directory of the current process. - * @param log the logger to log output by the external application to - * @throws IOException in case the external call fails - */ - public static void convert(String cmd, String[] envp, File workDir, final Log log) - throws IOException { - log.debug(cmd); - - Process process = null; - try { - process = Runtime.getRuntime().exec(cmd, envp, null); - - //Redirect stderr output - RedirectorLineHandler errorHandler = new AbstractRedirectorLineHandler() { - public void handleLine(String line) { - log.error("ERR> " + line); - } - }; - StreamRedirector errorRedirector - = new StreamRedirector(process.getErrorStream(), errorHandler); - - //Redirect stdout output - RedirectorLineHandler outputHandler = new AbstractRedirectorLineHandler() { - public void handleLine(String line) { - log.debug("OUT> " + line); - } - }; - StreamRedirector outputRedirector - = new StreamRedirector(process.getInputStream(), outputHandler); - new Thread(errorRedirector).start(); - new Thread(outputRedirector).start(); - - process.waitFor(); - } catch (java.lang.InterruptedException ie) { - throw new IOException("The call to the external converter failed: " + ie.getMessage()); - } catch (java.io.IOException ioe) { - throw new IOException("The call to the external converter failed: " + ioe.getMessage()); - } - - int exitValue = process.exitValue(); - if (exitValue != 0) { - throw new IOException("The call to the external converter failed. Result: " - + exitValue); - } - - } - - -} diff --git a/test/java/org/apache/fop/visual/ProducerContext.java b/test/java/org/apache/fop/visual/ProducerContext.java deleted file mode 100644 index 214820c82..000000000 --- a/test/java/org/apache/fop/visual/ProducerContext.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.visual; - -import java.io.File; - -import javax.xml.transform.Templates; -import javax.xml.transform.TransformerFactory; - -/** - * Context object for the bitmap production. - */ -public class ProducerContext { - - private TransformerFactory tFactory; - private Templates templates; - private int targetResolution; - private File targetDir; - - /** - * @return the TransformerFactory to be used. - */ - public TransformerFactory getTransformerFactory() { - if (tFactory == null) { - tFactory = TransformerFactory.newInstance(); - } - return tFactory; - } - - /** - * @return the requested bitmap resolution in dpi for all bitmaps. - */ - public int getTargetResolution() { - return targetResolution; - } - - /** - * Sets the requested bitmap resolution in dpi for all bitmaps. - * @param resolution the resolution in dpi - */ - public void setTargetResolution(int resolution) { - this.targetResolution = resolution; - } - - /** - * @return the XSLT stylesheet to preprocess the input files with. - */ - public Templates getTemplates() { - return templates; - } - - /** - * Sets an optional XSLT stylesheet which is used to preprocess all input files with. - * @param templates the XSLT stylesheet - */ - public void setTemplates(Templates templates) { - this.templates = templates; - } - - /** - * @return the target directory for all produced bitmaps - */ - public File getTargetDir() { - return targetDir; - } - - /** - * Sets the target directory for all produced bitmaps. - * @param targetDir the target directory - */ - public void setTargetDir(File targetDir) { - this.targetDir = targetDir; - } -} diff --git a/test/java/org/apache/fop/visual/RedirectorLineHandler.java b/test/java/org/apache/fop/visual/RedirectorLineHandler.java deleted file mode 100644 index 017dcbe5b..000000000 --- a/test/java/org/apache/fop/visual/RedirectorLineHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.visual; - -/** - * This interface is used to redirect output from an external application elsewhere. - */ -public interface RedirectorLineHandler { - - /** - * Called before the first handleLine() call. - */ - void notifyStart(); - - /** - * Called for each line of output to be processed. - * @param line a line of application output - */ - void handleLine(String line); - - /** - * Called after the last handleLine() call. - */ - void notifyEnd(); -} diff --git a/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java b/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java deleted file mode 100644 index 29b0afd00..000000000 --- a/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.visual; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.net.URI; - -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; - -/** - * BitmapProducer implementation that simply loads preproduced reference bitmaps from a - * certain directory. - * <p> - * Here's what the configuration element looks like for the class: - * <p> - * <pre> - * <producer classname="org.apache.fop.visual.ReferenceBitmapLoader"> - * <directory>C:/Temp/ref-bitmaps</directory> - * </producer> - * </pre> - */ -public class ReferenceBitmapLoader extends AbstractBitmapProducer implements Configurable { - - private File bitmapDirectory; - - public ReferenceBitmapLoader(URI baseUri) { - super(baseUri); - } - - /** @see org.apache.avalon.framework.configuration.Configurable */ - public void configure(Configuration cfg) throws ConfigurationException { - this.bitmapDirectory = new File(cfg.getChild("directory").getValue(null)); - if (!bitmapDirectory.exists()) { - throw new ConfigurationException("Directory could not be found: " + bitmapDirectory); - } - } - - /** @see org.apache.fop.visual.BitmapProducer */ - public BufferedImage produce(File src, int index, ProducerContext context) { - try { - File bitmap = new File(bitmapDirectory, src.getName() + ".png"); - if (bitmap.exists()) { - return BitmapComparator.getImage(bitmap); - } else { - return null; - } - } catch (Exception e) { - log.error(e); - return null; - } - } - -} diff --git a/test/java/org/apache/fop/visual/StreamRedirector.java b/test/java/org/apache/fop/visual/StreamRedirector.java deleted file mode 100644 index 543c539ff..000000000 --- a/test/java/org/apache/fop/visual/StreamRedirector.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.visual; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; - -/** - * Redirects the content coming in through an InputStream using a separate thread to a - * RedirectorLineHandler instance. The default text encoding is used. - */ -public class StreamRedirector implements Runnable { - - private InputStream in; - private RedirectorLineHandler handler; - private Exception exception; - - /** - * @param in the InputStream to read the content from - * @param handler the handler that receives all the lines - */ - public StreamRedirector(InputStream in, RedirectorLineHandler handler) { - this.in = in; - this.handler = handler; - } - - /** - * @return true if the run() method was terminated by an exception. - */ - public boolean hasFailed() { - return (this.exception != null); - } - - /** - * @return the exception if the run() method was terminated by an exception, or null - */ - public Exception getException() { - return this.exception; - } - - /** @see java.lang.Runnable#run() */ - public void run() { - this.exception = null; - try { - Reader inr = new java.io.InputStreamReader(in); - BufferedReader br = new BufferedReader(inr); - if (handler != null) { - handler.notifyStart(); - } - String line = null; - while ((line = br.readLine()) != null) { - if (handler != null) { - handler.handleLine(line); - } - } - if (handler != null) { - handler.notifyStart(); - } - } catch (IOException ioe) { - this.exception = ioe; - } - } -} |