diff options
author | Simon Steiner <ssteiner@apache.org> | 2016-04-22 14:21:59 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2016-04-22 14:21:59 +0000 |
commit | c55eb89a85e549dc6456f0bae6bf8081bce00586 (patch) | |
tree | 3efe4e6cbce91821661bc12bd93270d5e80b3360 /fop-core | |
parent | e5c576f3c070e5c7ec94b9d0d3e8d2071fdc6f82 (diff) | |
download | xmlgraphics-fop-c55eb89a85e549dc6456f0bae6bf8081bce00586.tar.gz xmlgraphics-fop-c55eb89a85e549dc6456f0bae6bf8081bce00586.zip |
FOP-2532: FontCache throws IllegalArgumentException with non file
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1740529 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/fonts/FontCache.java | 3 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/fonts/FontManagerTestCase.java | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontCache.java b/fop-core/src/main/java/org/apache/fop/fonts/FontCache.java index 1f5b96b80..e14ed85b0 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontCache.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontCache.java @@ -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); diff --git a/fop-core/src/test/java/org/apache/fop/fonts/FontManagerTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/FontManagerTestCase.java index 9012f843b..5362cf1a8 100644 --- a/fop-core/src/test/java/org/apache/fop/fonts/FontManagerTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fonts/FontManagerTestCase.java @@ -17,8 +17,11 @@ 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 { @@ -58,6 +62,17 @@ public class FontManagerTestCase { } @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(); verify(fontCacheManager).load(); |