Commits

P_W999  committed eeb49f7

- added unit test for custom tag support

  • Participants
  • Parent commits 05a4318

Comments (0)

Files changed (1)

File test/be/pw/jexif/JExifToolTest.java

  ******************************************************************************/
 package be.pw.jexif;
 
+import static be.pw.jexif.enums.DataType.INT8U;
 import static org.fest.assertions.Assertions.assertThat;
 
 import java.io.File;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import be.pw.jexif.enums.DataType;
 import be.pw.jexif.enums.tag.ExifIFD;
 import be.pw.jexif.enums.tag.IFD0;
 import be.pw.jexif.enums.tag.Tag;
 import be.pw.jexif.exception.JExifException;
 import be.pw.jexif.internal.constants.ExecutionConstant;
 import be.pw.jexif.internal.util.DateUtil;
+import be.pw.jexif.internal.util.TagUtil;
 
 import com.google.common.io.Files;
 
 		assertThat(r).isNotNull().isNotEmpty();
 	}
 	
-
+	@Test(groups = {"simple", "read"})
+	public void testCustomTagImplementation() throws Exception {
+		TagUtil.register(TestTagClass.class);
+		String lensSpec = tool.getInfo(read02).getTagValue(TestTagClass.LENSSPEC);
+		assertThat(lensSpec).isNotNull().isNotEmpty().isEqualTo("E 18-55mm F3.5-5.6 OSS");
+	}
+	
 	@AfterClass
 	public void afterClass() {
 	}
+	
+	public enum TestTagClass implements Tag {
+		LENSSPEC("LensSpec", false, false, false, DataType.STRING);
+		private final boolean avoided;
+		private final boolean unsafe;
+		private final boolean protectedField;
+		private final String name;
+		private final DataType type;
+
+		private TestTagClass(final String name, final boolean unsafe, final boolean avoided, final boolean protectedField, final DataType type) {
+			this.avoided = avoided;
+			this.unsafe = unsafe;
+			this.protectedField = protectedField;
+			this.name = name;
+			this.type = type;
+		}
+		
+		/*
+		 * (non-Javadoc)
+		 * @see be.pw.jexif.enums.tag.Tag#isAvoided()
+		 */
+		@Override
+		public final boolean isAvoided() {
+			return avoided;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * @see be.pw.jexif.enums.tag.Tag#isUnsafe()
+		 */
+		@Override
+		public final boolean isUnsafe() {
+			return unsafe;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * @see be.pw.jexif.enums.tag.Tag#isProtectedField()
+		 */
+		@Override
+		public final boolean isProtectedField() {
+			return protectedField;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * @see be.pw.jexif.enums.tag.Tag#getName()
+		 */
+		@Override
+		public final String getName() {
+			return name;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * @see be.pw.jexif.enums.tag.Tag#getType()
+		 */
+		@Override
+		public final DataType getType() {
+			return type;
+		}
+		
+	}
 
 }