commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1649148 - in /commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif: ExifBaseTest.java ExifDumpTest.java
Date Fri, 02 Jan 2015 22:40:33 GMT
Author: britter
Date: Fri Jan  2 22:40:32 2015
New Revision: 1649148

URL: http://svn.apache.org/r1649148
Log:
Make ExifDumpTest a parameterized test

Modified:
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java?rev=1649148&r1=1649147&r2=1649148&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java
Fri Jan  2 22:40:32 2015
@@ -59,7 +59,7 @@ public abstract class ExifBaseTest exten
         return getTestImage(HAS_EXIF_IMAGE_FILTER);
     }
 
-    protected List<File> getImagesWithExifData() throws IOException,
+    protected static List<File> getImagesWithExifData() throws IOException,
             ImageReadException {
         return getTestImages(HAS_EXIF_IMAGE_FILTER);
     }

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java?rev=1649148&r1=1649147&r2=1649148&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java
Fri Jan  2 22:40:32 2015
@@ -17,7 +17,10 @@
 
 package org.apache.commons.imaging.formats.jpeg.exif;
 
+import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,40 +32,39 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.jpeg.JpegUtils;
 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 ExifDumpTest extends ExifBaseTest {
-    // public ExifDumpTest(String name)
-    // {
-    // super(name);
-    // }
 
-    @Test
-    public void test() throws Exception {
-        final List<File> images = getImagesWithExifData();
-        for (int i = 0; i < images.size(); i++) {
-
-            final File imageFile = images.get(i);
-            Debug.debug("imageFile", imageFile);
-            Debug.debug();
-
-            final ByteSource byteSource = new ByteSourceFile(imageFile);
-            Debug.debug("Segments:");
-            new JpegUtils().dumpJFIF(byteSource);
-
-            final Map<String, Object> params = new HashMap<String, Object>();
-            final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
-            params.put(PARAM_KEY_READ_THUMBNAILS, new Boolean(!ignoreImageData));
-
-            final JpegImageMetadata metadata = (JpegImageMetadata) Imaging
-                    .getMetadata(imageFile, params);
-            if (null == metadata)
-             {
-                continue;
-            // assertNotNull(metadata.getExif());
-            }
+    private File imageFile;
 
-            metadata.dump();
-        }
+    @Parameterized.Parameters
+    public static Collection<File> data() throws Exception {
+        return getImagesWithExifData();
     }
 
+    public ExifDumpTest(File imageFile) {
+        this.imageFile = imageFile;
+    }
+
+    @Test
+    public void testDumpJFIF() throws Exception {
+        final ByteSource byteSource = new ByteSourceFile(imageFile);
+        Debug.debug("Segments:");
+        new JpegUtils().dumpJFIF(byteSource);
+        // TODO assert someting
+    }
+
+    @Test
+    public void testMetadata() throws Exception {
+        final Map<String, Object> params = new HashMap<String, Object>();
+        final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
+        params.put(PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));
+
+        final JpegImageMetadata metadata = (JpegImageMetadata) Imaging.getMetadata(imageFile,
params);
+        assertNotNull(metadata);
+        // TODO assert more
+    }
 }



Mime
View raw message