xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r605222 [3/3] - in /xmlgraphics/commons/branches/TempNewImagePackage: ./ lib/ src/java/org/apache/xmlgraphics/image/loader/ src/java/org/apache/xmlgraphics/image/loader/cache/ src/java/org/apache/xmlgraphics/image/loader/impl/ src/java/org/...
Date Tue, 18 Dec 2007 15:03:51 GMT
Modified: xmlgraphics/commons/branches/TempNewImagePackage/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/TempNewImagePackage/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java?rev=605222&r1=605206&r2=605222&view=diff
==============================================================================
--- xmlgraphics/commons/branches/TempNewImagePackage/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java
(original)
+++ xmlgraphics/commons/branches/TempNewImagePackage/test/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheTestCase.java
Tue Dec 18 07:03:41 2007
@@ -17,52 +17,34 @@
 
 /* $Id$ */
 
-package org.apache.fop.image2.cache;
+package org.apache.xmlgraphics.image.loader.cache;
 
-import java.io.File;
 import java.io.FileNotFoundException;
-import java.net.MalformedURLException;
 
 import junit.framework.TestCase;
 
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.FopFactory;
-import org.apache.fop.image2.ImageFlavor;
-import org.apache.fop.image2.ImageInfo;
-import org.apache.fop.image2.ImageManager;
-import org.apache.fop.image2.ImageSessionContext;
-import org.apache.fop.image2.impl.ImageBuffered;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.image.loader.MockImageContext;
+import org.apache.xmlgraphics.image.loader.impl.ImageBuffered;
 
 /**
  * Tests for bundled ImageLoader implementations.
  */
 public class ImageCacheTestCase extends TestCase {
 
-    private FopFactory createFopFactory() {
-        FopFactory fopFactory = FopFactory.newInstance();
-        fopFactory.setSourceResolution(72);
-        fopFactory.setTargetResolution(300);
-        File baseDir = new File("test/resources/images/");
-        if (!baseDir.isDirectory()) {
-            throw new IllegalStateException("Base directory for test was not found.");
-        }
-        try {
-            fopFactory.setBaseURL(baseDir.toURL().toExternalForm());
-        } catch (MalformedURLException e) {
-            throw new RuntimeException(e);
-        }
-        return fopFactory;
-    }
+    private MockImageContext imageContext = MockImageContext.getInstance();
     
     /**
      * Tests the ImageInfo cache.
      * @throws Exception if an error occurs
      */
     public void testImageInfoCache() throws Exception {
-        FopFactory fopFactory = createFopFactory();
 
-        FOUserAgent userAgent = fopFactory.newFOUserAgent();
-        ImageManager manager = fopFactory.getImageManager();
+        ImageSessionContext sessionContext = imageContext.newSessionContext();
+        ImageManager manager = imageContext.getImageManager();
         
         String invalid1 = "invalid1.jpg";
         String invalid2 = "invalid2.jpg";
@@ -73,12 +55,12 @@
         manager.getCache().setCacheListener(statistics);
         
         ImageInfo info1, info2;
-        info1 = manager.getImageInfo(valid1, userAgent.getImageSessionContext());
+        info1 = manager.getImageInfo(valid1, sessionContext);
         assertNotNull(info1);
         assertEquals(valid1, info1.getOriginalURI());
         
         try {
-            manager.getImageInfo(invalid1, userAgent.getImageSessionContext());
+            manager.getImageInfo(invalid1, sessionContext);
             fail("Expected FileNotFoundException for invalid URI");
         } catch (FileNotFoundException e) {
             //expected
@@ -91,25 +73,25 @@
         statistics.reset();
         
         //Cache Hit
-        info1 = manager.getImageInfo(valid1, userAgent.getImageSessionContext());
+        info1 = manager.getImageInfo(valid1, sessionContext);
         assertNotNull(info1);
         assertEquals(valid1, info1.getOriginalURI());
 
         //Cache Miss
-        info2 = manager.getImageInfo(valid2, userAgent.getImageSessionContext());
+        info2 = manager.getImageInfo(valid2, sessionContext);
         assertNotNull(info2);
         assertEquals(valid2, info2.getOriginalURI());
         
         try {
             //Invalid Hit
-            manager.getImageInfo(invalid1, userAgent.getImageSessionContext());
+            manager.getImageInfo(invalid1, sessionContext);
             fail("Expected FileNotFoundException for invalid URI");
         } catch (FileNotFoundException e) {
             //expected
         }
         try {
             //Invalid (Cache Miss)
-            manager.getImageInfo(invalid2, userAgent.getImageSessionContext());
+            manager.getImageInfo(invalid2, sessionContext);
             fail("Expected FileNotFoundException for invalid URI");
         } catch (FileNotFoundException e) {
             //expected
@@ -128,27 +110,24 @@
      * @throws Exception if an error occurs
      */
     public void testImageCache1() throws Exception {
-        FopFactory fopFactory = createFopFactory();
-
-        FOUserAgent userAgent = fopFactory.newFOUserAgent();
-        ImageManager manager = fopFactory.getImageManager();
+        ImageSessionContext sessionContext = imageContext.newSessionContext();
+        ImageManager manager = imageContext.getImageManager();
         
-        String valid1 = "bgimg300dpi.bmp";
+        String valid1 = "bgimg72dpi.gif";
         
         ImageCacheStatistics statistics = new ImageCacheLoggingStatistics(true);
         manager.getCache().setCacheListener(statistics);
         
-        ImageSessionContext session = userAgent.getImageSessionContext();
-        ImageInfo info = manager.getImageInfo(valid1, session);
+        ImageInfo info = manager.getImageInfo(valid1, sessionContext);
         assertNotNull(info);
         
         ImageBuffered img1 = (ImageBuffered)manager.getImage(
-                info, ImageFlavor.BUFFERED_IMAGE, session);
+                info, ImageFlavor.BUFFERED_IMAGE, sessionContext);
         assertNotNull(img1);
         assertNotNull(img1.getBufferedImage());
         
         ImageBuffered img2 = (ImageBuffered)manager.getImage(
-                info, ImageFlavor.BUFFERED_IMAGE, session);
+                info, ImageFlavor.BUFFERED_IMAGE, sessionContext);
         //ImageBuffered does not have to be the same instance but we want at least the
         //BufferedImage to be reused.
         assertTrue("BufferedImage must be reused",
@@ -163,28 +142,25 @@
      * a converter pipeline.
      * @throws Exception if an error occurs
      */
-    public void testImageCache2() throws Exception {
-        FopFactory fopFactory = createFopFactory();
-
-        FOUserAgent userAgent = fopFactory.newFOUserAgent();
-        ImageManager manager = fopFactory.getImageManager();
+    public void DISABLEDtestImageCache2() throws Exception {
+        ImageSessionContext sessionContext = imageContext.newSessionContext();
+        ImageManager manager = imageContext.getImageManager();
         
         String valid1 = "test/resources/images/img-w-size.svg";
         
         ImageCacheStatistics statistics = new ImageCacheLoggingStatistics(true);
         manager.getCache().setCacheListener(statistics);
         
-        ImageSessionContext session = userAgent.getImageSessionContext();
-        ImageInfo info = manager.getImageInfo(valid1, session);
+        ImageInfo info = manager.getImageInfo(valid1, sessionContext);
         assertNotNull(info);
         
         ImageBuffered img1 = (ImageBuffered)manager.getImage(
-                info, ImageFlavor.BUFFERED_IMAGE, session);
+                info, ImageFlavor.BUFFERED_IMAGE, sessionContext);
         assertNotNull(img1);
         assertNotNull(img1.getBufferedImage());
         
         ImageBuffered img2 = (ImageBuffered)manager.getImage(
-                info, ImageFlavor.BUFFERED_IMAGE, session);
+                info, ImageFlavor.BUFFERED_IMAGE, sessionContext);
         //ImageBuffered does not have to be the same instance but we want at least the
         //BufferedImage to be reused.
         assertTrue("BufferedImage must be reused",



---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message