From 8c1aba3f976127d33ec50b67d760f56364c08487 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 28 May 2007 14:31:24 +0000 Subject: Bugzilla #41831: - Add support font auto-detection (easier font configuration) including a font cache to speed up the auto-detection process. - Refactoring of the configuration code: All Avalon configuration stuff is extracted into separate "Configurator" classes. - Refactoring of the FOURIResolver. Submitted by: Adrian Cumiskey Changes to the patch by jeremias during the review: - Font cache simplified (Java object serialization instead of XML), functionality fixed and moved to the fonts.package. - Relocated default cache file location to user directory. - Fixed the font configuration for PDFDocumentGraphics2D/PDFTranscoder that got lost with the patch. - Fixed a problem with having a non-file URL as font base URL. - Simplified RendererContextInfo stuff to make it easier to understand. - Fixed handling of Type 1 fonts in auto-detection. - Reduced verbosity of font-related log output. - Updated Jakarta Commons IO to version 1.3.1 (the patch depends on it) - Various javadocs improvements git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@542237 13f79535-47bb-0310-9956-ffa450edef68 --- .../config/BaseConstructiveUserConfigTestCase.java | 45 +++++++++++++ .../config/BaseDestructiveUserConfigTestCase.java | 45 +++++++++++++ .../apache/fop/config/BaseUserConfigTestCase.java | 75 +++++++++++----------- .../org/apache/fop/config/EmbedUrlBadTestCase.java | 41 ------------ .../fop/config/EmbedUrlMalformedTestCase.java | 38 ----------- .../fop/config/FontAttributesMissingTestCase.java | 19 +++--- .../org/apache/fop/config/FontBaseBadTestCase.java | 19 ++---- .../apache/fop/config/FontEmbedUrlBadTestCase.java | 37 +++++++++++ .../fop/config/FontEmbedUrlMalformedTestCase.java | 37 +++++++++++ .../fop/config/FontMetricsUrlBadTestCase.java | 40 ++++++++++++ .../config/FontMetricsUrlMalformedTestCase.java | 37 +++++++++++ .../FontTripletAttributeMissingTestCase.java | 19 +++--- .../apache/fop/config/FontsAutoDetectTestCase.java | 34 ++++++++++ .../fop/config/FontsDirectoryBadTestCase.java | 42 ++++++++++++ .../config/FontsDirectoryRecursiveTestCase.java | 37 +++++++++++ .../apache/fop/config/MetricsUrlBadTestCase.java | 44 ------------- .../fop/config/MetricsUrlMalformedTestCase.java | 38 ----------- .../org/apache/fop/config/UserConfigTestSuite.java | 10 +-- .../org/apache/fop/render/pdf/BasePDFTestCase.java | 5 +- 19 files changed, 425 insertions(+), 237 deletions(-) create mode 100644 test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java create mode 100644 test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java delete mode 100644 test/java/org/apache/fop/config/EmbedUrlBadTestCase.java delete mode 100644 test/java/org/apache/fop/config/EmbedUrlMalformedTestCase.java create mode 100644 test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java create mode 100644 test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java create mode 100644 test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java create mode 100644 test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java create mode 100644 test/java/org/apache/fop/config/FontsAutoDetectTestCase.java create mode 100644 test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java create mode 100644 test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java delete mode 100644 test/java/org/apache/fop/config/MetricsUrlBadTestCase.java delete mode 100644 test/java/org/apache/fop/config/MetricsUrlMalformedTestCase.java (limited to 'test/java') diff --git a/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java new file mode 100644 index 000000000..cd1c26f8c --- /dev/null +++ b/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java @@ -0,0 +1,45 @@ +/* + * 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.config; + +public abstract class BaseConstructiveUserConfigTestCase extends BaseUserConfigTestCase { + + /** + * @see junit.framework.TestCase#TestCase(String) + */ + public BaseConstructiveUserConfigTestCase(String name) { + super(name); + } + + /** + * Test using a standard FOP font + * @throws Exception checkstyle wants a comment here, even a silly one + */ + public void testUserConfig() throws Exception { + try { + initConfig(); + convertFO(); + } catch (Exception e) { + // this should *not* happen! + e.printStackTrace(); + fail(e.getMessage()); + } + } +} diff --git a/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java new file mode 100644 index 000000000..c02f99c03 --- /dev/null +++ b/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java @@ -0,0 +1,45 @@ +/* + * 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.config; + +import org.apache.fop.apps.FOPException; + +public abstract class BaseDestructiveUserConfigTestCase extends BaseUserConfigTestCase { + + /** + * @see junit.framework.TestCase#TestCase(String) + */ + public BaseDestructiveUserConfigTestCase(String name) { + super(name); + } + + public void testUserConfig() throws Exception { + try { + initConfig(); + convertFO(); + fail( getName() + ": Expected Configuration Exception" ); + } catch (FOPException e) { + // this *should* happen! + } catch (Exception e) { + e.printStackTrace(); + fail( getName() + ": Expected FOPException but got: " + e.getMessage() ); + } + } +} diff --git a/test/java/org/apache/fop/config/BaseUserConfigTestCase.java b/test/java/org/apache/fop/config/BaseUserConfigTestCase.java index 3a97f4303..ae862664c 100644 --- a/test/java/org/apache/fop/config/BaseUserConfigTestCase.java +++ b/test/java/org/apache/fop/config/BaseUserConfigTestCase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id$ */ +/* $Id: $ */ package org.apache.fop.config; @@ -28,7 +28,6 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.render.pdf.BasePDFTestCase; import org.xml.sax.SAXException; @@ -39,7 +38,7 @@ import org.xml.sax.SAXException; */ public abstract class BaseUserConfigTestCase extends BasePDFTestCase { - protected static DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); + protected DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); /** logging instance */ protected Log log = LogFactory.getLog(BaseUserConfigTestCase.class); @@ -59,28 +58,19 @@ public abstract class BaseUserConfigTestCase extends BasePDFTestCase { // do nothing } - /** - * Test using a standard FOP font - * @throws Exception checkstyle wants a comment here, even a silly one - */ - public void testUserConfig() throws Exception { - try { - fopFactory.setUserConfig(getUserConfig()); - final File baseDir = getBaseDir(); - final String fontFOFilePath = getFontFOFilePath(); - File foFile = new File(baseDir, fontFOFilePath); - final boolean dumpOutput = false; - FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - convertFO(foFile, foUserAgent, dumpOutput); - fail( getName() + ": Expected Configuration Exception" ); - } catch (FOPException e) { - // this *should* happen! - } catch (Exception e) { - fail( getName() + ": Expected FOPException but got: " + e.getMessage() ); - } + protected void initConfig() throws Exception { + fopFactory.setUserConfig(getUserConfig()); } - + protected void convertFO() throws Exception { + final File baseDir = getBaseDir(); + final String fontFOFilePath = getFontFOFilePath(); + File foFile = new File(baseDir, fontFOFilePath); + final boolean dumpOutput = false; + FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); + convertFO(foFile, foUserAgent, dumpOutput); + } + /** * get test FOP config File * @return fo test filepath @@ -96,11 +86,31 @@ public abstract class BaseUserConfigTestCase extends BasePDFTestCase { * @throws SAXException * @throws ConfigurationException */ - protected Configuration getUserConfig(String configString) - throws ConfigurationException, SAXException, IOException { + protected Configuration getUserConfig(String configString) throws ConfigurationException, SAXException, IOException { return cfgBuilder.build(new ByteArrayInputStream(configString.getBytes())); } + /** get base config directory */ + protected String getBaseConfigDir() { + return "test/config"; + } + + /** + * @return user config File + */ + abstract protected String getUserConfigFilename(); + + /* + * @see junit.framework.TestCase#getName() + */ + public String getName() { + return getUserConfigFilename(); + } + + protected File getUserConfigFile() { + return new File(getBaseConfigDir() + File.separator + getUserConfigFilename()); + } + /** * get test FOP Configuration * @return fo test filepath @@ -108,18 +118,7 @@ public abstract class BaseUserConfigTestCase extends BasePDFTestCase { * @throws SAXException * @throws ConfigurationException */ - protected Configuration getUserConfig() - throws ConfigurationException, SAXException, IOException { + protected Configuration getUserConfig() throws ConfigurationException, SAXException, IOException { return cfgBuilder.buildFromFile(getUserConfigFile()); - } - - /** get base config directory */ - protected String getBaseConfigDir() { - return "test/config"; - } - - /** - * @return user config File - */ - protected abstract File getUserConfigFile(); + } } diff --git a/test/java/org/apache/fop/config/EmbedUrlBadTestCase.java b/test/java/org/apache/fop/config/EmbedUrlBadTestCase.java deleted file mode 100644 index 2934004fd..000000000 --- a/test/java/org/apache/fop/config/EmbedUrlBadTestCase.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.config; - -import java.io.File; - -// -/** - * this font has an embed-url that does not exist on filesystem. - */ -public class EmbedUrlBadTestCase extends BaseUserConfigTestCase { - - public EmbedUrlBadTestCase(String name) { - super(name); - } - - protected File getUserConfigFile() { - return new File( getBaseConfigDir() + "/test_embedurl_bad.xconf"); - } - - public String getName() { - return "test_embedurl_bad.xconf"; - } -} diff --git a/test/java/org/apache/fop/config/EmbedUrlMalformedTestCase.java b/test/java/org/apache/fop/config/EmbedUrlMalformedTestCase.java deleted file mode 100644 index ab622fd69..000000000 --- a/test/java/org/apache/fop/config/EmbedUrlMalformedTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.config; - -import java.io.File; - -// this font has a malformed embed-url -public class EmbedUrlMalformedTestCase extends BaseUserConfigTestCase { - - public EmbedUrlMalformedTestCase(String name) { - super(name); - } - - protected File getUserConfigFile() { - return new File( getBaseConfigDir() + "/test_embedurl_malformed.xconf"); - } - - public String getName() { - return "test_embedurl_malformed.xconf"; - } -} diff --git a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java index fc5b10a60..a6333009d 100644 --- a/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java +++ b/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java @@ -19,20 +19,19 @@ package org.apache.fop.config; -import java.io.File; - -// this font is without a metrics-url or an embed-url -public class FontAttributesMissingTestCase extends BaseUserConfigTestCase { +/* + * this font is without a metrics-url or an embed-url + */ +public class FontAttributesMissingTestCase extends BaseDestructiveUserConfigTestCase { public FontAttributesMissingTestCase(String name) { super(name); } - protected File getUserConfigFile() { - return new File( getBaseConfigDir() + "/test_fontattributes_missing.xconf"); - } - - public String getName() { - return "test_fontattributes_missing.xconf"; + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + public String getUserConfigFilename() { + return "test_font_attributes_missing.xconf"; } } diff --git a/test/java/org/apache/fop/config/FontBaseBadTestCase.java b/test/java/org/apache/fop/config/FontBaseBadTestCase.java index 4280306d0..af9031199 100644 --- a/test/java/org/apache/fop/config/FontBaseBadTestCase.java +++ b/test/java/org/apache/fop/config/FontBaseBadTestCase.java @@ -19,10 +19,10 @@ package org.apache.fop.config; -import java.io.File; - -// this font base does not exist and a relative font path is used -public class FontBaseBadTestCase extends BaseUserConfigTestCase { +/* + * this font base does not exist and a relative font path is used + */ +public class FontBaseBadTestCase extends BaseDestructiveUserConfigTestCase { public FontBaseBadTestCase(String name) { super(name); @@ -34,16 +34,9 @@ public class FontBaseBadTestCase extends BaseUserConfigTestCase { } /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFile() - */ - protected File getUserConfigFile() { - return new File( getBaseConfigDir() + "/test_fontbase_bad.xconf"); - } - - /** - * @return configuration filename + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() */ - public String getName() { + public String getUserConfigFilename() { return "test_fontbase_bad.xconf"; } } diff --git a/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java b/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java new file mode 100644 index 000000000..218cee795 --- /dev/null +++ b/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java @@ -0,0 +1,37 @@ +/* + * 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.config; + +/** + * this font has an embed-url that does not exist on filesystem. + */ +public class FontEmbedUrlBadTestCase extends BaseDestructiveUserConfigTestCase { + + public FontEmbedUrlBadTestCase(String name) { + super(name); + } + + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + public String getUserConfigFilename() { + return "test_font_embedurl_bad.xconf"; + } +} diff --git a/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java b/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java new file mode 100644 index 000000000..e87164e90 --- /dev/null +++ b/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java @@ -0,0 +1,37 @@ +/* + * 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.config; + +/** + * this font has a malformed embed-url + */ +public class FontEmbedUrlMalformedTestCase extends BaseDestructiveUserConfigTestCase { + + public FontEmbedUrlMalformedTestCase(String name) { + super(name); + } + + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + public String getUserConfigFilename() { + return "test_font_embedurl_malformed.xconf"; + } +} diff --git a/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java new file mode 100644 index 000000000..00c4db752 --- /dev/null +++ b/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java @@ -0,0 +1,40 @@ +/* + * 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.config; + +/* + * this font has a metrics-url that does not exist on filesystem + */ +public class FontMetricsUrlBadTestCase extends BaseDestructiveUserConfigTestCase { + + /** + * @see junit.framework.TestCase#TestCase(String) + */ + public FontMetricsUrlBadTestCase(String name) { + super(name); + } + + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + public String getUserConfigFilename() { + return "test_font_metricsurl_bad.xconf"; + } +} diff --git a/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java new file mode 100644 index 000000000..d5815b42f --- /dev/null +++ b/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java @@ -0,0 +1,37 @@ +/* + * 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.config; + +/* + * this font has a malformed metrics-url + */ +public class FontMetricsUrlMalformedTestCase extends BaseDestructiveUserConfigTestCase { + + public FontMetricsUrlMalformedTestCase(String name) { + super(name); + } + + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + public String getUserConfigFilename() { + return "test_font_metricsurl_malformed.xconf"; + } +} diff --git a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java index c321926f8..aed07ed48 100644 --- a/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java +++ b/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java @@ -19,20 +19,19 @@ package org.apache.fop.config; -import java.io.File; - -// this font has an embed-url that does not exist on filesystem -public class FontTripletAttributeMissingTestCase extends BaseUserConfigTestCase { +/* + * this font has a missing font triplet attribute + */ +public class FontTripletAttributeMissingTestCase extends BaseDestructiveUserConfigTestCase { public FontTripletAttributeMissingTestCase(String name) { super(name); } - protected File getUserConfigFile() { - return new File( getBaseConfigDir() + "/test_fonttripletattribute_missing.xconf"); - } - - public String getName() { - return "test_fonttripletattribute_missing.xconf"; + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + public String getUserConfigFilename() { + return "test_font_tripletattribute_missing.xconf"; } } diff --git a/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java new file mode 100644 index 000000000..3e188a3e9 --- /dev/null +++ b/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java @@ -0,0 +1,34 @@ +/* + * 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.config; + +public class FontsAutoDetectTestCase extends BaseConstructiveUserConfigTestCase { + + public FontsAutoDetectTestCase(String name) { + super(name); + } + + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + public String getUserConfigFilename() { + return "test_fonts_autodetect.xconf"; + } +} diff --git a/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java b/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java new file mode 100644 index 000000000..b439e37b2 --- /dev/null +++ b/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java @@ -0,0 +1,42 @@ +/* + * 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.config; + +/* + * this font has a metrics-url that does not exist on filesystem + */ +public class FontsDirectoryBadTestCase extends BaseDestructiveUserConfigTestCase { + + public FontsDirectoryBadTestCase(String name) { + super(name); + } + + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + public String getUserConfigFilename() { + return "test_fonts_directory_bad.xconf"; + } + + /** get test FOP config File */ + protected String getFontFOFilePath() { + return "test/xml/bugtests/font-dir.fo"; + } +} diff --git a/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java new file mode 100644 index 000000000..1759f532d --- /dev/null +++ b/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java @@ -0,0 +1,37 @@ +/* + * 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.config; + +/** + * tests font directory on system + */ +public class FontsDirectoryRecursiveTestCase extends BaseConstructiveUserConfigTestCase { + + public FontsDirectoryRecursiveTestCase(String name) { + super(name); + } + + /** + * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename() + */ + protected String getUserConfigFilename() { + return "test_fonts_directory_recursive.xconf"; + } +} diff --git a/test/java/org/apache/fop/config/MetricsUrlBadTestCase.java b/test/java/org/apache/fop/config/MetricsUrlBadTestCase.java deleted file mode 100644 index 80f7e285b..000000000 --- a/test/java/org/apache/fop/config/MetricsUrlBadTestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.config; - -import java.io.File; - -// this font has a metrics-url that does not exist on filesystem -public class MetricsUrlBadTestCase extends BaseUserConfigTestCase { - - /** - * @see junit.framework.TestCase#TestCase(String) - */ - public MetricsUrlBadTestCase(String name) { - super(name); - } - - /** - * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFile() - */ - protected File getUserConfigFile() { - return new File( getBaseConfigDir() + "/test_metricsurl_bad.xconf"); - } - - public String getName() { - return "test_metricsurl_bad.xconf"; - } -} diff --git a/test/java/org/apache/fop/config/MetricsUrlMalformedTestCase.java b/test/java/org/apache/fop/config/MetricsUrlMalformedTestCase.java deleted file mode 100644 index 6b623e06e..000000000 --- a/test/java/org/apache/fop/config/MetricsUrlMalformedTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.config; - -import java.io.File; - -// this font has a malformed metrics-url -public class MetricsUrlMalformedTestCase extends BaseUserConfigTestCase { - - public MetricsUrlMalformedTestCase(String name) { - super(name); - } - - protected File getUserConfigFile() { - return new File( getBaseConfigDir() + "/test_metricsurl_malformed.xconf"); - } - - public String getName() { - return "test_metricsurl_malformed.xconf"; - } -} diff --git a/test/java/org/apache/fop/config/UserConfigTestSuite.java b/test/java/org/apache/fop/config/UserConfigTestSuite.java index ab612d043..439a2c031 100644 --- a/test/java/org/apache/fop/config/UserConfigTestSuite.java +++ b/test/java/org/apache/fop/config/UserConfigTestSuite.java @@ -38,10 +38,12 @@ public class UserConfigTestSuite { suite.addTest(new TestSuite(FontBaseBadTestCase.class)); suite.addTest(new TestSuite(FontAttributesMissingTestCase.class)); suite.addTest(new TestSuite(FontTripletAttributeMissingTestCase.class)); - suite.addTest(new TestSuite(MetricsUrlBadTestCase.class)); - suite.addTest(new TestSuite(EmbedUrlBadTestCase.class)); - suite.addTest(new TestSuite(MetricsUrlMalformedTestCase.class)); - suite.addTest(new TestSuite(EmbedUrlMalformedTestCase.class)); + suite.addTest(new TestSuite(FontMetricsUrlBadTestCase.class)); + suite.addTest(new TestSuite(FontEmbedUrlBadTestCase.class)); + suite.addTest(new TestSuite(FontMetricsUrlMalformedTestCase.class)); + suite.addTest(new TestSuite(FontEmbedUrlMalformedTestCase.class)); + suite.addTest(new TestSuite(FontsDirectoryRecursiveTestCase.class)); + suite.addTest(new TestSuite(FontsAutoDetectTestCase.class)); //$JUnit-END$ return suite; } diff --git a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java index 3e399e064..3b4e03118 100644 --- a/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java +++ b/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java @@ -93,7 +93,10 @@ public class BasePDFTestCase extends AbstractFOPTestCase { return result; } - /** get FOP config File */ + /** + * get FOP config File + * @return user config file to be used for testing + */ protected File getUserConfigFile() { return new File("test/test.xconf"); } -- cgit v1.2.3