commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1680075 - in /commons/proper/imaging/trunk/src: changes/changes.xml test/java/org/apache/commons/imaging/formats/jpeg/exif/MicrosoftTagTest.java
Date Mon, 18 May 2015 19:26:08 GMT
Author: britter
Date: Mon May 18 19:26:07 2015
New Revision: 1680075

URL: http://svn.apache.org/r1680075
Log:
IMAGING-171: MicrosoftTagTest rewrite image exif fails in some environments. This also closes
#17 from github. Thanks to Jan Helbich.

Modified:
    commons/proper/imaging/trunk/src/changes/changes.xml
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MicrosoftTagTest.java

Modified: commons/proper/imaging/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/changes/changes.xml?rev=1680075&r1=1680074&r2=1680075&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/changes/changes.xml (original)
+++ commons/proper/imaging/trunk/src/changes/changes.xml Mon May 18 19:26:07 2015
@@ -46,6 +46,9 @@ The <action> type attribute can be add,u
   <body>
 
     <release version="1.0" date="TBA" description="TBA">
+      <action issue="IMAGING-171" dev="britter" type="fix" due-to="Jan Helbich">
+        MicrosoftTagTest rewrite image exif fails in some environments
+      </action>
       <action issue="IMAGING-169" dev="britter" type="fix" due-to="Nebu Pookins">
         PnmImageParser throws NumberFormatException instead of ImageReadException when parsing
invalid images
       </action>

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MicrosoftTagTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MicrosoftTagTest.java?rev=1680075&r1=1680074&r2=1680075&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MicrosoftTagTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MicrosoftTagTest.java
Mon May 18 19:26:07 2015
@@ -16,11 +16,13 @@
  */
 package org.apache.commons.imaging.formats.jpeg.exif;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -29,9 +31,9 @@ import org.apache.commons.imaging.Imagin
 import org.apache.commons.imaging.ImagingConstants;
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
+import org.apache.commons.imaging.formats.tiff.TiffDirectory;
 import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
 import org.apache.commons.imaging.formats.tiff.constants.MicrosoftTagConstants;
-import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
 import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory;
 import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
 import org.junit.Test;
@@ -85,9 +87,22 @@ public class MicrosoftTagTest extends Ex
     
     private void checkFields(final byte[] file) throws Exception {
         final TiffImageMetadata metadata = toTiffMetadata(Imaging.getMetadata(file));
-        assertEquals(AUTHOR, metadata.getFieldValue(MicrosoftTagConstants.EXIF_TAG_XPAUTHOR));
-        assertEquals(COMMENT, metadata.getFieldValue(MicrosoftTagConstants.EXIF_TAG_XPCOMMENT));
-        assertEquals(SUBJECT, metadata.getFieldValue(MicrosoftTagConstants.EXIF_TAG_XPSUBJECT));
-        assertEquals(TITLE, metadata.getFieldValue(MicrosoftTagConstants.EXIF_TAG_XPTITLE));
+        
+        // field values may be duplicated between directories, we have to check all
+        List<Object> authorValues = new ArrayList<Object>();
+        List<Object> commentValues = new ArrayList<Object>();
+        List<Object> subjectValues = new ArrayList<Object>();
+        List<Object> titleValues = new ArrayList<Object>();
+        for (TiffDirectory d : metadata.contents.directories) {
+            titleValues.add(d.getFieldValue(MicrosoftTagConstants.EXIF_TAG_XPTITLE, false));
+            authorValues.add(d.getFieldValue(MicrosoftTagConstants.EXIF_TAG_XPAUTHOR, false));
+            commentValues.add(d.getFieldValue(MicrosoftTagConstants.EXIF_TAG_XPCOMMENT, false));
+            subjectValues.add(d.getFieldValue(MicrosoftTagConstants.EXIF_TAG_XPSUBJECT, false));
+        }
+        
+        assertTrue(authorValues.contains(AUTHOR));
+        assertTrue(commentValues.contains(COMMENT));
+        assertTrue(subjectValues.contains(SUBJECT));
+        assertTrue(titleValues.contains(TITLE));
     }
 }



Mime
View raw message