xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From me...@apache.org
Subject svn commit: r1356646 [9/12] - in /xmlgraphics/fop/trunk: ./ examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/ examples/embedding/java/embedding/events/ examples/embedding/java/embedding/intermediate/ src/java/org/apache/fop/af...
Date Tue, 03 Jul 2012 09:47:25 GMT
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTest.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTest.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTest.java Tue Jul  3 09:46:41 2012
@@ -19,18 +19,20 @@
 
 package org.apache.fop.config;
 
-import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
+
+import org.xml.sax.SAXException;
 
-import org.apache.avalon.framework.configuration.Configuration;
-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.FOUserAgent;
 import org.apache.fop.render.pdf.BasePDFTest;
-import org.xml.sax.SAXException;
+
+import static org.apache.fop.FOPTestUtils.getBaseDir;
 
 /**
  * Basic runtime test for FOP's font configuration. It is used to verify that
@@ -44,6 +46,10 @@ public abstract class BaseUserConfigTest
     protected Log log = LogFactory.getLog(BaseUserConfigTest.class);
 
 
+    public BaseUserConfigTest(InputStream confStream) throws SAXException, IOException {
+        super(confStream);
+    }
+
     /**
      * @see org.apache.fop.render.pdf.BasePDFTest#init()
      */
@@ -51,10 +57,6 @@ public abstract class BaseUserConfigTest
         // do nothing
     }
 
-    protected void initConfig() throws Exception {
-        fopFactory.setUserConfig(getUserConfig());
-    }
-
     protected void convertFO() throws Exception {
         final File baseDir = getBaseDir();
         final String fontFOFilePath = getFontFOFilePath();
@@ -72,46 +74,8 @@ public abstract class BaseUserConfigTest
         return "test/xml/bugtests/font.fo";
     }
 
