Author: britter
Date: Mon Jan 12 19:45:22 2015
New Revision: 1651182

URL: http://svn.apache.org/r1651182
Log:
Make JpegReadTests a parameterized test

Modified:
    
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java
    
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java

Modified: 
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java?rev=1651182&r1=1651181&r2=1651182&view=diff
==============================================================================
--- 
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java
 (original)
+++ 
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java
 Mon Jan 12 19:45:22 2015
@@ -41,7 +41,7 @@ public abstract class JpegBaseTest exten
         }
     };
 
-    protected List<File> getJpegImages() throws IOException, 
ImageReadException {
+    protected static List<File> getJpegImages() throws IOException, 
ImageReadException {
         return getTestImages(imageFilter);
     }
 

Modified: 
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java?rev=1651182&r1=1651181&r2=1651182&view=diff
==============================================================================
--- 
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java
 (original)
+++ 
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java
 Mon Jan 12 19:45:22 2015
@@ -22,8 +22,8 @@ import static org.junit.Assert.assertNot
 
 import java.awt.image.BufferedImage;
 import java.io.File;
+import java.util.Collection;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.imaging.ImageInfo;
@@ -32,40 +32,45 @@ import org.apache.commons.imaging.Imagin
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.util.Debug;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
+@RunWith(Parameterized.class)
 public class JpegReadTest extends JpegBaseTest {
 
-    @Test
-    public void test() throws Exception {
-        final List<File> images = getJpegImages();
-        for (int i = 0; i < images.size(); i++) {
+    private File imageFile;
 
-            final File imageFile = images.get(i);
-            Debug.debug("imageFile", imageFile.getAbsoluteFile());
+    @Parameterized.Parameters
+    public static Collection<File> data() throws Exception{
+        return getJpegImages();
+    }
 
-            // ByteSource byteSource = new ByteSourceFile(imageFile);
-            // new JpegUtils().dumpJFIF(byteSource);
+    public JpegReadTest(File imageFile) {
+        this.imageFile = imageFile;
+    }
 
-            final Map<String, Object> params = new HashMap<String, Object>();
-            final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
-            params.put(PARAM_KEY_READ_THUMBNAILS, new 
Boolean(!ignoreImageData));
-
-            final ImageMetadata metadata = Imaging.getMetadata(imageFile, 
params);
-            // assertNotNull(metadata);
-            Debug.debug("metadata", metadata);
-            
-            Debug.debug("ICC profile", Imaging.getICCProfile(imageFile, 
params));
-
-            final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, 
params);
-            assertNotNull(imageInfo);
-            
-            try {
-                final BufferedImage image = 
Imaging.getBufferedImage(imageFile, params);
-                assertNotNull(image);
-            } catch (final ImageReadException imageReadException) {
-                assertEquals("Only sequential, baseline JPEGs are supported at 
the moment",
-                        imageReadException.getMessage());
-            }
+    @Test
+    public void test() throws Exception {
+        final Map<String, Object> params = new HashMap<String, Object>();
+        final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
+        params.put(PARAM_KEY_READ_THUMBNAILS, new Boolean(!ignoreImageData));
+
+        final ImageMetadata metadata = Imaging.getMetadata(imageFile, params);
+        // TODO only run this tests with images that have metadata...
+        //assertNotNull(metadata);
+        Debug.debug("metadata", metadata);
+        
+        Debug.debug("ICC profile", Imaging.getICCProfile(imageFile, params));
+
+        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
+        assertNotNull(imageInfo);
+        
+        try {
+            final BufferedImage image = Imaging.getBufferedImage(imageFile, 
params);
+            assertNotNull(image);
+        } catch (final ImageReadException imageReadException) {
+            assertEquals("Only sequential, baseline JPEGs are supported at the 
moment",
+                    imageReadException.getMessage());
         }
     }
 


Reply via email to