commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1649644 - in /commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc: IptcBaseTest.java IptcDumpTest.java
Date Mon, 05 Jan 2015 20:24:14 GMT
Author: britter
Date: Mon Jan  5 20:24:14 2015
New Revision: 1649644

URL: http://svn.apache.org/r1649644
Log:
Make IptcDumpTest a parameterized test

Modified:
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java?rev=1649644&r1=1649643&r2=1649644&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java
Mon Jan  5 20:24:14 2015
@@ -66,7 +66,7 @@ public abstract class IptcBaseTest exten
         return getTestImage(HAS_IPTC_IMAGE_FILTER);
     }
 
-    protected List<File> getImagesWithIptcData() throws IOException,
+    protected static List<File> getImagesWithIptcData() throws IOException,
             ImageReadException {
         return getTestImages(HAS_IPTC_IMAGE_FILTER);
     }

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java?rev=1649644&r1=1649643&r2=1649644&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java
Mon Jan  5 20:24:14 2015
@@ -17,9 +17,12 @@
 
 package org.apache.commons.imaging.formats.jpeg.iptc;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 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,51 +32,47 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata;
 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 IptcDumpTest extends IptcBaseTest {
 
+    private File imageFile;
+
+    @Parameterized.Parameters
+    public static Collection<File> data() throws Exception {
+        return getImagesWithIptcData();
+    }
+
+    public IptcDumpTest(File imageFile) {
+        this.imageFile = imageFile;
+    }
+
     @Test
     public void test() throws Exception {
-        final List<File> images = getImagesWithIptcData();
-        for (int i = 0; i < images.size(); i++) {
-
-            final File imageFile = images.get(i);
-            Debug.debug("imageFile", imageFile);
-            Debug.debug();
-
-            // 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));
-            // params.put(PARAM_KEY_VERBOSE, Boolean.TRUE);
-
-            final JpegImageMetadata metadata = (JpegImageMetadata) Imaging
-                    .getMetadata(imageFile, params);
-            assertNotNull(metadata);
-            assertNotNull(metadata.getPhotoshop());
-
-            metadata.getPhotoshop().dump();
-            // if(metadata.getPhotoshop().getItems().size()>0)
-            // Debug.debug("iptc size",
-            // metadata.getPhotoshop().getItems().size());
-
-            final JpegPhotoshopMetadata psMetadata = metadata.getPhotoshop();
-            final List<IptcRecord> oldRecords = psMetadata.photoshopApp13Data.getRecords();
-
-            Debug.debug();
-            for (int j = 0; j < oldRecords.size(); j++) {
-                final IptcRecord record = oldRecords.get(j);
-                if (record.iptcType != IptcTypes.CITY) {
-                    Debug.debug("Key: " + record.iptcType.getName() + " (0x"
-                            + Integer.toHexString(record.iptcType.getType())
-                            + "), value: " + record.value);
-                }
+        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);
+        assertNotNull(metadata.getPhotoshop());
+
+        metadata.getPhotoshop().dump();
+
+        final JpegPhotoshopMetadata psMetadata = metadata.getPhotoshop();
+        final List<IptcRecord> oldRecords = psMetadata.photoshopApp13Data.getRecords();
+
+        Debug.debug();
+        for (final IptcRecord record : oldRecords) {
+            if (record.iptcType != IptcTypes.CITY) {
+                Debug.debug("Key: " + record.iptcType.getName() + " (0x"
+                        + Integer.toHexString(record.iptcType.getType())
+                        + "), value: " + record.value);
             }
-            Debug.debug();
         }
+        Debug.debug();
     }
 
 }



Mime
View raw message