You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by me...@apache.org on 2012/06/26 11:14:34 UTC

svn commit: r1353883 [4/4] - in /xmlgraphics/fop/branches/Temp_URI_Unification: ./ lib/ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/complexscripts/fonts/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/apps/ src/java/org...

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/ResourceHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/ResourceHandler.java?rev=1353883&r1=1353882&r2=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/ResourceHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/ResourceHandler.java Tue Jun 26 09:14:25 2012
@@ -83,6 +83,8 @@ public class ResourceHandler implements 
     private FOUserAgent userAgent;
     private FontInfo fontInfo;
 
+    private PSEventProducer eventProducer;
+
     private ResourceTracker resTracker;
 
     //key: URI, values PSImageFormResource
@@ -93,13 +95,15 @@ public class ResourceHandler implements 
     /**
      * Main constructor.
      * @param userAgent the FO user agent
+     * @param eventProducer the event producer
      * @param fontInfo the font information
      * @param resTracker the resource tracker to use
      * @param formResources Contains all forms used by this document (maintained by PSRenderer)
      */
-    public ResourceHandler(FOUserAgent userAgent, FontInfo fontInfo,
-            ResourceTracker resTracker, Map formResources) {
+    public ResourceHandler(FOUserAgent userAgent, PSEventProducer eventProducer,
+            FontInfo fontInfo, ResourceTracker resTracker, Map formResources) {
         this.userAgent = userAgent;
+        this.eventProducer = eventProducer;
         this.fontInfo = fontInfo;
         this.resTracker = resTracker;
         determineInlineForms(formResources);
@@ -222,7 +226,7 @@ public class ResourceHandler implements 
         if (fontSetupPlaceholder == null) {
             throw new DSCException("Didn't find %FOPFontSetup comment in stream");
         }
-        PSFontUtils.writeFontDict(gen, fontInfo, fontInfo.getUsedFonts());
+        PSFontUtils.writeFontDict(gen, fontInfo, fontInfo.getUsedFonts(), eventProducer);
         generateForms(globalFormResources, gen);
 
         //Skip the prolog and to the first page

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=1353883&r1=1353882&r2=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/svg/PDFGraphics2D.java Tue Jun 26 09:14:25 2012
@@ -1201,6 +1201,8 @@ public class PDFGraphics2D extends Abstr
                 currentStream.write("] ");
                 float offset = bs.getDashPhase();
                 currentStream.write(PDFNumber.doubleOut(offset) + " d\n");
+            } else {
+                currentStream.write("[] 0 d\n");
             }
             int ec = bs.getEndCap();
             switch (ec) {

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/status.xml?rev=1353883&r1=1353882&r2=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/status.xml Tue Jun 26 09:14:25 2012
@@ -63,6 +63,21 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Code" dev="GA" type="fix" fixes-bug="53458" due-to="Dieter von Holten">
+        Fix incorrect language and country code key generation in hyphenation tree cache.
+      </action>
+      <action context="Images" dev="GA" type="fix" fixes-bug="53431" due-to="Luis Bernardo">
+        Fix incorrect SVG line dash pattern with PDF output format.
+      </action>
+      <action context="Images" dev="GA" type="update" fixes-bug="40676" due-to="Luis Bernardo">
+        Fix interoperability issue with Adobe reader regarding use of multiple filters.
+      </action>
+      <action context="Code" dev="GA" type="fix">
+        Eliminate javadocs warnings.
+      </action>
+      <action context="Renderers" dev="VH" type="add" fixes-bug="52338" importance="high">
+        Added possibility to embed TrueType fonts in PostScript.
+      </action>
       <action context="Images" dev="GA" type="update" fixes-bug="40676" due-to="Luis Bernardo">
         Update site documentation about PNG image loading configuration and support.
       </action>

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/UtilityCodeTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/UtilityCodeTestSuite.java?rev=1353883&r1=1353882&r2=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/UtilityCodeTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/UtilityCodeTestSuite.java Tue Jun 26 09:14:25 2012
@@ -28,10 +28,13 @@ import org.apache.fop.pdf.FileIDGenerato
 import org.apache.fop.pdf.PDFDocumentGraphics2DTestCase;
 import org.apache.fop.pdf.PDFEncryptionJCETestCase;
 import org.apache.fop.pdf.PDFFactoryTestCase;
+import org.apache.fop.pdf.PDFNumberTestCase;
+import org.apache.fop.pdf.PDFObjectTestCase;
 import org.apache.fop.traits.BorderPropsTestCase;
 import org.apache.fop.util.BitmapImageUtilTestCase;
 import org.apache.fop.util.ColorUtilTestCase;
 import org.apache.fop.util.ElementListUtilsTestCase;
+import org.apache.fop.util.HexEncoderTestCase;
 import org.apache.fop.util.XMLResourceBundleTestCase;
 
 /**
@@ -49,7 +52,10 @@ import org.apache.fop.util.XMLResourceBu
     PDFFactoryTestCase.class,
     PDFEncryptionJCETestCase.class,
     BitmapImageUtilTestCase.class,
-    PDFDocumentGraphics2DTestCase.class
+    PDFDocumentGraphics2DTestCase.class,
+    PDFNumberTestCase.class,
+    PDFObjectTestCase.class,
+    HexEncoderTestCase.class
 })
 public class UtilityCodeTestSuite {
 }

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java?rev=1353883&r1=1353882&r2=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java Tue Jun 26 09:14:25 2012
@@ -47,8 +47,8 @@ public class DejaVuLGCSerifTestCase {
     @Before
     public void setUp() throws Exception {
         File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
-        font = FontLoader.loadFont(file.toURI(), "", true, EncodingMode.AUTO, false, false,
-                resolver);
+        font = FontLoader.loadFont(file.toURI(), "", true, EmbeddingMode.AUTO, EncodingMode.AUTO,
+                false, false, resolver);
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java?rev=1353883&r1=1353882&r2=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java Tue Jun 26 09:14:25 2012
@@ -43,6 +43,7 @@ public class EmbedFontInfoTestCase {
     private final boolean useAdvanced = false;
     private final String subFontName = "Gladiator Bold";
     private final EncodingMode encMode = EncodingMode.CID;
+    private final EmbeddingMode embedMode = EmbeddingMode.AUTO;
     private final FontTriplet triplet = new FontTriplet(subFontName, "bold", Font.WEIGHT_BOLD);
 
     @Before
@@ -50,7 +51,7 @@ public class EmbedFontInfoTestCase {
         List<FontTriplet> triplets = new ArrayList<FontTriplet>();
         triplets.add(triplet);
         sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced, triplets, embedURI, subFontName,
-                encMode);
+                encMode, embedMode);
     }
 
     @Test
@@ -80,7 +81,7 @@ public class EmbedFontInfoTestCase {
     @Test
     public void testQuirkyBoundaryCasesIsEmbedded() {
         sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced, sut.getFontTriplets(), null,
-                subFontName, encMode);
+                subFontName, encMode, embedMode);
         sut.setEmbedded(true);
         assertFalse(sut.isEmbedded());
 

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/EncodingModeTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/EncodingModeTestCase.java?rev=1353883&r1=1353882&r2=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/EncodingModeTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/EncodingModeTestCase.java Tue Jun 26 09:14:25 2012
@@ -19,10 +19,13 @@
 
 package org.apache.fop.fonts;
 
-import static org.junit.Assert.assertEquals;
-
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link EncodingMode}.
+ */
 public class EncodingModeTestCase {
 
     @Test
@@ -34,8 +37,13 @@ public class EncodingModeTestCase {
 
     @Test
     public void testGetValue() {
-        assertEquals(EncodingMode.AUTO, EncodingMode.getEncodingMode("auto"));
-        assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getEncodingMode("single-byte"));
-        assertEquals(EncodingMode.CID, EncodingMode.getEncodingMode("cid"));
+        assertEquals(EncodingMode.AUTO, EncodingMode.getValue("auto"));
+        assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getValue("single-byte"));
+        assertEquals(EncodingMode.CID, EncodingMode.getValue("cid"));
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void getValueMustCheckForIllegalArguments() {
+        EncodingMode.getValue("fail");
     }
 }

Copied: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java (from r1353397, xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java?p2=xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java&p1=xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java&r1=1353397&r2=1353883&rev=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java Tue Jun 26 09:14:25 2012
@@ -20,6 +20,7 @@
 package org.apache.fop.fonts.truetype;
 
 import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
@@ -55,7 +56,13 @@ public class GlyfTableTestCase {
 
     @Before
     public void setUp() throws IOException {
-        originalFontReader = new FontFileReader("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        FileInputStream fontStream = new FileInputStream(
+                "test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        try {
+            originalFontReader = new FontFileReader(fontStream);
+        } finally {
+            fontStream.close();
+        }
     }
 
     /**

Copied: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java (from r1353397, xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java?p2=xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java&p1=xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java&r1=1353397&r2=1353883&rev=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java Tue Jun 26 09:14:25 2012
@@ -19,17 +19,19 @@
 
 package org.apache.fop.fonts.truetype;
 
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Map;
 
 import org.junit.Test;
 
+import org.apache.fop.fonts.truetype.TTFFile.PostScriptVersion;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.apache.fop.fonts.truetype.TTFFile.PostScriptVersion;
-
 /**
  * Class for testing org.apache.fop.fonts.truetype.TTFFile
  */
@@ -51,11 +53,17 @@ public class TTFFileTestCase {
      */
     public TTFFileTestCase() throws IOException {
         dejavuTTFFile = new TTFFile();
-        dejavuReader = new FontFileReader("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        InputStream dejaStream = new FileInputStream("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        dejavuReader = new FontFileReader(dejaStream);
         dejavuTTFFile.readFont(dejavuReader);
+        dejaStream.close();
+
+        InputStream droidStream = new FileInputStream("test/resources/fonts/ttf/DroidSansMono.ttf");
+
         droidmonoTTFFile = new TTFFile();
-        droidmonoReader = new FontFileReader("test/resources/fonts/ttf/DroidSansMono.ttf");
+        droidmonoReader = new FontFileReader(droidStream);
         droidmonoTTFFile.readFont(droidmonoReader);
+        droidStream.close();
     }
 
     /**

Copied: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java (from r1353397, xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java?p2=xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java&p1=xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java&r1=1353397&r2=1353883&rev=1353883&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java Tue Jun 26 09:14:25 2012
@@ -21,13 +21,14 @@ package org.apache.fop.fonts.truetype;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
 
 import org.junit.Test;
 
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
 import org.apache.fop.fonts.EmbeddingMode;
 import org.apache.fop.fonts.EncodingMode;
-import org.apache.fop.fonts.FontManager;
-import org.apache.fop.fonts.FontResolver;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -41,19 +42,20 @@ public class TTFFontLoaderTestCase {
     public void testUseKerning() throws IOException {
         boolean useComplexScriptFeatures = false;
         File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
-        String absoluteFilePath = file.toURI().toURL().toExternalForm();
-        FontResolver resolver = FontManager.createMinimalFontResolver(useComplexScriptFeatures);
+        URI absoluteFilePath = file.toURI();
+        InternalResourceResolver resourceResolver = ResourceResolverFactory.createDefaultInternalResourceResolver(
+                                                                           new File(".").toURI());
         String fontName = "Deja Vu";
         boolean embedded = false;
         boolean useKerning = true;
 
         TTFFontLoader fontLoader = new TTFFontLoader(absoluteFilePath, fontName, embedded,
-                EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resolver);
+                EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resourceResolver);
         assertTrue(fontLoader.getFont().hasKerningInfo());
         useKerning = false;
 
         fontLoader = new TTFFontLoader(absoluteFilePath, fontName, embedded, EmbeddingMode.AUTO,
-                EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resolver);
+                EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resourceResolver);
         assertFalse(fontLoader.getFont().hasKerningInfo());
     }
 }

Added: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java?rev=1353883&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java Tue Jun 26 09:14:25 2012
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps.fonts;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+/**
+ * The test class for org.apache.fop.render.ps.fonts.PSGenerator
+ */
+public class PSTTFGeneratorTestCase {
+    private PSTTFGenerator ttfGen;
+    private ByteArrayOutputStream out = new ByteArrayOutputStream();
+    private PSGenerator gen = new PSGenerator(out);
+    private byte[] byteArray;
+
+    /**
+     * Constructor
+     */
+    public PSTTFGeneratorTestCase() {
+        byteArray = new byte[65536];
+        for (int i = 0; i < 65536; i++) {
+            byteArray[i] = (byte) i;
+        }
+    }
+
+    @Before
+    public void setUp() {
+        ttfGen = new PSTTFGenerator(gen);
+    }
+
+    /**
+     * Tests startString() - starts the string in an appropriate way for a PostScript file.
+     * @exception IOException write error
+     */
+    @Test
+    public void testStartString() throws IOException {
+        ttfGen.startString();
+        assertEquals("<\n", out.toString());
+    }
+
+    /**
+     * Test streamBytes() - tests that strings are written to file in the proper format.
+     * @throws IOException write error.
+     */
+    @Test
+    public void testStreamBytes() throws IOException {
+        ttfGen.streamBytes(byteArray, 0, 16);
+        assertEquals("000102030405060708090A0B0C0D0E0F", out.toString());
+        /*
+         * 65520 is the closes multiple of 80 to 65535 (max string size in PS document) and since
+         * one byte takes up two characters, 65520 / 2 - 16 (16 bytes already written)= 32744.
+         */
+        ttfGen.streamBytes(byteArray, 0, 32744);
+        // Using a regex to ensure that the format is correct
+        assertTrue(out.toString().matches("([0-9A-F]{80}\n){819}"));
+        try {
+            ttfGen.streamBytes(byteArray, 0, PSTTFGenerator.MAX_BUFFER_SIZE + 1);
+            fail("Shouldn't be able to write more than MAX_BUFFER_SIZE to a PS document");
+        } catch (UnsupportedOperationException e) {
+            // PASS
+        }
+    }
+
+    /**
+     * Test reset() - reset should reset the line counter such that when reset() is invoked the
+     * following string streamed to the PS document should be 80 chars long.
+     * @throws IOException file write error.
+     */
+    @Test
+    public void testReset() throws IOException {
+        ttfGen.streamBytes(byteArray, 0, 40);
+        assertTrue(out.toString().matches("([0-9A-F]{80}\n)"));
+        ttfGen.streamBytes(byteArray, 0, 40);
+        assertTrue(out.toString().matches("([0-9A-F]{80}\n){2}"));
+
+    }
+
+    /**
+     * Test endString() - ensures strings are ended in the PostScript document in the correct
+     * format, a "00" needs to be appended to the end of a string.
+     * @throws IOException file write error
+     */
+    @Test
+    public void testEndString() throws IOException {
+        ttfGen.endString();
+        assertEquals("00\n> ", out.toString());
+        out.reset();
+        // we need to check that this doesn't write more than 80 chars per line
+        ttfGen.streamBytes(byteArray, 0, 40);
+        ttfGen.endString();
+        assertTrue(out.toString().matches("([0-9A-F]{80}\n)00\n> "));
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGeneratorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java?rev=1353883&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java Tue Jun 26 09:14:25 2012
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps.fonts;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InOrder;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+/**
+ * Test class for PSTTFGlyphOutputStream
+ */
+public class PSTTFGlyphOutputStreamTestCase {
+    private PSTTFGenerator mockGen;
+    private PSTTFGlyphOutputStream glyphOut;
+
+    @Before
+    public void setUp() {
+        mockGen = mock(PSTTFGenerator.class);
+        glyphOut = new PSTTFGlyphOutputStream(mockGen);
+    }
+
+    /**
+     * Test startGlyphStream() - test that startGlyphStream() invokes reset() and startString() in
+     * PSTTFGenerator.
+     * @exception IOException file write error
+     */
+    @Test
+    public void testStartGlyphStream() throws IOException {
+        glyphOut.startGlyphStream();
+        verify(mockGen).startString();
+    }
+
+    /**
+     * Test streamGlyph(byte[],int,int) - tests several paths:
+     * 1) strings are properly appended
+     * 2) when total strings size > PSTTFGenerator.MAX_BUFFER_SIZE, the strings is closed and a new
+     * strings is started.
+     * 3) if a glyph of size > PSTTFGenerator.MAX_BUFFER_SIZE is attempted, an exception is thrown.
+     * @throws IOException file write error.
+     */
+    @Test
+    public void testStreamGlyph() throws IOException {
+        int byteArraySize = 10;
+        byte[] byteArray = new byte[byteArraySize];
+        int runs = 100;
+        for (int i = 0; i < runs; i++) {
+            glyphOut.streamGlyph(byteArray, 0, byteArraySize);
+        }
+        verify(mockGen, times(runs)).streamBytes(byteArray, 0, byteArraySize);
+
+        /*
+         * We want to run this for MAX_BUFFER_SIZE / byteArraySize so that go over the string
+         * boundary and enforce the ending and starting of a new string. Using mockito to ensure
+         * that this behaviour is performed in order (since this is an integral behavioural aspect)
+         */
+        int stringLimit = PSTTFGenerator.MAX_BUFFER_SIZE / byteArraySize;
+        for (int i = 0; i < stringLimit; i++) {
+            glyphOut.streamGlyph(byteArray, 0, byteArraySize);
+        }
+        InOrder inOrder = inOrder(mockGen);
+        inOrder.verify(mockGen, times(stringLimit)).streamBytes(byteArray, 0, byteArraySize);
+        inOrder.verify(mockGen).endString();
+        inOrder.verify(mockGen).startString();
+        inOrder.verify(mockGen, times(runs)).streamBytes(byteArray, 0, byteArraySize);
+
+        try {
+            glyphOut.streamGlyph(byteArray, 0, PSTTFGenerator.MAX_BUFFER_SIZE + 1);
+            fail("Shouldn't allow a length > PSTTFGenerator.MAX_BUFFER_SIZE");
+        } catch (UnsupportedOperationException e) {
+            // PASS
+        }
+    }
+
+    /**
+     * Test endGlyphStream() - tests that PSTTFGenerator.endString() is invoked when this method
+     * is called.
+     * @throws IOException file write exception
+     */
+    @Test
+    public void testEndGlyphStream() throws IOException {
+        glyphOut.endGlyphStream();
+        verify(mockGen).endString();
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFGlyphOutputStreamTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java?rev=1353883&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java Tue Jun 26 09:14:25 2012
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps.fonts;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+import org.apache.fop.fonts.truetype.TTFGlyphOutputStream;
+import org.apache.fop.fonts.truetype.TTFTableOutputStream;
+
+/**
+ * Tests PSTTFOuputStream
+ */
+public class PSTTFOutputStreamTestCase {
+    private PSGenerator gen;
+    private PSTTFOutputStream out;
+
+    /**
+     * Assigns an OutputStream to the PSGenerator.
+     */
+    @Before
+    public void setUp() {
+        gen = mock(PSGenerator.class);
+        out = new PSTTFOutputStream(gen);
+    }
+
+    /**
+     * Test startFontStream() - Just tests that the font is properly initiated in the PostScript
+     * document (in this case with "/sfnts[")
+     * @throws IOException write exception.
+     */
+    @Test
+    public void testStartFontStream() throws IOException {
+        out.startFontStream();
+        verify(gen).write("/sfnts[");
+    }
+
+    /**
+     * Test getTableOutputStream() - we need to test that the inheritance model is properly obeyed.
+     */
+    @Test
+    public void testGetTableOutputStream() {
+        TTFTableOutputStream tableOut = out.getTableOutputStream();
+        assertTrue(tableOut instanceof PSTTFTableOutputStream);
+    }
+
+    /**
+     * Test getGlyphOutputStream() - we need to test that the inheritance model is properly obeyed.
+     */
+    @Test
+    public void testGetGlyphOutputStream() {
+        TTFGlyphOutputStream glyphOut = out.getGlyphOutputStream();
+        assertTrue(glyphOut instanceof PSTTFGlyphOutputStream);
+    }
+
+    /**
+     * Test endFontStream()
+     * @exception IOException write error.
+     */
+    @Test
+    public void testEndFontStream() throws IOException {
+        out.endFontStream();
+        verify(gen).writeln("] def");
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFOutputStreamTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java?rev=1353883&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java (added)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java Tue Jun 26 09:14:25 2012
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps.fonts;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InOrder;
+
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Test class for unit testing PSTTFTableOutputStream
+ */
+public class PSTTFTableOutputStreamTestCase {
+    private PSTTFGenerator mockGen;
+    private PSTTFTableOutputStream tableOut;
+
+    @Before
+    public void setUp() {
+        mockGen = mock(PSTTFGenerator.class);
+        tableOut = new PSTTFTableOutputStream(mockGen);
+    }
+
+    /**
+     * Test streamTable() - several paths to test (2. and 3. test corner cases):
+     * 1) that a table of length < PSTTFGenerator.MAX_BUFFER_SIZE invokes the correct methods in
+     * PSTTFGenerator.
+     * 2) that a table of length > PSTTFGenerator.MAX_BUFFER_SIZE and
+     * length == n * PSTTFGenerator.MAX_BUFFER_SIZE is split up and the methods in PSTTFGenerator
+     * are invoked.
+     * 3) that a table of length > PSTTFGenerator.MAX_BUFFER_SIZE but
+     * length != n * PSTTFGenerator.MAX_BUFFER_SIZE is split up and the methods in PSTTFGenerator
+     * are invoked.
+     * @throws IOException file write error.
+     */
+    @Test
+    public void testStreamTable() throws IOException {
+        byte[] byteArray = new byte[PSTTFGenerator.MAX_BUFFER_SIZE * 3];
+        tableOut.streamTable(byteArray, 0, 10);
+        InOrder inOrder = inOrder(mockGen);
+        inOrder.verify(mockGen).startString();
+        inOrder.verify(mockGen).streamBytes(byteArray, 0, 10);
+        inOrder.verify(mockGen).endString();
+
+        setUp(); // reset all all the method calls
+        /* We're going to run this 3 times to ensure the proper method calls are invoked and all
+         * the bytes are streamed */
+        tableOut.streamTable(byteArray, 0, byteArray.length);
+        inOrder = inOrder(mockGen);
+        for (int i = 0; i < 3; i++) {
+            int offset = PSTTFGenerator.MAX_BUFFER_SIZE * i;
+            inOrder.verify(mockGen).startString();
+            inOrder.verify(mockGen).streamBytes(byteArray, offset, PSTTFGenerator.MAX_BUFFER_SIZE);
+            inOrder.verify(mockGen).endString();
+        }
+
+        setUp(); // reset all the method calls
+        tableOut.streamTable(byteArray, 0, PSTTFGenerator.MAX_BUFFER_SIZE + 1);
+        inOrder = inOrder(mockGen);
+        inOrder.verify(mockGen).startString();
+        inOrder.verify(mockGen).streamBytes(byteArray, 0, PSTTFGenerator.MAX_BUFFER_SIZE);
+        inOrder.verify(mockGen).endString();
+        inOrder.verify(mockGen).startString();
+        inOrder.verify(mockGen).streamBytes(byteArray, PSTTFGenerator.MAX_BUFFER_SIZE, 1);
+        inOrder.verify(mockGen).endString();
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/fonts/PSTTFTableOutputStreamTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org