diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2013-11-15 07:13:53 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2013-11-15 07:13:53 +0000 |
commit | 2318d09b63a801f5d490d688c8636912aa785eb1 (patch) | |
tree | ec2fbb233ee0190571c251d469e7522dcd6373b0 /test | |
parent | 7d3dba6c3c2fc6caeeeaccbc8df159b87934e44a (diff) | |
download | xmlgraphics-fop-2318d09b63a801f5d490d688c8636912aa785eb1.tar.gz xmlgraphics-fop-2318d09b63a801f5d490d688c8636912aa785eb1.zip |
FOP-2312: font-base configuration setting not working as expected
Use the config file URI to resolve relative <base> / <font-base> URIs.
Fall back to default base URI only if the config input stream has no URI.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1542190 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r-- | test/config/relative-uri/base_font.xconf | 5 | ||||
-rw-r--r-- | test/config/relative-uri/base_no-font.xconf | 4 | ||||
-rw-r--r-- | test/config/relative-uri/no-base_font.xconf | 4 | ||||
-rw-r--r-- | test/config/relative-uri/no-base_no-font.xconf | 3 | ||||
-rw-r--r-- | test/java/org/apache/fop/apps/FopConfParserTestCase.java | 38 |
5 files changed, 54 insertions, 0 deletions
diff --git a/test/config/relative-uri/base_font.xconf b/test/config/relative-uri/base_font.xconf new file mode 100644 index 000000000..872c102e7 --- /dev/null +++ b/test/config/relative-uri/base_font.xconf @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fop version="1.0"> + <base>relative/</base> + <font-base>fonts/</font-base> +</fop> diff --git a/test/config/relative-uri/base_no-font.xconf b/test/config/relative-uri/base_no-font.xconf new file mode 100644 index 000000000..97d378511 --- /dev/null +++ b/test/config/relative-uri/base_no-font.xconf @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fop version="1.0"> + <base>relative/</base> +</fop> diff --git a/test/config/relative-uri/no-base_font.xconf b/test/config/relative-uri/no-base_font.xconf new file mode 100644 index 000000000..165cc1231 --- /dev/null +++ b/test/config/relative-uri/no-base_font.xconf @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fop version="1.0"> + <font-base>fonts/</font-base> +</fop> diff --git a/test/config/relative-uri/no-base_no-font.xconf b/test/config/relative-uri/no-base_no-font.xconf new file mode 100644 index 000000000..211d94212 --- /dev/null +++ b/test/config/relative-uri/no-base_no-font.xconf @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fop version="1.0"> +</fop> diff --git a/test/java/org/apache/fop/apps/FopConfParserTestCase.java b/test/java/org/apache/fop/apps/FopConfParserTestCase.java index 3c2930942..dc794fdb8 100644 --- a/test/java/org/apache/fop/apps/FopConfParserTestCase.java +++ b/test/java/org/apache/fop/apps/FopConfParserTestCase.java @@ -19,6 +19,7 @@ package org.apache.fop.apps; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URI; @@ -127,4 +128,41 @@ public class FopConfParserTestCase { builder.setPreferRenderer(true); assertTrue(buildFactory().getRendererFactory().isRendererPreferred()); } + + @Test + public void testRelativeURINoBaseNoFont() throws Exception { + checkRelativeURIs("test/config/relative-uri/no-base_no-font.xconf", + "", ""); + } + + @Test + public void testRelativeURINoBaseFont() throws Exception { + checkRelativeURIs("test/config/relative-uri/no-base_font.xconf", + "", "test/config/relative-uri/fonts/"); + } + + @Test + public void testRelativeURIBaseNoFont() throws Exception { + checkRelativeURIs("test/config/relative-uri/base_no-font.xconf", + "test/config/relative-uri/relative/", "test/config/relative-uri/relative/"); + } + + @Test + public void testRelativeURIBaseFont() throws Exception { + checkRelativeURIs("test/config/relative-uri/base_font.xconf", + "test/config/relative-uri/relative/", "test/config/relative-uri/fonts/"); + } + + private void checkRelativeURIs(String conf, String expectedBase, String expectedFontBase) + throws SAXException, IOException { + File configFile = new File(conf); + URI currentDir = new File(".").getCanonicalFile().toURI(); + FopConfParser parser = new FopConfParser(configFile, currentDir); + FopFactoryBuilder fopFactoryBuilder = parser.getFopFactoryBuilder(); + assertEquals("base URI", currentDir.resolve(expectedBase), + fopFactoryBuilder.getBaseURI()); + assertEquals("font base", currentDir.resolve(expectedFontBase), + fopFactoryBuilder.getFontManager().getResourceResolver().getBaseURI()); + } + } |