Author: damjan Date: Wed Sep 7 19:03:44 2016 New Revision: 1759662 URL: http://svn.apache.org/viewvc?rev=1759662&view=rev Log: List the newly added EXIF tags in the list of all EXIF tags. Improve the unit test that should have caught that it was missing.
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagIntegrityTest.java Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java?rev=1759662&r1=1759661&r2=1759662&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java Wed Sep 7 19:03:44 2016 @@ -600,7 +600,14 @@ public final class ExifTagConstants { EXIF_TAG_COMPRESSED_BITS_PER_PIXEL, EXIF_TAG_SHUTTER_SPEED_VALUE, EXIF_TAG_APERTURE_VALUE, EXIF_TAG_BRIGHTNESS_VALUE, EXIF_TAG_EXPOSURE_COMPENSATION, EXIF_TAG_MAX_APERTURE_VALUE, - EXIF_TAG_SUBJECT_DISTANCE, EXIF_TAG_METERING_MODE, + EXIF_TAG_SUBJECT_DISTANCE, EXIF_TAG_IMAGE_UNIQUE_ID, + EXIF_TAG_CAMERA_OWNER_NAME, + EXIF_TAG_BODY_SERIAL_NUMBER, + EXIF_TAG_LENS_SPECIFICATION, + EXIF_TAG_LENS_MAKE, + EXIF_TAG_LENS_MODEL, + EXIF_TAG_LENS_SERIAL_NUMBER, + EXIF_TAG_METERING_MODE, EXIF_TAG_LIGHT_SOURCE, EXIF_TAG_FLASH, EXIF_TAG_FOCAL_LENGTH, EXIF_TAG_SUBJECT_AREA, EXIF_TAG_STO_NITS, EXIF_TAG_SUB_SEC_TIME, Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagIntegrityTest.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagIntegrityTest.java?rev=1759662&r1=1759661&r2=1759662&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagIntegrityTest.java (original) +++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagIntegrityTest.java Wed Sep 7 19:03:44 2016 @@ -16,10 +16,14 @@ */ package org.apache.commons.imaging.formats.tiff; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Set; +import java.util.TreeSet; import org.apache.commons.imaging.ImagingTest; import org.apache.commons.imaging.formats.tiff.constants.AdobePageMaker6TagConstants; @@ -79,32 +83,36 @@ public class TiffTagIntegrityTest extend verifyFields(WangTagConstants.class, WangTagConstants.ALL_WANG_TAGS); } - private void verifyFields(final Class<?> cls, final List<TagInfo> tags) { - final Field[] fields = cls.getFields(); - int tagCount = 0; - int foundCount = 0; - for (final Field field : fields) { + private void verifyFields(final Class<?> cls, final List<TagInfo> allTags) { + ArrayList<Integer> fieldTags = new ArrayList<>(); + for (final Field field : cls.getFields()) { field.setAccessible(true); - if (!(field.getType().isInstance(TagInfo.class))) { - continue; - } - ++tagCount; - TagInfo src = null; + Object obj = null; try { - src = (TagInfo) field.get(null); + obj = field.get(null); } catch (final IllegalAccessException illegalAccess) { } - if (src == null) { + if (obj == null) { continue; } - for (int i = 0; i < tags.size(); i++) { - final TagInfo tagInfo = tags.get(i); - if (tagInfo.tag == src.tag) { - ++foundCount; - break; - } + if (!(obj instanceof TagInfo)) { + continue; } + TagInfo src = (TagInfo) obj; + if (src.tag == -1) { + // Skip TiffTagConstants.TIFF_TAG_UNKNOWN + continue; + } + fieldTags.add(src.tag); + } + Collections.sort(fieldTags); + final Set<Integer> allTagSet = new TreeSet<>(); + for (final TagInfo tagInfo : allTags) { + assertTrue("Missing field " + tagInfo.tag, Collections.binarySearch(fieldTags, tagInfo.tag) >= 0); + allTagSet.add(tagInfo.tag); + } + for (final Integer tag : fieldTags) { + assertTrue("Missing tag " + tag, allTagSet.contains(tag)); } - assertEquals(tagCount, foundCount); } }