commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1649421 - in /commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif: MakerNoteFieldTest.java SpecificExifTagTest.java TextFieldTest.java
Date Sun, 04 Jan 2015 21:07:01 GMT
Author: britter
Date: Sun Jan  4 21:07:00 2015
New Revision: 1649421

URL: http://svn.apache.org/r1649421
Log:
Make SpecificExifTagTest a parameterized test

Modified:
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java?rev=1649421&r1=1649420&r2=1649421&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java
Sun Jan  4 21:07:00 2015
@@ -28,6 +28,10 @@ import org.apache.commons.imaging.util.D
 
 public class MakerNoteFieldTest extends SpecificExifTagTest {
 
+    public MakerNoteFieldTest(File imageFile) {
+        super(imageFile);
+    }
+
     @Override
     protected void checkField(final File imageFile, final TiffField field)
             throws IOException, ImageReadException, ImageWriteException {

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java?rev=1649421&r1=1649420&r2=1649421&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java
Sun Jan  4 21:07:00 2015
@@ -19,6 +19,7 @@ package org.apache.commons.imaging.forma
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -32,32 +33,31 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
 import org.apache.commons.imaging.formats.tiff.constants.AllTagConstants;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
+@RunWith(Parameterized.class)
 public abstract class SpecificExifTagTest extends ExifBaseTest implements
         AllTagConstants {
-    // public SpecificExifTagTest(String name)
-    // {
-    // super(name);
-    // }
 
-    @Test
-    public void testSingleImage() throws Exception {
-        final File imageFile = getImageWithExifData();
-        checkImage(imageFile);
+    private File imageFile;
+
+    @Parameterized.Parameters
+    public static Collection<File> data() throws Exception {
+        return getImagesWithExifData();
+    }
+
+    public SpecificExifTagTest(File imageFile) {
+        this.imageFile = imageFile;
     }
 
     @Test
     public void testAllImages() throws Exception {
-        final List<File> images = getImagesWithExifData();
-        for (int i = 0; i < images.size(); i++) {
-
-            final File imageFile = images.get(i);
-            if (imageFile.getParentFile().getName().toLowerCase()
-                    .equals("@broken")) {
-                continue;
-            }
-            checkImage(imageFile);
+        if (imageFile.getParentFile().getName().toLowerCase()
+                .equals("@broken")) {
+            return;
         }
+        checkImage(imageFile);
     }
 
     protected abstract void checkField(File imageFile, TiffField field)
@@ -69,7 +69,7 @@ public abstract class SpecificExifTagTes
 
         final Map<String, Object> params = new HashMap<String, Object>();
         final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
-        params.put(PARAM_KEY_READ_THUMBNAILS, new Boolean(!ignoreImageData));
+        params.put(PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));
 
         // note that metadata might be null if no metadata is found.
         final ImageMetadata metadata = Imaging.getMetadata(imageFile, params);
@@ -85,8 +85,7 @@ public abstract class SpecificExifTagTes
         }
 
         final List<TiffField> fields = exif.getAllFields();
-        for (int i = 0; i < fields.size(); i++) {
-            final TiffField field = fields.get(i);
+        for (final TiffField field : fields) {
             checkField(imageFile, field);
         }
 

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java?rev=1649421&r1=1649420&r2=1649421&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java
Sun Jan  4 21:07:00 2015
@@ -31,6 +31,10 @@ import org.junit.Assert;
 
 public class TextFieldTest extends SpecificExifTagTest {
 
+    public TextFieldTest(File imageFile) {
+        super(imageFile);
+    }
+
     @Override
     protected void checkField(final File imageFile, final TiffField field)
             throws IOException, ImageReadException, ImageWriteException {



Mime
View raw message