Author: britter
Date: Sun Jan 4 18:51:16 2015
New Revision: 1649382
URL: http://svn.apache.org/r1649382
Log:
Make GpsTest 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/GpsTest.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=1649382&r1=1649381&r2=1649382&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
Sun Jan 4 18:51:16 2015
@@ -64,7 +64,7 @@ public abstract class ExifBaseTest exten
return getTestImages(HAS_EXIF_IMAGE_FILTER);
}
- protected List<File> getImagesWithExifData(final int max) throws
IOException,
+ protected static List<File> getImagesWithExifData(final int max) throws
IOException,
ImageReadException {
return getTestImages(HAS_EXIF_IMAGE_FILTER, max);
}
Modified:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java?rev=1649382&r1=1649381&r2=1649382&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java
(original)
+++
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java
Sun Jan 4 18:51:16 2015
@@ -18,6 +18,7 @@
package org.apache.commons.imaging.formats.jpeg.exif;
import java.io.File;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,66 +29,56 @@ import org.apache.commons.imaging.format
import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
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 GpsTest extends ExifBaseTest implements ImagingConstants {
- @Test
- public void test() throws Exception {
+ private File imageFile;
- final List<File> images = getImagesWithExifData(300);
- for (int i = 0; i < images.size(); i++) {
+ @Parameterized.Parameters
+ public static Collection<File> data() throws Exception {
+ return getImagesWithExifData();
+ }
- final File imageFile = images.get(i);
+ public GpsTest(File imageFile) {
+ this.imageFile = imageFile;
+ }
- // Debug.debug();
- // Debug.debug("imageFile", imageFile);
+ @Test
+ public void test() throws Exception {
+ if (imageFile.getParentFile().getName().toLowerCase()
+ .equals("@broken")) {
+ return;
+ }
- if (imageFile.getParentFile().getName().toLowerCase()
- .equals("@broken")) {
- continue;
- }
-
- try {
- 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);
- if (null == metadata) {
- continue;
- }
-
- final TiffImageMetadata exifMetadata = metadata.getExif();
- if (null == exifMetadata) {
- continue;
- }
-
- final TiffImageMetadata.GPSInfo gpsInfo =
exifMetadata.getGPS();
- if (null == gpsInfo) {
- continue;
- }
-
- Debug.debug("imageFile " + imageFile);
- Debug.debug("gpsInfo " + gpsInfo);
- Debug.debug("gpsInfo longitude as degrees east " +
gpsInfo.getLongitudeAsDegreesEast());
- Debug.debug("gpsInfo latitude as degrees north " +
gpsInfo.getLatitudeAsDegreesNorth());
- Debug.debug();
- } catch (final Exception e) {
- Debug.debug("imageFile " + imageFile.getAbsoluteFile());
- Debug.debug("imageFile " + imageFile.length());
- Debug.debug(e, 13);
-
- // File brokenFolder = new File(imageFile.getParentFile(),
- // "@Broken");
- // if(!brokenFolder.exists())
- // brokenFolder.mkdirs();
- // File movedFile = new File(brokenFolder,
imageFile.getName());
- // imageFile.renameTo(movedFile);
+ 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);
+ if (null == metadata) {
+ return;
+ }
- throw e;
- }
+ final TiffImageMetadata exifMetadata = metadata.getExif();
+ if (null == exifMetadata) {
+ return;
}
+ final TiffImageMetadata.GPSInfo gpsInfo = exifMetadata.getGPS();
+ if (null == gpsInfo) {
+ return;
+ }
+
+ // TODO we should assert something here.
+ Debug.debug("imageFile " + imageFile);
+ Debug.debug("gpsInfo " + gpsInfo);
+ Debug.debug("gpsInfo longitude as degrees east " +
gpsInfo.getLongitudeAsDegreesEast());
+ Debug.debug("gpsInfo latitude as degrees north " +
gpsInfo.getLatitudeAsDegreesNorth());
+ Debug.debug();
+
}
}