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 ph...@apache.org on 2012/07/04 15:50:25 UTC

svn commit: r1357266 - in /xmlgraphics/fop/branches/Temp_RoundedCorners: ./ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/afp/util/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/layoutmgr/inline/ test/java/org/apache/fop/afp/ t...

Author: phancock
Date: Wed Jul  4 13:50:24 2012
New Revision: 1357266

URL: http://svn.apache.org/viewvc?rev=1357266&view=rev
Log:
Merged trunk@1357248

Added:
    xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/resource_any_name.afp
      - copied unchanged from r1357265, xmlgraphics/fop/trunk/test/java/org/apache/fop/afp/resource_any_name.afp
    xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/resource_name_match.afp
      - copied unchanged from r1357265, xmlgraphics/fop/trunk/test/java/org/apache/fop/afp/resource_name_match.afp
    xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/resource_name_mismatch.afp
      - copied unchanged from r1357265, xmlgraphics/fop/trunk/test/java/org/apache/fop/afp/resource_name_mismatch.afp
    xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/resource_no_end_name.afp
      - copied unchanged from r1357265, xmlgraphics/fop/trunk/test/java/org/apache/fop/afp/resource_no_end_name.afp
Modified:
    xmlgraphics/fop/branches/Temp_RoundedCorners/   (props changed)
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/documentation/content/xdocs/trunk/output.xml
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentProfile.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactory.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryBuilder.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryConfig.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/apps/io/ResourceResolverFactoryTestCase.java
    xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java

Propchange: xmlgraphics/fop/branches/Temp_RoundedCorners/
------------------------------------------------------------------------------
  Merged /xmlgraphics/fop/trunk:r1356792-1357265

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/documentation/content/xdocs/trunk/output.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/documentation/content/xdocs/trunk/output.xml?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/documentation/content/xdocs/trunk/output.xml (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/documentation/content/xdocs/trunk/output.xml Wed Jul  4 13:50:24 2012
@@ -331,8 +331,6 @@ out = proc.getOutputStream();]]></source
     <title>Limitations</title>
     <ul>
       <li>Images and SVG may not be displayed correctly. SVG support is far from being complete. No image transparency is available.</li>
