You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2017/07/16 19:13:38 UTC
commons-imaging git commit: Increase code coverage one. Closes #27
Repository: commons-imaging
Updated Branches:
refs/heads/master 582cbf3ce -> a32cb5b3d
Increase code coverage one. Closes #27
Project: http://git-wip-us.apache.org/repos/asf/commons-imaging/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-imaging/commit/a32cb5b3
Tree: http://git-wip-us.apache.org/repos/asf/commons-imaging/tree/a32cb5b3
Diff: http://git-wip-us.apache.org/repos/asf/commons-imaging/diff/a32cb5b3
Branch: refs/heads/master
Commit: a32cb5b3d2179f55b1b23d372217c84ed20e7afc
Parents: 582cbf3
Author: TheRealHaui <an...@github.com>
Authored: Sun Jul 16 12:13:36 2017 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun Jul 16 12:13:36 2017 -0700
----------------------------------------------------------------------
.../apache/commons/imaging/ImageDumpTest.java | 44 +++++++++++++++++++
.../common/RgbBufferedImageFactoryTest.java | 36 +++++++++++++++
.../common/bytesource/ByteSourceTest.java | 34 ++++++++++-----
.../common/itu_t4/HuffmanTreeExceptionTest.java | 28 ++++++++++++
.../imaging/common/itu_t4/T4_T6_TablesTest.java | 32 ++++++++++++++
.../imaging/formats/bmp/BmpWriterRgbTest.java | 35 +++++++++++++++
.../formats/jpeg/iptc/IptcTypeLookupTest.java | 28 ++++++++++++
.../formats/jpeg/segments/AppnSegmentTest.java | 32 ++++++++++++++
.../formats/jpeg/segments/JfifSegmentTest.java | 35 +++++++++++++++
.../formats/jpeg/segments/SosSegmentTest.java | 46 ++++++++++++++++++++
.../formats/jpeg/xmp/JpegXmpParserTest.java | 35 +++++++++++++++
.../imaging/formats/pcx/RleReaderTest.java | 38 ++++++++++++++++
.../commons/imaging/formats/png/PngCrcTest.java | 29 ++++++++++++
.../formats/png/chunks/PngChunkTextTest.java | 35 +++++++++++++++
.../ScanlineFilterAverageTest.java | 32 ++++++++++++++
.../ScanlineFilterPaethTest.java | 32 ++++++++++++++
.../scanlinefilters/ScanlineFilterUpTest.java | 32 ++++++++++++++
.../TransparencyFilterIndexedColorTest.java | 35 +++++++++++++++
.../imaging/formats/pnm/PbmFileInfoTest.java | 41 +++++++++++++++++
.../formats/pnm/WhiteSpaceReaderTest.java | 35 +++++++++++++++
.../formats/psd/ImageResourceBlockTest.java | 30 +++++++++++++
.../formats/psd/ImageResourceTypeTest.java | 37 ++++++++++++++++
.../psd/dataparsers/DataParserCmykTest.java | 27 ++++++++++++
.../dataparsers/DataParserGrayscaleTest.java | 27 ++++++++++++
.../psd/dataparsers/DataParserIndexedTest.java | 35 +++++++++++++++
.../psd/dataparsers/DataParserLabTest.java | 27 ++++++++++++
.../imaging/formats/tiff/JpegImageDataTest.java | 28 ++++++++++++
.../imaging/formats/tiff/TiffTagsTest.java | 29 ++++++++++++
.../tiff/fieldtypes/FieldTypeByteTest.java | 37 ++++++++++++++++
.../tiff/fieldtypes/FieldTypeLongTest.java | 36 +++++++++++++++
.../tiff/fieldtypes/FieldTypeShortTest.java | 36 +++++++++++++++
.../formats/tiff/fieldtypes/FieldTypeTest.java | 32 ++++++++++++++
.../formats/tiff/taginfos/TagInfoByteTest.java | 30 +++++++++++++
.../formats/tiff/taginfos/TagInfoSByteTest.java | 33 ++++++++++++++
.../tiff/taginfos/TagInfoSBytesTest.java | 34 +++++++++++++++
.../formats/tiff/taginfos/TagInfoSLongTest.java | 32 ++++++++++++++
.../tiff/taginfos/TagInfoSShortTest.java | 32 ++++++++++++++
.../tiff/taginfos/TagInfoSShortsTest.java | 33 ++++++++++++++
.../tiff/taginfos/TagInfoUnknownTest.java | 29 ++++++++++++
.../imaging/palette/SimplePaletteTest.java | 29 ++++++++++++
40 files changed, 1317 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/ImageDumpTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/ImageDumpTest.java b/src/test/java/org/apache/commons/imaging/ImageDumpTest.java
new file mode 100644
index 0000000..7e75e0f
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/ImageDumpTest.java
@@ -0,0 +1,44 @@
+package org.apache.commons.imaging;
+
+import org.junit.Test;
+
+import java.awt.color.ColorSpace;
+import java.awt.image.BufferedImage;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link ImageDump}.
+ *
+ * @date 13.07.2017
+ * @see ImageDump
+ *
+ **/
+public class ImageDumpTest{
+
+
+ @Test
+ public void testDumpColorSpace() {
+
+ ImageDump imageDump = new ImageDump();
+ ColorSpace colorSpace = ColorSpace.getInstance(1004);
+ imageDump.dumpColorSpace("Ku&]N>!4'C#Jzn+", colorSpace);
+
+ assertEquals(3, colorSpace.getNumComponents());
+
+ }
+
+
+ @Test
+ public void testDump() {
+
+ ImageDump imageDump = new ImageDump();
+ BufferedImage bufferedImage = new BufferedImage(10, 10, 10);
+ imageDump.dump(bufferedImage);
+
+ assertEquals(10, bufferedImage.getHeight());
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/common/RgbBufferedImageFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/common/RgbBufferedImageFactoryTest.java b/src/test/java/org/apache/commons/imaging/common/RgbBufferedImageFactoryTest.java
new file mode 100644
index 0000000..4cf44f2
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/common/RgbBufferedImageFactoryTest.java
@@ -0,0 +1,36 @@
+package org.apache.commons.imaging.common;
+
+import org.junit.Test;
+
+import java.awt.image.DirectColorModel;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link RgbBufferedImageFactory}.
+ *
+ * @date 13.07.2017
+ * @see RgbBufferedImageFactory
+ *
+ **/
+public class RgbBufferedImageFactoryTest{
+
+
+ @Test
+ public void testGetColorBufferedImageThrowsIllegalArgumentException() {
+
+ RgbBufferedImageFactory rgbBufferedImageFactory = new RgbBufferedImageFactory();
+
+ try {
+ rgbBufferedImageFactory.getColorBufferedImage(0, 0, true);
+ fail("Expecting exception: IllegalArgumentException");
+ } catch(IllegalArgumentException e) {
+ assertEquals("Width (0) and height (0) cannot be <= 0",e.getMessage());
+ assertEquals(DirectColorModel.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java
index 7a0eb30..664a235 100644
--- a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java
+++ b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java
@@ -17,16 +17,14 @@
package org.apache.commons.imaging.common.bytesource;
-import static org.junit.Assert.assertTrue;
+import org.apache.commons.imaging.ImagingTest;
+import org.junit.Test;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
+import java.io.*;
-import org.apache.commons.imaging.ImagingTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public abstract class ByteSourceTest extends ImagingTest {
protected File createTempFile(final byte src[]) throws IOException {
@@ -34,7 +32,7 @@ public abstract class ByteSourceTest extends ImagingTest {
// write test bytes to file.
try (FileOutputStream fos = new FileOutputStream(file);
- OutputStream os = new BufferedOutputStream(fos)) {
+ OutputStream os = new BufferedOutputStream(fos)) {
os.write(src);
}
@@ -66,6 +64,22 @@ public abstract class ByteSourceTest extends ImagingTest {
}
final byte longArray[] = (baos.toByteArray());
- return new byte[][] { emptyArray, single, simple, zeroes, longArray, };
+ return new byte[][]{emptyArray, single, simple, zeroes, longArray,};
+ }
+
+ @Test
+ public void testGetInputStreamThrowsNullPointerException() throws IOException {
+
+ ByteSourceArray byteSourceArray = new ByteSourceArray((byte[]) null);
+
+ try {
+ byteSourceArray.getInputStream(0L);
+ fail("Expecting exception: NullPointerException");
+ } catch (NullPointerException e) {
+ assertEquals(ByteArrayInputStream.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
}
+
}
+
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/common/itu_t4/HuffmanTreeExceptionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/common/itu_t4/HuffmanTreeExceptionTest.java b/src/test/java/org/apache/commons/imaging/common/itu_t4/HuffmanTreeExceptionTest.java
new file mode 100644
index 0000000..c03bc4b
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/common/itu_t4/HuffmanTreeExceptionTest.java
@@ -0,0 +1,28 @@
+package org.apache.commons.imaging.common.itu_t4;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+
+/**
+ * Unit tests for class {@link HuffmanTreeException}.
+ *
+ * @date 13.07.2017
+ * @see HuffmanTreeException
+ *
+ **/
+public class HuffmanTreeExceptionTest{
+
+
+ @Test
+ public void testCreatesHuffmanTreeExceptionTakingString() {
+
+ HuffmanTreeException huffmanTreeException = new HuffmanTreeException("");
+ HuffmanTreeException huffmanTreeExceptionTwo = new HuffmanTreeException("", huffmanTreeException);
+
+ assertFalse(huffmanTreeExceptionTwo.equals(huffmanTreeException));
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/common/itu_t4/T4_T6_TablesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/common/itu_t4/T4_T6_TablesTest.java b/src/test/java/org/apache/commons/imaging/common/itu_t4/T4_T6_TablesTest.java
new file mode 100644
index 0000000..2406ebb
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/common/itu_t4/T4_T6_TablesTest.java
@@ -0,0 +1,32 @@
+package org.apache.commons.imaging.common.itu_t4;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link T4_T6_Tables}.
+ *
+ * @date 13.07.2017
+ * @see T4_T6_Tables
+ *
+ **/
+public class T4_T6_TablesTest{
+
+
+ @Test
+ public void testCreatesT4_T6_TablesTakingNoArgumentsAndCallsWriteBits() {
+
+ T4_T6_Tables t4_T6_Tables = new T4_T6_Tables();
+ BitArrayOutputStream bitArrayOutputStream = new BitArrayOutputStream(2309);
+ t4_T6_Tables.EOL16.writeBits(bitArrayOutputStream);
+
+ assertEquals(2, bitArrayOutputStream.size());
+ assertEquals("[0, 1]", Arrays.toString(bitArrayOutputStream.toByteArray()));
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/bmp/BmpWriterRgbTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpWriterRgbTest.java b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpWriterRgbTest.java
new file mode 100644
index 0000000..7217365
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpWriterRgbTest.java
@@ -0,0 +1,35 @@
+package org.apache.commons.imaging.formats.bmp;
+
+import org.junit.Test;
+
+import java.awt.image.BufferedImage;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link BmpWriterRgb}.
+ *
+ * @date 13.07.2017
+ * @see BmpWriterRgb
+ *
+ **/
+public class BmpWriterRgbTest{
+
+
+ @Test
+ public void testGetImageData() {
+
+ BmpWriterRgb bmpWriterRgb = new BmpWriterRgb();
+ BufferedImage bufferedImage = new BufferedImage(2, 2, 5);
+ byte[] byteArray = bmpWriterRgb.getImageData(bufferedImage);
+
+ assertEquals( 24, bmpWriterRgb.getBitsPerPixel() );
+ assertEquals( 0, bmpWriterRgb.getPaletteSize() );
+ assertEquals( 16, byteArray.length );
+ assertEquals( "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]", Arrays.toString(byteArray) );
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookupTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookupTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookupTest.java
new file mode 100644
index 0000000..57bd791
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookupTest.java
@@ -0,0 +1,28 @@
+package org.apache.commons.imaging.formats.jpeg.iptc;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link IptcTypeLookup}.
+ *
+ * @date 13.07.2017
+ * @see IptcTypeLookup
+ *
+ **/
+public class IptcTypeLookupTest{
+
+
+ @Test
+ public void testGetIptcTypeWithPositive() {
+
+ IptcType iptcType = IptcTypeLookup.getIptcType(1117);
+
+ assertEquals( 1117, iptcType.getType() );
+ assertEquals( "Unknown", iptcType.getName() );
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/AppnSegmentTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/AppnSegmentTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/AppnSegmentTest.java
new file mode 100644
index 0000000..28192ea
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/AppnSegmentTest.java
@@ -0,0 +1,32 @@
+package org.apache.commons.imaging.formats.jpeg.segments;
+
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link AppnSegment}.
+ *
+ * @date 13.07.2017
+ * @see AppnSegment
+ *
+ **/
+public class AppnSegmentTest{
+
+
+ @Test
+ public void testCreatesAppnSegment() throws IOException {
+
+ InputStream inputStream = new ByteArrayInputStream(new byte[0]);
+ AppnSegment appnSegment = new AppnSegment(0, 0, inputStream);
+
+ assertEquals("[Segment: APPN (APP-65504) (Unknown)]", appnSegment.toString());
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegmentTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegmentTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegmentTest.java
new file mode 100644
index 0000000..0a78806
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/JfifSegmentTest.java
@@ -0,0 +1,35 @@
+package org.apache.commons.imaging.formats.jpeg.segments;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link JfifSegment}.
+ *
+ * @date 13.07.2017
+ * @see JfifSegment
+ *
+ **/
+public class JfifSegmentTest{
+
+
+ @Test
+ public void testCreatesJfifSegment() {
+
+ byte[] byteArray = new byte[25];
+ JfifSegment jfifSegment = null;
+
+ try {
+ jfifSegment = new JfifSegment((-2275), byteArray);
+ fail("Expecting exception: Exception");
+ } catch(Throwable e) {
+ assertEquals("Not a Valid JPEG File: missing JFIF string",e.getMessage());
+ assertEquals(JfifSegment.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegmentTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegmentTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegmentTest.java
new file mode 100644
index 0000000..ddd8baa
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegmentTest.java
@@ -0,0 +1,46 @@
+package org.apache.commons.imaging.formats.jpeg.segments;
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link SosSegment}.
+ *
+ * @date 13.07.2017
+ * @see SosSegment
+ *
+ **/
+public class SosSegmentTest{
+
+
+ @Test
+ public void testGetComponentsTakingNoArguments() throws IOException {
+
+ byte[] byteArray = new byte[5];
+ SosSegment sosSegment = new SosSegment((-1044), byteArray);
+ sosSegment.getComponents();
+
+ assertEquals(0, sosSegment.successiveApproximationBitHigh);
+ assertEquals(0, sosSegment.successiveApproximationBitLow);
+
+ }
+
+
+ @Test
+ public void testCreatesSosSegmentTakingThreeArguments() throws IOException {
+
+ byte[] byteArray = new byte[5];
+ SosSegment sosSegment = new SosSegment((-1044), byteArray);
+
+ assertEquals(0, sosSegment.successiveApproximationBitLow);
+ assertEquals(0, sosSegment.successiveApproximationBitHigh);
+
+ assertEquals("[Segment: SOS (Unknown)]", sosSegment.toString());
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParserTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParserTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParserTest.java
new file mode 100644
index 0000000..f1592f1
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParserTest.java
@@ -0,0 +1,35 @@
+package org.apache.commons.imaging.formats.jpeg.xmp;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link JpegXmpParser}.
+ *
+ * @date 13.07.2017
+ * @see JpegXmpParser
+ *
+ **/
+public class JpegXmpParserTest{
+
+
+ @Test
+ public void testCreatesJpegXmpParserAndCallsParseXmpJpegSegment() {
+
+ JpegXmpParser jpegXmpParser = new JpegXmpParser();
+ byte[] byteArray = new byte[1];
+
+ try {
+ jpegXmpParser.parseXmpJpegSegment(byteArray);
+ fail("Expecting exception: Exception");
+ } catch(Exception e) {
+ assertEquals("Invalid JPEG XMP Segment.",e.getMessage());
+ assertEquals(JpegXmpParser.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/pcx/RleReaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/pcx/RleReaderTest.java b/src/test/java/org/apache/commons/imaging/formats/pcx/RleReaderTest.java
new file mode 100644
index 0000000..de2f7bc
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/pcx/RleReaderTest.java
@@ -0,0 +1,38 @@
+package org.apache.commons.imaging.formats.pcx;
+
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link RleReader}.
+ *
+ * @date 13.07.2017
+ * @see RleReader
+ *
+ **/
+public class RleReaderTest{
+
+
+ @Test
+ public void testReadWithNonNull() {
+
+ RleReader rleReader = new RleReader(false);
+ byte[] byteArray = new byte[1];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray, (byte) (-64), (byte) (-64));
+
+ try {
+ rleReader.read(byteArrayInputStream, byteArray);
+ fail("Expecting exception: Exception");
+ } catch(Exception e) {
+ assertEquals("Premature end of file reading image data",e.getMessage());
+ assertEquals(RleReader.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/png/PngCrcTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/PngCrcTest.java b/src/test/java/org/apache/commons/imaging/formats/png/PngCrcTest.java
new file mode 100644
index 0000000..abccfc5
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/png/PngCrcTest.java
@@ -0,0 +1,29 @@
+package org.apache.commons.imaging.formats.png;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link PngCrc}.
+ *
+ * @date 13.07.2017
+ * @see PngCrc
+ *
+ **/
+public class PngCrcTest{
+
+
+ @Test
+ public void testCrc() {
+
+ PngCrc pngCrc = new PngCrc();
+ byte[] byteArray = new byte[4];
+
+ assertEquals(558161692, pngCrc.crc(byteArray, (byte)32));
+ assertEquals(3736805603L, pngCrc.start_partial_crc(byteArray, 0));
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkTextTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkTextTest.java b/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkTextTest.java
new file mode 100644
index 0000000..0824e81
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkTextTest.java
@@ -0,0 +1,35 @@
+package org.apache.commons.imaging.formats.png.chunks;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link PngChunkText}.
+ *
+ * @date 13.07.2017
+ * @see PngChunkText
+ *
+ **/
+public class PngChunkTextTest{
+
+
+ @Test
+ public void testCreatesPngChunkText() {
+
+ byte[] byteArray = new byte[0];
+ PngChunkText pngChunkText = null;
+
+ try {
+ pngChunkText = new PngChunkText(1214, 1214, 0, byteArray);
+ fail("Expecting exception: Exception");
+ } catch(Throwable e) {
+ assertEquals("PNG tEXt chunk keyword is not terminated.",e.getMessage());
+ assertEquals(PngChunkText.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverageTest.java b/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverageTest.java
new file mode 100644
index 0000000..bb76c05
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterAverageTest.java
@@ -0,0 +1,32 @@
+package org.apache.commons.imaging.formats.png.scanlinefilters;
+
+import org.apache.commons.imaging.ImageReadException;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Unit tests for class {@link ScanlineFilterAverage}.
+ *
+ * @date 13.07.2017
+ * @see ScanlineFilterAverage
+ *
+ **/
+public class ScanlineFilterAverageTest{
+
+
+ @Test
+ public void testUnfilterWithNull() throws IOException, ImageReadException {
+
+ ScanlineFilterAverage scanlineFilterAverage = new ScanlineFilterAverage(2);
+ byte[] byteArray = new byte[9];
+ scanlineFilterAverage.unfilter(byteArray, byteArray, (byte[]) null);
+
+ assertArrayEquals(new byte[] {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0}, byteArray);
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaethTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaethTest.java b/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaethTest.java
new file mode 100644
index 0000000..03a0c06
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterPaethTest.java
@@ -0,0 +1,32 @@
+package org.apache.commons.imaging.formats.png.scanlinefilters;
+
+import org.apache.commons.imaging.ImageReadException;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Unit tests for class {@link ScanlineFilterPaeth}.
+ *
+ * @date 13.07.2017
+ * @see ScanlineFilterPaeth
+ *
+ **/
+public class ScanlineFilterPaethTest{
+
+
+ @Test
+ public void testUnfilter() throws IOException, ImageReadException {
+
+ ScanlineFilterPaeth scanlineFilterPaeth = new ScanlineFilterPaeth(0);
+ byte[] byteArray = new byte[5];
+ scanlineFilterPaeth.unfilter(byteArray, byteArray, (byte[]) null);
+
+ assertArrayEquals(new byte[] {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0}, byteArray);
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUpTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUpTest.java b/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUpTest.java
new file mode 100644
index 0000000..7030356
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterUpTest.java
@@ -0,0 +1,32 @@
+package org.apache.commons.imaging.formats.png.scanlinefilters;
+
+import org.apache.commons.imaging.ImageReadException;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Unit tests for class {@link ScanlineFilterUp}.
+ *
+ * @date 13.07.2017
+ * @see ScanlineFilterUp
+ *
+ **/
+public class ScanlineFilterUpTest{
+
+
+ @Test
+ public void testUnfilterWithNull() throws IOException, ImageReadException {
+
+ ScanlineFilterUp scanlineFilterUp = new ScanlineFilterUp();
+ byte[] byteArray = new byte[4];
+ scanlineFilterUp.unfilter(byteArray, byteArray, (byte[]) null);
+
+ assertArrayEquals(new byte[] {(byte)0, (byte)0, (byte)0, (byte)0}, byteArray);
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColorTest.java b/src/test/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColorTest.java
new file mode 100644
index 0000000..cc92ee9
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColorTest.java
@@ -0,0 +1,35 @@
+package org.apache.commons.imaging.formats.png.transparencyfilters;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link TransparencyFilterIndexedColor}.
+ *
+ * @date 13.07.2017
+ * @see TransparencyFilterIndexedColor
+ *
+ **/
+public class TransparencyFilterIndexedColorTest{
+
+
+ @Test
+ public void testFilterWithNegativeAndNegative() {
+
+ byte[] byteArray = new byte[0];
+ TransparencyFilterIndexedColor transparencyFilterIndexedColor = new TransparencyFilterIndexedColor(byteArray);
+
+ try {
+ transparencyFilterIndexedColor.filter((-416), (-398));
+ fail("Expecting exception: Exception");
+ } catch(Exception e) {
+ assertEquals("TransparencyFilterIndexedColor index: -398, bytes.length: 0",e.getMessage());
+ assertEquals(TransparencyFilterIndexedColor.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/pnm/PbmFileInfoTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/pnm/PbmFileInfoTest.java b/src/test/java/org/apache/commons/imaging/formats/pnm/PbmFileInfoTest.java
new file mode 100644
index 0000000..0f982c3
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/pnm/PbmFileInfoTest.java
@@ -0,0 +1,41 @@
+package org.apache.commons.imaging.formats.pnm;
+
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link PbmFileInfo}.
+ *
+ * @date 13.07.2017
+ * @see PbmFileInfo
+ *
+ **/
+public class PbmFileInfoTest{
+
+
+ @Test
+ public void testGetRGBThrowsIOException() throws IOException {
+
+ PbmFileInfo pbmFileInfo = new PbmFileInfo(2764, 354, true);
+ byte[] byteArray = new byte[2];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ byteArrayInputStream.read(byteArray);
+
+ try {
+ pbmFileInfo.getRGB((InputStream) byteArrayInputStream);
+ fail("Expecting exception: IOException");
+ } catch(IOException e) {
+ assertEquals("PBM: Unexpected EOF",e.getMessage());
+ assertEquals(PbmFileInfo.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReaderTest.java b/src/test/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReaderTest.java
new file mode 100644
index 0000000..8c9ba06
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReaderTest.java
@@ -0,0 +1,35 @@
+package org.apache.commons.imaging.formats.pnm;
+
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link WhiteSpaceReader}.
+ *
+ * @date 13.07.2017
+ * @see WhiteSpaceReader
+ *
+ **/
+public class WhiteSpaceReaderTest{
+
+
+ @Test
+ public void testReadLineReturningNonEmptyString() throws IOException {
+
+ byte[] byteArray = new byte[6];
+ byteArray[4] = (byte)13;
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ WhiteSpaceReader whiteSpaceReader = new WhiteSpaceReader(byteArrayInputStream);
+
+ assertEquals(6, byteArrayInputStream.available());
+ assertEquals("[0, 0, 0, 0]", Arrays.toString( whiteSpaceReader.readLine().getBytes() ) );
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/psd/ImageResourceBlockTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/psd/ImageResourceBlockTest.java b/src/test/java/org/apache/commons/imaging/formats/psd/ImageResourceBlockTest.java
new file mode 100644
index 0000000..c75b044
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/psd/ImageResourceBlockTest.java
@@ -0,0 +1,30 @@
+package org.apache.commons.imaging.formats.psd;
+
+import org.junit.Test;
+
+import java.io.UnsupportedEncodingException;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link ImageResourceBlock}.
+ *
+ * @date 13.07.2017
+ * @see ImageResourceBlock
+ *
+ **/
+public class ImageResourceBlockTest{
+
+
+ @Test
+ public void testCreatesImageResourceBlockAndCallsGetName() throws UnsupportedEncodingException {
+
+ byte[] byteArray = new byte[3];
+ ImageResourceBlock imageResourceBlock = new ImageResourceBlock(0, byteArray, byteArray);
+
+ assertEquals( new String(byteArray, "ISO-8859-1"), imageResourceBlock.getName());
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/psd/ImageResourceTypeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/psd/ImageResourceTypeTest.java b/src/test/java/org/apache/commons/imaging/formats/psd/ImageResourceTypeTest.java
new file mode 100644
index 0000000..095c3c0
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/psd/ImageResourceTypeTest.java
@@ -0,0 +1,37 @@
+package org.apache.commons.imaging.formats.psd;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link ImageResourceType}.
+ *
+ * @date 13.07.2017
+ * @see ImageResourceType
+ *
+ **/
+public class ImageResourceTypeTest{
+
+
+ @Test
+ public void testGetDescriptionWithPositive() {
+
+ String string = ImageResourceType.getDescription(2309);
+
+ assertEquals("Path Information (saved paths).", string);
+
+ }
+
+
+ @Test
+ public void testGetDescriptionWithZero() {
+
+ String string = ImageResourceType.getDescription(0);
+
+ assertEquals("Unknown", string);
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmykTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmykTest.java b/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmykTest.java
new file mode 100644
index 0000000..2df22c4
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmykTest.java
@@ -0,0 +1,27 @@
+package org.apache.commons.imaging.formats.psd.dataparsers;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link DataParserCmyk}.
+ *
+ * @date 13.07.2017
+ * @see DataParserCmyk
+ *
+ **/
+public class DataParserCmykTest{
+
+
+ @Test
+ public void testGetBasicChannelsCount() {
+
+ DataParserCmyk dataParserCmyk = new DataParserCmyk();
+
+ assertEquals(4, dataParserCmyk.getBasicChannelsCount());
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscaleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscaleTest.java b/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscaleTest.java
new file mode 100644
index 0000000..837a83b
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscaleTest.java
@@ -0,0 +1,27 @@
+package org.apache.commons.imaging.formats.psd.dataparsers;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link DataParserGrayscale}.
+ *
+ * @date 13.07.2017
+ * @see DataParserGrayscale
+ *
+ **/
+public class DataParserGrayscaleTest{
+
+
+ @Test
+ public void testGetBasicChannelsCount() {
+
+ DataParserGrayscale dataParserGrayscale = new DataParserGrayscale();
+
+ assertEquals(1, dataParserGrayscale.getBasicChannelsCount());
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexedTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexedTest.java b/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexedTest.java
new file mode 100644
index 0000000..b6a7236
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexedTest.java
@@ -0,0 +1,35 @@
+package org.apache.commons.imaging.formats.psd.dataparsers;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link DataParserIndexed}.
+ *
+ * @date 13.07.2017
+ * @see DataParserIndexed
+ *
+ **/
+public class DataParserIndexedTest{
+
+
+ @Test
+ public void testFailsToCreateDataParserIndexedThrowsArrayIndexOutOfBoundsException() {
+
+ byte[] byteArray = new byte[24];
+ DataParserIndexed dataParserIndexed = null;
+
+ try {
+ dataParserIndexed = new DataParserIndexed(byteArray);
+ fail("Expecting exception: ArrayIndexOutOfBoundsException");
+ } catch(ArrayIndexOutOfBoundsException e) {
+ assertEquals("256",e.getMessage());
+ assertEquals(DataParserIndexed.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserLabTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserLabTest.java b/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserLabTest.java
new file mode 100644
index 0000000..6e95119
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserLabTest.java
@@ -0,0 +1,27 @@
+package org.apache.commons.imaging.formats.psd.dataparsers;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link DataParserLab}.
+ *
+ * @date 13.07.2017
+ * @see DataParserLab
+ *
+ **/
+public class DataParserLabTest{
+
+
+ @Test
+ public void testGetBasicChannelsCount() {
+
+ DataParserLab dataParserLab = new DataParserLab();
+
+ assertEquals(3, dataParserLab.getBasicChannelsCount());
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/JpegImageDataTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/JpegImageDataTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/JpegImageDataTest.java
new file mode 100644
index 0000000..a13c444
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/JpegImageDataTest.java
@@ -0,0 +1,28 @@
+package org.apache.commons.imaging.formats.tiff;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link JpegImageData}.
+ *
+ * @date 13.07.2017
+ * @see JpegImageData
+ *
+ **/
+public class JpegImageDataTest{
+
+
+ @Test
+ public void testCreatesJpegImageDataAndCallsGetElementDescription() {
+
+ byte[] byteArray = new byte[5];
+ JpegImageData jpegImageData = new JpegImageData((-1L), 1, byteArray);
+ String string = jpegImageData.getElementDescription(true);
+
+ assertEquals("Jpeg image data: 5 bytes", string);
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagsTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagsTest.java
new file mode 100644
index 0000000..180194f
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffTagsTest.java
@@ -0,0 +1,29 @@
+package org.apache.commons.imaging.formats.tiff;
+
+import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link TiffTags}.
+ *
+ * @date 13.07.2017
+ * @see TiffTags
+ *
+ **/
+public class TiffTagsTest{
+
+
+ @Test
+ public void testGetTagWithNegativeAndPositive() {
+
+ TagInfo tagInfo = TiffTags.getTag((-1), 50933);
+
+ assertEquals((-1), tagInfo.tag);
+ assertEquals( "Unknown Tag", tagInfo.name );
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByteTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByteTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByteTest.java
new file mode 100644
index 0000000..8d6b482
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByteTest.java
@@ -0,0 +1,37 @@
+package org.apache.commons.imaging.formats.tiff.fieldtypes;
+
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link FieldTypeByte}.
+ *
+ * @date 13.07.2017
+ * @see FieldTypeByte
+ *
+ **/
+public class FieldTypeByteTest{
+
+
+ @Test
+ public void testWriteDataWithNull() {
+
+ FieldTypeByte fieldTypeByte = FieldType.UNDEFINED;
+ ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+
+ try {
+ fieldTypeByte.writeData( null, byteOrder);
+ fail("Expecting exception: Exception");
+ } catch(Exception e) {
+ assertEquals("Invalid data: null (null)",e.getMessage());
+ assertEquals(FieldTypeByte.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLongTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLongTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLongTest.java
new file mode 100644
index 0000000..a288ab1
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLongTest.java
@@ -0,0 +1,36 @@
+package org.apache.commons.imaging.formats.tiff.fieldtypes;
+
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link FieldTypeLong}.
+ *
+ * @date 13.07.2017
+ * @see FieldTypeLong
+ **/
+public class FieldTypeLongTest {
+
+
+ @Test
+ public void testWriteDataWithNonNull() {
+
+ FieldTypeLong fieldTypeLong = FieldType.IFD;
+ ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+
+ try {
+ fieldTypeLong.writeData(byteOrder, byteOrder);
+ fail("Expecting exception: Exception");
+ } catch (Exception e) {
+ assertEquals("Invalid data: BIG_ENDIAN (java.nio.ByteOrder)", e.getMessage());
+ assertEquals(FieldTypeLong.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShortTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShortTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShortTest.java
new file mode 100644
index 0000000..7437995
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShortTest.java
@@ -0,0 +1,36 @@
+package org.apache.commons.imaging.formats.tiff.fieldtypes;
+
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link FieldTypeShort}.
+ *
+ * @date 13.07.2017
+ * @see FieldTypeShort
+ **/
+public class FieldTypeShortTest {
+
+
+ @Test
+ public void testCreatesFieldTypeShortAndCallsWriteData() {
+
+ FieldTypeShort fieldTypeShort = new FieldTypeShort(1234, "");
+ ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
+
+ try {
+ fieldTypeShort.writeData("", byteOrder);
+ fail("Expecting exception: Exception");
+ } catch (Exception e) {
+ assertEquals("Invalid data: (java.lang.String)", e.getMessage());
+ assertEquals(FieldTypeShort.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeTest.java
new file mode 100644
index 0000000..09998e8
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeTest.java
@@ -0,0 +1,32 @@
+package org.apache.commons.imaging.formats.tiff.fieldtypes;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Unit tests for class {@link FieldType}.
+ *
+ * @date 13.07.2017
+ * @see FieldType
+ *
+ **/
+public class FieldTypeTest{
+
+
+ @Test
+ public void testGetFieldTypeWithNegative() {
+
+ try {
+ FieldType.getFieldType((-748));
+ fail("Expecting exception: Exception");
+ } catch(Exception e) {
+ assertEquals("Field type -748 is unsupported",e.getMessage());
+ assertEquals(FieldType.class.getName(), e.getStackTrace()[0].getClassName());
+ }
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteTest.java
new file mode 100644
index 0000000..30967b4
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteTest.java
@@ -0,0 +1,30 @@
+package org.apache.commons.imaging.formats.tiff.taginfos;
+
+import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Unit tests for class {@link TagInfoByte}.
+ *
+ * @date 13.07.2017
+ * @see TagInfoByte
+ **/
+public class TagInfoByteTest {
+
+
+ @Test
+ public void testCreatesTagInfoByteTakingFourArgumentsAndCallsEncodeValue() {
+
+ TiffDirectoryType tiffDirectoryType = TiffDirectoryType.TIFF_DIRECTORY_IFD0;
+ TagInfoByte tagInfoByte = new TagInfoByte("", 347, tiffDirectoryType);
+
+ assertArrayEquals(new byte[]{(byte) 0}, tagInfoByte.encodeValue((ByteOrder) null, (byte) 0));
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByteTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByteTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByteTest.java
new file mode 100644
index 0000000..18836ef
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByteTest.java
@@ -0,0 +1,33 @@
+package org.apache.commons.imaging.formats.tiff.taginfos;
+
+import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Unit tests for class {@link TagInfoSByte}.
+ *
+ * @date 13.07.2017
+ * @see TagInfoSByte
+ *
+ **/
+public class TagInfoSByteTest{
+
+
+ @Test
+ public void testCreatesTagInfoSByteAndCallsEncodeValue() {
+
+ TiffDirectoryType tiffDirectoryType = TiffDirectoryType.EXIF_DIRECTORY_GPS;
+ TagInfoSByte tagInfoSByte = new TagInfoSByte("", 0, tiffDirectoryType);
+ ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+ byte[] byteArray = tagInfoSByte.encodeValue(byteOrder, (byte)6);
+
+ assertArrayEquals(new byte[] {(byte)6}, byteArray);
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSBytesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSBytesTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSBytesTest.java
new file mode 100644
index 0000000..6652821
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSBytesTest.java
@@ -0,0 +1,34 @@
+package org.apache.commons.imaging.formats.tiff.taginfos;
+
+import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertSame;
+
+/**
+ * Unit tests for class {@link TagInfoSBytes}.
+ *
+ * @date 13.07.2017
+ * @see TagInfoSBytes
+ *
+ **/
+public class TagInfoSBytesTest{
+
+
+ @Test
+ public void testCreatesTagInfoSBytesAndCallsEncodeValue() {
+
+ TiffDirectoryType tiffDirectoryType = TiffDirectoryType.TIFF_DIRECTORY_IFD3;
+ TagInfoSBytes tagInfoSBytes = new TagInfoSBytes("", (-198), 10, tiffDirectoryType);
+ ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
+ byte[] byteArray = new byte[2];
+ byte[] byteArrayTwo = tagInfoSBytes.encodeValue(byteOrder, byteArray);
+
+ assertSame(byteArrayTwo, byteArray);
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLongTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLongTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLongTest.java
new file mode 100644
index 0000000..07170a4
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLongTest.java
@@ -0,0 +1,32 @@
+package org.apache.commons.imaging.formats.tiff.taginfos;
+
+import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Unit tests for class {@link TagInfoSLong}.
+ *
+ * @date 13.07.2017
+ * @see TagInfoSLong
+ *
+ **/
+public class TagInfoSLongTest{
+
+
+ @Test
+ public void testEncodeValue() {
+
+ TiffDirectoryType tiffDirectoryType = TiffDirectoryType.TIFF_DIRECTORY_IFD0;
+ TagInfoSLong tagInfoSLong = new TagInfoSLong("ttq{\"0r{s}'RQ", (-1770), tiffDirectoryType);
+ ByteOrder byteOrder = ByteOrder.nativeOrder();
+
+ assertArrayEquals(new byte[] {(byte)0, (byte)0, (byte)0, (byte)0}, tagInfoSLong.encodeValue(byteOrder, 0));
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSShortTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSShortTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSShortTest.java
new file mode 100644
index 0000000..e34a4ba
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSShortTest.java
@@ -0,0 +1,32 @@
+package org.apache.commons.imaging.formats.tiff.taginfos;
+
+import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link TagInfoSShort}.
+ *
+ * @date 13.07.2017
+ * @see TagInfoSShort
+ *
+ **/
+public class TagInfoSShortTest{
+
+
+ @Test
+ public void testGetValue() {
+
+ TiffDirectoryType tiffDirectoryType = TiffDirectoryType.TIFF_DIRECTORY_IFD3;
+ TagInfoSShort tagInfoSShort = new TagInfoSShort("n1SN[2cj\"2),+O", (-1785), tiffDirectoryType);
+ ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+
+ assertEquals((short) (-10231), tagInfoSShort.getValue(null, tagInfoSShort.encodeValue(byteOrder, (short) 2520)));
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSShortsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSShortsTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSShortsTest.java
new file mode 100644
index 0000000..429556c
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSShortsTest.java
@@ -0,0 +1,33 @@
+package org.apache.commons.imaging.formats.tiff.taginfos;
+
+import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
+import org.junit.Test;
+
+import java.nio.ByteOrder;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Unit tests for class {@link TagInfoSShorts}.
+ *
+ * @date 13.07.2017
+ * @see TagInfoSShorts
+ *
+ **/
+public class TagInfoSShortsTest{
+
+
+ @Test
+ public void testEncodeValue() {
+
+ TiffDirectoryType tiffDirectoryType = TiffDirectoryType.TIFF_DIRECTORY_IFD0;
+ TagInfoSShorts tagInfoSShorts = new TagInfoSShorts("", 2269, 2269, tiffDirectoryType);
+ ByteOrder byteOrder = ByteOrder.nativeOrder();
+ short[] shortArray = new short[2];
+
+ assertArrayEquals(new byte[] {(byte)0, (byte)0, (byte)0, (byte)0}, tagInfoSShorts.encodeValue(byteOrder, shortArray));
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoUnknownTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoUnknownTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoUnknownTest.java
new file mode 100644
index 0000000..b2b432e
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoUnknownTest.java
@@ -0,0 +1,29 @@
+package org.apache.commons.imaging.formats.tiff.taginfos;
+
+import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link TagInfoUnknown}.
+ *
+ * @date 13.07.2017
+ * @see TagInfoUnknown
+ *
+ **/
+public class TagInfoUnknownTest{
+
+
+ @Test
+ public void testCreatesTagInfoUnknown() {
+
+ TiffDirectoryType tiffDirectoryType = TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD;
+ TagInfoUnknown tagInfoUnknown = new TagInfoUnknown("", 2670, tiffDirectoryType);
+
+ assertEquals((-1), TagInfo.LENGTH_UNKNOWN);
+
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/a32cb5b3/src/test/java/org/apache/commons/imaging/palette/SimplePaletteTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/imaging/palette/SimplePaletteTest.java b/src/test/java/org/apache/commons/imaging/palette/SimplePaletteTest.java
new file mode 100644
index 0000000..014fd69
--- /dev/null
+++ b/src/test/java/org/apache/commons/imaging/palette/SimplePaletteTest.java
@@ -0,0 +1,29 @@
+package org.apache.commons.imaging.palette;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link SimplePalette}.
+ *
+ * @date 13.07.2017
+ * @see SimplePalette
+ *
+ **/
+public class SimplePaletteTest{
+
+
+ @Test
+ public void testGetPaletteIndexReturningNegative() {
+
+ int[] intArray = new int[1];
+ SimplePalette simplePalette = new SimplePalette(intArray);
+
+ assertEquals( -1, simplePalette.getPaletteIndex((-1)));
+ assertEquals(1, simplePalette.length() );
+
+ }
+
+
+}
\ No newline at end of file