]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2532: FontCache throws IllegalArgumentException with non file
authorSimon Steiner <ssteiner@apache.org>
Fri, 22 Apr 2016 14:21:59 +0000 (14:21 +0000)
committerSimon Steiner <ssteiner@apache.org>
Fri, 22 Apr 2016 14:21:59 +0000 (14:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1740529 13f79535-47bb-0310-9956-ffa450edef68

fop-core/src/main/java/org/apache/fop/fonts/FontCache.java
fop-core/src/test/java/org/apache/fop/fonts/FontManagerTestCase.java

index 1f5b96b808caca8314e0ce70781f7f8fb7754b65..e14ed85b0840baac935c6e04a2ab13a06341089e 100644 (file)
@@ -332,8 +332,7 @@ public final class FontCache implements Serializable {
             } else {
                 // try and determine modified date
                 URI fontUri = resourceResolver.resolveFromBase(fontInfo.getEmbedURI());
-                File fontFile = new File(fontUri);
-                long lastModified = fontFile.lastModified();
+                long lastModified = getLastModified(fontUri);
                 cachedFontFile = new CachedFontFile(lastModified);
                 if (log.isTraceEnabled()) {
                     log.trace("Font added to cache: " + cacheKey);
index 9012f843b1dd913c98d36729682803287d0dd8e9..5362cf1a8d2d49ffc4b6c8c98d8a5e0d2ec9d7b7 100644 (file)
 
 package org.apache.fop.fonts;
 
+import java.io.File;
 import java.net.URI;
+import java.net.URISyntaxException;
 
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.InOrder;
@@ -30,6 +33,7 @@ import static org.mockito.Mockito.verify;
 
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
 
 public class FontManagerTestCase {
 
@@ -57,6 +61,17 @@ public class FontManagerTestCase {
         inOrder.verify(fontCacheManager).setCacheFile(any(URI.class));
     }
 
+    @Test
+    public void testSetCacheURL() throws URISyntaxException {
+        InternalResourceResolver rr = ResourceResolverFactory.createDefaultInternalResourceResolver(
+                new File(".").toURI());
+        String uri = "abc://localhost/f";
+        EmbedFontInfo efi = new EmbedFontInfo(new FontUris(new URI(uri), null), false, false, null, null);
+        FontCache fc = new FontCache();
+        fc.addFont(efi, rr);
+        Assert.assertTrue(fc.containsFont(uri));
+    }
+
     @Test
     public void testGetFontCache() {
         sut.getFontCache();