-    /**
-     * get test FOP Configuration
-     * @return fo test filepath
-     * @throws IOException
-     * @throws SAXException
-     * @throws ConfigurationException
-     */
-    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
-     */
-    protected abstract String getUserConfigFilename();
-
-    /**
-     * The name of this test.
-     */
-    public String getName() {
-        return getUserConfigFilename();
-    }
-
-    protected File getUserConfigFile() {
-        return new File(getBaseConfigDir() + File.separator + getUserConfigFilename());
-    }
-
-    /**
-     * get test FOP Configuration
-     * @return fo test filepath
-     * @throws IOException
-     * @throws SAXException
-     * @throws ConfigurationException
-     */
-    protected Configuration getUserConfig() throws ConfigurationException, SAXException, IOException {
-        return cfgBuilder.buildFromFile(getUserConfigFile());
+    protected static String getBaseConfigDir() {
+        return "test/config/";
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,13 +19,27 @@
 
 package org.apache.fop.config;
 
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
+
+import org.apache.fop.apps.FopConfBuilder;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.PDFRendererConfBuilder;
+
 /**
  * this font is without a metrics-url or an embed-url
  */
 public class FontAttributesMissingTestCase extends BaseDestructiveUserConfigTest {
 
-    @Override
-    public String getUserConfigFilename() {
-        return "test_font_attributes_missing.xconf";
+    public FontAttributesMissingTestCase() throws SAXException, IOException {
+        super(new FopConfBuilder().setStrictValidation(true)
+                                  .startRendererConfig(PDFRendererConfBuilder.class)
+                                      .startFontsConfig()
+                                          .startFont(null, null)
+                                              .addTriplet("Gladiator", "normal", "normal")
+                                          .endFont()
+                                      .endFontConfig()
+                                  .endRendererConfig().build());
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,13 +19,27 @@
 
 package org.apache.fop.config;
 
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
+
+import org.apache.fop.apps.FopConfBuilder;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.PDFRendererConfBuilder;
+
 /**
  * this font has a metrics-url that does not exist on filesystem
  */
 public class FontMetricsUrlBadTestCase extends BaseDestructiveUserConfigTest {
 
-    @Override
-    public String getUserConfigFilename() {
-        return "test_font_metricsurl_bad.xconf";
+    public FontMetricsUrlBadTestCase() throws SAXException, IOException {
+        super(new FopConfBuilder().setStrictValidation(true)
+                                  .startRendererConfig(PDFRendererConfBuilder.class)
+                                      .startFontsConfig()
+                                          .startFont("test/doesnotexist.ttf.ansi.xml", null)
+                                              .addTriplet("Gladiator-Ansi", "normal", "normal")
+                                          .endFont()
+                                      .endFontConfig()
+                                  .endRendererConfig().build());
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,13 +19,27 @@
 
 package org.apache.fop.config;
 
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
+
+import org.apache.fop.apps.FopConfBuilder;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.PDFRendererConfBuilder;
+
 /**
  * this font has a malformed metrics-url
  */
 public class FontMetricsUrlMalformedTestCase extends BaseDestructiveUserConfigTest {
 
-    @Override
-    public String getUserConfigFilename() {
-        return "test_font_metricsurl_malformed.xconf";
+    public FontMetricsUrlMalformedTestCase() throws SAXException, IOException {
+        super(new FopConfBuilder().setStrictValidation(true)
+                                  .startRendererConfig(PDFRendererConfBuilder.class)
+                                      .startFontsConfig()
+                                          .startFont("badprotocol:test/glb12.ttf.xml", null)
+                                              .addTriplet("Gladiator", "normal", "normal")
+                                          .endFont()
+                                      .endFontConfig()
+                                  .endRendererConfig().build());
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,13 +19,27 @@
 
 package org.apache.fop.config;
 
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
+
+import org.apache.fop.apps.FopConfBuilder;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.PDFRendererConfBuilder;
+
 /**
  * this font has a missing font triplet attribute
  */
 public class FontTripletAttributeMissingTestCase extends BaseDestructiveUserConfigTest {
 
-    @Override
-    public String getUserConfigFilename() {
-        return "test_font_tripletattribute_missing.xconf";
+    public FontTripletAttributeMissingTestCase() throws SAXException, IOException {
+        super(new FopConfBuilder().setStrictValidation(true)
+                                  .startRendererConfig(PDFRendererConfBuilder.class)
+                                      .startFontsConfig()
+                                          .startFont(null, "test/resources/fonts/ttf/glb12.ttf")
+                                              .addTriplet("Gladiator", null, "normal")
+                                          .endFont()
+                                      .endFontConfig()
+                                  .endRendererConfig().build());
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,10 +19,21 @@
 
 package org.apache.fop.config;
 
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
+
+import org.apache.fop.apps.FopConfBuilder;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.PDFRendererConfBuilder;
+
 public class FontsAutoDetectTestCase extends BaseConstructiveUserConfigTest {
 
-    @Override
-    public String getUserConfigFilename() {
-        return "test_fonts_autodetect.xconf";
+    public FontsAutoDetectTestCase() throws SAXException, IOException {
+        super(new FopConfBuilder().startRendererConfig(PDFRendererConfBuilder.class)
+                                      .startFontsConfig()
+                                          .addAutoDetect()
+                                      .endFontConfig()
+                                  .endRendererConfig().build());
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,13 +19,24 @@
 
 package org.apache.fop.config;
 
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
+
+import org.apache.fop.apps.FopConfBuilder;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.PDFRendererConfBuilder;
+
 /**
  * tests font directory on system
  */
 public class FontsDirectoryRecursiveTestCase extends BaseConstructiveUserConfigTest {
 
-    @Override
-    protected String getUserConfigFilename() {
-        return "test_fonts_directory_recursive.xconf";
+    public FontsDirectoryRecursiveTestCase() throws SAXException, IOException {
+        super(new FopConfBuilder().startRendererConfig(PDFRendererConfBuilder.class)
+                                      .startFontsConfig()
+                                          .addDirectory("test/resources/fonts", true)
+                                      .endFontConfig()
+                                  .endRendererConfig().build());
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java Tue Jul  3 09:46:41 2012
@@ -20,9 +20,14 @@
 package org.apache.fop.config;
 
 import java.io.File;
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
 
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopConfBuilder;
 import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.PDFRendererConfBuilder;
 import org.apache.fop.fonts.CustomFontCollection;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontCollection;
@@ -35,8 +40,21 @@ import org.apache.fop.render.PrintRender
 /**
  * Tests the font substitution mechanism
  */
-public class FontsSubstitutionTestCase extends
-        BaseConstructiveUserConfigTest {
+public class FontsSubstitutionTestCase extends BaseConstructiveUserConfigTest {
+
+    public FontsSubstitutionTestCase() throws SAXException, IOException {
+        super(new FopConfBuilder()
+                    .startFontsConfig()
+                        .substituteFonts("Times", "italic", null, "Gladiator", "normal", "bold")
+                    .endFontsConfig()
+                    .startRendererConfig(PDFRendererConfBuilder.class)
+                        .startFontsConfig()
+                            .startFont(null, "resources/fonts/ttf/glb12.ttf")
+                                .addTriplet("Gladiator", "normal", "bold")
+                            .endFont()
+                        .endFontConfig()
+                    .endRendererConfig().build());
+    }
 
     @Override
     protected byte[] convertFO(File foFile, FOUserAgent ua, boolean dumpPdfFile)
@@ -45,11 +63,11 @@ public class FontsSubstitutionTestCase e
                 .createRenderer(ua, MimeConstants.MIME_PDF);
         FontInfo fontInfo = new FontInfo();
         renderer.setupFontInfo(fontInfo);
-        FontManager fontManager = ua.getFactory().getFontManager();
+        FontManager fontManager = ua.getFontManager();
         FontCollection[] fontCollections = new FontCollection[] {
                 new Base14FontCollection(fontManager.isBase14KerningEnabled()),
-                new CustomFontCollection(renderer.getFontResolver(), renderer.getFontList(),
-                                         ua.isComplexScriptFeaturesEnabled())
+                new CustomFontCollection(fontManager.getResourceResolver(), renderer.getFontList(),
+                        ua.isComplexScriptFeaturesEnabled())
         };
         fontManager.setup(fontInfo, fontCollections);
         FontTriplet triplet = new FontTriplet("Times", "italic",
@@ -62,9 +80,4 @@ public class FontsSubstitutionTestCase e
         }
         return null;
     }
-
-    @Override
-    public String getUserConfigFilename() {
-        return "test_fonts_substitution.xconf";
-    }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java Tue Jul  3 09:46:41 2012
@@ -28,16 +28,13 @@ import org.junit.runners.Suite.SuiteClas
  */
 @RunWith(Suite.class)
 @SuiteClasses({
-    FontBaseBadTestCase.class,
-    FontAttributesMissingTestCase.class,
-    FontTripletAttributeMissingTestCase.class,
-    FontMetricsUrlBadTestCase.class,
-    FontEmbedUrlBadTestCase.class,
-    FontMetricsUrlMalformedTestCase.class,
-    FontsDirectoryRecursiveTestCase.class,
-    FontsAutoDetectTestCase.class,
-    FontsSubstitutionTestCase.class,
-    FOURIResolverTestCase.class
+        FontAttributesMissingTestCase.class,
+        FontTripletAttributeMissingTestCase.class,
+        FontMetricsUrlBadTestCase.class,
+        FontMetricsUrlMalformedTestCase.class,
+        FontsDirectoryRecursiveTestCase.class,
+        FontsAutoDetectTestCase.class,
+        FontsSubstitutionTestCase.class
 })
 public class UserConfigTestSuite {
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,27 +19,24 @@
 
 package org.apache.fop.events;
 
-import java.io.FileInputStream;
-import java.io.IOException;
+import java.io.File;
 import java.io.InputStream;
+import java.net.URI;
 
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.sax.SAXResult;
 import javax.xml.transform.stream.StreamSource;
 
 import org.junit.Test;
-import org.xml.sax.SAXException;
 
 import org.apache.commons.io.output.NullOutputStream;
 
 import org.apache.xmlgraphics.util.MimeConstants;
 
 import org.apache.fop.ResourceEventProducer;
-import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
@@ -54,22 +51,29 @@ import org.apache.fop.layoutmgr.inline.I
  */
 public class EventProcessingTestCase {
 
-    private final FopFactory fopFactory = FopFactory.newInstance();
-
     private final TransformerFactory tFactory = TransformerFactory.newInstance();
+    private static final URI BASE_DIR;
+    public static final URI CONFIG_BASE_DIR;
+    static {
+        URI base = (new File(".")).toURI();
+        BASE_DIR = base.resolve("test/events/");
 
-    private static final String BASE_DIR = "test/events/";
-
-    /** The base directory of configuration files */
-    public static final String CONFIG_BASE_DIR = "test/config/";
+        /** The base directory of configuration files */
+        CONFIG_BASE_DIR = base.resolve("test/config/");
 
-    public void doTest(InputStream inStream, String fopConf, String expectedEventID, String mimeType)
-            throws FOPException, TransformerException, IOException, SAXException {
+    }
+    public void doTest(InputStream inStream, URI fopConf, String expectedEventID, String mimeType)
+            throws Exception {
         EventChecker eventChecker = new EventChecker(expectedEventID);
+        FopFactory fopFactory;
         if (fopConf != null) {
-            fopFactory.setUserConfig(fopConf);
+            fopFactory = FopFactory.newInstance(new File(fopConf));
+        } else {
+            fopFactory = FopFactory.newInstance(BASE_DIR);
         }
+
         FOUserAgent userAgent = fopFactory.newFOUserAgent();
+
         userAgent.getEventBroadcaster().addEventListener(eventChecker);
         Fop fop = fopFactory.newFop(mimeType, userAgent, new NullOutputStream());
         Transformer transformer = tFactory.newTransformer();
@@ -79,61 +83,54 @@ public class EventProcessingTestCase {
         eventChecker.end();
     }
 
-    public void doTest(String filename, String expectedEventID) throws
-            FOPException, TransformerException, IOException, SAXException {
-        doTest(new FileInputStream(BASE_DIR + filename), null, expectedEventID,
+    public void doTest(String filename, String expectedEventID) throws Exception {
+        doTest(BASE_DIR.resolve(filename).toURL().openStream(), null, expectedEventID,
                 MimeConstants.MIME_PDF);
     }
 
     @Test
-    public void testArea() throws TransformerException, IOException, SAXException {
+    public void testArea() throws Exception {
         doTest("area.fo",
                 AreaEventProducer.class.getName() + ".unresolvedIDReferenceOnPage");
     }
 
     @Test
-    public void testResource() throws FOPException, TransformerException, IOException,
-            SAXException {
+    public void testResource() throws Exception {
         doTest("resource.fo",
                 ResourceEventProducer.class.getName() + ".imageNotFound");
     }
 
     @Test
-    public void testValidation() throws FOPException, TransformerException, IOException,
-            SAXException {
+    public void testValidation() throws Exception {
         doTest("validation.fo",
                 FOValidationEventProducer.class.getName() + ".invalidPropertyValue");
     }
 
     @Test
-    public void testTable() throws FOPException, TransformerException, IOException, SAXException {
+    public void testTable() throws Exception {
         doTest("table.fo",
                 TableEventProducer.class.getName() + ".noTablePaddingWithCollapsingBorderModel");
     }
 
     @Test
-    public void testBlockLevel() throws FOPException, TransformerException, IOException,
-            SAXException {
+    public void testBlockLevel() throws Exception {
         doTest("block-level.fo",
                 BlockLevelEventProducer.class.getName() + ".overconstrainedAdjustEndIndent");
     }
 
     @Test
-    public void testInlineLevel() throws FOPException, TransformerException, IOException,
-            SAXException {
+    public void testInlineLevel() throws Exception {
         doTest("inline-level.fo",
                 InlineLevelEventProducer.class.getName() + ".lineOverflows");
     }
 
     @Test
-    public void testViewportIPDOverflow() throws FOPException, TransformerException, IOException,
-            SAXException {
+    public void testViewportIPDOverflow() throws Exception {
         doTest("viewport-overflow.fo", BlockLevelEventProducer.class.getName() + ".viewportIPDOverflow");
     }
 
     @Test
-    public void testViewportBPDOverflow() throws FOPException, TransformerException, IOException,
-            SAXException {
+    public void testViewportBPDOverflow() throws Exception {
         doTest("viewport-overflow.fo", BlockLevelEventProducer.class.getName() + ".viewportBPDOverflow");
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FODocumentParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FODocumentParser.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FODocumentParser.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FODocumentParser.java Tue Jul  3 09:46:41 2012
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fo;
 
+import java.io.File;
 import java.io.InputStream;
 
 import javax.xml.transform.Result;
@@ -50,7 +51,7 @@ public final class FODocumentParser {
 
     private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
 
-    private static final FopFactory FOP_FACTORY = FopFactory.newInstance();
+    private static final FopFactory FOP_FACTORY = FopFactory.newInstance(new File(".").toURI());
 
     private final FOEventHandlerFactory foEventHandlerFactory;
 

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FONodeMocks.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FONodeMocks.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FONodeMocks.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FONodeMocks.java Tue Jul  3 09:46:41 2012
@@ -62,22 +62,16 @@ public final class FONodeMocks {
 
     private static void mockGetUserAgent(FOEventHandler mockFOEventHandler) {
         FOUserAgent mockFOUserAgent = mock(FOUserAgent.class);
-        mockGetFactory(mockFOUserAgent);
+        mockGetImageManager(mockFOUserAgent);
         when(mockFOEventHandler.getUserAgent()).thenReturn(mockFOUserAgent);
     }
 
-    private static void mockGetFactory(FOUserAgent mockFOUserAgent) {
-        FopFactory mockFopFactory = mock(FopFactory.class);
-        mockGetImageManager(mockFopFactory);
-        when(mockFOUserAgent.getFactory()).thenReturn(mockFopFactory);
-    }
-
-    private static void mockGetImageManager(FopFactory mockFopFactory) {
+    private static void mockGetImageManager(FOUserAgent mockFOUserAgent) {
         try {
             ImageManager mockImageManager = mock(ImageManager.class);
             when(mockImageManager.getImageInfo(anyString(), any(ImageSessionContext.class)))
                     .thenReturn(null);
-            when(mockFopFactory.getImageManager()).thenReturn(mockImageManager);
+            when(mockFOUserAgent.getImageManager()).thenReturn(mockImageManager);
         } catch (ImageException e) {
             throw new RuntimeException(e);
         } catch (IOException e) {

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,19 +19,23 @@
 
 package org.apache.fop.fonts;
 
-import static org.junit.Assert.assertEquals;
-
 import java.io.File;
 
 import org.junit.Before;
 import org.junit.Test;
 
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
+
+import static org.junit.Assert.assertEquals;
+
 /**
  *
  */
 public class DejaVuLGCSerifTestCase {
 
-    private FontResolver fontResolver = FontManager.createMinimalFontResolver(false);
+    private InternalResourceResolver resolver =
+            ResourceResolverFactory.createDefaultInternalResourceResolver(new File(".").toURI());
     private CustomFont font;
 
     /**
@@ -43,8 +47,8 @@ public class DejaVuLGCSerifTestCase {
     @Before
     public void setUp() throws Exception {
         File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
-        font = FontLoader.loadFont(file, "", true, EmbeddingMode.AUTO, EncodingMode.AUTO,
-                fontResolver);
+        font = FontLoader.loadFont(file.toURI(), "", true, EmbeddingMode.AUTO, EncodingMode.AUTO,
+                false, false, resolver);
     }
 
     /**

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/FontEventProcessingTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,17 +19,13 @@
 
 package org.apache.fop.fonts;
 
-import java.io.IOException;
 import java.io.InputStream;
-
-import javax.xml.transform.TransformerException;
+import java.net.URI;
 
 import org.junit.Test;
-import org.xml.sax.SAXException;
 
 import org.apache.xmlgraphics.util.MimeConstants;
 
-import org.apache.fop.apps.FOPException;
 import org.apache.fop.events.EventProcessingTestCase;
 
 /**
@@ -39,27 +35,25 @@ public class FontEventProcessingTestCase
 
     private EventProcessingTestCase eventsTests = new EventProcessingTestCase();
 
-    private static final String CONFIG_BASE_DIR = EventProcessingTestCase.CONFIG_BASE_DIR;
+    private static final URI CONFIG_BASE_DIR = EventProcessingTestCase.CONFIG_BASE_DIR;
 
     @Test
-    public void testFont() throws FOPException, TransformerException, IOException, SAXException {
+    public void testFont() throws Exception {
         InputStream inStream = getClass().getResourceAsStream("substituted-font.fo");
         eventsTests.doTest(inStream, null, FontEventProducer.class.getName() + ".fontSubstituted",
                 MimeConstants.MIME_PDF);
     }
 
     @Test
-    public void testFontWithBadDirectory() throws FOPException, TransformerException, IOException,
-            SAXException {
+    public void testFontWithBadDirectory() throws Exception {
         InputStream inStream = getClass().getResourceAsStream("substituted-font.fo");
-        eventsTests.doTest(inStream, CONFIG_BASE_DIR + "test_fonts_directory_bad.xconf",
+        eventsTests.doTest(inStream, CONFIG_BASE_DIR.resolve("test_fonts_directory_bad.xconf"),
                 FontEventProducer.class.getName() + ".fontDirectoryNotFound",
                 MimeConstants.MIME_PDF);
     }
 
     @Test
-    public void testSVGFontStrokedAsShapes() throws FOPException, TransformerException, IOException,
-            SAXException {
+    public void testSVGFontStrokedAsShapes() throws Exception {
         // svg-fonts.fo embeds two fonts; one that is present in the system and the other is not; the
         // missing font is stroked as shapes while the fonts that exists is stroked as text
         InputStream inStream = getClass().getResourceAsStream("svg-fonts.fo");

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java Tue Jul  3 09:46:41 2012
@@ -20,6 +20,7 @@
 package org.apache.fop.fonts.truetype;
 
 import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
@@ -55,7 +56,13 @@ public class GlyfTableTestCase {
 
     @Before
     public void setUp() throws IOException {
-        originalFontReader = new FontFileReader("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        FileInputStream fontStream = new FileInputStream(
+                "test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        try {
+            originalFontReader = new FontFileReader(fontStream);
+        } finally {
+            fontStream.close();
+        }
     }
 
     /**

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,17 +19,19 @@
 
 package org.apache.fop.fonts.truetype;
 
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Map;
 
 import org.junit.Test;
 
+import org.apache.fop.fonts.truetype.TTFFile.PostScriptVersion;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.apache.fop.fonts.truetype.TTFFile.PostScriptVersion;
-
 /**
  * Class for testing org.apache.fop.fonts.truetype.TTFFile
  */
@@ -51,11 +53,17 @@ public class TTFFileTestCase {
      */
     public TTFFileTestCase() throws IOException {
         dejavuTTFFile = new TTFFile();
-        dejavuReader = new FontFileReader("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        InputStream dejaStream = new FileInputStream("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        dejavuReader = new FontFileReader(dejaStream);
         dejavuTTFFile.readFont(dejavuReader);
+        dejaStream.close();
+
+        InputStream droidStream = new FileInputStream("test/resources/fonts/ttf/DroidSansMono.ttf");
+
         droidmonoTTFFile = new TTFFile();
-        droidmonoReader = new FontFileReader("test/resources/fonts/ttf/DroidSansMono.ttf");
+        droidmonoReader = new FontFileReader(droidStream);
         droidmonoTTFFile.readFont(droidmonoReader);
+        droidStream.close();
     }
 
     /**

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java Tue Jul  3 09:46:41 2012
@@ -21,13 +21,14 @@ package org.apache.fop.fonts.truetype;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
 
 import org.junit.Test;
 
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
 import org.apache.fop.fonts.EmbeddingMode;
 import org.apache.fop.fonts.EncodingMode;
-import org.apache.fop.fonts.FontManager;
-import org.apache.fop.fonts.FontResolver;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -41,19 +42,20 @@ public class TTFFontLoaderTestCase {
     public void testUseKerning() throws IOException {
         boolean useComplexScriptFeatures = false;
         File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
-        String absoluteFilePath = file.toURI().toURL().toExternalForm();
-        FontResolver resolver = FontManager.createMinimalFontResolver(useComplexScriptFeatures);
+        URI absoluteFilePath = file.toURI();
+        InternalResourceResolver resourceResolver = ResourceResolverFactory.createDefaultInternalResourceResolver(
+                                                                           new File(".").toURI());
         String fontName = "Deja Vu";
         boolean embedded = false;
         boolean useKerning = true;
 
         TTFFontLoader fontLoader = new TTFFontLoader(absoluteFilePath, fontName, embedded,
-                EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resolver);
+                EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resourceResolver);
         assertTrue(fontLoader.getFont().hasKerningInfo());
         useKerning = false;
 
         fontLoader = new TTFFontLoader(absoluteFilePath, fontName, embedded, EmbeddingMode.AUTO,
-                EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resolver);
+                EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resourceResolver);
         assertFalse(fontLoader.getFont().hasKerningInfo());
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java Tue Jul  3 09:46:41 2012
@@ -20,8 +20,11 @@
 package org.apache.fop.fotreetest;
 
 import java.io.File;
+import java.net.URI;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
@@ -35,14 +38,22 @@ import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLFilterImpl;
 
+import org.apache.avalon.framework.configuration.Configuration;
+
+import org.apache.xmlgraphics.image.loader.ImageManager;
+
 import org.apache.fop.DebugHelper;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
-import org.apache.fop.apps.FopFactoryConfigurator;
+import org.apache.fop.apps.FopFactoryBuilder;
+import org.apache.fop.apps.FopFactoryConfig;
+import org.apache.fop.apps.io.ResourceResolver;
+import org.apache.fop.fonts.FontManager;
 import org.apache.fop.fotreetest.ext.TestElementMapping;
 import org.apache.fop.layoutengine.LayoutEngineTestUtils;
 import org.apache.fop.layoutengine.TestFilesConfiguration;
+import org.apache.fop.layoutmgr.LayoutManagerMaker;
 import org.apache.fop.util.ConsoleEventListenerForTests;
 
 /**
@@ -51,6 +62,9 @@ import org.apache.fop.util.ConsoleEventL
 @RunWith(Parameterized.class)
 public class FOTreeTestCase {
 
+    private static final String BASE_DIR = "test/fotree/";
+    private static final String TEST_CASES = "testcases";
+
     @BeforeClass
     public static void registerElementListObservers() {
         DebugHelper.registerStandardElementListObservers();
@@ -63,7 +77,7 @@ public class FOTreeTestCase {
     @Parameters
     public static Collection<File[]> getParameters() {
         TestFilesConfiguration.Builder builder = new TestFilesConfiguration.Builder();
-        builder.testDir("test/fotree")
+        builder.testDir(BASE_DIR)
                .singleProperty("fop.fotree.single")
                .startsWithProperty("fop.fotree.starts-with")
                .suffix(".fo")
@@ -75,7 +89,7 @@ public class FOTreeTestCase {
         return LayoutEngineTestUtils.getTestFiles(testConfig);
     }
 
-    private FopFactory fopFactory = FopFactory.newInstance();
+
 
     private final File testFile;
 
@@ -85,7 +99,6 @@ public class FOTreeTestCase {
      * @param testFile the FO file to test
      */
     public FOTreeTestCase(File testFile) {
-        fopFactory.addElementMapping(new TestElementMapping());
         this.testFile = testFile;
     }
 
@@ -104,21 +117,23 @@ public class FOTreeTestCase {
             spf.setValidating(false);
             SAXParser parser = spf.newSAXParser();
             XMLReader reader = parser.getXMLReader();
-
+            FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI());
             // Resetting values modified by processing instructions
-            fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary(
-                    FopFactoryConfigurator.DEFAULT_BREAK_INDENT_INHERITANCE);
-            fopFactory.setSourceResolution(FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION);
+            builder.setBreakIndentInheritanceOnReferenceAreaBoundary(
+                   FopFactoryConfig.DEFAULT_BREAK_INDENT_INHERITANCE);
+            builder.setSourceResolution(FopFactoryConfig.DEFAULT_SOURCE_RESOLUTION);
+
+            MutableConfig mutableConfig = new MutableConfig(builder.buildConfig());
 
+            FopFactory fopFactory = FopFactory.newInstance(mutableConfig);
+            fopFactory.addElementMapping(new TestElementMapping());
             FOUserAgent ua = fopFactory.newFOUserAgent();
-            ua.setBaseURL(testFile.getParentFile().toURI().toURL().toString());
             ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua));
             ua.getEventBroadcaster().addEventListener(
                     new ConsoleEventListenerForTests(testFile.getName()));
 
             // Used to set values in the user agent through processing instructions
-            reader = new PIListener(reader, ua);
-
+            reader = new PIListener(reader, mutableConfig);
             Fop fop = fopFactory.newFop(ua);
 
             reader.setContentHandler(fop.getDefaultHandler());
@@ -135,9 +150,9 @@ public class FOTreeTestCase {
             List<String> results = collector.getResults();
             if (results.size() > 0) {
                 for (int i = 0; i < results.size(); i++) {
-                    System.out.println((String) results.get(i));
+                    System.out.println(results.get(i));
                 }
-                throw new IllegalStateException((String) results.get(0));
+                throw new IllegalStateException(results.get(0));
             }
         } catch (Exception e) {
             org.apache.commons.logging.LogFactory.getLog(this.getClass()).info(
@@ -148,24 +163,121 @@ public class FOTreeTestCase {
 
     private static class PIListener extends XMLFilterImpl {
 
-        private FOUserAgent userAgent;
+        private final MutableConfig fopConfig;
 
-        public PIListener(XMLReader parent, FOUserAgent userAgent) {
+        public PIListener(XMLReader parent, MutableConfig fopConfig) {
             super(parent);
-            this.userAgent = userAgent;
+            this.fopConfig = fopConfig;
         }
 
         /** @see org.xml.sax.helpers.XMLFilterImpl */
         public void processingInstruction(String target, String data) throws SAXException {
             if ("fop-useragent-break-indent-inheritance".equals(target)) {
-                userAgent.getFactory().setBreakIndentInheritanceOnReferenceAreaBoundary(
+                fopConfig.setBreakIndentInheritanceOnReferenceAreaBoundary(
                         Boolean.valueOf(data).booleanValue());
             } else if ("fop-source-resolution".equals(target)) {
-                userAgent.getFactory().setSourceResolution(Float.parseFloat(data));
+                fopConfig.setSourceResolution(Float.parseFloat(data));
             }
             super.processingInstruction(target, data);
         }
+    }
+
+    private static final class MutableConfig implements FopFactoryConfig {
+
+        private final FopFactoryConfig delegate;
+
+        private boolean setBreakInheritance;
+        private float sourceResolution;
+
+        private MutableConfig(FopFactoryConfig wrappedConfig) {
+            delegate = wrappedConfig;
+            setBreakInheritance = delegate.isBreakIndentInheritanceOnReferenceAreaBoundary();
+            sourceResolution = delegate.getSourceResolution();
+        }
+
+        public boolean isAccessibilityEnabled() {
+            return delegate.isAccessibilityEnabled();
+        }
+
+        public LayoutManagerMaker getLayoutManagerMakerOverride() {
+            return delegate.getLayoutManagerMakerOverride();
+        }
+
+        public ResourceResolver getResourceResolver() {
+            return delegate.getResourceResolver();
+        }
+
+        public URI getBaseURI() {
+            return delegate.getBaseURI();
+        }
+
+        public boolean validateStrictly() {
+            return delegate.validateStrictly();
+        }
+
+        public boolean validateUserConfigStrictly() {
+            return delegate.validateUserConfigStrictly();
+        }
+
+        public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() {
+            return setBreakInheritance;
+        }
 
+        public void setBreakIndentInheritanceOnReferenceAreaBoundary(boolean value) {
+            setBreakInheritance = value;
+        }
+
+        public float getSourceResolution() {
+            return sourceResolution;
+        }
+
+        public void setSourceResolution(float srcRes) {
+            sourceResolution = srcRes;
+        }
+
+        public float getTargetResolution() {
+            return delegate.getTargetResolution();
+        }
+
+        public String getPageHeight() {
+            return delegate.getPageHeight();
+        }
+
+        public String getPageWidth() {
+            return delegate.getPageWidth();
+        }
+
+        public Set<String> getIgnoredNamespaces() {
+            return delegate.getIgnoredNamespaces();
+        }
+
+        public boolean isNamespaceIgnored(String namespace) {
+            return delegate.isNamespaceIgnored(namespace);
+        }
+
+        public Configuration getUserConfig() {
+            return delegate.getUserConfig();
+        }
+
+        public boolean preferRenderer() {
+            return delegate.preferRenderer();
+        }
+
+        public FontManager getFontManager() {
+            return delegate.getFontManager();
+        }
+
+        public ImageManager getImageManager() {
+            return delegate.getImageManager();
+        }
+
+        public boolean isComplexScriptFeaturesEnabled() {
+            return delegate.isComplexScriptFeaturesEnabled();
+        }
+
+        public Map<String, String> getHyphPatNames() {
+            return delegate.getHyphPatNames();
+        }
     }
 
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java Tue Jul  3 09:46:41 2012
@@ -27,8 +27,9 @@ import java.awt.image.Raster;
 import java.awt.image.RenderedImage;
 import java.io.File;
 
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.FopFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+
 import org.apache.xmlgraphics.image.loader.Image;
 import org.apache.xmlgraphics.image.loader.ImageFlavor;
 import org.apache.xmlgraphics.image.loader.ImageInfo;
@@ -37,21 +38,26 @@ import org.apache.xmlgraphics.image.load
 import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
 import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
 import org.apache.xmlgraphics.image.writer.ImageWriterUtil;
-import org.junit.Test;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.FopFactoryBuilder;
 
 /**
  * Tests for bundled ImageLoader implementations.
  */
+@Ignore("Batik fails big time")
 public class ImageLoaderTestCase {
 
-    private static final File DEBUG_TARGET_DIR = null; //new File("D:/");
+    private static final File DEBUG_TARGET_DIR = null;
 
     private FopFactory fopFactory;
 
     public ImageLoaderTestCase() {
-        fopFactory = FopFactory.newInstance();
-        fopFactory.setSourceResolution(72);
-        fopFactory.setTargetResolution(300);
+        FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI());
+        builder.setSourceResolution(72);
+        builder.setTargetResolution(300);
+        fopFactory = builder.build();
     }
 
     @Test
@@ -76,7 +82,7 @@ public class ImageLoaderTestCase {
         assertEquals(16000, info.getSize().getHeightMpt());
 
         img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
-                    userAgent.getImageSessionContext());
+                userAgent.getImageSessionContext());
         assertNotNull("Image must not be null", img);
         assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
         ImageRendered imgRed = (ImageRendered)img;
@@ -97,9 +103,10 @@ public class ImageLoaderTestCase {
     public void testSVGNoViewbox() throws Exception {
         String uri = "test/resources/images/circles.svg";
 
-        FopFactory ff = FopFactory.newInstance();
-        ff.setSourceResolution(96);
-        ff.setTargetResolution(300);
+        FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI());
+        builder.setSourceResolution(96);
+        builder.setTargetResolution(300);
+        FopFactory ff = builder.build();
 
         FOUserAgent userAgent = ff.newFOUserAgent();
 
@@ -122,7 +129,7 @@ public class ImageLoaderTestCase {
         assertEquals(454, info.getSize().getHeightPx());
 
         img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
-                    userAgent.getImageSessionContext());
+                userAgent.getImageSessionContext());
         assertNotNull("Image must not be null", img);
         assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
         ImageRendered imgRed = (ImageRendered)img;
@@ -170,7 +177,7 @@ public class ImageLoaderTestCase {
     @Test
     public void testSVGWithReferences() throws Exception {
         String uri = "test/resources/fop/svg/images.svg";
-        FopFactory ff = FopFactory.newInstance();
+        FopFactory ff = FopFactory.newInstance(new File(".").toURI());
         FOUserAgent userAgent = ff.newFOUserAgent();
 
         ImageManager manager = ff.getImageManager();
@@ -191,7 +198,7 @@ public class ImageLoaderTestCase {
         assertEquals(400, info.getSize().getHeightPx());
 
         img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
-                    userAgent.getImageSessionContext());
+                userAgent.getImageSessionContext());
         assertNotNull("Image must not be null", img);
         assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
         ImageRendered imgRed = (ImageRendered)img;

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImagePreloaderTestCase.java Tue Jul  3 09:46:41 2012
@@ -22,24 +22,20 @@ package org.apache.fop.image.loader.bati
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.File;
 import java.io.IOException;
 
-import javax.xml.transform.Source;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.dom.DOMSource;
+import org.junit.Ignore;
+import org.junit.Test;
 
-import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.FopFactory;
-import org.apache.fop.apps.MimeConstants;
 import org.apache.xmlgraphics.image.loader.ImageException;
 import org.apache.xmlgraphics.image.loader.ImageInfo;
 import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.junit.Test;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.FopFactoryBuilder;
+import org.apache.fop.apps.MimeConstants;
 
 /**
  * Tests for bundled image preloader implementations.
@@ -49,9 +45,10 @@ public class ImagePreloaderTestCase {
     private FopFactory fopFactory;
 
     public ImagePreloaderTestCase() {
-        fopFactory = FopFactory.newInstance();
-        fopFactory.setSourceResolution(72);
-        fopFactory.setTargetResolution(300);
+        FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI());
+        builder.setSourceResolution(72);
+        builder.setTargetResolution(300);
+        fopFactory = builder.build();
     }
 
     @Test
@@ -101,37 +98,39 @@ public class ImagePreloaderTestCase {
     }
 
     @Test
+    @Ignore("Batik has not yet been handled")
     public void testSVGWithDOM() throws Exception {
         String uri = "my:SVGImage";
         FOUserAgent userAgent = fopFactory.newFOUserAgent();
 
-        userAgent.setURIResolver(new URIResolver() {
-
-            public Source resolve(String href, String base) throws TransformerException {
-                if (href.startsWith("my:")) {
-                    DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
-                    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
-                    Document doc = impl.createDocument(svgNS, "svg", null);
-                    Element element = doc.getDocumentElement();
-                    element.setAttribute("viewBox", "0 0 20 20");
-                    element.setAttribute("width", "20pt");
-                    element.setAttribute("height", "20pt");
-
-                    Element rect = doc.createElementNS(svgNS, "rect");
-                    rect.setAttribute("x", "5");
-                    rect.setAttribute("y", "5");
-                    rect.setAttribute("width", "10");
-                    rect.setAttribute("height", "10");
-                    element.appendChild(rect);
-
-                    DOMSource src = new DOMSource(doc);
-                    return src;
-                } else {
-                    return null;
-                }
-            }
-
-        });
+        // TODO: SORT THIS OUT!!
+        //        userAgent.setURIResolver(new URIResolver() {
+        //
+        //            public Source resolve(String href, String base) throws TransformerException {
+        //                if (href.startsWith("my:")) {
+        //                    DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
+        //                    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
+        //                    Document doc = impl.createDocument(svgNS, "svg", null);
+        //                    Element element = doc.getDocumentElement();
+        //                    element.setAttribute("viewBox", "0 0 20 20");
+        //                    element.setAttribute("width", "20pt");
+        //                    element.setAttribute("height", "20pt");
+        //
+        //                    Element rect = doc.createElementNS(svgNS, "rect");
+        //                    rect.setAttribute("x", "5");
+        //                    rect.setAttribute("y", "5");
+        //                    rect.setAttribute("width", "10");
+        //                    rect.setAttribute("height", "10");
+        //                    element.appendChild(rect);
+        //
+        //                    DOMSource src = new DOMSource(doc);
+        //                    return src;
+        //                } else {
+        //                    return null;
+        //                }
+        //            }
+        //
+        //        });
 
         ImageManager manager = fopFactory.getImageManager();
         ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext());

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AbstractIFTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AbstractIFTest.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AbstractIFTest.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AbstractIFTest.java Tue Jul  3 09:46:41 2012
@@ -112,8 +112,7 @@ abstract class AbstractIFTest extends Ab
                 userAgent, getTargetMIME());
 
         //Setup painter
-        IFSerializer serializer = new IFSerializer();
-        serializer.setContext(new IFContext(userAgent));
+        IFSerializer serializer = new IFSerializer(new IFContext(userAgent));
         serializer.mimicDocumentHandler(targetHandler);
         serializer.setResult(domResult);
 

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AbstractIntermediateTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AbstractIntermediateTest.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AbstractIntermediateTest.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AbstractIntermediateTest.java Tue Jul  3 09:46:41 2012
@@ -24,7 +24,6 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.net.MalformedURLException;
 
 import javax.xml.transform.ErrorListener;
 import javax.xml.transform.Source;
@@ -139,14 +138,8 @@ public abstract class AbstractIntermedia
      */
     protected FOUserAgent createUserAgent() {
         FOUserAgent userAgent = fopFactory.newFOUserAgent();
-        try {
-            userAgent.setBaseURL(testDir.toURI().toURL().toExternalForm());
-            userAgent.getEventBroadcaster().addEventListener(
-                    new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.FATAL));
-        } catch (MalformedURLException e) {
-            // Shouldn't happen
-            throw new AssertionError();
-        }
+        userAgent.getEventBroadcaster().addEventListener(
+                new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.FATAL));
         return userAgent;
     }
 

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java Tue Jul  3 09:46:41 2012
@@ -33,6 +33,12 @@ import javax.xml.transform.dom.DOMSource
 import javax.xml.transform.sax.SAXResult;
 import javax.xml.transform.sax.TransformerHandler;
 
+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.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.MimeConstants;
@@ -43,11 +49,6 @@ import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.layoutengine.LayoutEngineTestUtils;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.render.xml.XMLRenderer;
-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;
 
 /**
  * Tests the area tree parser.
@@ -65,6 +66,7 @@ public class AreaTreeParserTestCase exte
     public static Collection<File[]> getParameters() throws IOException {
         return LayoutEngineTestUtils.getLayoutTestFiles();
     }
+
     /**
      * Constructor for the test suite that is used for each test file.
      * @param testFile the test file to run

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java Tue Jul  3 09:46:41 2012
@@ -57,9 +57,8 @@ public class IFMimickingTestCase {
 
     @Before
     public void setUp() throws Exception {
-        fopFactory = FopFactory.newInstance();
         File configFile = new File("test/test-no-xml-metrics.xconf");
-        fopFactory.setUserConfig(configFile);
+        fopFactory = FopFactory.newInstance(configFile);
     }
 
     /**
@@ -111,8 +110,7 @@ public class IFMimickingTestCase {
                 userAgent, mime);
 
         //Setup painter
-        IFSerializer serializer = new IFSerializer();
-        serializer.setContext(new IFContext(userAgent));
+        IFSerializer serializer = new IFSerializer(new IFContext(userAgent));
         serializer.mimicDocumentHandler(targetHandler);
         serializer.setResult(domResult);
 

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFParserTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFParserTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFParserTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IFParserTestCase.java Tue Jul  3 09:46:41 2012
@@ -104,8 +104,7 @@ public class IFParserTestCase extends Ab
 
         FOUserAgent userAgent = createUserAgent();
 
-        IFSerializer serializer = new IFSerializer();
-        serializer.setContext(new IFContext(userAgent));
+        IFSerializer serializer = new IFSerializer(new IFContext(userAgent));
         DOMResult domResult = new DOMResult();
         serializer.setResult(domResult);
 

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/TestAssistant.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/TestAssistant.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/TestAssistant.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/TestAssistant.java Tue Jul  3 09:46:41 2012
@@ -43,6 +43,7 @@ import org.apache.xpath.XPathAPI;
 import org.apache.xpath.objects.XObject;
 
 import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.FopFactoryBuilder;
 
 /**
  * Helper class for running FOP tests.
@@ -50,11 +51,9 @@ import org.apache.fop.apps.FopFactory;
 public class TestAssistant {
 
     // configure fopFactory as desired
-    private FopFactory fopFactory = FopFactory.newInstance();
-    private FopFactory fopFactoryWithBase14Kerning = FopFactory.newInstance();
+    protected final File testDir = new File("test/layoutengine/standard-testcases");
 
-    private SAXTransformerFactory tfactory
-            = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
+    private SAXTransformerFactory tfactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
 
     private DocumentBuilderFactory domBuilderFactory;
 
@@ -65,8 +64,6 @@ public class TestAssistant {
      * Main constructor.
      */
     public TestAssistant() {
-        fopFactory.getFontManager().setBase14KerningEnabled(false);
-        fopFactoryWithBase14Kerning.getFontManager().setBase14KerningEnabled(true);
         domBuilderFactory = DocumentBuilderFactory.newInstance();
         domBuilderFactory.setNamespaceAware(true);
         domBuilderFactory.setValidating(false);
@@ -115,19 +112,13 @@ public class TestAssistant {
         return doc.getDocumentElement();
     }
 
-    public FopFactory getFopFactory(boolean base14KerningEnabled) {
-        FopFactory effFactory = (base14KerningEnabled ? fopFactoryWithBase14Kerning : fopFactory);
-        return effFactory;
-    }
-
     public FopFactory getFopFactory(Document testDoc) {
         boolean base14KerningEnabled = isBase14KerningEnabled(testDoc);
-        FopFactory effFactory = getFopFactory(base14KerningEnabled);
-
         boolean strictValidation = isStrictValidation(testDoc);
-        effFactory.setStrictValidation(strictValidation);
-
-        return effFactory;
+        FopFactoryBuilder builder = new FopFactoryBuilder(testDir.getParentFile().toURI());
+        builder.setStrictFOValidation(strictValidation);
+        builder.getFontManager().setBase14KerningEnabled(base14KerningEnabled);
+        return builder.build();
     }
 
     private boolean isBase14KerningEnabled(Document testDoc) {

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java Tue Jul  3 09:46:41 2012
@@ -146,7 +146,6 @@ public class LayoutEngineTestCase {
 
             //Setup FOP for area tree rendering
             FOUserAgent ua = effFactory.newFOUserAgent();
-            ua.setBaseURL(testFile.getParentFile().toURI().toURL().toString());
             ua.getEventBroadcaster().addEventListener(
                     new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN));
 
@@ -203,14 +202,12 @@ public class LayoutEngineTestCase {
             throws TransformerException {
         try {
             FOUserAgent ua = fopFactory.newFOUserAgent();
-            ua.setBaseURL(testFile.getParentFile().toURI().toURL().toExternalForm());
             ua.getEventBroadcaster().addEventListener(
                     new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN));
 
             IFRenderer ifRenderer = new IFRenderer(ua);
 
-            IFSerializer serializer = new IFSerializer();
-            serializer.setContext(new IFContext(ua));
+            IFSerializer serializer = new IFSerializer(new IFContext(ua));
             DOMResult result = new DOMResult();
             serializer.setResult(result);
             ifRenderer.setDocumentHandler(serializer);

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/memory/MemoryEater.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/memory/MemoryEater.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/memory/MemoryEater.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/memory/MemoryEater.java Tue Jul  3 09:46:41 2012
@@ -49,7 +49,6 @@ public class MemoryEater {
 
     private SAXTransformerFactory tFactory
             = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
-    private FopFactory fopFactory = FopFactory.newInstance();
     private Templates replicatorTemplates;
 
     private Stats stats;
@@ -62,15 +61,17 @@ public class MemoryEater {
 
     private void eatMemory(File foFile, int runRepeats, int replicatorRepeats) throws Exception {
         stats = new Stats();
+        FopFactory fopFactory = FopFactory.newInstance(foFile.getParentFile().toURI());
         for (int i = 0; i < runRepeats; i++) {
-            eatMemory(i, foFile, replicatorRepeats);
+            eatMemory(i, foFile, replicatorRepeats, fopFactory);
             stats.progress(i, runRepeats);
         }
         stats.dumpFinalStats();
         System.out.println(stats.getGoogleChartURL());
     }
 
-    private void eatMemory(int callIndex, File foFile, int replicatorRepeats) throws Exception {
+    private void eatMemory(int callIndex, File foFile, int replicatorRepeats, FopFactory fopFactory)
+            throws Exception {
         Source src = new StreamSource(foFile);
 
         Transformer transformer = replicatorTemplates.newTransformer();
@@ -79,7 +80,6 @@ public class MemoryEater {
         OutputStream out = new NullOutputStream(); //write to /dev/nul
         try {
             FOUserAgent userAgent = fopFactory.newFOUserAgent();
-            userAgent.setBaseURL(foFile.getParentFile().toURI().toURL().toExternalForm());
             Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);
             Result res = new SAXResult(fop.getDefaultHandler());
 

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java Tue Jul  3 09:46:41 2012
@@ -19,11 +19,18 @@
 
 package org.apache.fop.pdf;
 
-import static org.junit.Assert.assertEquals;
+import java.io.File;
+import java.net.URI;
+
+import org.junit.Test;
 
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
 import org.apache.fop.fonts.CIDSubset;
 import org.apache.fop.fonts.MultiByteFont;
-import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 /**
  * Test case for {@link PDFFactory}.
@@ -37,6 +44,10 @@ public class PDFFactoryTestCase {
     @Test
     public void testSubsetFontNamePrefix() {
         class MockedFont extends MultiByteFont {
+            public MockedFont(InternalResourceResolver resolver) {
+                super(resolver);
+            }
+
             @Override
             public int[] getWidths() {
                 return new int[] { 0 };
@@ -49,7 +60,11 @@ public class PDFFactoryTestCase {
         }
         PDFDocument doc = new PDFDocument("Test");
         PDFFactory pdfFactory = new PDFFactory(doc);
-        MockedFont font = new MockedFont();
+        URI thisURI = new File(".").toURI();
+        ResourceResolver resolver = ResourceResolverFactory.createDefaultResourceResolver();
+        InternalResourceResolver resourceResolver = ResourceResolverFactory.createInternalResourceResolver(
+                thisURI, resolver);
+        MockedFont font = new MockedFont(resourceResolver);
 
         PDFFont pdfDejaVu = pdfFactory.makeFont("DejaVu", "DejaVu", "TTF", font, font);
         assertEquals("/EAAAAA+DejaVu", pdfDejaVu.getBaseFont().toString());

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/AbstractRenderingTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/AbstractRenderingTest.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/AbstractRenderingTest.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/AbstractRenderingTest.java Tue Jul  3 09:46:41 2012
@@ -54,7 +54,7 @@ public abstract class AbstractRenderingT
     /** the JAXP TransformerFactory */
     protected TransformerFactory tFactory = TransformerFactory.newInstance();
     /** the FopFactory */
-    protected FopFactory fopFactory = FopFactory.newInstance();
+    protected final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
 
     /**
      * Renders a test file.

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/RendererFactoryTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/RendererFactoryTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/RendererFactoryTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/RendererFactoryTestCase.java Tue Jul  3 09:46:41 2012
@@ -22,6 +22,8 @@ package org.apache.fop.render;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.File;
+
 import org.junit.Test;
 
 import org.apache.commons.io.output.NullOutputStream;
@@ -45,7 +47,7 @@ public class RendererFactoryTestCase {
 
     @Test
     public void testDocumentHandlerLevel() throws Exception {
-        FopFactory fopFactory = FopFactory.newInstance();
+        FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
         RendererFactory factory = fopFactory.getRendererFactory();
         FOUserAgent ua;
         IFDocumentHandler handler;
@@ -55,8 +57,7 @@ public class RendererFactoryTestCase {
         handler = factory.createDocumentHandler(ua, MimeConstants.MIME_PDF);
 
         ua = fopFactory.newFOUserAgent();
-        overrideHandler = new PDFDocumentHandler();
-        overrideHandler.setContext(new IFContext(ua));
+        overrideHandler = new PDFDocumentHandler(new IFContext(ua));
         ua.setDocumentHandlerOverride(overrideHandler);
         handler = factory.createDocumentHandler(ua, null);
         assertTrue(handler == overrideHandler);
@@ -72,7 +73,7 @@ public class RendererFactoryTestCase {
 
     @Test
     public void testRendererLevel() throws Exception {
-        FopFactory fopFactory = FopFactory.newInstance();
+        FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
         RendererFactory factory = fopFactory.getRendererFactory();
         FOUserAgent ua;
         Renderer renderer;
@@ -87,8 +88,7 @@ public class RendererFactoryTestCase {
 
         ua = fopFactory.newFOUserAgent();
         IFDocumentHandler overrideHandler;
-        overrideHandler = new PDFDocumentHandler();
-        overrideHandler.setContext(new IFContext(ua));
+        overrideHandler = new PDFDocumentHandler(new IFContext(ua));
         ua.setDocumentHandlerOverride(overrideHandler);
         renderer = factory.createRenderer(ua, null);
         assertTrue(renderer instanceof IFRenderer);
@@ -104,7 +104,7 @@ public class RendererFactoryTestCase {
 
     @Test
     public void testFOEventHandlerLevel() throws Exception {
-        FopFactory fopFactory = FopFactory.newInstance();
+        FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
         RendererFactory factory = fopFactory.getRendererFactory();
         FOUserAgent ua;
         FOEventHandler foEventHandler;

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/afp/AFPRendererConfiguratorTestCase.java Tue Jul  3 09:46:41 2012
@@ -15,78 +15,199 @@
  * limitations under the License.
  */
 
-/* $Id$ */
-
 package org.apache.fop.render.afp;
 
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.fop.afp.AFPResourceLevel;
+import org.apache.fop.afp.AFPResourceLevel.ResourceType;
+import org.apache.fop.afp.AFPResourceLevelDefaults;
+import org.apache.fop.apps.AFPRendererConfBuilder;
+import org.apache.fop.apps.AbstractRendererConfiguratorTest;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.render.afp.AFPRendererConfig.AFPRendererConfigParser;
+import org.apache.fop.render.afp.AFPRendererConfig.ImagesModeOptions;
+
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.mockito.Mockito.verify;
 
-import java.io.IOException;
+public class AFPRendererConfiguratorTestCase extends
+        AbstractRendererConfiguratorTest<AFPRendererConfigurator, AFPRendererConfBuilder> {
 
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.xml.sax.SAXException;
+    public AFPRendererConfiguratorTestCase() {
+        super(MimeConstants.MIME_AFP, AFPRendererConfBuilder.class, AFPDocumentHandler.class);
+    }
+
+    @Override
+    public void setUpDocumentHandler() {
+    }
 
-import org.apache.fop.afp.AFPPaintingState;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.FopFactory;
+    @Override
+    protected AFPRendererConfigurator createConfigurator() {
+        return new AFPRendererConfigurator(userAgent, new AFPRendererConfigParser());
+    }
 
-/**
- * Test case for {@link AFPRendererConfigurator}.
- */
-public class AFPRendererConfiguratorTestCase {
-    private static FOUserAgent userAgent;
+    private AFPDocumentHandler getDocHandler() {
+        return (AFPDocumentHandler) docHandler;
+    }
+
+    @Test
+    public void testColorImages() throws Exception {
+        parseConfig(createBuilder().startImages(ImagesModeOptions.MODE_COLOR)
+                                   .endImages());
+        verify(getDocHandler()).setColorImages(true);
+
+        parseConfig(createBuilder().startImages(ImagesModeOptions.MODE_GRAYSCALE)
+                                   .endImages());
+        verify(getDocHandler()).setColorImages(false);
+    }
+
+    @Test
+    public void testCMYKImagesSupport() throws Exception {
+        parseConfig(createBuilder().startImages(ImagesModeOptions.MODE_COLOR)
+                                       .setModeAttribute("cmyk", "true")
+                                   .endImages());
+        verify(getDocHandler()).setCMYKImagesSupported(true);
+
+        parseConfig(createBuilder().startImages(ImagesModeOptions.MODE_COLOR)
+                                       .setModeAttribute("cmyk", "false")
+                                   .endImages());
+        verify(getDocHandler()).setCMYKImagesSupported(false);
+    }
+
+    @Test
+    public void testBitsPerPixel() throws Exception {
+        for (int bpp = 0; bpp < 40; bpp += 8) {
+            parseConfig(createBuilder().startImages()
+                                       .setModeAttribute("bits-per-pixel", String.valueOf(bpp))
+                                       .endImages());
+            verify(getDocHandler()).setBitsPerPixel(bpp);
+        }
+    }
+
+    @Test
+    public void testDitheringQuality() throws Exception {
+        float ditheringQuality = 100f;
+        parseConfig(createBuilder().startImages()
+                                       .setDitheringQuality(ditheringQuality)
+                                   .endImages());
+        verify(getDocHandler()).setDitheringQuality(ditheringQuality);
+
+        ditheringQuality = 1000f;
+        parseConfig(createBuilder().startImages()
+                                       .setDitheringQuality(ditheringQuality)
+                                   .endImages());
+        verify(getDocHandler()).setDitheringQuality(ditheringQuality);
+    }
+
+    @Test
+    public void testNativeImagesSupported() throws Exception {
+        parseConfig(createBuilder().startImages()
+                                       .setNativeImageSupport(true)
+                                   .endImages());
+        verify(getDocHandler()).setNativeImagesSupported(true);
+
+        parseConfig(createBuilder().startImages()
+                                       .setNativeImageSupport(false)
+                                   .endImages());
+        verify(getDocHandler()).setNativeImagesSupported(false);
+    }
+
+    @Test
+    public void testShadingMode() throws Exception {
+        for (AFPShadingMode mode : AFPShadingMode.values()) {
+            parseConfig(createBuilder().setShading(mode));
+            verify(getDocHandler()).setShadingMode(mode);
+        }
+    }
 
-    private AFPRendererConfigurator sut;
+    @Test
+    public void testRendererResolution() throws Exception {
+        for (int resolution = 0; resolution < 1000; resolution += 100) {
+            parseConfig(createBuilder().setRenderingResolution(resolution));
+            verify(getDocHandler()).setResolution(resolution);
+        }
+    }
 
-    /**
-     * The FOUserAgent only needs to be created once.
-     */
-    @BeforeClass
-    public static void createUserAgent() {
-        userAgent = FopFactory.newInstance().newFOUserAgent();
-    }
-
-    /**
-     * Assigns an FOUserAgen with a config file at <code>uri</code>
-     *
-     * @param uri the URI of the config file
-     */
-    private void setConfigFile(String uri) {
-        String confTestsDir = "test/resources/conf/afp/";
-        try {
-            userAgent.getFactory().setUserConfig(confTestsDir + uri);
-            sut = new AFPRendererConfigurator(userAgent);
-        } catch (IOException ioe) {
-            fail("IOException: " + ioe);
-        } catch (SAXException se) {
-            fail("SAXException: " + se);
+    @Test
+    public void testLineWidthCorrection() throws Exception {
+        for (float resolution = 0; resolution < 50; resolution += 5) {
+            parseConfig(createBuilder().setLineWidthCorrection(resolution));
+            verify(getDocHandler()).setLineWidthCorrection(resolution);
         }
     }
 
-    /**
-     * Test several config files relating to JPEG images in AFP.
-     *
-     * @throws FOPException if an error is thrown
-     */
-    @Test
-    public void testJpegImageConfig() throws FOPException {
-        testJpegSettings("no_image_config.xconf", 1.0f, false);
-        testJpegSettings("can_embed_jpeg.xconf", 1.0f, true);
-        testJpegSettings("bitmap_encode_quality.xconf", 0.5f, false);
-    }
-
-    private void testJpegSettings(String uri, float bitmapEncodingQual, boolean canEmbed)
-            throws FOPException {
-        AFPDocumentHandler docHandler = new AFPDocumentHandler();
-
-        setConfigFile(uri);
-        sut.configure(docHandler);
-
-        AFPPaintingState paintingState = docHandler.getPaintingState();
-        assertEquals(bitmapEncodingQual, paintingState.getBitmapEncodingQuality(), 0.01f);
-        assertEquals(canEmbed, paintingState.canEmbedJpeg());
+    @Test
+    public void testResourceGroupURI() throws Exception {
+        URI uri = URI.create("test://URI/just/used/for/testing");
+        parseConfig(createBuilder().setResourceGroupUri(uri.toASCIIString()));
+        verify(getDocHandler()).setDefaultResourceGroupUri(uri);
+    }
+
+    @Test
+    public void testResourceLevelDefaults() throws Exception {
+        testResourceLevelDefault(ResourceType.DOCUMENT);
+    }
+
+    private void testResourceLevelDefault(ResourceType resType) throws Exception {
+        Map<String, String> resourceLevels = new HashMap<String, String>();
+        resourceLevels.put("goca", resType.getName());
+        parseConfig(createBuilder().setDefaultResourceLevels(resourceLevels));
+        ArgumentCaptor<AFPResourceLevelDefaults> argument = ArgumentCaptor.forClass(AFPResourceLevelDefaults.class);
+        verify(getDocHandler()).setResourceLevelDefaults(argument.capture());
+        AFPResourceLevel expectedLevel = new AFPResourceLevel(resType);
+        assertEquals(expectedLevel, argument.getValue().getDefaultResourceLevel((byte) 3));
+    }
+
+    @Test
+    public void testExternalResourceDefault() throws Exception {
+        testResourceLevelDefault(ResourceType.EXTERNAL);
+    }
+
+    @Test
+    public void testInlineResourceDefault() throws Exception {
+        testResourceLevelDefault(ResourceType.INLINE);
+    }
+
+    @Test
+    public void testPageResourceDefault() throws Exception {
+        testResourceLevelDefault(ResourceType.PAGE);
+    }
+
+    @Test
+    public void testPageGroupResourceDefault() throws Exception {
+        testResourceLevelDefault(ResourceType.PAGE_GROUP);
+    }
+
+    @Test
+    public void testPrintFileResourceDefault() throws Exception {
+        testResourceLevelDefault(ResourceType.PRINT_FILE);
+    }
+
+    @Test
+    public void testBitmapEncodeQuality() throws Exception {
+        parseConfig(createBuilder().startImages()
+                                       .setBitmapEncodingQuality(0.5f)
+                                   .endImages());
+        verify(getDocHandler()).setBitmapEncodingQuality(0.5f);
     }
+
+    @Test
+    public void testCanEmbedJpeg() throws Exception {
+        parseConfig(createBuilder().startImages()
+                                       .setAllowJpegEmbedding(true)
+                                   .endImages());
+        verify(getDocHandler()).canEmbedJpeg(true);
+
+        parseConfig(createBuilder().startImages()
+                                       .setAllowJpegEmbedding(false)
+                                   .endImages());
+        verify(getDocHandler()).canEmbedJpeg(false);
+    }
+
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTest.java?rev=1356646&r1=1356645&r2=1356646&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTest.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTest.java Tue Jul  3 09:46:41 2012
@@ -20,6 +20,8 @@
 package org.apache.fop.render.pdf;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
 
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
@@ -28,45 +30,35 @@ import javax.xml.transform.TransformerFa
 import javax.xml.transform.sax.SAXResult;
 import javax.xml.transform.stream.StreamSource;
 
+import org.xml.sax.SAXException;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.fop.AbstractFOPTest;
+
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopConfParser;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.apps.MimeConstants;
-import org.xml.sax.SAXException;
 
 /**
  * Base class for automated tests that create PDF files
  */
-public class BasePDFTest extends AbstractFOPTest {
+public class BasePDFTest {
 
     /** the FopFactory */
-    protected final FopFactory fopFactory = FopFactory.newInstance();
+    protected final FopFactory fopFactory;
 
     /** the JAXP TransformerFactory */
     protected final TransformerFactory tFactory = TransformerFactory.newInstance();
 
-    /**
-     * Main constructor
-     */
-    protected BasePDFTest() {
-        init();
+    public BasePDFTest(String fopConf) throws SAXException, IOException {
+        fopFactory = FopFactory.newInstance(new File(fopConf));
     }
 
-    /**
-     * initalizes the test
-     */
-    protected void init() {
-        final File uc = getUserConfigFile();
-
-        try {
-            fopFactory.setUserConfig(uc);
-        } catch (Exception e) {
-            throw new RuntimeException("fopFactory.setUserConfig ("
-                    + uc.getAbsolutePath() + ") failed: " + e.getMessage());
-        }
+    public BasePDFTest(InputStream confStream) throws SAXException, IOException {
+        fopFactory = new FopConfParser(confStream, new File(".").toURI()).getFopFactoryBuilder()
+                                                                         .build();
     }
 
     /**
@@ -113,7 +105,7 @@ public class BasePDFTest extends Abstrac
      * get FOP config File
      * @return user config file to be used for testing
      */
-    protected File getUserConfigFile() {
-        return new File("test/test.xconf");
+    protected static String getDefaultConfFile() {
+        return "test/test.xconf";
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message