From 9860d5a1338df6ad70e269d2423e7059c9194102 Mon Sep 17 00:00:00 2001 From: Peter Hancock Date: Wed, 19 Oct 2011 10:21:17 +0000 Subject: [PATCH] Bugzilla#512010: Simplification of the build. Reduced code duplication and layout engine tests. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1186070 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 234 +++++------------- .../org/apache/fop/layoutmgr/PageBreaker.java | 5 +- status.xml | 3 + .../apache/fop/fotreetest/FOTreeTester.java | 57 ++--- .../fop/fotreetest/ResultCollector.java | 5 +- .../intermediate/AreaTreeParserTestCase.java | 2 +- .../fop/intermediate/IFParserTestCase.java | 2 +- .../layoutengine/LayoutEngineTestUtils.java | 95 ++++--- .../fop/layoutengine/LayoutEngineTester.java | 39 +-- .../layoutengine/TestFilesConfiguration.java | 205 +++++++++++++++ .../org/apache/fop/visual/BatchDiffer.java | 18 +- 11 files changed, 379 insertions(+), 286 deletions(-) create mode 100644 test/java/org/apache/fop/layoutengine/TestFilesConfiguration.java diff --git a/build.xml b/build.xml index 8da44847d..a7e548a53 100644 --- a/build.xml +++ b/build.xml @@ -186,10 +186,6 @@ list of possible build targets. - - - - @@ -747,84 +743,34 @@ list of possible build targets. - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -844,132 +790,68 @@ list of possible build targets. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - + - - + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - + - - + - + diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java index ea2d09268..90e1b3e51 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java @@ -277,9 +277,8 @@ public class PageBreaker extends AbstractBreaker { separatorArea.setIPD( pslm.getCurrentPV().getRegionReference(Constants.FO_REGION_BODY).getIPD()); // create a StaticContentLM for the footnote separator - footnoteSeparatorLM = (StaticContentLayoutManager) - pslm.getLayoutManagerMaker().makeStaticContentLayoutManager( - pslm, footnoteSeparator, separatorArea); + footnoteSeparatorLM = pslm.getLayoutManagerMaker().makeStaticContentLayoutManager( + pslm, footnoteSeparator, separatorArea); footnoteSeparatorLM.doLayout(); } diff --git a/status.xml b/status.xml index 891b62496..118887d69 100644 --- a/status.xml +++ b/status.xml @@ -60,6 +60,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Simplification of the build: Reduced code duplication and layout engine tests. + Various bugfixes to make PDFDocumentGraphics2D operational again. diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTester.java b/test/java/org/apache/fop/fotreetest/FOTreeTester.java index 80bf44034..3eb7a490d 100644 --- a/test/java/org/apache/fop/fotreetest/FOTreeTester.java +++ b/test/java/org/apache/fop/fotreetest/FOTreeTester.java @@ -20,7 +20,6 @@ package org.apache.fop.fotreetest; import java.io.File; -import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -36,14 +35,6 @@ import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLFilterImpl; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.AndFileFilter; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.NameFileFilter; -import org.apache.commons.io.filefilter.PrefixFileFilter; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.apache.commons.io.filefilter.TrueFileFilter; - import org.apache.fop.DebugHelper; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; @@ -51,6 +42,7 @@ import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.FopFactoryConfigurator; import org.apache.fop.fotreetest.ext.TestElementMapping; import org.apache.fop.layoutengine.LayoutEngineTestUtils; +import org.apache.fop.layoutengine.TestFilesConfiguration; import org.apache.fop.util.ConsoleEventListenerForTests; /** @@ -64,36 +56,23 @@ public class FOTreeTester { DebugHelper.registerStandardElementListObservers(); } + /** + * Gets the parameters to run the FO tree test cases. + * @return a collection of file arrays containing the test files + */ @Parameters - public static Collection testXMLTestCases() throws Exception { - File mainDir = new File("test/fotree"); - - IOFileFilter filter; - String single = System.getProperty("fop.fotree.single"); - String startsWith = System.getProperty("fop.fotree.starts-with"); - if (single != null) { - filter = new NameFileFilter(single); - } else if (startsWith != null) { - filter = new PrefixFileFilter(startsWith); - filter = new AndFileFilter(filter, new SuffixFileFilter(".fo")); - } else { - filter = new SuffixFileFilter(".fo"); - filter = LayoutEngineTestUtils.decorateWithDisabledList(filter); - } - Collection files = FileUtils.listFiles(new File(mainDir, "testcases"), filter, - TrueFileFilter.INSTANCE); - String privateTests = System.getProperty("fop.fotree.private"); - if ("true".equalsIgnoreCase(privateTests)) { - Collection privateFiles = FileUtils.listFiles(new File(mainDir, "private-testcases"), - filter, TrueFileFilter.INSTANCE); - files.addAll(privateFiles); - } - // Unfortunately JUnit forces us to return a collection of arrays. - Collection parameters = new ArrayList(); - for (File f : files) { - parameters.add(new File[] { f }); - } - return parameters; + public static Collection getParameters() { + TestFilesConfiguration.Builder builder = new TestFilesConfiguration.Builder(); + builder.testDir("test/fotree") + .singleProperty("fop.fotree.single") + .startsWithProperty("fop.fotree.starts-with") + .suffix(".fo") + .testSet("testcases") + .disabledProperty("fop.layoutengine.disabled", "test/fotree/disabled-testcases.xml") + .privateTestsProperty("fop.fotree.private"); + + TestFilesConfiguration testConfig = builder.build(); + return LayoutEngineTestUtils.getTestFiles(testConfig); } private FopFactory fopFactory = FopFactory.newInstance(); @@ -153,7 +132,7 @@ public class FOTreeTester { throw e; } - List results = collector.getResults(); + List results = collector.getResults(); if (results.size() > 0) { for (int i = 0; i < results.size(); i++) { System.out.println((String) results.get(i)); diff --git a/test/java/org/apache/fop/fotreetest/ResultCollector.java b/test/java/org/apache/fop/fotreetest/ResultCollector.java index 3f6502803..d5b362704 100644 --- a/test/java/org/apache/fop/fotreetest/ResultCollector.java +++ b/test/java/org/apache/fop/fotreetest/ResultCollector.java @@ -19,6 +19,7 @@ package org.apache.fop.fotreetest; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -29,7 +30,7 @@ public class ResultCollector { private static ResultCollector instance = null; - private List results = new java.util.ArrayList(); + private List results = new ArrayList(); /** @return the ResultCollector singleton */ public static ResultCollector getInstance() { @@ -70,7 +71,7 @@ public class ResultCollector { } /** @return the list of results */ - public List getResults() { + public List getResults() { return Collections.unmodifiableList(results); } } diff --git a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java index 645183844..6c06971e6 100644 --- a/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java @@ -63,7 +63,7 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTestCase { */ @Parameters public static Collection getParameters() throws IOException { - return LayoutEngineTestUtils.getTestFiles(); + return LayoutEngineTestUtils.getLayoutTestFiles(); } /** * Constructor for the test suite that is used for each test file. diff --git a/test/java/org/apache/fop/intermediate/IFParserTestCase.java b/test/java/org/apache/fop/intermediate/IFParserTestCase.java index 08a96a506..52d322e3e 100644 --- a/test/java/org/apache/fop/intermediate/IFParserTestCase.java +++ b/test/java/org/apache/fop/intermediate/IFParserTestCase.java @@ -56,7 +56,7 @@ public class IFParserTestCase extends AbstractIFTestCase { */ @Parameters public static Collection getParameters() throws IOException { - return LayoutEngineTestUtils.getTestFiles(); + return LayoutEngineTestUtils.getLayoutTestFiles(); } /** diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java index 6beda1f30..772204d28 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTestUtils.java @@ -20,7 +20,6 @@ package org.apache.fop.layoutengine; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -58,9 +57,9 @@ public final class LayoutEngineTestUtils { private static class FilenameHandler extends DefaultHandler { private StringBuffer buffer = new StringBuffer(128); private boolean readingFilename = false; - private List filenames; + private List filenames; - public FilenameHandler(List filenames) { + public FilenameHandler(List filenames) { this.filenames = filenames; } @@ -93,19 +92,24 @@ public final class LayoutEngineTestUtils { } } - public static IOFileFilter decorateWithDisabledList(IOFileFilter filter) throws IOException { - String disabled = System.getProperty("fop.layoutengine.disabled"); + /** + * Removes from {@code filter} any tests that have been disabled. + * + * @param filter the filter populated with tests + * @param disabled name of the file containing disabled test cases. If null or empty, + * no file is read + * @return {@code filter} minus any disabled tests + */ + public static IOFileFilter decorateWithDisabledList(IOFileFilter filter, String disabled) { if (disabled != null && disabled.length() > 0) { - filter = new AndFileFilter(new NotFileFilter( - new NameFileFilter(LayoutEngineTestUtils.readDisabledTestcases(new File( - disabled)))), - filter); + filter = new AndFileFilter(new NotFileFilter(new NameFileFilter( + LayoutEngineTestUtils.readDisabledTestcases(new File(disabled)))), filter); } return filter; } - public static String[] readDisabledTestcases(File f) throws IOException { - List lines = new java.util.ArrayList(); + private static String[] readDisabledTestcases(File f) { + List lines = new ArrayList(); Source stylesheet = new StreamSource( new File("test/layoutengine/disabled-testcase2filename.xsl")); Source source = new StreamSource(f); @@ -114,43 +118,41 @@ public final class LayoutEngineTestUtils { Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesheet); transformer.transform(source, result); } catch (TransformerConfigurationException tce) { - throw new RuntimeException(tce.getMessage()); + throw new RuntimeException(tce); } catch (TransformerException te) { - throw new RuntimeException(te.getMessage()); + throw new RuntimeException(te); } return (String[]) lines.toArray(new String[lines.size()]); } /** - * @return a Collection of File instances containing all the test cases set up for processing. - * @throws IOException if there's a problem gathering the list of test files + * Returns the test files matching the given configuration. + * + * @param testConfig the test configuration + * @return the applicable test cases */ - public static Collection getTestFiles() throws IOException { - File mainDir = new File("test/layoutengine"); + public static Collection getTestFiles(TestFilesConfiguration testConfig) { + File mainDir = testConfig.getTestDirectory(); IOFileFilter filter; - String single = System.getProperty("fop.layoutengine.single"); - String startsWith = System.getProperty("fop.layoutengine.starts-with"); + String single = testConfig.getSingleTest(); + String startsWith = testConfig.getStartsWith(); if (single != null) { filter = new NameFileFilter(single); } else if (startsWith != null) { filter = new PrefixFileFilter(startsWith); - filter = new AndFileFilter(filter, new SuffixFileFilter(".xml")); - filter = decorateWithDisabledList(filter); + filter = new AndFileFilter(filter, new SuffixFileFilter(testConfig.getFileSuffix())); + filter = decorateWithDisabledList(filter, testConfig.getDisabledTests()); } else { - filter = new SuffixFileFilter(".xml"); - filter = decorateWithDisabledList(filter); + filter = new SuffixFileFilter(testConfig.getFileSuffix()); + filter = decorateWithDisabledList(filter, testConfig.getDisabledTests()); } - String testset = System.getProperty("fop.layoutengine.testset"); - if (testset == null) { - testset = "standard"; - } - Collection files = FileUtils.listFiles(new File(mainDir, testset + "-testcases"), - filter, TrueFileFilter.INSTANCE); - String privateTests = System.getProperty("fop.layoutengine.private"); - if ("true".equalsIgnoreCase(privateTests)) { - Collection privateFiles = FileUtils.listFiles( - new File(mainDir, "private-testcases"), - filter, TrueFileFilter.INSTANCE); + String testset = testConfig.getTestSet(); + + Collection files = FileUtils.listFiles(new File(mainDir, testset), filter, + TrueFileFilter.INSTANCE); + if (testConfig.hasPrivateTests()) { + Collection privateFiles = FileUtils.listFiles(new File(mainDir, + "private-testcases"), filter, TrueFileFilter.INSTANCE); files.addAll(privateFiles); } @@ -162,4 +164,29 @@ public final class LayoutEngineTestUtils { return parametersForJUnit4; } + /** + * This is a helper method that uses the standard parameters for FOP's layout engine tests and + * returns a set of test files. These pull in System parameters to configure the layout tests + * to run. + * + * @return A collection of file arrays that contain the test files + */ + public static Collection getLayoutTestFiles() { + TestFilesConfiguration.Builder builder = new TestFilesConfiguration.Builder(); + String testSet = System.getProperty("fop.layoutengine.testset"); + testSet = (testSet != null ? testSet : "standard") + "-testcases"; + + builder.testDir("test/layoutengine") + .singleProperty("fop.layoutengine.single") + .startsWithProperty("fop.layoutengine.starts-with") + .suffix(".xml") + .testSet(testSet) + .disabledProperty("fop.layoutengine.disabled", + "test/layoutengine/disabled-testcases.xml") + .privateTestsProperty("fop.layoutengine.private"); + + TestFilesConfiguration testConfig = builder.build(); + return getTestFiles(testConfig); + } + } diff --git a/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java b/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java index 867602cce..33f621f84 100644 --- a/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java +++ b/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java @@ -34,6 +34,17 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.TransformerHandler; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + import org.apache.fop.DebugHelper; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; @@ -53,16 +64,6 @@ import org.apache.fop.render.intermediate.IFSerializer; import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.util.ConsoleEventListenerForTests; import org.apache.fop.util.DelegatingContentHandler; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; /** * Class for testing the FOP's layout engine using testcases specified in XML @@ -71,14 +72,15 @@ import org.xml.sax.SAXException; @RunWith(Parameterized.class) public class LayoutEngineTester { private static File areaTreeBackupDir; - /** - * Sets up the class, this is invoked only once. - */ + @BeforeClass - public static void makeDirAndRegisterDebugHelper() { + public static void makeDirAndRegisterDebugHelper() throws IOException { DebugHelper.registerStandardElementListObservers(); areaTreeBackupDir = new File("build/test-results/layoutengine"); - areaTreeBackupDir.mkdirs(); + if (!areaTreeBackupDir.mkdirs() && !areaTreeBackupDir.exists()) { + throw new IOException("Failed to create the layout engine directory at " + + "build/test-results/layoutengine"); + } } /** @@ -89,7 +91,7 @@ public class LayoutEngineTester { */ @Parameters public static Collection getParameters() throws IOException { - return LayoutEngineTestUtils.getTestFiles(); + return LayoutEngineTestUtils.getLayoutTestFiles(); } private TestAssistant testAssistant = new TestAssistant(); @@ -161,9 +163,9 @@ public class LayoutEngineTester { } Document doc = (Document)domres.getNode(); - if (this.areaTreeBackupDir != null) { + if (areaTreeBackupDir != null) { testAssistant.saveDOM(doc, - new File(this.areaTreeBackupDir, testFile.getName() + ".at.xml")); + new File(areaTreeBackupDir, testFile.getName() + ".at.xml")); } FormattingResults results = fop.getResults(); LayoutResult result = new LayoutResult(doc, elCollector, results); @@ -172,6 +174,7 @@ public class LayoutEngineTester { /** * Perform all checks on the area tree and, optionally, on the intermediate format. + * @param fopFactory the FOP factory * @param testFile Test case XML file * @param result The layout results * @throws TransformerException if a problem occurs in XSLT/JAXP diff --git a/test/java/org/apache/fop/layoutengine/TestFilesConfiguration.java b/test/java/org/apache/fop/layoutengine/TestFilesConfiguration.java new file mode 100644 index 000000000..656fc5f6f --- /dev/null +++ b/test/java/org/apache/fop/layoutengine/TestFilesConfiguration.java @@ -0,0 +1,205 @@ +/* + * 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.layoutengine; + +import java.io.File; + +/** + * A class that contains the information needed to run a suite of layout engine and FO tree + * tests. + */ +public final class TestFilesConfiguration { + + private final File testDirectory; + private final String singleTest; + private final String testStartsWith; + private final String testFileSuffix; + private final String testSet; + private final String disabledTests; + private final boolean privateTests; + + private TestFilesConfiguration(Builder builder) { + this.testDirectory = new File(builder.testDirectory); + this.singleTest = builder.singleTest; + this.testStartsWith = builder.testStartsWith; + this.testFileSuffix = builder.testFileSuffix; + this.testSet = builder.testSet; + this.privateTests = builder.privateTests; + this.disabledTests = builder.disabledTests; + } + + /** + * Returns the directory of the tests. + * @return the test directory + */ + public File getTestDirectory() { + return testDirectory; + } + + /** + * Returns the name of the single test file to run. + * @return the single test file name + */ + public String getSingleTest() { + return singleTest; + } + + /** + * Returns the string that must prefix the test file names. + * @return the prefixing string + */ + public String getStartsWith() { + return testStartsWith; + } + + /** + * Returns the file suffix (i.e. ".xml" for XML files and ".fo" for FOs). + * @return the file suffix + */ + public String getFileSuffix() { + return testFileSuffix; + } + + /** + * Returns the directory set of tests to be run. + * @return the directory tests + */ + public String getTestSet() { + return testSet; + } + + /** + * Returns the name of the XML file containing the disabled tests. + * @return a file name, may be null + */ + public String getDisabledTests() { + return disabledTests; + } + + /** + * Whether any private tests should be invoked. + * @return true if private tests should be tested + */ + public boolean hasPrivateTests() { + return privateTests; + } + + /** + * A builder class that configures the data for running a suite of tests designed for the + * layout engine and FOTree. + */ + public static class Builder { + + private String testDirectory; + private String singleTest; + private String testStartsWith; + private String testFileSuffix; + private String testSet; + private String disabledTests; + private boolean privateTests; + + /** + * Configures the test directory. + * @param dir the test directory + * @return {@code this} + */ + public Builder testDir(String dir) { + testDirectory = dir; + return this; + } + + /** + * Configures the name of the single test to run. + * @param singleProperty name of the property that determines the single test case + * @return {@code this} + */ + public Builder singleProperty(String singleProperty) { + singleTest = getSystemProperty(singleProperty); + return this; + } + + /** + * Configures the prefix that all test cases must match. + * @param startsWithProperty name of the property that determines the common prefix + * @return {@code this} + */ + public Builder startsWithProperty(String startsWithProperty) { + testStartsWith = getSystemProperty(startsWithProperty); + return this; + } + + /** + * Configures the test file name suffix. + * @param suffix the suffixing string + * @return {@code this} + */ + public Builder suffix(String suffix) { + testFileSuffix = suffix; + return this; + } + + /** + * Configures the name of the directory containing the set of tests. + * @param testSet the directory of tests. If null, defaults to "standard-testcases" + * @return {@code this} + */ + public Builder testSet(String testSet) { + this.testSet = testSet != null ? testSet : "standard-testcases"; + return this; + } + + /** + * Configures whether any tests are disabled. + * @param disabledProperty name of the property that determines the file of + * disabled test cases + * @param defaultValue if the property was not defined, uses this file name + * instead + * @return {@code this} + */ + public Builder disabledProperty(String disabledProperty, String defaultValue) { + String property = getSystemProperty(disabledProperty); + disabledTests = property != null ? property : defaultValue; + return this; + } + + /** + * Configures whether private tests must be run or not. + * @param privateTestsProperty name of the property containing the boolean switch + * @return {@code this} + */ + public Builder privateTestsProperty(String privateTestsProperty) { + String property = getSystemProperty(privateTestsProperty); + this.privateTests = property != null && property.equalsIgnoreCase("true"); + return this; + } + + private String getSystemProperty(String property) { + return System.getProperty(property); + } + + /** + * Creates the configuration instance. + * @return a configuration instance configured by this builder + */ + public TestFilesConfiguration build() { + return new TestFilesConfiguration(this); + } + } +} diff --git a/test/java/org/apache/fop/visual/BatchDiffer.java b/test/java/org/apache/fop/visual/BatchDiffer.java index 0a0b6e11b..cbc9cd5e9 100644 --- a/test/java/org/apache/fop/visual/BatchDiffer.java +++ b/test/java/org/apache/fop/visual/BatchDiffer.java @@ -23,7 +23,6 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Collection; -import java.util.Iterator; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.stream.StreamSource; @@ -150,8 +149,7 @@ public class BatchDiffer { throw new RuntimeException("source-directory does not exist: " + srcDir); } final File targetDir = new File(cfg.getChild("target-directory").getValue()); - targetDir.mkdirs(); - if (!targetDir.exists()) { + if (!targetDir.mkdirs() && !targetDir.exists()) { throw new RuntimeException("target-directory is invalid: " + targetDir); } context.setTargetDir(targetDir); @@ -164,7 +162,8 @@ public class BatchDiffer { IOFileFilter filter = new SuffixFileFilter(new String[] {".xml", ".fo"}); //Same filtering as in layout engine tests if (cfg.getChild("filter-disabled").getValueAsBoolean(true)) { - filter = LayoutEngineTestUtils.decorateWithDisabledList(filter); + String disabled = System.getProperty("fop.layoutengine.disabled"); + filter = LayoutEngineTestUtils.decorateWithDisabledList(filter, disabled); } String manualFilter = cfg.getChild("manual-filter").getValue(null); if (manualFilter != null) { @@ -176,10 +175,8 @@ public class BatchDiffer { } int maxfiles = cfg.getChild("max-files").getValueAsInteger(-1); - Collection files = FileUtils.listFiles(srcDir, filter, null); - Iterator i = files.iterator(); - while (i.hasNext()) { - final File f = (File)i.next(); + Collection files = FileUtils.listFiles(srcDir, filter, null); + for (final File f : files) { try { log.info("---=== " + f + " ===---"); long[] times = new long[producers.length]; @@ -228,9 +225,6 @@ public class BatchDiffer { break; } } - } catch (IOException ioe) { - log.error("I/O problem while processing", ioe); - throw new RuntimeException("I/O problem: " + ioe.getMessage()); } catch (ConfigurationException e) { log.error("Error while configuring BatchDiffer", e); throw new RuntimeException("Error while configuring BatchDiffer: " + e.getMessage()); @@ -260,7 +254,7 @@ public class BatchDiffer { BitmapProducer[] producers = new BitmapProducer[children.length]; for (int i = 0; i < children.length; i++) { try { - Class clazz = Class.forName(children[i].getAttribute("classname")); + Class clazz = Class.forName(children[i].getAttribute("classname")); producers[i] = (BitmapProducer)clazz.newInstance(); ContainerUtil.configure(producers[i], children[i]); } catch (Exception e) { -- 2.39.5