-      <li>Only Type 1 fonts are supported.</li>
-      <li>Multibyte characters are not supported.</li>
       <li>PPD support is still missing.</li>
     </ul>
   </section>

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/afp/util/AFPResourceUtil.java Wed Jul  4 13:50:24 2012
@@ -56,8 +56,11 @@ import org.apache.fop.afp.parser.Unparse
  */
 public final class AFPResourceUtil {
 
-    private static final byte TYPE_CODE_BEGIN = (byte)(0xA8 & 0xFF);
-    private static final byte TYPE_CODE_END = (byte)(0xA9 & 0xFF);
+    private static final byte TYPE_CODE_BEGIN = (byte) (0xA8 & 0xFF);
+
+    private static final byte TYPE_CODE_END = (byte) (0xA9 & 0xFF);
+
+    private static final byte END_FIELD_ANY_NAME = (byte) (0xFF & 0xFF);
 
     private static final Log LOG = LogFactory.getLog(AFPResourceUtil.class);
 
@@ -92,10 +95,13 @@ public final class AFPResourceUtil {
             throws UnsupportedEncodingException {
         //The first 8 bytes of the field data represent the resource name
         byte[] nameBytes = new byte[8];
-        System.arraycopy(field.getData(), 0, nameBytes, 0, 8);
-        String asciiName;
-        asciiName = new String(nameBytes, AFPConstants.EBCIDIC_ENCODING);
-        return asciiName;
+
+        byte[] fieldData = field.getData();
+        if (fieldData.length < 8) {
+            throw new IllegalArgumentException("Field data does not contain a resource name");
+        }
+        System.arraycopy(fieldData, 0, nameBytes, 0, 8);
+        return new String(nameBytes, AFPConstants.EBCIDIC_ENCODING);
     }
 
     /**
@@ -128,12 +134,13 @@ public final class AFPResourceUtil {
     public static void copyNamedResource(String name,
             final InputStream in, final OutputStream out) throws IOException {
         final MODCAParser parser = new MODCAParser(in);
-        Collection resourceNames = new java.util.HashSet();
+        Collection<String> resourceNames = new java.util.HashSet<String>();
 
         //Find matching "Begin" field
         final UnparsedStructuredField fieldBegin;
         while (true) {
-            UnparsedStructuredField field = parser.readNextStructuredField();
+            final UnparsedStructuredField field = parser.readNextStructuredField();
+
             if (field == null) {
                 throw new IOException("Requested resource '" + name
                         + "' not found. Encountered resource names: " + resourceNames);
@@ -142,8 +149,10 @@ public final class AFPResourceUtil {
             if (field.getSfTypeCode() != TYPE_CODE_BEGIN) { //0xA8=Begin
                 continue; //Not a "Begin" field
             }
-            String resourceName = getResourceName(field);
+            final String resourceName = getResourceName(field);
+
             resourceNames.add(resourceName);
+
             if (resourceName.equals(name)) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Start of requested structured field found:\n"
@@ -170,45 +179,65 @@ public final class AFPResourceUtil {
         if (wrapInResource) {
             ResourceObject resourceObject =  new ResourceObject(name) {
                 protected void writeContent(OutputStream os) throws IOException {
-                    copyStructuredFields(name, fieldBegin, parser, out);
+                    copyNamedStructuredFields(name, fieldBegin, parser, out);
                 }
             };
             resourceObject.setType(ResourceObject.TYPE_PAGE_SEGMENT);
             resourceObject.writeToStream(out);
         } else {
-            copyStructuredFields(name, fieldBegin, parser, out);
+            copyNamedStructuredFields(name, fieldBegin, parser, out);
         }
     }
 
-    private static void copyStructuredFields(String name, UnparsedStructuredField fieldBegin,
+    private static void copyNamedStructuredFields(final String name, UnparsedStructuredField fieldBegin,
             MODCAParser parser, OutputStream out) throws IOException {
-        boolean inRequestedResource;
-
-        //The "Begin" field first
-        out.write(MODCAParser.CARRIAGE_CONTROL_CHAR);
-        fieldBegin.writeTo(out);
-        UnparsedStructuredField field;
-
-        //Then the rest of the fields until the corresponding "End" field
-        inRequestedResource = true;
-        do {
-            field = parser.readNextStructuredField();
+        UnparsedStructuredField field = fieldBegin;
+        while (true) {
             if (field == null) {
-                break; //Unexpected EOF
-            }
-
-            if (field.getSfTypeCode() == TYPE_CODE_END) {
-                String resourceName = getResourceName(field);
-                if (resourceName.equals(name)) {
-                    inRequestedResource = false; //Signal end of loop
-                }
+                throw new IOException("Ending structured field not found for resource " + name);
             }
             out.write(MODCAParser.CARRIAGE_CONTROL_CHAR);
             field.writeTo(out);
-        } while (inRequestedResource);
-        if (inRequestedResource) {
-            throw new IOException("Ending structured field not found for resource " + name);
+
+            if (isEndOfStructuredField(field, fieldBegin, name)) {
+                break;
+            }
+            field = parser.readNextStructuredField();
         }
     }
 
+    private static boolean isEndOfStructuredField(UnparsedStructuredField field,
+            UnparsedStructuredField fieldBegin, String name) throws UnsupportedEncodingException {
+        return fieldMatchesEndTagType(field)
+                && fieldMatchesBeginCategoryCode(field, fieldBegin)
+                && fieldHasValidName(field, name);
+    }
+
+    private static boolean fieldMatchesEndTagType(UnparsedStructuredField field) {
+        return field.getSfTypeCode() == TYPE_CODE_END;
+    }
+
+    private static boolean fieldMatchesBeginCategoryCode(UnparsedStructuredField field,
+            UnparsedStructuredField fieldBegin) {
+        return fieldBegin.getSfCategoryCode() == field.getSfCategoryCode();
+    }
+
+    /**
+     * The AFP specification states that it is valid for the end structured field to have:
+     *  - No tag name specified, which will cause it to match any existing tag type match.
+     *  - The name has FFFF as its first two bytes
+     *  - The given name matches the previous structured field name
+     */
+    private static boolean fieldHasValidName(UnparsedStructuredField field, String name)
+            throws UnsupportedEncodingException {
+        if (field.getData().length > 0) {
+            if (field.getData()[0] == field.getData()[1]
+                    && field.getData()[0] == END_FIELD_ANY_NAME) {
+                return true;
+            } else {
+                return name.equals(getResourceName(field));
+            }
+        }
+        return true;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentProfile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentProfile.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentProfile.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentProfile.java Wed Jul  4 13:50:24 2012
@@ -25,7 +25,10 @@ import org.apache.fop.apps.io.ResourceRe
 import org.apache.fop.fonts.FontManager;
 
 /**
- * The environment profile represents the restrictions and allowances that FOP is
+ * The environment profile represents the system in which FOP is invoked. Some of FOPs services rely
+ * upon features within the system, as such, the client may want to restrict access to these
+ * services. This object allows clients to control those restrictions by implementing the interfaces
+ * that the environment profile holds.
  */
 public interface EnvironmentProfile {
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java Wed Jul  4 13:50:24 2012
@@ -84,7 +84,10 @@ public final class EnvironmentalProfileF
                 throw new IllegalArgumentException("Default base URI must not be null");
             }
             if (resourceResolver == null) {
-                throw new IllegalArgumentException("URI Resolver must not be null");
+                throw new IllegalArgumentException("ResourceResolver must not be null");
+            }
+            if (fontManager == null) {
+                throw new IllegalArgumentException("The FontManager must not be null");
             }
             this.defaultBaseURI = defaultBaseURI;
             this.resourceResolver = resourceResolver;

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FOUserAgent.java Wed Jul  4 13:50:24 2012
@@ -786,13 +786,14 @@ public class FOUserAgent {
         return factory.getImageHandlerRegistry();
     }
 
-    /** TODO: javadoc*/
+    /** @return the color space cache */
     public ColorSpaceCache getColorSpaceCache() {
         return factory.getColorSpaceCache();
     }
 
-    public Map<String, String> getHyphPatNames() {
-        return factory.getHyphPatNames();
+    /** @see {@link FopFactory#getHyphenationPatternNames()} */
+    public Map<String, String> getHyphenationPatternNames() {
+        return factory.getHyphenationPatternNames();
     }
 }
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactory.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactory.java Wed Jul  4 13:50:24 2012
@@ -341,9 +341,9 @@ public final class FopFactory implements
         return config.getLayoutManagerMakerOverride();
     }
 
-
-    public Map<String, String> getHyphPatNames() {
-        return config.getHyphPatNames();
+    /** @return the hyphenation pattern names */
+    public Map<String, String> getHyphenationPatternNames() {
+        return config.getHyphenationPatternNames();
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryBuilder.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryBuilder.java Wed Jul  4 13:50:24 2012
@@ -452,7 +452,7 @@ public final class FopFactoryBuilder {
             return isComplexScript;
         }
 
-        public Map<String, String> getHyphPatNames() {
+        public Map<String, String> getHyphenationPatternNames() {
             return hyphPatNames;
         }
     }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryConfig.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryConfig.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/apps/FopFactoryConfig.java Wed Jul  4 13:50:24 2012
@@ -126,5 +126,6 @@ public interface FopFactoryConfig {
 
     boolean isComplexScriptFeaturesEnabled();
 
-    Map<String, String> getHyphPatNames();
+    /** @see {@link FopFactory#getHyphenationPatternNames()} */
+    Map<String, String> getHyphenationPatternNames();
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Wed Jul  4 13:50:24 2012
@@ -1399,7 +1399,7 @@ public class LineLayoutManager extends I
         Hyphenation hyph = Hyphenator.hyphenate(hyphenationProperties.language.getString(),
                                hyphenationProperties.country.getString(),
                                getFObj().getUserAgent().getResourceResolver(),
-                               getFObj().getUserAgent().getHyphPatNames(),
+                               getFObj().getUserAgent().getHyphenationPatternNames(),
                                sbChars.toString(),
                                hyphenationProperties.hyphenationRemainCharacterCount.getValue(),
                                hyphenationProperties.hyphenationPushCharacterCount.getValue());

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java Wed Jul  4 13:50:24 2012
@@ -22,23 +22,34 @@ package org.apache.fop.afp;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.Arrays;
 
+import org.junit.Test;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.fop.afp.util.AFPResourceUtil;
 import org.junit.Test;
 
+import static org.junit.Assert.assertTrue;
+
 /**
  * Tests the {@link AFPResourceUtil} class.
  */
 public class AFPResourceUtilTestCase {
 
     private static final String RESOURCE_FILENAME = "expected_resource.afp";
-
     private static final String NAMED_RESOURCE_FILENAME = "expected_named_resource.afp";
 
-    private static final String PSEG = "XFEATHER";
+    private static final String RESOURCE_ANY_NAME = "resource_any_name.afp";
+    private static final String RESOURCE_NAME_MATCH = "resource_name_match.afp";
+    private static final String RESOURCE_NAME_MISMATCH = "resource_name_mismatch.afp";
+    private static final String RESOURCE_NO_END_NAME = "resource_no_end_name.afp";
+
+    private static final String PSEG_A = "XFEATHER";
+    private static final String PSEG_B = "S1CODEQR";
 
     /**
      * Tests copyResourceFile()
@@ -46,57 +57,105 @@ public class AFPResourceUtilTestCase {
      */
     @Test
     public void testCopyResourceFile() throws Exception {
+        compareResources(new ResourceCopier() {
+            public void copy(InputStream in, OutputStream out) throws IOException {
+                AFPResourceUtil.copyResourceFile(in, out);
+            }
+        }, RESOURCE_FILENAME, RESOURCE_FILENAME);
+    }
 
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    /**
+     * Tests copyNamedResource()
+     * @throws Exception -
+     */
+    @Test
+    public void testCopyNamedResource() throws Exception {
+        compareResources(new ResourceCopier() {
+            public void copy(InputStream in, OutputStream out) throws IOException {
+                AFPResourceUtil.copyNamedResource(PSEG_A, in, out);
+            }
+        }, RESOURCE_FILENAME, NAMED_RESOURCE_FILENAME);
+    }
 
-        InputStream in = null;
+    private void compareResources(ResourceCopier copyResource, String resourceA, String resourceB)
+            throws IOException {
+        ByteArrayOutputStream baos = copyResource(resourceA, copyResource);
+        byte[] expectedBytes = resourceAsByteArray(resourceB);
+        assertTrue(Arrays.equals(expectedBytes, baos.toByteArray()));
+    }
 
+    private ByteArrayOutputStream copyResource(String resource, ResourceCopier resourceCopier)
+            throws IOException {
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        InputStream in = null;
         try {
-            in = getClass().getResourceAsStream(RESOURCE_FILENAME);
-            AFPResourceUtil.copyResourceFile(in, baos);
+            in = getClass().getResourceAsStream(resource);
+            resourceCopier.copy(in, baos);
         } finally {
             in.close();
         }
+        return baos;
+    }
 
+    private byte[] resourceAsByteArray(String resource) throws IOException {
+        InputStream in = null;
         byte[] expectedBytes = null;
-
         try {
-            in = getClass().getResourceAsStream(RESOURCE_FILENAME);
+            in = getClass().getResourceAsStream(resource);
             expectedBytes = IOUtils.toByteArray(in);
         } finally {
             in.close();
         }
-
-        assertTrue(Arrays.equals(expectedBytes, baos.toByteArray()));
-
+        return expectedBytes;
     }
 
     /**
-     * Tests copyNamedResource()
+     * Tests the validity of a closing structured field having an FF FF name which
+     * allows it to match any existing matching starting field
      * @throws Exception -
      */
     @Test
-    public void testCopyNamedResource() throws Exception {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    public void testResourceAnyName() throws Exception {
+        testResource(RESOURCE_ANY_NAME, PSEG_B);
+    }
 
-        InputStream in = null;
+    /**
+     * Tests a matching end structured field name
+     * @throws Exception -
+     */
+    @Test
+    public void testResourceNameMatch() throws Exception {
+        testResource(RESOURCE_NAME_MATCH, PSEG_B);
+    }
 
-        try {
-            in = getClass().getResourceAsStream(RESOURCE_FILENAME);
-            AFPResourceUtil.copyNamedResource(PSEG, in, baos);
-        } finally {
-            in.close();
-        }
+    /**
+     * Tests to see whether a matching structured field pair with mismatching
+     * names fails.
+     * @throws Exception -
+     */
+    @Test(expected=Exception.class)
+    public void testResourceNameMismatch() throws Exception {
+        testResource(RESOURCE_NAME_MISMATCH, PSEG_B);
+    }
 
-        byte[] expectedBytes = null;
+    /**
+     * Tests a matching structured end field with no name
+     * @throws Exception -
+     */
+    @Test
+    public void testResourceNoEndName() throws Exception {
+        testResource(RESOURCE_NO_END_NAME, PSEG_B);
+    }
 
-        try {
-            in = getClass().getResourceAsStream(NAMED_RESOURCE_FILENAME);
-            expectedBytes = IOUtils.toByteArray(in);
-        } finally {
-            in.close();
-        }
+    private void testResource(String resource, final String pseg) throws Exception {
+        copyResource(resource, new ResourceCopier() {
+            public void copy(InputStream in, OutputStream out) throws IOException {
+                AFPResourceUtil.copyNamedResource(pseg, in, out);
+            }
+        });
+    }
 
-        assertTrue(Arrays.equals(expectedBytes, baos.toByteArray()));
+    private interface ResourceCopier {
+        public void copy(InputStream in, OutputStream out) throws IOException;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/apps/io/ResourceResolverFactoryTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/apps/io/ResourceResolverFactoryTestCase.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/apps/io/ResourceResolverFactoryTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/apps/io/ResourceResolverFactoryTestCase.java Wed Jul  4 13:50:24 2012
@@ -79,6 +79,7 @@ public class ResourceResolverFactoryTest
     public void testDefaultResourceResolverGetOutput() throws Exception {
         ResourceResolver sut = ResourceResolverFactory.createDefaultResourceResolver();
         File outputFile = File.createTempFile("prefix", "suffix");
+        outputFile.deleteOnExit();
         writeDataTo(sut.getOutputStream(outputFile.toURI()));
         InputStream is = new FileInputStream(outputFile);
         try {

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java?rev=1357266&r1=1357265&r2=1357266&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java Wed Jul  4 13:50:24 2012
@@ -275,9 +275,8 @@ public class FOTreeTestCase {
             return delegate.isComplexScriptFeaturesEnabled();
         }
 
-        public Map<String, String> getHyphPatNames() {
-            return delegate.getHyphPatNames();
+        public Map<String, String> getHyphenationPatternNames() {
+            return delegate.getHyphenationPatternNames();
         }
     }
-
 }



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