Browse Source

Cosmetics only: enabled Checkstyle for test files and fixed resulting errors


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1551536 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-2_0
Vincent Hennebert 10 years ago
parent
commit
126e31e719
100 changed files with 387 additions and 409 deletions
  1. 1
    0
      build.xml
  2. 3
    0
      checkstyle-suppressions.xml
  3. 4
    2
      test/java/org/apache/fop/AbstractBasicTranscoderTest.java
  4. 4
    3
      test/java/org/apache/fop/BasicDriverTestCase.java
  5. 1
    1
      test/java/org/apache/fop/BasicDriverTestSuite.java
  6. 1
    0
      test/java/org/apache/fop/BasicPSTranscoderTestCase.java
  7. 4
    1
      test/java/org/apache/fop/DebugHelper.java
  8. 4
    3
      test/java/org/apache/fop/DigestFilterTestCase.java
  9. 5
    4
      test/java/org/apache/fop/KnuthAlgorithmTestCase.java
  10. 3
    2
      test/java/org/apache/fop/URIResolutionTestCase.java
  11. 2
    2
      test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java
  12. 2
    2
      test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java
  13. 3
    3
      test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java
  14. 5
    7
      test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java
  15. 5
    4
      test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java
  16. 6
    5
      test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java
  17. 2
    2
      test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java
  18. 2
    1
      test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java
  19. 4
    4
      test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java
  20. 4
    3
      test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java
  21. 5
    5
      test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java
  22. 5
    4
      test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java
  23. 3
    3
      test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java
  24. 5
    4
      test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java
  25. 0
    1
      test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java
  26. 6
    6
      test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java
  27. 4
    5
      test/java/org/apache/fop/apps/FopFactoryTestCase.java
  28. 0
    2
      test/java/org/apache/fop/apps/PDFRendererConfBuilder.java
  29. 2
    1
      test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java
  30. 3
    4
      test/java/org/apache/fop/apps/io/FontURIResolver.java
  31. 2
    2
      test/java/org/apache/fop/area/ViewportTest.java
  32. 2
    1
      test/java/org/apache/fop/area/ViewportTestSuite.java
  33. 2
    1
      test/java/org/apache/fop/area/inline/InlineViewportTestCase.java
  34. 1
    1
      test/java/org/apache/fop/check/ChecksFactory.java
  35. 5
    4
      test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java
  36. 10
    12
      test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java
  37. 4
    5
      test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java
  38. 1
    1
      test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java
  39. 2
    9
      test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java
  40. 8
    12
      test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java
  41. 8
    12
      test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java
  42. 71
    81
      test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java
  43. 1
    3
      test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java
  44. 13
    17
      test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java
  45. 9
    9
      test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestConstants.java
  46. 12
    9
      test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java
  47. 33
    35
      test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java
  48. 1
    3
      test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java
  49. 0
    1
      test/java/org/apache/fop/config/FontAttributesMissingTestCase.java
  50. 0
    1
      test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java
  51. 0
    1
      test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java
  52. 0
    1
      test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java
  53. 0
    1
      test/java/org/apache/fop/config/FontsAutoDetectTestCase.java
  54. 0
    1
      test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java
  55. 2
    2
      test/java/org/apache/fop/datatypes/URISpecificationTestCase.java
  56. 2
    1
      test/java/org/apache/fop/events/BasicEventTestCase.java
  57. 4
    1
      test/java/org/apache/fop/events/TestEventProducer.java
  58. 2
    2
      test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java
  59. 1
    1
      test/java/org/apache/fop/fo/FODocumentParser.java
  60. 1
    2
      test/java/org/apache/fop/fo/FONodeMocks.java
  61. 0
    4
      test/java/org/apache/fop/fo/flow/MarkersTestCase.java
  62. 1
    1
      test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java
  63. 4
    2
      test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java
  64. 5
    5
      test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java
  65. 2
    2
      test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java
  66. 0
    1
      test/java/org/apache/fop/fo/flow/table/TableHandler.java
  67. 2
    2
      test/java/org/apache/fop/fo/pagination/AllTests.java
  68. 3
    3
      test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java
  69. 2
    2
      test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java
  70. 2
    2
      test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java
  71. 4
    4
      test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java
  72. 2
    2
      test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
  73. 1
    1
      test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
  74. 3
    3
      test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java
  75. 4
    4
      test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java
  76. 1
    1
      test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java
  77. 3
    4
      test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java
  78. 5
    5
      test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java
  79. 2
    2
      test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
  80. 3
    3
      test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java
  81. 3
    3
      test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java
  82. 2
    2
      test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java
  83. 4
    4
      test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java
  84. 3
    3
      test/java/org/apache/fop/fotreetest/ext/AssertElement.java
  85. 1
    1
      test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java
  86. 4
    4
      test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java
  87. 3
    3
      test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java
  88. 0
    1
      test/java/org/apache/fop/intermediate/AbstractIFTest.java
  89. 1
    1
      test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java
  90. 2
    2
      test/java/org/apache/fop/intermediate/IFMimickingTestCase.java
  91. 1
    1
      test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java
  92. 1
    1
      test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java
  93. 5
    4
      test/java/org/apache/fop/layoutengine/ElementListCheck.java
  94. 1
    1
      test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java
  95. 2
    1
      test/java/org/apache/fop/layoutengine/LayoutResult.java
  96. 4
    4
      test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java
  97. 2
    1
      test/java/org/apache/fop/logging/LoggingElementListObserver.java
  98. 2
    2
      test/java/org/apache/fop/memory/MemoryEater.java
  99. 2
    1
      test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java
  100. 0
    0
      test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java

+ 1
- 0
build.xml View File

<pathelement location="${build.codegen-classes.dir}"/> <pathelement location="${build.codegen-classes.dir}"/>
</classpath> </classpath>
<fileset dir="${src.dir}" includes="**/*.java"/> <fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${test.dir}" includes="**/*.java"/>
<formatter type="xml" toFile="${build.dir}/report_checkstyle.xml"/> <formatter type="xml" toFile="${build.dir}/report_checkstyle.xml"/>
</checkstyle> </checkstyle>
<xslt in="${build.dir}/report_checkstyle.xml" out="${build.dir}/report_checkstyle.html" style="${checkstyle.noframes.xslt}"/> <xslt in="${build.dir}/report_checkstyle.xml" out="${build.dir}/report_checkstyle.html" style="${checkstyle.noframes.xslt}"/>

+ 3
- 0
checkstyle-suppressions.xml View File

<suppress files="org/apache/fop/complexscripts/bidi/GenerateBidiTestData.java" checks="SimplifyBooleanReturn"/> <suppress files="org/apache/fop/complexscripts/bidi/GenerateBidiTestData.java" checks="SimplifyBooleanReturn"/>
<suppress files="org/apache/fop/complexscripts/scripts/ArabicScriptProcessor.java" checks="SimplifyBooleanReturn"/> <suppress files="org/apache/fop/complexscripts/scripts/ArabicScriptProcessor.java" checks="SimplifyBooleanReturn"/>
<suppress files="org/apache/fop/complexscripts/util/CharScript.java" checks="SimplifyBooleanReturn"/> <suppress files="org/apache/fop/complexscripts/util/CharScript.java" checks="SimplifyBooleanReturn"/>
<suppress files="org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java" checks="AvoidNestedBlocks"/>
<suppress files="org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java" checks="AvoidNestedBlocks"/>
<suppress files="org/apache/fop/fo/flow/MarkersTestCase.java" checks="LocalVariableName"/>
</suppressions> </suppressions>

+ 4
- 2
test/java/org/apache/fop/AbstractBasicTranscoderTest.java View File



import org.junit.Test; 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.Transcoder;
import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.commons.io.output.ByteArrayOutputStream;


import static org.apache.fop.FOPTestUtils.getBaseDir; import static org.apache.fop.FOPTestUtils.getBaseDir;
import static org.junit.Assert.assertTrue;


/** /**
* Basic runtime test for FOP's transcoders. It is used to verify that * Basic runtime test for FOP's transcoders. It is used to verify that

+ 4
- 3
test/java/org/apache/fop/BasicDriverTestCase.java View File

import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;


import org.apache.fop.apps.FOPException;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertTrue;

import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.commons.io.output.ByteArrayOutputStream;


import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.FopFactory;
import org.apache.fop.cli.InputHandler; import org.apache.fop.cli.InputHandler;


import static org.apache.fop.FOPTestUtils.getBaseDir; import static org.apache.fop.FOPTestUtils.getBaseDir;
import static org.junit.Assert.assertTrue;


/** /**
* Basic runtime test for the old Fop class. It is used to verify that * Basic runtime test for the old Fop class. It is used to verify that
InputHandler handler = new InputHandler(xmlFile, xsltFile, null); InputHandler handler = new InputHandler(xmlFile, xsltFile, null);
try { try {
handler.renderTo(foUserAgent, MimeConstants.MIME_PDF, baout); handler.renderTo(foUserAgent, MimeConstants.MIME_PDF, baout);
} catch (FOPException e) {}
} catch (FOPException e) { /* NOP */ }
} }


} }

+ 1
- 1
test/java/org/apache/fop/BasicDriverTestSuite.java View File

* Test suite for basic functionality of FOP's Driver API. * Test suite for basic functionality of FOP's Driver API.
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ BasicDriverTestCase.class })
@SuiteClasses(BasicDriverTestCase.class)
public class BasicDriverTestSuite { public class BasicDriverTestSuite {
} }

+ 1
- 0
test/java/org/apache/fop/BasicPSTranscoderTestCase.java View File

package org.apache.fop; package org.apache.fop;


import org.apache.batik.transcoder.Transcoder; import org.apache.batik.transcoder.Transcoder;

import org.apache.fop.render.ps.PSTranscoder; import org.apache.fop.render.ps.PSTranscoder;


/** /**

+ 4
- 1
test/java/org/apache/fop/DebugHelper.java View File

/** /**
* Handles some standard tasks for debugging. * Handles some standard tasks for debugging.
*/ */
public class DebugHelper {
public final class DebugHelper {

private DebugHelper() {
}


private static boolean elObserversRegistered = false; private static boolean elObserversRegistered = false;



+ 4
- 3
test/java/org/apache/fop/DigestFilterTestCase.java View File



package org.apache.fop; package org.apache.fop;


import static org.junit.Assert.assertTrue;

import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;


import org.apache.fop.util.DigestFilter;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;


import static org.junit.Assert.assertTrue;

import org.apache.fop.util.DigestFilter;

/** /**
* Test case for digesting SAX filter. * Test case for digesting SAX filter.
* *

+ 5
- 4
test/java/org/apache/fop/KnuthAlgorithmTestCase.java View File



package org.apache.fop; package org.apache.fop;


import static org.junit.Assert.assertEquals;

import java.util.List; 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.BlockKnuthSequence;
import org.apache.fop.layoutmgr.BreakingAlgorithm; import org.apache.fop.layoutmgr.BreakingAlgorithm;
import org.apache.fop.layoutmgr.ElementListObserver; import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.layoutmgr.KnuthGlue; import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty; import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.KnuthSequence; import org.apache.fop.layoutmgr.KnuthSequence;
import org.junit.Before;
import org.junit.Test;


/** /**
* Tests the Knuth algorithm implementation. * Tests the Knuth algorithm implementation.

+ 3
- 2
test/java/org/apache/fop/URIResolutionTestCase.java View File

import org.junit.Test; import org.junit.Test;
import org.w3c.dom.Document; 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.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.xpath.XPathAPI; import org.apache.xpath.XPathAPI;
import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.render.xml.XMLRenderer;


import static org.apache.fop.FOPTestUtils.getBaseDir; import static org.apache.fop.FOPTestUtils.getBaseDir;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


/** /**
* Tests URI resolution facilities. * Tests URI resolution facilities.

+ 2
- 2
test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java View File



package org.apache.fop.afp; package org.apache.fop.afp;


import static org.junit.Assert.assertEquals;

import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

/** /**
* Test case for {@link AFPObjectAreaInfo}. * Test case for {@link AFPObjectAreaInfo}.
*/ */

+ 2
- 2
test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java View File



package org.apache.fop.afp; package org.apache.fop.afp;


import static org.junit.Assert.assertEquals;

import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

/** /**
* Test case for {@link AFPPaintingState}. * Test case for {@link AFPPaintingState}.
*/ */

+ 3
- 3
test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java View File

import org.junit.Before; import org.junit.Before;
import org.junit.Test; 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.xmlgraphics.util.MimeConstants;


import org.apache.fop.apps.io.ResourceResolverFactory; import org.apache.fop.apps.io.ResourceResolverFactory;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/** /**
* Test case for {@link AFPResourceManager}. * Test case for {@link AFPResourceManager}.
*/ */

+ 5
- 7
test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java View File



package org.apache.fop.afp; package org.apache.fop.afp;


import static org.junit.Assert.assertTrue;

import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertTrue;

import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.fop.afp.util.AFPResourceUtil;
import org.junit.Test;


import static org.junit.Assert.assertTrue;
import org.apache.fop.afp.util.AFPResourceUtil;


/** /**
* Tests the {@link AFPResourceUtil} class. * Tests the {@link AFPResourceUtil} class.
* names fails. * names fails.
* @throws Exception - * @throws Exception -
*/ */
@Test(expected=Exception.class)
@Test(expected = Exception.class)
public void testResourceNameMismatch() throws Exception { public void testResourceNameMismatch() throws Exception {
testResource(RESOURCE_NAME_MISMATCH, PSEG_B); testResource(RESOURCE_NAME_MISMATCH, PSEG_B);
} }
} }


