commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1649131 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/formats/gif/ test/java/org/apache/commons/imaging/formats/gif/
Date Fri, 02 Jan 2015 21:46:40 GMT
Author: britter
Date: Fri Jan  2 21:46:40 2015
New Revision: 1649131

URL: http://svn.apache.org/r1649131
Log:
Make GifReadTest a parameterized test

Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1649131&r1=1649130&r2=1649131&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
Fri Jan  2 21:46:40 2015
@@ -496,6 +496,7 @@ public class GifImageParser extends Imag
         return new Dimension(id.imageWidth, id.imageHeight);
     }
 
+    // FIXME should throw UOE
     @Override
     public ImageMetadata getMetadata(final ByteSource byteSource, final Map<String, Object>
params)
             throws ImageReadException, IOException {

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java?rev=1649131&r1=1649130&r2=1649131&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java
Fri Jan  2 21:46:40 2015
@@ -41,7 +41,7 @@ public abstract class GifBaseTest extend
         }
     };
 
-    protected List<File> getGifImages() throws IOException, ImageReadException {
+    protected static List<File> getGifImages() throws IOException, ImageReadException
{
         return getTestImages(IMAGE_FILTER);
     }
 

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java?rev=1649131&r1=1649130&r2=1649131&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java
Fri Jan  2 21:46:40 2015
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertNot
 
 import java.awt.image.BufferedImage;
 import java.io.File;
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.commons.imaging.ImageInfo;
@@ -28,29 +29,43 @@ import org.apache.commons.imaging.Imagin
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.util.Debug;
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
+@RunWith(Parameterized.class)
 public class GifReadTest extends GifBaseTest {
 
-    @Test
-    public void test() throws Exception {
-        Debug.debug("start");
-
-        final List<File> images = getGifImages();
-        for (int i = 0; i < images.size(); i++) {
+    private File imageFile;
 
-            final File imageFile = images.get(i);
-            Debug.debug("imageFile", imageFile);
+    @Parameterized.Parameters
+    public static Collection<File> data() throws Exception {
+        return getGifImages();
+    }
 
-            final ImageMetadata metadata = Imaging.getMetadata(imageFile);
-            Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused
warning (it may be null)
+    public GifReadTest(File imageFile) {
+        this.imageFile = imageFile;
+    }
 
-            final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
-            assertNotNull(imageInfo);
+    @Ignore(value = "RoundtripTest has to be fixed befor implementation can throw UnsupportedOperationException")
+    @Test(expected = UnsupportedOperationException.class)
+    public void testMetadata() throws Exception {
+        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
+        assertNotNull(metadata);
+    }
 
-            final BufferedImage image = Imaging.getBufferedImage(imageFile);
-            assertNotNull(image);
-        }
+    @Test
+    public void testImageInfo() throws Exception {
+        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
+        assertNotNull(imageInfo);
+        // TODO assert more
     }
 
+    @Test
+    public void testBufferedImage() throws Exception {
+        final BufferedImage image = Imaging.getBufferedImage(imageFile);
+        assertNotNull(image);
+        // TODO assert more
+    }
 }



Mime
View raw message