private interface ResourceCopier { private interface ResourceCopier {
public void copy(InputStream in, OutputStream out) throws IOException;
void copy(InputStream in, OutputStream out) throws IOException;
} }
} }

+ 5
- 4
test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java View File

*/ */
package org.apache.fop.afp.goca; package org.apache.fop.afp.goca;


import static org.junit.Assert.assertEquals;

import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; 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.CharacterSet;
import org.apache.fop.afp.fonts.CharacterSetBuilder; import org.apache.fop.afp.fonts.CharacterSetBuilder;
import org.apache.fop.fonts.Typeface; import org.apache.fop.fonts.Typeface;
import org.junit.Before;
import org.junit.Test;


public class GraphicsCharacterStringTestCase { public class GraphicsCharacterStringTestCase {
private GraphicsCharacterString gcsCp500; private GraphicsCharacterString gcsCp500;

+ 6
- 5
test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java View File



package org.apache.fop.afp.modca; package org.apache.fop.afp.modca;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;


import org.apache.fop.afp.Streamable;
import org.junit.Test; 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. * Tests the {@link AbstractAFPObject} class.
*/ */

+ 2
- 2
test/java/org/apache/fop/afp/modca/AbstractNamedAFPObjectTest.java View File



package org.apache.fop.afp.modca; package org.apache.fop.afp.modca;


import static org.junit.Assert.assertTrue;

import java.util.Arrays; import java.util.Arrays;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertTrue;

/** /**
* Tests the {@linkplain AbstractAFPObject} class. * Tests the {@linkplain AbstractAFPObject} class.
*/ */

+ 2
- 1
test/java/org/apache/fop/afp/modca/AbstractStructuredObjectTest.java View File



import java.io.IOException; import java.io.IOException;


public abstract class AbstractStructuredObjectTest<S extends AbstractStructuredObject> extends AbstractAFPObjectTest<S> {
public abstract class AbstractStructuredObjectTest<S extends AbstractStructuredObject>
extends AbstractAFPObjectTest<S> {


/** /**
* Test writeStart() - test that the contract is maintained with * Test writeStart() - test that the contract is maintained with

+ 4
- 4
test/java/org/apache/fop/afp/modca/AbstractTripletStructuredObjectTest.java View File



package org.apache.fop.afp.modca; package org.apache.fop.afp.modca;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; 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.AbstractTriplet;
import org.apache.fop.afp.modca.triplets.AttributeQualifierTriplet; import org.apache.fop.afp.modca.triplets.AttributeQualifierTriplet;
import org.apache.fop.afp.modca.triplets.CommentTriplet; import org.apache.fop.afp.modca.triplets.CommentTriplet;

+ 4
- 3
test/java/org/apache/fop/afp/modca/IncludeObjectTestCase.java View File



package org.apache.fop.afp.modca; package org.apache.fop.afp.modca;


import static org.junit.Assert.assertTrue;

import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;


import org.apache.fop.afp.util.BinaryUtils;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertTrue;

import org.apache.fop.afp.util.BinaryUtils;

/** /**
* Test {@link IncludeObject} * Test {@link IncludeObject}
*/ */

+ 5
- 5
test/java/org/apache/fop/afp/parser/MODCAParserTestCase.java View File



package org.apache.fop.afp.parser; package org.apache.fop.afp.parser;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.EOFException; import java.io.EOFException;


import org.junit.Test; 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 * MODCAParser and MODCAParser.UnparsedStructuredField Unit tests
*/ */

+ 5
- 4
test/java/org/apache/fop/afp/ptoca/TransparentDataControlSequenceTestCase.java View File



import org.junit.Test; import org.junit.Test;


import org.apache.fop.afp.fonts.CharactersetEncoder.EncodedChars;
import org.apache.fop.afp.ptoca.TransparentDataControlSequence.TransparentData;

import static org.apache.fop.afp.ptoca.PtocaConstants.TRANSPARENT_DATA_MAX_SIZE;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; 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 { public class TransparentDataControlSequenceTestCase {


private EncodedChars encodedChars; private EncodedChars encodedChars;

+ 3
- 3
test/java/org/apache/fop/apps/AbstractRendererConfigParserTester.java View File



package org.apache.fop.apps; 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.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;


import org.apache.fop.render.RendererConfig; import org.apache.fop.render.RendererConfig;
import org.apache.fop.render.RendererConfig.RendererConfigParser; import org.apache.fop.render.RendererConfig.RendererConfigParser;


import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public abstract class AbstractRendererConfigParserTester<B extends RendererConfBuilder, public abstract class AbstractRendererConfigParserTester<B extends RendererConfBuilder,
C extends RendererConfig> { C extends RendererConfig> {



+ 5
- 4
test/java/org/apache/fop/apps/AbstractRendererConfiguratorTest.java View File



import org.xml.sax.SAXException; 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.avalon.framework.configuration.ConfigurationException;


import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder;
import org.apache.fop.render.PrintRendererConfigurator; import org.apache.fop.render.PrintRendererConfigurator;
import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandler;


import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public abstract class AbstractRendererConfiguratorTest<T extends PrintRendererConfigurator, B extends RendererConfBuilder> {
public abstract class AbstractRendererConfiguratorTest<T extends PrintRendererConfigurator,
B extends RendererConfBuilder> {


protected final String mimeType; protected final String mimeType;
protected FOUserAgent userAgent; protected FOUserAgent userAgent;

+ 0
- 1
test/java/org/apache/fop/apps/EnvironmentalProfileFactoryTestCase.java View File



import org.junit.Test; import org.junit.Test;



import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;



+ 6
- 6
test/java/org/apache/fop/apps/FopFactoryBuilderTestCase.java View File

import org.junit.Before; import org.junit.Before;
import org.junit.Test; 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.apps.io.ResourceResolverFactory;
import org.apache.fop.area.AreaTreeHandler; import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.Block; import org.apache.fop.area.Block;
import org.apache.fop.layoutmgr.StaticContentLayoutManager; import org.apache.fop.layoutmgr.StaticContentLayoutManager;
import org.apache.fop.layoutmgr.inline.ContentLayoutManager; import org.apache.fop.layoutmgr.inline.ContentLayoutManager;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/** /**
* Test case for {@link FopFactoryBuilder}. * Test case for {@link FopFactoryBuilder}.
*/ */

+ 4
- 5
test/java/org/apache/fop/apps/FopFactoryTestCase.java View File

import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import org.apache.fop.apps.MimeConstants;
import org.apache.fop.config.BaseConstructiveUserConfigTest;
import org.apache.fop.render.RendererConfig.RendererConfigParser;
import org.apache.fop.render.pdf.PDFRendererConfig;

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; 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 class FopFactoryTestCase extends BaseConstructiveUserConfigTest {


public FopFactoryTestCase() throws SAXException, IOException { public FopFactoryTestCase() throws SAXException, IOException {

+ 0
- 2
test/java/org/apache/fop/apps/PDFRendererConfBuilder.java View File

import org.w3c.dom.Element; import org.w3c.dom.Element;


import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder; import org.apache.fop.apps.FopConfBuilder.RendererConfBuilder;
import org.apache.fop.pdf.PDFEncryptionParams;
import org.apache.fop.render.RendererConfigOption; import org.apache.fop.render.RendererConfigOption;
import org.apache.fop.render.pdf.PDFEncryptionOption; import org.apache.fop.render.pdf.PDFEncryptionOption;
import org.apache.fop.render.pdf.PDFRendererOption;


import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_LENGTH; import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_LENGTH;
import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_PARAMS; import static org.apache.fop.render.pdf.PDFEncryptionOption.ENCRYPTION_PARAMS;

+ 2
- 1
test/java/org/apache/fop/apps/io/BaseURIResolutionTest.java View File



import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import static org.junit.Assert.assertTrue;

import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.commons.io.output.ByteArrayOutputStream;


import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.MimeConstants;


import static org.apache.fop.FOPTestUtils.getBaseDir; import static org.apache.fop.FOPTestUtils.getBaseDir;
import static org.junit.Assert.assertTrue;


public abstract class BaseURIResolutionTest { public abstract class BaseURIResolutionTest {



+ 3
- 4
test/java/org/apache/fop/apps/io/FontURIResolver.java View File

import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PDFRendererConfBuilder;

import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


import org.apache.xmlgraphics.io.Resource; import org.apache.xmlgraphics.io.Resource;


import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.PDFRendererConfBuilder;

public class FontURIResolver extends BaseURIResolutionTest { public class FontURIResolver extends BaseURIResolutionTest {


public enum Event { public enum Event {

+ 2
- 2
test/java/org/apache/fop/area/ViewportTest.java View File



package org.apache.fop.area; package org.apache.fop.area;


import java.awt.Rectangle;

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


import java.awt.Rectangle;

/** /**
* Tests implementations of the {@linkplain Viewport} interface. * Tests implementations of the {@linkplain Viewport} interface.
*/ */

+ 2
- 1
test/java/org/apache/fop/area/ViewportTestSuite.java View File



package org.apache.fop.area; package org.apache.fop.area;


import org.apache.fop.area.inline.InlineViewportTestCase;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; 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. * A suite of all the tests relating to the {@linkplain Viewport} interface.
*/ */

+ 2
- 1
test/java/org/apache/fop/area/inline/InlineViewportTestCase.java View File



package org.apache.fop.area.inline; package org.apache.fop.area.inline;


import org.apache.fop.area.ViewportTest;
import org.junit.Test; import org.junit.Test;


import org.apache.fop.area.ViewportTest;

/** /**
* Tests the {@linkplain InlineViewport} class. * Tests the {@linkplain InlineViewport} class.
*/ */

+ 1
- 1
test/java/org/apache/fop/check/ChecksFactory.java View File

/** /**
* A factory to create a particular kind of check. * A factory to create a particular kind of check.
*/ */
protected static interface CheckFactory<C> {
protected interface CheckFactory<C> {


/** /**
* Creates a {@link Check} instance from the given XML element. * Creates a {@link Check} instance from the given XML element.

+ 5
- 4
test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java View File



package org.apache.fop.cli; package org.apache.fop.cli;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.IOException; import java.io.IOException;


import org.apache.fop.apps.FOPException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; 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 { public class CommandLineOptionsTestCase {


private final CommandLineOptions clo = new CommandLineOptions(); private final CommandLineOptions clo = new CommandLineOptions();

+ 10
- 12
test/java/org/apache/fop/complexscripts/bidi/BidiAlgorithmTestCase.java View File



package org.apache.fop.complexscripts.bidi; package org.apache.fop.complexscripts.bidi;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.fop.complexscripts.bidi.UnicodeBidiAlgorithm;

import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; 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> * <p>Test case for Unicode Bidi Algorithm.</p>
* @author Glenn Adams
*/ */
public class BidiAlgorithmTestCase { public class BidiAlgorithmTestCase {


/** /**
* logging instance * logging instance
*/ */
private static final Log log = LogFactory.getLog(BidiAlgorithmTestCase.class); // CSOK: ConstantNameCheck
private static final Log log = LogFactory.getLog(BidiAlgorithmTestCase.class);


/** /**
* Concatenated array of <test-set,test-sequence> tuples * Concatenated array of <test-set,test-sequence> tuples
} }
if (includeSequence(testSet, testSequence)) { if (includeSequence(testSet, testSequence)) {
includedSequences++; includedSequences++;
if (! excludeSequence(testSet, testSequence)) {
if (!excludeSequence(testSet, testSequence)) {
if (testBidiAlgorithm(testSet, testSequence, la, ra, ta, bs)) { if (testBidiAlgorithm(testSet, testSequence, la, ra, ta, bs)) {
passedSequences++; passedSequences++;
} }
} }


private boolean includeSequence(int testSet, int testSequence) { private boolean includeSequence(int testSet, int testSequence) {
if (! includeTestSet(testSet)) {
if (!includeTestSet(testSet)) {
return false; return false;
} else { } else {
for (int i = 0, n = INCLUSIONS.length / 2; i < n; i++) { for (int i = 0, n = INCLUSIONS.length / 2; i < n; i++) {
return false; return false;
} }


private boolean testBidiAlgorithm(int testSet, int testSequence, int[] la, int[] ra, int[] ta, int bs) throws Exception {
private boolean testBidiAlgorithm(int testSet, int testSequence, int[] la, int[] ra, int[] ta, int bs)
throws Exception {
boolean passed = true; boolean passed = true;
int n = la.length; int n = la.length;
if (ra.length != n) { if (ra.length != n) {
// LTR // LTR
if ((bs & 2) != 0) { if ((bs & 2) != 0) {
int[] levels = UnicodeBidiAlgorithm.resolveLevels(null, ta, 0, new int [ n ], true); int[] levels = UnicodeBidiAlgorithm.resolveLevels(null, ta, 0, new int [ n ], true);
if (! verifyResults(la, levels, ta, 0, testSet, testSequence)) {
if (!verifyResults(la, levels, ta, 0, testSet, testSequence)) {
passed = false; passed = false;
} }
} }
// RTL // RTL
if ((bs & 4) != 0) { if ((bs & 4) != 0) {
int[] levels = UnicodeBidiAlgorithm.resolveLevels(null, ta, 1, new int [ n ], true); int[] levels = UnicodeBidiAlgorithm.resolveLevels(null, ta, 1, new int [ n ], true);
if (! verifyResults(la, levels, ta, 1, testSet, testSequence)) {
if (!verifyResults(la, levels, ta, 1, testSet, testSequence)) {
passed = false; passed = false;
} }
} }

+ 4
- 5
test/java/org/apache/fop/complexscripts/bidi/BidiClassTestCase.java View File



package org.apache.fop.complexscripts.bidi; package org.apache.fop.complexscripts.bidi;


import org.apache.fop.complexscripts.bidi.BidiClass;
import org.apache.fop.util.CharUtilities;

import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


import org.apache.fop.util.CharUtilities;

public class BidiClassTestCase { public class BidiClassTestCase {


@Test @Test
private void testBidiClass(int[] da) throws Exception { private void testBidiClass(int[] da) throws Exception {
int bc = da[0]; int bc = da[0];
for (int i = 1, n = da.length; i < n; i += 2) { for (int i = 1, n = da.length; i < n; i += 2) {
int s = da[i+0];
int e = da[i+1];
int s = da[i + 0];
int e = da[i + 1];
for (int c = s; c < e; c++) { for (int c = s; c < e; c++) {
int cbc = BidiClass.getBidiClass(c); int cbc = BidiClass.getBidiClass(c);
assertEquals("bad bidi class for CH(" + CharUtilities.format(c) + ")", bc, cbc); assertEquals("bad bidi class for CH(" + CharUtilities.format(c) + ")", bc, cbc);

+ 1
- 1
test/java/org/apache/fop/complexscripts/bidi/BidiTestData.java View File

data = null; data = null;
} finally { } finally {
if (is != null) { if (is != null) {
try { is.close(); } catch (Exception e) {}
try { is.close(); } catch (Exception e) { /* NOP */ }
} }
} }
return data; return data;

+ 2
- 9
test/java/org/apache/fop/complexscripts/fonts/GDEFTestCase.java View File



import java.io.File; import java.io.File;


import org.apache.fop.complexscripts.fonts.GlyphSubtable;
import org.apache.fop.complexscripts.fonts.GlyphDefinitionSubtable;
import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable;
import org.apache.fop.complexscripts.fonts.GlyphTable.LookupSpec;
import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable;
import org.apache.fop.complexscripts.fonts.ttx.TTXFile;
import org.apache.fop.complexscripts.util.GlyphContextTester;
import org.apache.fop.complexscripts.util.GlyphSequence;

import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


import org.apache.fop.complexscripts.fonts.ttx.TTXFile;

public class GDEFTestCase { public class GDEFTestCase {


private static String ttxFilesRoot = "test/resources/complexscripts"; private static String ttxFilesRoot = "test/resources/complexscripts";

+ 8
- 12
test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java View File

package org.apache.fop.complexscripts.fonts; package org.apache.fop.complexscripts.fonts;


import java.io.File; import java.io.File;
import java.util.List;
import java.util.Map;

import org.apache.fop.complexscripts.fonts.GlyphSubtable;
import org.apache.fop.complexscripts.fonts.GlyphPositioningSubtable;
import org.apache.fop.complexscripts.fonts.GlyphPositioningTable;
import org.apache.fop.complexscripts.fonts.GlyphTable.LookupSpec;
import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable;
import org.apache.fop.complexscripts.fonts.ttx.TTXFile;
import org.apache.fop.complexscripts.util.GlyphContextTester;
import org.apache.fop.complexscripts.util.GlyphSequence;
import org.apache.fop.complexscripts.util.ScriptContextTester;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; 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 { public class GPOSTestCase implements ScriptContextTester, GlyphContextTester {


private static String ttxFilesRoot = "test/resources/complexscripts"; private static String ttxFilesRoot = "test/resources/complexscripts";

+ 8
- 12
test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java View File



import java.io.File; import java.io.File;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.List;
import java.util.Map;

import org.apache.fop.complexscripts.fonts.GlyphSubtable;
import org.apache.fop.complexscripts.fonts.GlyphSubstitutionSubtable;
import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable;
import org.apache.fop.complexscripts.fonts.GlyphTable.LookupSpec;
import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable;
import org.apache.fop.complexscripts.fonts.ttx.TTXFile;
import org.apache.fop.complexscripts.util.GlyphContextTester;
import org.apache.fop.complexscripts.util.GlyphSequence;
import org.apache.fop.complexscripts.util.ScriptContextTester;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; 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 { public class GSUBTestCase implements ScriptContextTester, GlyphContextTester {


private static String ttxFilesRoot = "test/resources/complexscripts"; private static String ttxFilesRoot = "test/resources/complexscripts";

+ 71
- 81
test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java View File



import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;

import java.nio.IntBuffer; import java.nio.IntBuffer;

import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;


import org.apache.fop.complexscripts.fonts.GlyphClassTable; import org.apache.fop.complexscripts.fonts.GlyphClassTable;
import org.apache.fop.complexscripts.fonts.GlyphCoverageTable; import org.apache.fop.complexscripts.fonts.GlyphCoverageTable;
import org.apache.fop.complexscripts.fonts.GlyphDefinitionSubtable;
import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable; import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable;
import org.apache.fop.complexscripts.fonts.GlyphMappingTable; import org.apache.fop.complexscripts.fonts.GlyphMappingTable;
import org.apache.fop.complexscripts.fonts.GlyphPositioningSubtable;
import org.apache.fop.complexscripts.fonts.GlyphPositioningTable; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable;
import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.Anchor; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.Anchor;
import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.MarkAnchor; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.MarkAnchor;
import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.PairValues; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.PairValues;
import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.Value; import org.apache.fop.complexscripts.fonts.GlyphPositioningTable.Value;
import org.apache.fop.complexscripts.fonts.GlyphSubstitutionSubtable;
import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable; import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable;
import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable.Ligature; import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable.Ligature;
import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable.LigatureSet; import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable.LigatureSet;
import org.apache.fop.complexscripts.util.UTF32; import org.apache.fop.complexscripts.util.UTF32;
import org.apache.fop.util.CharUtilities; import org.apache.fop.util.CharUtilities;


import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;



// CSOFF: LineLengthCheck // CSOFF: LineLengthCheck


* files directly in the FOP distribution. In such cases, <code>TTX</code> files are used * 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 * to distribute a subset of the complex script advanced table information contained in
* certain font files to facilitate testing. * certain font files to facilitate testing.
*
* @author Glenn Adams
*/ */
public class TTXFile { public class TTXFile {


private static final String DEFAULT_LANGUAGE_TAG = "dflt"; private static final String DEFAULT_LANGUAGE_TAG = "dflt";


/** ttxfile cache */ /** ttxfile cache */
private static Map<String,TTXFile> cache = new HashMap<String,TTXFile>();
private static Map<String, TTXFile> cache = new HashMap<String, TTXFile>();


// transient parsing state // transient parsing state
private Locator locator; // current document locator private Locator locator; // current document locator
private Stack<String[]> elements; // stack of ttx elements being parsed private Stack<String[]> elements; // stack of ttx elements being parsed
private Map<String,Integer> glyphIds; // map of glyph names to glyph identifiers
private Map<String, Integer> glyphIds; // map of glyph names to glyph identifiers
private List<int[]> cmapEntries; // list of <charCode,glyphCode> pairs private List<int[]> cmapEntries; // list of <charCode,glyphCode> pairs
private Vector<int[]> hmtxEntries; // vector of <width,lsb> pairs private Vector<int[]> hmtxEntries; // vector of <width,lsb> pairs
private Map<String,Integer> glyphClasses; // map of glyph names to glyph classes
private Map<String,Map<String,List<String>>> scripts; // map of script tag to Map<language-tag,List<features-id>>>
private Map<String,List<String>> languages; // map of language tag to List<feature-id>
private Map<String,Object[]> features; // map of feature id to Object[2] : { feature-tag, List<lookup-id> }
private Map<String, Integer> glyphClasses; // map of glyph names to glyph classes
private Map<String, Map<String, List<String>>> scripts; // map of script tag to Map<language-tag,List<features-id>>>
private Map<String, List<String>> languages; // map of language tag to List<feature-id>
private Map<String, Object[]> features; // map of feature id to Object[2] : { feature-tag, List<lookup-id> }
private List<String> languageFeatures; // list of language system feature ids, where first is (possibly null) required feature id private List<String> 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<String> featureLookups; // list of lookup ids for feature being constructed
private List<Integer> coverageEntries; // list of entries for coverage table being constructed private List<Integer> coverageEntries; // list of entries for coverage table being constructed
private Map<String,GlyphCoverageTable> coverages; // map of coverage table keys to coverage tables
private Map<String, GlyphCoverageTable> coverages; // map of coverage table keys to coverage tables
private List subtableEntries; // list of lookup subtable entries private List subtableEntries; // list of lookup subtable entries
private List<GlyphSubtable> subtables; // list of constructed subtables private List<GlyphSubtable> subtables; // list of constructed subtables
private List<Integer> alternates; // list of alternates in alternate set being constructed private List<Integer> alternates; // list of alternates in alternate set being constructed


// resultant state // resultant state
private int upem; // units per em private int upem; // units per em
private Map<Integer,Integer> cmap; // constructed character map
private Map<Integer,Integer> gmap; // constructed glyph map
private Map<Integer, Integer> cmap; // constructed character map
private Map<Integer, Integer> gmap; // constructed glyph map
private int[][] hmtx; // constructed horizontal metrics - array of design { width, lsb } pairs, indexed by glyph code private int[][] hmtx; // constructed horizontal metrics - array of design { width, lsb } pairs, indexed by glyph code
private int[] widths; // pdf normalized widths (millipoints) private int[] widths; // pdf normalized widths (millipoints)
private GlyphDefinitionTable gdef; // constructed glyph definition table private GlyphDefinitionTable gdef; // constructed glyph definition table


public TTXFile() { public TTXFile() {
elements = new Stack<String[]>(); elements = new Stack<String[]>();
glyphIds = new HashMap<String,Integer>();
glyphIds = new HashMap<String, Integer>();
cmapEntries = new ArrayList<int[]>(); cmapEntries = new ArrayList<int[]>();
hmtxEntries = new Vector<int[]>(); hmtxEntries = new Vector<int[]>();
glyphClasses = new HashMap<String,Integer>();
scripts = new HashMap<String,Map<String,List<String>>>();
languages = new HashMap<String,List<String>>();
features = new HashMap<String,Object[]>();
glyphClasses = new HashMap<String, Integer>();
scripts = new HashMap<String, Map<String, List<String>>>();
languages = new HashMap<String, List<String>>();
features = new HashMap<String, Object[]>();
languageFeatures = new ArrayList<String>(); languageFeatures = new ArrayList<String>();
featureLookups = new ArrayList<String>(); featureLookups = new ArrayList<String>();
coverageEntries = new ArrayList<Integer>(); coverageEntries = new ArrayList<Integer>();
coverages = new HashMap<String,GlyphCoverageTable>();
coverages = new HashMap<String, GlyphCoverageTable>();
subtableEntries = new ArrayList(); subtableEntries = new ArrayList();
subtables = new ArrayList<GlyphSubtable>(); subtables = new ArrayList<GlyphSubtable>();
alternates = new ArrayList<Integer>(); alternates = new ArrayList<Integer>();
long rest1 = tw % upem; long rest1 = tw % upem;
long storrest = 1000 * rest1; long storrest = 1000 * rest1;
long ledd2 = (storrest != 0) ? (rest1 / storrest) : 0; long ledd2 = (storrest != 0) ? (rest1 / storrest) : 0;
pw = - ((-1000 * tw) / upem - (int) ledd2);
pw = -((-1000 * tw) / upem - (int) ledd2);
} else { } else {
pw = (tw / upem) * 1000 + ((tw % upem) * 1000) / upem; pw = (tw / upem) * 1000 + ((tw % upem) * 1000) / upem;
} }
public static synchronized void clearCache() { public static synchronized void clearCache() {
cache.clear(); cache.clear();
} }
private class Handler extends DefaultHandler {
private final class Handler extends DefaultHandler {
private Handler() { private Handler() {
} }
@Override @Override
} }
} else if (en[1].equals("BaseArray")) { } else if (en[1].equals("BaseArray")) {
String[] pn = new String[] { null, "MarkBasePos" }; String[] pn = new String[] { null, "MarkBasePos" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("BaseCoverage")) { } else if (en[1].equals("BaseCoverage")) {
if (glyphClass == null) { if (glyphClass == null) {
missingRequiredAttribute(en, "class"); missingRequiredAttribute(en, "class");
} }
if (! glyphIds.containsKey(glyph)) {
if (!glyphIds.containsKey(glyph)) {
unsupportedGlyph(en, glyph); unsupportedGlyph(en, glyph);
} else if (isParent(pn1)) { } else if (isParent(pn1)) {
if (glyphClasses.containsKey(glyph)) { if (glyphClasses.containsKey(glyph)) {
} }
} else if (en[1].equals("DefaultLangSys")) { } else if (en[1].equals("DefaultLangSys")) {
String[] pn = new String[] { null, "Script" }; String[] pn = new String[] { null, "Script" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} else { } else {
assertLanguageFeaturesClear(); assertLanguageFeaturesClear();
} }
} else if (en[1].equals("Feature")) { } else if (en[1].equals("Feature")) {
String[] pn = new String[] { null, "FeatureRecord" }; String[] pn = new String[] { null, "FeatureRecord" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} else { } else {
assertFeatureLookupsClear(); assertFeatureLookupsClear();
String[] pn1 = new String[] { null, "GSUB" }; String[] pn1 = new String[] { null, "GSUB" };
String[] pn2 = new String[] { null, "GPOS" }; String[] pn2 = new String[] { null, "GPOS" };
String[][] pnx = new String[][] { pn1, pn2 }; String[][] pnx = new String[][] { pn1, pn2 };
if (! isParent(pnx)) {
if (!isParent(pnx)) {
notPermittedInElementContext(en, getParent(), pnx); notPermittedInElementContext(en, getParent(), pnx);
} }
} else if (en[1].equals("FeatureRecord")) { } else if (en[1].equals("FeatureRecord")) {
} }
} else if (en[1].equals("GlyphOrder")) { } else if (en[1].equals("GlyphOrder")) {
String[] pn = new String[] { null, "ttFont" }; String[] pn = new String[] { null, "ttFont" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("InputCoverage")) { } else if (en[1].equals("InputCoverage")) {
} }
} else if (en[1].equals("LangSys")) { } else if (en[1].equals("LangSys")) {
String[] pn = new String[] { null, "LangSysRecord" }; String[] pn = new String[] { null, "LangSysRecord" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} else { } else {
assertLanguageFeaturesClear(); assertLanguageFeaturesClear();
} }
} else if (en[1].equals("LigCaretList")) { } else if (en[1].equals("LigCaretList")) {
String[] pn = new String[] { null, "GDEF" }; String[] pn = new String[] { null, "GDEF" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("Ligature")) { } else if (en[1].equals("Ligature")) {
} }
} else if (en[1].equals("LigatureArray")) { } else if (en[1].equals("LigatureArray")) {
String[] pn = new String[] { null, "MarkLigPos" }; String[] pn = new String[] { null, "MarkLigPos" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("LigatureAttach")) { } else if (en[1].equals("LigatureAttach")) {
String[] pn1 = new String[] { null, "GSUB" }; String[] pn1 = new String[] { null, "GSUB" };
String[] pn2 = new String[] { null, "GPOS" }; String[] pn2 = new String[] { null, "GPOS" };
String[][] pnx = new String[][] { pn1, pn2 }; String[][] pnx = new String[][] { pn1, pn2 };
if (! isParent(pnx)) {
if (!isParent(pnx)) {
notPermittedInElementContext(en, getParent(), pnx); notPermittedInElementContext(en, getParent(), pnx);
} }
} else if (en[1].equals("LookupListIndex")) { } else if (en[1].equals("LookupListIndex")) {
} }
} else if (en[1].equals("Mark1Array")) { } else if (en[1].equals("Mark1Array")) {
String[] pn = new String[] { null, "MarkMarkPos" }; String[] pn = new String[] { null, "MarkMarkPos" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("Mark1Coverage")) { } else if (en[1].equals("Mark1Coverage")) {
} }
} else if (en[1].equals("Mark2Array")) { } else if (en[1].equals("Mark2Array")) {
String[] pn = new String[] { null, "MarkMarkPos" }; String[] pn = new String[] { null, "MarkMarkPos" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("Mark2Coverage")) { } else if (en[1].equals("Mark2Coverage")) {
String[] pn1 = new String[] { null, "MarkBasePos" }; String[] pn1 = new String[] { null, "MarkBasePos" };
String[] pn2 = new String[] { null, "MarkLigPos" }; String[] pn2 = new String[] { null, "MarkLigPos" };
String[][] pnx = new String[][] { pn1, pn2 }; String[][] pnx = new String[][] { pn1, pn2 };
if (! isParent(pnx)) {
if (!isParent(pnx)) {
notPermittedInElementContext(en, getParent(), pnx); notPermittedInElementContext(en, getParent(), pnx);
} }
} else if (en[1].equals("MarkAttachClassDef")) { } else if (en[1].equals("MarkAttachClassDef")) {
} }
} else if (en[1].equals("Script")) { } else if (en[1].equals("Script")) {
String[] pn = new String[] { null, "ScriptRecord" }; String[] pn = new String[] { null, "ScriptRecord" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("ScriptList")) { } else if (en[1].equals("ScriptList")) {
String[] pn1 = new String[] { null, "GSUB" }; String[] pn1 = new String[] { null, "GSUB" };
String[] pn2 = new String[] { null, "GPOS" }; String[] pn2 = new String[] { null, "GPOS" };
String[][] pnx = new String[][] { pn1, pn2 }; String[][] pnx = new String[][] { pn1, pn2 };
if (! isParent(pnx)) {
if (!isParent(pnx)) {
notPermittedInElementContext(en, getParent(), pnx); notPermittedInElementContext(en, getParent(), pnx);
} }
} else if (en[1].equals("ScriptRecord")) { } else if (en[1].equals("ScriptRecord")) {
} }
} else if (en[1].equals("cmap")) { } else if (en[1].equals("cmap")) {
String[] pn = new String[] { null, "ttFont" }; String[] pn = new String[] { null, "ttFont" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("cmap_format_0")) { } else if (en[1].equals("cmap_format_0")) {
} }
} else if (en[1].equals("head")) { } else if (en[1].equals("head")) {
String[] pn = new String[] { null, "ttFont" }; String[] pn = new String[] { null, "ttFont" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} }
} else if (en[1].equals("hmtx")) { } else if (en[1].equals("hmtx")) {
String[] pn = new String[] { null, "ttFont" }; String[] pn = new String[] { null, "ttFont" };
if (! isParent(pn)) {
if (!isParent(pn)) {
notPermittedInElementContext(en, getParent(), pn); notPermittedInElementContext(en, getParent(), pn);
} else if (glyphIdMax > 0) { } else if (glyphIdMax > 0) {
hmtxEntries.setSize(glyphIdMax + 1); hmtxEntries.setSize(glyphIdMax + 1);
throw new SAXException("element stack is empty, elements are not balanced"); throw new SAXException("element stack is empty, elements are not balanced");
} }
String[] en = makeExpandedName(uri, localName, qName); String[] en = makeExpandedName(uri, localName, qName);
if (! sameExpandedName(enParent, en)) {
if (!sameExpandedName(enParent, en)) {
throw new SAXException("element stack is unbalanced, expanded name mismatch"); throw new SAXException("element stack is unbalanced, expanded name mismatch");
} }
if (en[0] != null) { if (en[0] != null) {
} else if (en[1].equals("AlternateSet")) { } else if (en[1].equals("AlternateSet")) {
subtableEntries.add(extractAlternates()); subtableEntries.add(extractAlternates());
} else if (en[1].equals("AlternateSubst")) { } else if (en[1].equals("AlternateSubst")) {
if (! sortEntries(coverageEntries, subtableEntries)) {
if (!sortEntries(coverageEntries, subtableEntries)) {
mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); mismatchedEntries(en, coverageEntries.size(), subtableEntries.size());
} }
addGSUBSubtable(GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_ALTERNATE, extractCoverage()); addGSUBSubtable(GlyphSubstitutionTable.GSUB_LOOKUP_TYPE_ALTERNATE, extractCoverage());
} else if (en[1].equals("ChainContextPos") || en[1].equals("ChainContextSubst")) { } else if (en[1].equals("ChainContextPos") || en[1].equals("ChainContextSubst")) {
GlyphCoverageTable coverage = null; GlyphCoverageTable coverage = null;
if (stFormat == 3) { if (stFormat == 3) {
GlyphCoverageTable igca[] = getCoveragesWithPrefix("in");
GlyphCoverageTable bgca[] = getCoveragesWithPrefix("bk");
GlyphCoverageTable lgca[] = getCoveragesWithPrefix("la");
GlyphCoverageTable[] igca = getCoveragesWithPrefix("in");
GlyphCoverageTable[] bgca = getCoveragesWithPrefix("bk");
GlyphCoverageTable[] lgca = getCoveragesWithPrefix("la");
if ((igca.length == 0) || hasMissingCoverage(igca)) { if ((igca.length == 0) || hasMissingCoverage(igca)) {
missingCoverage(en, "input", igca.length); missingCoverage(en, "input", igca.length);
} else if (hasMissingCoverage(bgca)) { } else if (hasMissingCoverage(bgca)) {
} else if (en[1].equals("LigatureSet")) { } else if (en[1].equals("LigatureSet")) {
subtableEntries.add(extractLigatures()); subtableEntries.add(extractLigatures());
} else if (en[1].equals("LigatureSubst")) { } else if (en[1].equals("LigatureSubst")) {
if (! sortEntries(coverageEntries, subtableEntries)) {
if (!sortEntries(coverageEntries, subtableEntries)) {
mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); mismatchedEntries(en, coverageEntries.size(), subtableEntries.size());
} }
GlyphCoverageTable coverage = extractCoverage(); GlyphCoverageTable coverage = extractCoverage();
} }
GlyphCoverageTable coverage = coverages.get("main"); GlyphCoverageTable coverage = coverages.get("main");
addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_PAIR, coverage); addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_PAIR, coverage);
vf1 = vf2 = -1; psIndex = -1;
vf1 = vf2 = -1;
psIndex = -1;
} else if (en[1].equals("PairSet")) { } else if (en[1].equals("PairSet")) {
if (psIndex != pairSets.size()) { if (psIndex != pairSets.size()) {
invalidIndex(en, psIndex, pairSets.size()); invalidIndex(en, psIndex, pairSets.size());
addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_SINGLE, coverage); addGPOSSubtable(GlyphPositioningTable.GPOS_LOOKUP_TYPE_SINGLE, coverage);
vf1 = -1; vf1 = -1;
} else if (en[1].equals("SingleSubst")) { } else if (en[1].equals("SingleSubst")) {
if (! sortEntries(coverageEntries, subtableEntries)) {
if (!sortEntries(coverageEntries, subtableEntries)) {
mismatchedEntries(en, coverageEntries.size(), subtableEntries.size()); mismatchedEntries(en, coverageEntries.size(), subtableEntries.size());
} }
GlyphCoverageTable coverage = extractCoverage(); GlyphCoverageTable coverage = extractCoverage();
public void characters(char[] chars, int start, int length) { public void characters(char[] chars, int start, int length) {
} }
private String[] getParent() { private String[] getParent() {
if (! elements.empty()) {
if (!elements.empty()) {
return elements.peek(); return elements.peek();
} else { } else {
return new String[] { null, null }; return new String[] { null, null };
return false; return false;
} else if (enx instanceof String[]) { } else if (enx instanceof String[]) {
String[] en = (String[]) enx; String[] en = (String[]) enx;
if (! elements.empty()) {
if (!elements.empty()) {
String[] pn = elements.peek(); String[] pn = elements.peek();
return (pn != null) && sameExpandedName(en, pn); return (pn != null) && sameExpandedName(en, pn);
} else if ((en[0] == null) && (en[1] == null)) {
return true;
} else { } else {
return false;
return ((en[0] == null) && (en[1] == null));
} }
} else { } else {
return false; return false;
return true; return true;
} else if (ln.equals("MarkAnchor")) { } else if (ln.equals("MarkAnchor")) {
return true; return true;
} else if (ln.equals("Mark2Anchor")) {
return true;
} else { } else {
return false;
return ln.equals("Mark2Anchor");
} }
} }
private Map<Integer,Integer> getCMAP() {
Map<Integer,Integer> cmap = new TreeMap();
private Map<Integer, Integer> getCMAP() {
Map<Integer, Integer> cmap = new TreeMap();
for (int[] cme : cmapEntries) { for (int[] cme : cmapEntries) {
Integer c = Integer.valueOf(cme[0]); Integer c = Integer.valueOf(cme[0]);
Integer g = Integer.valueOf(cme[1]); Integer g = Integer.valueOf(cme[1]);
} }
return cmap; return cmap;
} }
private Map<Integer,Integer> getGMAP() {
Map<Integer,Integer> gmap = new TreeMap();
private Map<Integer, Integer> getGMAP() {
Map<Integer, Integer> gmap = new TreeMap();
for (int[] cme : cmapEntries) { for (int[] cme : cmapEntries) {
Integer c = Integer.valueOf(cme[0]); Integer c = Integer.valueOf(cme[0]);
Integer g = Integer.valueOf(cme[1]); Integer g = Integer.valueOf(cme[1]);
} }
return hmtx; return hmtx;
} }
private GlyphClassTable extractClassDefMapping(Map<String,Integer> glyphClasses, int format, boolean clearSourceMap) {
private GlyphClassTable extractClassDefMapping(Map<String, Integer> glyphClasses, int format, boolean clearSourceMap) {
GlyphClassTable ct; GlyphClassTable ct;
if (format == 1) { if (format == 1) {
ct = extractClassDefMapping1(extractClassMappings(glyphClasses, clearSourceMap)); ct = extractClassDefMapping1(extractClassMappings(glyphClasses, clearSourceMap));
} }
return GlyphClassTable.createClassTable(entries); return GlyphClassTable.createClassTable(entries);
} }
private int[][] extractClassMappings(Map<String,Integer> glyphClasses, boolean clearSourceMap) {
private int[][] extractClassMappings(Map<String, Integer> glyphClasses, boolean clearSourceMap) {
int nc = glyphClasses.size(); int nc = glyphClasses.size();
int i = 0; int i = 0;
int[][] cma = new int [ nc ] [ 2 ]; int[][] cma = new int [ nc ] [ 2 ];
for (Map.Entry<String,Integer> e : glyphClasses.entrySet()) {
for (Map.Entry<String, Integer> e : glyphClasses.entrySet()) {
Integer gid = glyphIds.get(e.getKey()); Integer gid = glyphIds.get(e.getKey());
assert gid != null; assert gid != null;
int[] m = cma [ i ]; int[] m = cma [ i ];
private void clearLanguageFeatures() { private void clearLanguageFeatures() {
languageFeatures.clear(); languageFeatures.clear();
} }
private Map<String,List<String>> extractLanguages() {
Map<String,List<String>> lm = new HashMap(languages);
private Map<String, List<String>> extractLanguages() {
Map<String, List<String>> lm = new HashMap(languages);
clearLanguages(); clearLanguages();
return lm; return lm;
} }
ltFlags = 0; ltFlags = 0;
clearSubtablesInLookup(); clearSubtablesInLookup();
} }
private Map<GlyphTable.LookupSpec,List<String>> extractLookups() {
Map<GlyphTable.LookupSpec,List<String>> lookups = new LinkedHashMap<GlyphTable.LookupSpec,List<String>>();
private Map<GlyphTable.LookupSpec, List<String>> extractLookups() {
Map<GlyphTable.LookupSpec, List<String>> lookups = new LinkedHashMap<GlyphTable.LookupSpec, List<String>>();
for (String st : scripts.keySet()) { for (String st : scripts.keySet()) {
Map<String,List<String>> lm = scripts.get(st);
Map<String, List<String>> lm = scripts.get(st);
if (lm != null) { if (lm != null) {
for (String lt : lm.keySet()) { for (String lt : lm.keySet()) {
List<String> fids = lm.get(lt); List<String> fids = lm.get(lt);
missingParameter(en, "xAdvance"); missingParameter(en, "xAdvance");
} }
String yAdvance = attrs.getValue("YAdvance"); String yAdvance = attrs.getValue("YAdvance");
int ya = 0;;
int ya = 0;
if (yAdvance != null) { if (yAdvance != null) {
ya = Integer.parseInt(yAdvance); ya = Integer.parseInt(yAdvance);
} else if ((format & GlyphPositioningTable.Value.Y_ADVANCE) != 0) { } else if ((format & GlyphPositioningTable.Value.Y_ADVANCE) != 0) {
if (cm != null) { if (cm != null) {
for (Anchor[] aa : cm) { for (Anchor[] aa : cm) {
if (aa != null) { if (aa != null) {
int nc = aa.length;;
int nc = aa.length;
if (nc > ncMax) { if (nc > ncMax) {
ncMax = nc; ncMax = nc;
} }
if (lam != null) { if (lam != null) {
for (Anchor[][] cm : lam) { for (Anchor[][] cm : lam) {
if (cm != null) { if (cm != null) {
int nx = cm.length;;
int nx = cm.length;
if (nx > nxMax) { if (nx > nxMax) {
nxMax = nx; nxMax = nx;
} }
return false; return false;
} }
if ((u1 != null) && (u2 != null)) { if ((u1 != null) && (u2 != null)) {
if (! u1.equals(u2)) {
if (!u1.equals(u2)) {
return false; return false;
} }
} }
return false; return false;
} }
if ((l1 != null) && (l2 != null)) { if ((l1 != null) && (l2 != null)) {
if (! l1.equals(l2)) {
if (!l1.equals(l2)) {
return false; return false;
} }
} }

+ 1
- 3
test/java/org/apache/fop/complexscripts/scripts/ScriptsTestSuite.java View File

* Test suite for script specific functionality related to complex scripts. * Test suite for script specific functionality related to complex scripts.
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({
ArabicTestCase.class
})
@SuiteClasses(ArabicTestCase.class)
public class ScriptsTestSuite { public class ScriptsTestSuite {
} }

+ 13
- 17
test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestCase.java View File



import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List; import java.util.List;


import org.apache.fop.complexscripts.fonts.GlyphPositioningTable;
import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable;
import org.apache.fop.complexscripts.fonts.ttx.TTXFile;
import org.apache.fop.complexscripts.util.GlyphSequence;

import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; 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. * Tests for functionality related to the arabic script.
*/ */


@Test @Test
public void testArabicWordForms() { public void testArabicWordForms() {
for (String sfn : srcFiles) {
for (String sfn : SRC_FILES) {
try { try {
processWordForms(new File(datFilesDir));
processWordForms(new File(DAT_FILES_DIR));
} catch (Exception e) { } catch (Exception e) {
fail(e.getMessage()); fail(e.getMessage());
} }
private String[] listWordFormFiles(File dfd) { private String[] listWordFormFiles(File dfd) {
return dfd.list(new FilenameFilter() { return dfd.list(new FilenameFilter() {
public boolean accept(File f, String name) { public boolean accept(File f, String name) {
return hasPrefixFrom(name, srcFiles) && hasExtension(name, WF_FILE_DAT_EXT);
return hasPrefixFrom(name, SRC_FILES) && hasExtension(name, WF_FILE_DAT_EXT);
} }
private boolean hasPrefixFrom(String name, String[] prefixes) { private boolean hasPrefixFrom(String name, String[] prefixes) {
for (String p : prefixes) { for (String p : prefixes) {
throw new RuntimeException(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e);
} finally { } finally {
if (fis != null) { if (fis != null) {
try { fis.close(); } catch (Exception e) {}
try { fis.close(); } catch (Exception e) { /* NOP */ }
} }
} }
} }
script = (String) d[0]; script = (String) d[0];
language = (String) d[1]; language = (String) d[1];
tfn = (String) d[3]; tfn = (String) d[3];
tf = TTXFile.getFromCache(ttxFontsDir + File.separator + tfn);
tf = TTXFile.getFromCache(TTX_FONTS_DIR + File.separator + tfn);
assertTrue(tf != null); assertTrue(tf != null);
gsub = tf.getGSUB(); gsub = tf.getGSUB();
assertTrue(gsub != null); assertTrue(gsub != null);

+ 9
- 9
test/java/org/apache/fop/complexscripts/scripts/arabic/ArabicTestConstants.java View File

*/ */
public interface ArabicTestConstants { public interface ArabicTestConstants {


final String WF_FILE_SCRIPT = "arab";
final String WF_FILE_LANGUAGE = "dflt";
String WF_FILE_SCRIPT = "arab";
String WF_FILE_LANGUAGE = "dflt";


String srcFilesDir = "test/resources/complexscripts/arab/data";
String datFilesDir = "test/resources/complexscripts/arab/data";
String SRC_FILES_DIR = "test/resources/complexscripts/arab/data";
String DAT_FILES_DIR = "test/resources/complexscripts/arab/data";


String[] srcFiles = {
String[] SRC_FILES = {
"arab-001", // unpointed word forms "arab-001", // unpointed word forms
}; };


final String WF_FILE_SRC_EXT = "txt";
final String WF_FILE_DAT_EXT = "ser";
String WF_FILE_SRC_EXT = "txt";
String WF_FILE_DAT_EXT = "ser";


String ttxFontsDir = "test/resources/complexscripts/arab/ttx";
String TTX_FONTS_DIR = "test/resources/complexscripts/arab/ttx";


String[] ttxFonts = {
String[] TTX_FONTS = {
"arab-001.ttx", // simplified arabic "arab-001.ttx", // simplified arabic
"arab-002.ttx", // traditional arabic "arab-002.ttx", // traditional arabic
"arab-003.ttx", // lateef "arab-003.ttx", // lateef

+ 12
- 9
test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java View File

/** /**
* Tests for functionality related to the arabic script. * Tests for functionality related to the arabic script.
*/ */
public class GenerateArabicTestData implements ArabicTestConstants {
public final class GenerateArabicTestData implements ArabicTestConstants {

private GenerateArabicTestData() {
}


public static void main(String[] args) { public static void main(String[] args) {
boolean compile = false; boolean compile = false;
} }


private static void compile() { private static void compile() {
for (String sfn : srcFiles) {
for (String sfn : SRC_FILES) {
try { try {
String spn = srcFilesDir + File.separator + sfn + "." + WF_FILE_SRC_EXT;
String spn = SRC_FILES_DIR + File.separator + sfn + "." + WF_FILE_SRC_EXT;
compile(WF_FILE_SCRIPT, WF_FILE_LANGUAGE, spn); compile(WF_FILE_SCRIPT, WF_FILE_LANGUAGE, spn);
} catch (Exception e) { } catch (Exception e) {
System.err.println(e.getMessage()); System.err.println(e.getMessage());


private static void compile(String script, String language, String spn) { private static void compile(String script, String language, String spn) {
int fno = 0; int fno = 0;
for (String tfn : ttxFonts) {
TTXFile tf = TTXFile.getFromCache(ttxFontsDir + File.separator + tfn);
for (String tfn : TTX_FONTS) {
TTXFile tf = TTXFile.getFromCache(TTX_FONTS_DIR + File.separator + tfn);
assert tf != null; assert tf != null;
List data = compile(script, language, spn, tfn, tf); List data = compile(script, language, spn, tfn, tf);
output(makeDataPathName(spn, fno++), data); output(makeDataPathName(spn, fno++), data);
GlyphSequence igs = tf.mapCharsToGlyphs(wf); GlyphSequence igs = tf.mapCharsToGlyphs(wf);
GlyphSequence ogs = gsub.substitute(igs, script, language); GlyphSequence ogs = gsub.substitute(igs, script, language);
int[][] paa = new int [ ogs.getGlyphCount() ] [ 4 ]; int[][] paa = new int [ ogs.getGlyphCount() ] [ 4 ];
if (! gpos.position(ogs, script, language, 1000, widths, paa)) {
if (!gpos.position(ogs, script, language, 1000, widths, paa)) {
paa = null; paa = null;
} }
data.add(new Object[] { wf, getGlyphs(igs), getGlyphs(ogs), paa }); data.add(new Object[] { wf, getGlyphs(igs), getGlyphs(ogs), paa });
throw new RuntimeException(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e);
} finally { } finally {
if (fis != null) { if (fis != null) {
try { fis.close(); } catch (Exception e) {}
try { fis.close(); } catch (Exception e) { /* NOP */ }
} }
} }
} else { } else {


private static String makeDataPathName(String spn, int fno) { private static String makeDataPathName(String spn, int fno) {
File f = new File(spn); File f = new File(spn);
return datFilesDir + File.separator + stripExtension(f.getName()) + "-f" + fno + "." + WF_FILE_DAT_EXT;
return DAT_FILES_DIR + File.separator + stripExtension(f.getName()) + "-f" + fno + "." + WF_FILE_DAT_EXT;
} }


private static String stripExtension(String s) { private static String stripExtension(String s) {
throw new RuntimeException(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e);
} finally { } finally {
if (fos != null) { if (fos != null) {
try { fos.close(); } catch (Exception e) {}
try { fos.close(); } catch (Exception e) { /* NOP */ }
} }
} }
} }

+ 33
- 35
test/java/org/apache/fop/complexscripts/util/NumberConverterTestCase.java View File



/** /**
* Test number converter functionality. * Test number converter functionality.
*
* @author Glenn Adams
*/ */
public class NumberConverterTestCase { public class NumberConverterTestCase {


static private String[][] formatDecimal =
private static String[][] formatDecimal =
{ {
{ "1" }, { "1" },
{ "0", "0" }, { "0", "0" },
{ "1000000000", "1000000000" }, { "1000000000", "1000000000" },
}; };


static private String[][] formatDecimalPadded =
private static String[][] formatDecimalPadded =
{ {
{ "001" }, { "001" },
{ "0", "000" }, { "0", "000" },
{ "1000", "1000" }, { "1000", "1000" },
}; };


static private String[][] formatDecimalGrouped =
private static String[][] formatDecimalGrouped =
{ {
{ "1", ",", "1" }, { "1", ",", "1" },
{ "0", "0" }, { "0", "0" },
{ "1000000000", "1,0,0,0,0,0,0,0,0,0" }, { "1000000000", "1,0,0,0,0,0,0,0,0,0" },
}; };


static private String[][] formatDecimalGroupedPadded =
private static String[][] formatDecimalGroupedPadded =
{ {
{ "001", ",", "2" }, { "001", ",", "2" },
{ "0", "0,00" }, { "0", "0,00" },
{ "1000", "10,00" }, { "1000", "10,00" },
}; };


static private String[][] formatDecimalArabic =
private static String[][] formatDecimalArabic =
{ {
{ "\u0661" }, { "\u0661" },
{ "0", "\u0660" }, { "0", "\u0660" },
{ "1000000000", "\u0661\u0660\u0660\u0660\u0660\u0660\u0660\u0660\u0660\u0660" }, { "1000000000", "\u0661\u0660\u0660\u0660\u0660\u0660\u0660\u0660\u0660\u0660" },
}; };


static private String[][] formatDecimalArabicPadded =
private static String[][] formatDecimalArabicPadded =
{ {
{ "\u0660\u0660\u0661" }, { "\u0660\u0660\u0661" },
{ "0", "\u0660\u0660\u0660" }, { "0", "\u0660\u0660\u0660" },
{ "1000", "\u0661\u0660\u0660\u0660" }, { "1000", "\u0661\u0660\u0660\u0660" },
}; };


static private String[][] formatDecimalArabicGrouped =
private static String[][] formatDecimalArabicGrouped =
{ {
{ "\u0661", "\u066c", "1" }, { "\u0661", "\u066c", "1" },
{ "0", "\u0660" }, { "0", "\u0660" },
{ "1000000000", "\u0661\u066c\u0660\u066c\u0660\u066c\u0660\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" },
}; };


static private String[][] formatDecimalArabicGroupedPadded =
private static String[][] formatDecimalArabicGroupedPadded =
{ {
{ "\u0660\u0660\u0661", "\u066c", "2" }, { "\u0660\u0660\u0661", "\u066c", "2" },
{ "0", "\u0660\u066c\u0660\u0660" }, { "0", "\u0660\u066c\u0660\u0660" },
{ "1000", "\u0661\u0660\u066c\u0660\u0660" }, { "1000", "\u0661\u0660\u066c\u0660\u0660" },
}; };


static private String[][] formatDecimalThai =
private static String[][] formatDecimalThai =
{ {
{ "\u0E51" }, { "\u0E51" },
{ "0", "\u0E50" }, { "0", "\u0E50" },
{ "1000000000", "\u0E51\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50" }, { "1000000000", "\u0E51\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50\u0E50" },
}; };


static private String[][] formatDecimalThaiPadded =
private static String[][] formatDecimalThaiPadded =
{ {
{ "\u0E50\u0E50\u0E51" }, { "\u0E50\u0E50\u0E51" },
{ "0", "\u0E50\u0E50\u0E50" }, { "0", "\u0E50\u0E50\u0E50" },
{ "1000", "\u0E51\u0E50\u0E50\u0E50" }, { "1000", "\u0E51\u0E50\u0E50\u0E50" },
}; };


static private String[][] formatRomanLower =
private static String[][] formatRomanLower =
{ {
{ "i" }, { "i" },
{ "0", "0" }, { "0", "0" },
{ "5000", "5000" }, { "5000", "5000" },
}; };


static private String[][] formatRomanUpper =
private static String[][] formatRomanUpper =
{ {


{ "I" }, { "I" },
{ "5000", "5000" }, { "5000", "5000" },
}; };


static private String[][] formatRomanLargeLower =
private static String[][] formatRomanLargeLower =
{ {
{ "i", null, null, null, "large" }, { "i", null, null, null, "large" },
{ "0", "0" }, { "0", "0" },
{ "200000", "200000" }, { "200000", "200000" },
}; };


static private String[][] formatRomanLargeUpper =
private static String[][] formatRomanLargeUpper =
{ {
{ "I", null, null, null, "large" }, { "I", null, null, null, "large" },
{ "0", "0" }, { "0", "0" },
{ "200000", "200000" }, { "200000", "200000" },
}; };


static private String[][] formatRomanNumberFormsLower =
private static String[][] formatRomanNumberFormsLower =
{ {
{ "i", null, null, null, "unicode-number-forms" }, { "i", null, null, null, "unicode-number-forms" },
{ "0", "0" }, { "0", "0" },
{ "200000", "200000" }, { "200000", "200000" },
}; };


static private String[][] formatRomanNumberFormsUpper =
private static String[][] formatRomanNumberFormsUpper =
{ {
{ "I", null, null, null, "unicode-number-forms" }, { "I", null, null, null, "unicode-number-forms" },
{ "0", "0" }, { "0", "0" },
{ "200000", "200000" }, { "200000", "200000" },
}; };


static private String[][] formatAlphabeticLatinLower =
private static String[][] formatAlphabeticLatinLower =
{ {
{ "a" }, { "a" },
{ "0", "0" }, { "0", "0" },
{ "1000000", "bdwgn" }, { "1000000", "bdwgn" },
}; };


static private String[][] formatAlphabeticLatinUpper =
private static String[][] formatAlphabeticLatinUpper =
{ {
{ "A" }, { "A" },
{ "0", "0" }, { "0", "0" },
{ "1000000", "BDWGN" }, { "1000000", "BDWGN" },
}; };


static private String[][] formatAlphabeticArabicHijai =
private static String[][] formatAlphabeticArabicHijai =
{ {
{ "\u0627", null, null, "alphabetic" }, { "\u0627", null, null, "alphabetic" },
{ "0", "0" }, { "0", "0" },
{ "1000000", "\u0623\u0638\u0636\u0635\u062F" }, { "1000000", "\u0623\u0638\u0636\u0635\u062F" },
}; };


static private String[][] formatAlphabeticArabicAbjadi =
private static String[][] formatAlphabeticArabicAbjadi =
{ {
{ "\u0627", null, null, "traditional" }, { "\u0627", null, null, "traditional" },
{ "0", "0" }, { "0", "0" },
{ "1000000", "\u0623\u0641\u0633\u0646\u062D" }, { "1000000", "\u0623\u0641\u0633\u0646\u062D" },
}; };


static private String[][] formatNumeralArabicAbjadi =
private static String[][] formatNumeralArabicAbjadi =
{ {
{ "\u0623", null, null, "traditional" }, { "\u0623", null, null, "traditional" },
{ "0", "0" }, { "0", "0" },
{ "2000", "2000" }, { "2000", "2000" },
}; };


static private String[][] formatAlphabeticHebrew =
private static String[][] formatAlphabeticHebrew =
{ {
{ "\u05D0", null, null, "alphabetic" }, { "\u05D0", null, null, "alphabetic" },
{ "0", "0" }, { "0", "0" },
{ "1000000", "\u05D0\u05DA\u05E9\u05E8\u05D0" }, { "1000000", "\u05D0\u05DA\u05E9\u05E8\u05D0" },
}; };


static private String[][] formatNumeralHebrewGematria =
private static String[][] formatNumeralHebrewGematria =
{ {
{ "\u05D0", null, null, "traditional" }, { "\u05D0", null, null, "traditional" },
{ "0", "0" }, { "0", "0" },
{ "2000", "2000" }, { "2000", "2000" },
}; };


static private String[][] formatAlphabeticThai =
private static String[][] formatAlphabeticThai =
{ {
{ "\u0E01", null, null, "alphabetic" }, { "\u0E01", null, null, "alphabetic" },
{ "0", "0" }, { "0", "0" },
{ "1000000", "\u0E0B\u0E20\u0E17\u0E0C" }, { "1000000", "\u0E0B\u0E20\u0E17\u0E0C" },
}; };


static private String[][] formatWordEnglishLower =
private static String[][] formatWordEnglishLower =
{ {
{ "w", null, null, null, null, "eng" }, { "w", null, null, null, null, "eng" },
{ "0", "zero" }, { "0", "zero" },
{ "1000000000", "one billion" } { "1000000000", "one billion" }
}; };


static private String[][] formatWordEnglishUpper =
private static String[][] formatWordEnglishUpper =
{ {
{ "W", null, null, null, null, "eng" }, { "W", null, null, null, null, "eng" },
{ "0", "ZERO" }, { "0", "ZERO" },
{ "1000000000", "ONE BILLION" } { "1000000000", "ONE BILLION" }
}; };


static private String[][] formatWordEnglishTitle =
private static String[][] formatWordEnglishTitle =
{ {
{ "Ww", null, null, null, null, "eng" }, { "Ww", null, null, null, null, "eng" },
{ "0", "Zero" }, { "0", "Zero" },
{ "1000000000", "One Billion" } { "1000000000", "One Billion" }
}; };


static private String[][] formatWordSpanishLower =
private static String[][] formatWordSpanishLower =
{ {
{ "w", null, null, null, null, "spa" }, { "w", null, null, null, null, "spa" },
{ "0", "cero" }, { "0", "cero" },
{ "1000000000", "mil millones" } { "1000000000", "mil millones" }
}; };


static private String[][] formatWordSpanishUpper =
private static String[][] formatWordSpanishUpper =
{ {
{ "W", null, null, null, null, "spa" }, { "W", null, null, null, null, "spa" },
{ "0", "CERO" }, { "0", "CERO" },
{ "1000000000", "MIL MILLONES" } { "1000000000", "MIL MILLONES" }
}; };


static private String[][] formatWordSpanishTitle =
private static String[][] formatWordSpanishTitle =
{ {
{ "Ww", null, null, null, null, "spa" }, { "Ww", null, null, null, null, "spa" },
{ "0", "Cero" }, { "0", "Cero" },
{ "1000000000", "Mil Millones" } { "1000000000", "Mil Millones" }
}; };


static private String[][] formatWordFrenchLower =
private static String[][] formatWordFrenchLower =
{ {
{ "w", null, null, null, null, "fra" }, { "w", null, null, null, null, "fra" },
{ "0", "z\u00e9ro" }, { "0", "z\u00e9ro" },
{ "1000000000", "un milliard" } { "1000000000", "un milliard" }
}; };


static private String[][] formatWordFrenchUpper =
private static String[][] formatWordFrenchUpper =
{ {
{ "W", null, null, null, null, "fra" }, { "W", null, null, null, null, "fra" },
{ "0", "Z\u00c9RO" }, { "0", "Z\u00c9RO" },
{ "1000000000", "UN MILLIARD" } { "1000000000", "UN MILLIARD" }
}; };


static private String[][] formatWordFrenchTitle =
private static String[][] formatWordFrenchTitle =
{ {
{ "Ww", null, null, null, null, "fra" }, { "Ww", null, null, null, null, "fra" },
{ "0", "Z\u00e9ro" }, { "0", "Z\u00e9ro" },

+ 1
- 3
test/java/org/apache/fop/complexscripts/util/UtilTestSuite.java View File

* Test suite for bidirectional functionality. * Test suite for bidirectional functionality.
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({
NumberConverterTestCase.class
})
@SuiteClasses(NumberConverterTestCase.class)
public class UtilTestSuite { public class UtilTestSuite {
} }

+ 0
- 1
test/java/org/apache/fop/config/FontAttributesMissingTestCase.java View File

import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PDFRendererConfBuilder; import org.apache.fop.apps.PDFRendererConfBuilder;


/** /**

+ 0
- 1
test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java View File

import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PDFRendererConfBuilder; import org.apache.fop.apps.PDFRendererConfBuilder;


/** /**

+ 0
- 1
test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java View File

import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PDFRendererConfBuilder; import org.apache.fop.apps.PDFRendererConfBuilder;


/** /**

+ 0
- 1
test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java View File

import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PDFRendererConfBuilder; import org.apache.fop.apps.PDFRendererConfBuilder;


/** /**

+ 0
- 1
test/java/org/apache/fop/config/FontsAutoDetectTestCase.java View File

import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PDFRendererConfBuilder; import org.apache.fop.apps.PDFRendererConfBuilder;


public class FontsAutoDetectTestCase extends BaseConstructiveUserConfigTest { public class FontsAutoDetectTestCase extends BaseConstructiveUserConfigTest {

+ 0
- 1
test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java View File

import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PDFRendererConfBuilder; import org.apache.fop.apps.PDFRendererConfBuilder;


/** /**

+ 2
- 2
test/java/org/apache/fop/datatypes/URISpecificationTestCase.java View File



package org.apache.fop.datatypes; package org.apache.fop.datatypes;


import static org.junit.Assert.assertEquals;

import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

/** /**
* Tests for URISpecification. * Tests for URISpecification.
*/ */

+ 2
- 1
test/java/org/apache/fop/events/BasicEventTestCase.java View File



package org.apache.fop.events; package org.apache.fop.events;


import org.junit.Test;

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


import org.apache.fop.events.model.EventSeverity; import org.apache.fop.events.model.EventSeverity;
import org.junit.Test;


public class BasicEventTestCase { public class BasicEventTestCase {



+ 4
- 1
test/java/org/apache/fop/events/TestEventProducer.java View File

*/ */
void enjoy(Object source, String what); void enjoy(Object source, String what);


public class Provider {
public static final class Provider {

private Provider() {
}


public static TestEventProducer get(EventBroadcaster broadcaster) { public static TestEventProducer get(EventBroadcaster broadcaster) {
return (TestEventProducer)broadcaster.getEventProducerFor(TestEventProducer.class); return (TestEventProducer)broadcaster.getEventProducerFor(TestEventProducer.class);

+ 2
- 2
test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java View File



package org.apache.fop.fo; package org.apache.fop.fo;


import static org.junit.Assert.assertArrayEquals;

import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;


import static org.junit.Assert.assertArrayEquals;

import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory;
import org.apache.fop.fo.flow.BasicLink; import org.apache.fop.fo.flow.BasicLink;

+ 1
- 1
test/java/org/apache/fop/fo/FODocumentParser.java View File

/** /**
* A factory to create custom instances of {@link FOEventHandler}. * A factory to create custom instances of {@link FOEventHandler}.
*/ */
public static interface FOEventHandlerFactory {
public interface FOEventHandlerFactory {


/** /**
* Creates a new {@code FOEventHandler} instance parameterized with the given FO user agent. * Creates a new {@code FOEventHandler} instance parameterized with the given FO user agent.

+ 1
- 2
test/java/org/apache/fop/fo/FONodeMocks.java View File

import org.apache.xmlgraphics.image.loader.ImageSessionContext; import org.apache.xmlgraphics.image.loader.ImageSessionContext;


import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.events.EventBroadcaster; import org.apache.fop.events.EventBroadcaster;
import org.apache.fop.fo.flow.table.ColumnNumberManager; import org.apache.fop.fo.flow.table.ColumnNumberManager;
import org.apache.fop.fo.flow.table.ColumnNumberManagerHolder; import org.apache.fop.fo.flow.table.ColumnNumberManagerHolder;
/** /**
* Creates and returns a mock {@link FONode} configured with a mock * Creates and returns a mock {@link FONode} configured with a mock
* {@link FOEventHandler}. The FO event handler returns a mock {@link FOUserAgent}, * {@link FOEventHandler}. The FO event handler returns a mock {@link FOUserAgent},
* which in turn returns a mock {@link FopFactory}, which returns a mock
* which in turn returns a mock {@link org.apache.fop.apps.FopFactory}, which returns a mock
* {@link ImageManager}. * {@link ImageManager}.
* *
* @return a mock FO node * @return a mock FO node

+ 0
- 4
test/java/org/apache/fop/fo/flow/MarkersTestCase.java View File

import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;


import org.apache.fop.fo.Constants; import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.flow.Markers;
import org.apache.fop.fo.flow.RetrieveMarker;
import org.apache.fop.fo.flow.RetrieveTableMarker;


public class MarkersTestCase { public class MarkersTestCase {



+ 1
- 1
test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java View File



import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.FODocumentParser; import org.apache.fop.fo.FODocumentParser;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.util.ConsoleEventListenerForTests; import org.apache.fop.util.ConsoleEventListenerForTests;


/** /**

+ 4
- 2
test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java View File



package org.apache.fop.fo.flow.table; package org.apache.fop.fo.flow.table;


import static org.junit.Assert.assertEquals;

import java.awt.Color; import java.awt.Color;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

import org.apache.fop.fo.Constants; import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode.FONodeIterator; import org.apache.fop.fo.FONode.FONodeIterator;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;


// CSOFF: LineLength

/** /**
* A testcase for the resolution of collapsed borders in the FO tree, taking * A testcase for the resolution of collapsed borders in the FO tree, taking
* conditionality into account. The resolved borders are generated by the * conditionality into account. The resolved borders are generated by the

+ 5
- 5
test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java View File



package org.apache.fop.fo.flow.table; package org.apache.fop.fo.flow.table;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;


import org.junit.Test; 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 * Tests that RowGroupBuilder returns, for each part of a table, the expected number of
* row-groups with the expected number or rows in each. * row-groups with the expected number or rows in each.

+ 2
- 2
test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java View File



package org.apache.fop.fo.flow.table; package org.apache.fop.fo.flow.table;


import static org.junit.Assert.assertEquals;

import java.util.Iterator; import java.util.Iterator;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FObj; import org.apache.fop.fo.FObj;



+ 0
- 1
test/java/org/apache/fop/fo/flow/table/TableHandler.java View File



import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.flow.table.Table;


public class TableHandler extends FOEventHandler { public class TableHandler extends FOEventHandler {



+ 2
- 2
test/java/org/apache/fop/fo/pagination/AllTests.java View File



package org.apache.fop.fo.pagination; package org.apache.fop.fo.pagination;


import org.junit.runners.Suite;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Suite;


/** /**
* All test to be added in FOTreeTestSuite * All test to be added in FOTreeTestSuite
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@Suite.SuiteClasses({ PageSequenceMasterTestCase.class, @Suite.SuiteClasses({ PageSequenceMasterTestCase.class,
RepeatablePageMasterAlternativesTestCase.class})
RepeatablePageMasterAlternativesTestCase.class })
public final class AllTests { public final class AllTests {
} }

+ 3
- 3
test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java View File



package org.apache.fop.fo.pagination; package org.apache.fop.fo.pagination;


import static org.junit.Assert.fail;
import org.junit.Test;
import org.xml.sax.Locator;


import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyObject;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode; import org.apache.fop.fo.FONode;
import org.apache.fop.layoutmgr.BlockLevelEventProducer; import org.apache.fop.layoutmgr.BlockLevelEventProducer;
import org.junit.Test;
import org.xml.sax.Locator;




/** /**

+ 2
- 2
test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java View File



package org.apache.fop.fo.pagination; package org.apache.fop.fo.pagination;


import org.junit.Test;

import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyInt;
import org.apache.fop.fo.expr.NumericProperty; import org.apache.fop.fo.expr.NumericProperty;
import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.Property;


import org.junit.Test;

/** /**
* Unit Test for RepeatablePageMasterAlternatives * Unit Test for RepeatablePageMasterAlternatives
* *

+ 2
- 2
test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java View File



package org.apache.fop.fo.properties; package org.apache.fop.fo.properties;


import org.junit.Test;

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;


import org.junit.Test;

import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.Constants; import org.apache.fop.fo.Constants;

+ 4
- 4
test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java View File



package org.apache.fop.fo.properties; package org.apache.fop.fo.properties;


import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;


import org.junit.Test; 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.Constants;
import org.apache.fop.fo.FONode; import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FONodeMocks; import org.apache.fop.fo.FONodeMocks;

+ 2
- 2
test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java View File

import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

import org.apache.fop.apps.io.InternalResourceResolver; import org.apache.fop.apps.io.InternalResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory; import org.apache.fop.apps.io.ResourceResolverFactory;


import static org.junit.Assert.assertEquals;

/** /**
* *
*/ */

+ 1
- 1
test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java View File

*/ */
public class EmbedFontInfoTestCase { public class EmbedFontInfoTestCase {


public EmbedFontInfoTestCase() {}
public EmbedFontInfoTestCase() { }


private EmbedFontInfo sut; private EmbedFontInfo sut;



+ 3
- 3
test/java/org/apache/fop/fonts/FontManagerConfiguratorTestCase.java View File

package org.apache.fop.fonts; package org.apache.fop.fonts;


import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;


import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;


import static org.junit.Assert.assertEquals;

import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FopConfBuilder; import org.apache.fop.apps.FopConfBuilder;
import org.apache.fop.apps.FopConfParser; import org.apache.fop.apps.FopConfParser;
import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.FopFactory;


import static org.apache.fop.apps.FopConfParserTestCase.getFopFactory; import static org.apache.fop.apps.FopConfParserTestCase.getFopFactory;
import static org.junit.Assert.assertEquals;


/** /**
* A test case for {@link FontManagerConfigurator}. * A test case for {@link FontManagerConfigurator}.
/** /**
* This test is an interesting one; it's basically testing that if a base URI pointing to a * 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 * directory that doesn't exist is used, an error is not thrown. The URI resolver should handle
* any {@link FileNotFoundException}s, not the configuration. We're NOT testing whether a font
* any {@link java.io.FileNotFoundException}s, not the configuration. We're NOT testing whether a font
* can be resolved here, just that the URI resolver accepts it as its base URI. * can be resolved here, just that the URI resolver accepts it as its base URI.
*/ */
@Test @Test

+ 4
- 4
test/java/org/apache/fop/fonts/cff/CFFDataReaderTestCase.java View File

import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

import org.apache.fontbox.cff.CFFDataInput; import org.apache.fontbox.cff.CFFDataInput;


import org.apache.fop.fonts.cff.CFFDataReader.CFFIndexData; import org.apache.fop.fonts.cff.CFFDataReader.CFFIndexData;
import org.apache.fop.fonts.cff.CFFDataReader.DICTEntry; import org.apache.fop.fonts.cff.CFFDataReader.DICTEntry;
import org.apache.fop.fonts.truetype.OTFSubSetFile; import org.apache.fop.fonts.truetype.OTFSubSetFile;


import static org.junit.Assert.assertEquals;

public class CFFDataReaderTestCase { public class CFFDataReaderTestCase {
private CFFDataReader cffReader; private CFFDataReader cffReader;


//Array comparison //Array comparison
int[] fontBBox = { -50, -40, 100, 120 }; int[] fontBBox = { -50, -40, 100, 120 };
DICTEntry fontBBoxEntry = dictMap.get("FontBBox"); DICTEntry fontBBoxEntry = dictMap.get("FontBBox");
for (int i = 0;i < fontBBoxEntry.getOperands().size();i++) {
for (int i = 0; i < fontBBoxEntry.getOperands().size(); i++) {
assertEquals(fontBBoxEntry.getOperands().get(i).intValue(), fontBBox[i]); assertEquals(fontBBoxEntry.getOperands().get(i).intValue(), fontBBox[i]);
} }
//Multi-byte offset (number) //Multi-byte offset (number)
}; };
Random randGen = new Random(); Random randGen = new Random();
byte[] data = new byte[31]; byte[] data = new byte[31];
for (int i = 0;i < data.length;i++) {
for (int i = 0; i < data.length; i++) {
data[i] = (byte)randGen.nextInt(255); data[i] = (byte)randGen.nextInt(255);
} }
testIndex = OTFSubSetFile.concatArray(testIndex, data); testIndex = OTFSubSetFile.concatArray(testIndex, data);

+ 1
- 1
test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java View File

*/ */
public class GlyfTableTestCase { public class GlyfTableTestCase {


private final static class DirData {
private static final class DirData {


final long offset; final long offset;
final long length; final long length;

+ 3
- 4
test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java View File

package org.apache.fop.fonts.truetype; package org.apache.fop.fonts.truetype;


import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;


import org.junit.Before; import org.junit.Before;


/** /**
* Initializes fonts used for the testing of reading OTF CFF * Initializes fonts used for the testing of reading OTF CFF
* @throws IOException
* @throws java.io.IOException
*/ */
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {


int[] gids = {32, 42, 44, 47}; int[] gids = {32, 42, 44, 47};
int[] sourceSansWidths = {516, 555, 572, 383}; int[] sourceSansWidths = {516, 555, 572, 383};
for (int i = 0;i < gids.length;i++) {
for (int i = 0; i < gids.length; i++) {
assertEquals(sourceSansWidths[i], sourceSansProBold.getWidths()[gids[i]]); assertEquals(sourceSansWidths[i], sourceSansProBold.getWidths()[gids[i]]);
} }
int[] carolynaWidths = {842, 822, 658, 784}; int[] carolynaWidths = {842, 822, 658, 784};
for (int i = 0;i < gids.length;i++) {
for (int i = 0; i < gids.length; i++) {
assertEquals(carolynaWidths[i], alexBrush.getWidths()[gids[i]]); assertEquals(carolynaWidths[i], alexBrush.getWidths()[gids[i]]);
} }
} }

+ 5
- 5
test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java View File

import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.apache.fontbox.cff.CFFDataInput; import org.apache.fontbox.cff.CFFDataInput;
import org.apache.fontbox.cff.CFFFont; import org.apache.fontbox.cff.CFFFont;
import org.apache.fontbox.cff.CFFParser; import org.apache.fontbox.cff.CFFParser;
import org.apache.fop.fonts.cff.CFFDataReader.CFFIndexData; import org.apache.fop.fonts.cff.CFFDataReader.CFFIndexData;
import org.apache.fop.fonts.cff.CFFDataReader.DICTEntry; import org.apache.fop.fonts.cff.CFFDataReader.DICTEntry;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class OTFSubSetFileTestCase extends OTFFileTestCase { public class OTFSubSetFileTestCase extends OTFFileTestCase {


CFFDataReader cffReaderSourceSans; CFFDataReader cffReaderSourceSans;


private boolean checkCorrectOffsets(CFFIndexData indexData) { private boolean checkCorrectOffsets(CFFIndexData indexData) {
int last = 0; int last = 0;
for (int i = 0;i < indexData.getOffsets().length;i++) {
for (int i = 0; i < indexData.getOffsets().length; i++) {
if (indexData.getOffsets()[i] < last) { if (indexData.getOffsets()[i] < last) {
return false; return false;
} }
IndexData localIndexData = CFFParser.readIndexData(localSubrs); IndexData localIndexData = CFFParser.readIndexData(localSubrs);


CFFIndexData charStrings = cffReader.getCharStringIndex(); CFFIndexData charStrings = cffReader.getCharStringIndex();
for (int i = 0;i < charStrings.getNumObjects();i++) {
for (int i = 0; i < charStrings.getNumObjects(); i++) {
byte[] charData = charStrings.getValue(i); byte[] charData = charStrings.getValue(i);
Type2CharStringParser parser = new Type2CharStringParser(); Type2CharStringParser parser = new Type2CharStringParser();



+ 2
- 2
test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java View File



import org.junit.Test; import org.junit.Test;


import org.apache.fop.fonts.truetype.OpenFont.PostScriptVersion;

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


import org.apache.fop.fonts.truetype.OpenFont.PostScriptVersion;

/** /**
* Class for testing org.apache.fop.fonts.truetype.TTFFile * Class for testing org.apache.fop.fonts.truetype.TTFFile
*/ */

+ 3
- 3
test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java View File



import org.junit.Test; 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.InternalResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory; import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.EmbeddingMode; import org.apache.fop.fonts.EmbeddingMode;
import org.apache.fop.fonts.EncodingMode; import org.apache.fop.fonts.EncodingMode;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/** /**
* Test case for {@link OFFontLoader}. * Test case for {@link OFFontLoader}.
*/ */

+ 3
- 3
test/java/org/apache/fop/fonts/type1/AFMParserTestCase.java View File



package org.apache.fop.fonts.type1; package org.apache.fop.fonts.type1;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;


import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/** /**
* Test case for {@link AFMParser}. * Test case for {@link AFMParser}.
*/ */

+ 2
- 2
test/java/org/apache/fop/fonts/type1/AdobeStandardEncodingTestCase.java View File



package org.apache.fop.fonts.type1; package org.apache.fop.fonts.type1;


import static org.junit.Assert.assertEquals;

import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

/** /**
* Test case for {@link AdobeStandardEncoding}. * Test case for {@link AdobeStandardEncoding}.
*/ */

+ 4
- 4
test/java/org/apache/fop/fonts/type1/CharMetricsHandlerTestCase.java View File



package org.apache.fop.fonts.type1; package org.apache.fop.fonts.type1;


import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;


import org.junit.Test; 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.NamedCharacter;
import org.apache.fop.fonts.type1.AFMParser.ValueHandler; import org.apache.fop.fonts.type1.AFMParser.ValueHandler;



+ 3
- 3
test/java/org/apache/fop/fotreetest/ext/AssertElement.java View File

package org.apache.fop.fotreetest.ext; 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.apps.FOPException;
import org.apache.fop.fo.FONode; import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOPropertyMapping; import org.apache.fop.fo.FOPropertyMapping;
import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.fo.properties.SpaceProperty;
import org.apache.fop.fotreetest.ResultCollector; import org.apache.fop.fotreetest.ResultCollector;


import org.xml.sax.Attributes;
import org.xml.sax.Locator;

/** /**
* Defines the assert element for the FOP Test extension. * Defines the assert element for the FOP Test extension.
*/ */

+ 1
- 1
test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java View File



package org.apache.fop.fotreetest.ext; package org.apache.fop.fotreetest.ext;


import org.apache.fop.fo.FONode;
import org.apache.fop.fo.ElementMapping; import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FONode;


/** /**
* This class provides the element mapping for FOP. * This class provides the element mapping for FOP.

+ 4
- 4
test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java View File



package org.apache.fop.image.loader.batik; package org.apache.fop.image.loader.batik;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

import java.awt.image.Raster; import java.awt.image.Raster;
import java.awt.image.RenderedImage; import java.awt.image.RenderedImage;
import java.io.File; import java.io.File;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; 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.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageInfo;

+ 3
- 3
test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java View File



package org.apache.fop.image.loader.batik; package org.apache.fop.image.loader.batik;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;


import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; 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.ImageException;
import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageManager;

+ 0
- 1
test/java/org/apache/fop/intermediate/AbstractIFTest.java View File

import javax.xml.validation.Validator; import javax.xml.validation.Validator;


import org.w3c.dom.Document; import org.w3c.dom.Document;

import org.xml.sax.ErrorHandler; import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;

+ 1
- 1
test/java/org/apache/fop/intermediate/AreaTreeXMLFormatTestSuite.java View File

* JUnit test suite for the area tree XML format * JUnit test suite for the area tree XML format
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ AreaTreeParserTestCase.class })
@SuiteClasses(AreaTreeParserTestCase.class)
public class AreaTreeXMLFormatTestSuite { public class AreaTreeXMLFormatTestSuite {
} }

+ 2
- 2
test/java/org/apache/fop/intermediate/IFMimickingTestCase.java View File



package org.apache.fop.intermediate; package org.apache.fop.intermediate;


import static org.junit.Assert.fail;

import java.io.File; import java.io.File;


import javax.xml.transform.ErrorListener; import javax.xml.transform.ErrorListener;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.fail;

import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;

+ 1
- 1
test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java View File

* A test suite for testing the Intermediate Format output. * A test suite for testing the Intermediate Format output.
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ IFTestCase.class })
@SuiteClasses(IFTestCase.class)
public final class IntermediateFormatTestSuite { public final class IntermediateFormatTestSuite {
} }

+ 1
- 1
test/java/org/apache/fop/intermediate/LayoutIFTestSuite.java View File

* JUnit test suite for the intermediate format * JUnit test suite for the intermediate format
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ IFParserTestCase.class })
@SuiteClasses(IFParserTestCase.class)
public final class LayoutIFTestSuite { public final class LayoutIFTestSuite {
} }

+ 5
- 4
test/java/org/apache/fop/layoutengine/ElementListCheck.java View File

import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;


import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty;
import org.w3c.dom.CDATASection; import org.w3c.dom.CDATASection;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.w3c.dom.Text; import org.w3c.dom.Text;


import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty;

/** /**
* Check implementation that checks a Knuth element list. * Check implementation that checks a Knuth element list.
*/ */

+ 1
- 1
test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java View File

* JUnit test suit for running layout engine test under JUnit control. * JUnit test suit for running layout engine test under JUnit control.
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ LayoutEngineTestCase.class })
@SuiteClasses(LayoutEngineTestCase.class)
public class LayoutEngineTestSuite { public class LayoutEngineTestSuite {
} }

+ 2
- 1
test/java/org/apache/fop/layoutengine/LayoutResult.java View File



package org.apache.fop.layoutengine; package org.apache.fop.layoutengine;


import org.apache.fop.apps.FormattingResults;
import org.w3c.dom.Document; import org.w3c.dom.Document;


import org.apache.fop.apps.FormattingResults;

/** /**
* This class holds references to all the results from the FOP processing run. * This class holds references to all the results from the FOP processing run.
*/ */

+ 4
- 4
test/java/org/apache/fop/layoutmgr/table/TableCellLayoutManagerTestCase.java View File



import org.junit.Test; 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.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableCell; import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.RetrieveTableMarkerLayoutManager; import org.apache.fop.layoutmgr.RetrieveTableMarkerLayoutManager;


import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class TableCellLayoutManagerTestCase { public class TableCellLayoutManagerTestCase {


// this test aims to check that the first call to addAreas() calls // this test aims to check that the first call to addAreas() calls

+ 2
- 1
test/java/org/apache/fop/logging/LoggingElementListObserver.java View File



import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;

import org.apache.fop.layoutmgr.ElementListObserver.Observer;
import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.fop.layoutmgr.ListElement; import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.ElementListObserver.Observer;


/** /**
* <p>Logs all observed element lists. * <p>Logs all observed element lists.

+ 2
- 2
test/java/org/apache/fop/memory/MemoryEater.java View File

/** /**
* Debug tool to create and process large FO files by replicating them a specified number of times. * Debug tool to create and process large FO files by replicating them a specified number of times.
*/ */
public class MemoryEater {
public final class MemoryEater {


private SAXTransformerFactory tFactory private SAXTransformerFactory tFactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance(); = (SAXTransformerFactory)SAXTransformerFactory.newInstance();


private Stats stats; private Stats stats;


public MemoryEater() throws TransformerConfigurationException, MalformedURLException {
private MemoryEater() throws TransformerConfigurationException, MalformedURLException {
File xsltFile = new File("test/xsl/fo-replicator.xsl"); File xsltFile = new File("test/xsl/fo-replicator.xsl");
Source xslt = new StreamSource(xsltFile); Source xslt = new StreamSource(xsltFile);
replicatorTemplates = tFactory.newTemplates(xslt); replicatorTemplates = tFactory.newTemplates(xslt);

+ 2
- 1
test/java/org/apache/fop/pdf/AbstractPDFStreamTestCase.java View File

import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;


import static org.junit.Assert.assertEquals;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import static org.junit.Assert.assertEquals;

/** /**
* Test case for {@link AbstractPDFStream}. * Test case for {@link AbstractPDFStream}.
*/ */

+ 0
- 0
test/java/org/apache/fop/pdf/FileIDGeneratorTestCase.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save