Adding the twelvemonkeys-imageio sub-project

This commit is contained in:
Harald Kuhr
2009-09-03 20:49:59 +02:00
parent 2523f31a8c
commit 4e7316886b
304 changed files with 27557 additions and 0 deletions
@@ -0,0 +1,116 @@
package com.twelvemonkeys.imageio.stream;
import com.twelvemonkeys.io.ole2.CompoundDocument;
import com.twelvemonkeys.io.ole2.Entry;
import junit.framework.TestCase;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.MemoryCacheImageInputStream;
import java.io.IOException;
import java.nio.ByteOrder;
import java.util.Random;
/**
* BufferedImageInputStreamTestCase
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: BufferedImageInputStreamTestCase.java,v 1.0 Jun 30, 2008 3:07:42 PM haraldk Exp$
*/
public class BufferedImageInputStreamTestCase extends TestCase{
protected final Random mRandom = new Random();
public void testCreate() {
new BufferedImageInputStream(new ByteArrayImageInputStream(new byte[0]));
}
public void testCreateNull() {
try {
new BufferedImageInputStream(null);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException expected) {
assertNotNull("Null exception message", expected.getMessage());
String message = expected.getMessage().toLowerCase();
assertTrue("Exception message does not contain parameter name", message.contains("stream"));
assertTrue("Exception message does not contain null", message.contains("null"));
}
}
// TODO: Write other tests
// TODO: Create test that exposes read += -1 (eof) bug
public void testArrayIndexOutOfBoundsBufferedReadBug() throws IOException {
// TODO: Create a more straight forward way to prove correctness, for now this is good enough to avoid regression
ImageInputStream input = new BufferedImageInputStream(new MemoryCacheImageInputStream(getClass().getResourceAsStream("/Thumbs-camera.db")));
input.setByteOrder(ByteOrder.LITTLE_ENDIAN);
Entry root = new CompoundDocument(input).getRootEntry();
Entry child = root.getChildEntry("Catalog");
assertNotNull("Input stream can never be null", child.getInputStream());
}
public void testReadResetReadDirectBufferBug() throws IOException {
// Make sure we use the exact size of the buffer
final int size = BufferedImageInputStream.DEFAULT_BUFFER_SIZE;
// Fill bytes
byte[] bytes = new byte[size * 2];
mRandom.nextBytes(bytes);
// Create wrapper stream
BufferedImageInputStream stream = new BufferedImageInputStream(new ByteArrayImageInputStream(bytes));
// Read to fill the buffer, then reset
stream.readLong();
stream.seek(0);
// Read fully and compare
byte[] result = new byte[size];
stream.readFully(result);
assertTrue(rangeEquals(bytes, 0, result, 0, size));
stream.readFully(result);
assertTrue(rangeEquals(bytes, size, result, 0, size));
}
/**
* Test two arrays for range equality. That is, they contain the same elements for some specified range.
*
* @param pFirst one array to test for equality
* @param pFirstOffset the offset into the first array to start testing for equality
* @param pSecond the other array to test for equality
* @param pSecondOffset the offset into the second array to start testing for equality
* @param pLength the length of the range to check for equality
*
* @return {@code true} if both arrays are non-{@code null}
* and have at least {@code offset + pLength} elements
* and all elements in the range from the first array is equal to the elements from the second array,
* or if {@code pFirst == pSecond} (including both arrays being {@code null})
* and {@code pFirstOffset == pSecondOffset}.
* Otherwise {@code false}.
*/
static boolean rangeEquals(byte[] pFirst, int pFirstOffset, byte[] pSecond, int pSecondOffset, int pLength) {
if (pFirst == pSecond && pFirstOffset == pSecondOffset) {
return true;
}
if (pFirst == null || pSecond == null) {
return false;
}
if (pFirst.length < pFirstOffset + pLength || pSecond.length < pSecondOffset + pLength) {
return false;
}
for (int i = 0; i < pLength; i++) {
if (pFirst[pFirstOffset + i] != pSecond[pSecondOffset + i]) {
return false;
}
}
return true;
}
}
@@ -0,0 +1,102 @@
package com.twelvemonkeys.imageio.stream;
import static com.twelvemonkeys.imageio.stream.BufferedImageInputStreamTestCase.rangeEquals;
import junit.framework.TestCase;
import java.io.IOException;
import java.util.Random;
/**
* ByteArrayImageInputStreamTestCase
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: ByteArrayImageInputStreamTestCase.java,v 1.0 Apr 21, 2009 10:58:48 AM haraldk Exp$
*/
public class ByteArrayImageInputStreamTestCase extends TestCase {
protected final Random mRandom = new Random();
public void testCreate() {
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(new byte[0]);
assertEquals("Data length should be same as stream length", 0, stream.length());
}
public void testCreateNull() {
try {
new ByteArrayImageInputStream(null);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException expected) {
assertNotNull("Null exception message", expected.getMessage());
String message = expected.getMessage().toLowerCase();
assertTrue("Exception message does not contain parameter name", message.contains("data"));
assertTrue("Exception message does not contain null", message.contains("null"));
}
}
public void testRead() throws IOException {
byte[] data = new byte[1024 * 1024];
mRandom.nextBytes(data);
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(data);
assertEquals("Data length should be same as stream length", data.length, stream.length());
for (byte b : data) {
assertEquals("Wrong data read", b & 0xff, stream.read());
}
}
public void testReadArray() throws IOException {
byte[] data = new byte[1024 * 1024];
mRandom.nextBytes(data);
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(data);
assertEquals("Data length should be same as stream length", data.length, stream.length());
byte[] result = new byte[1024];
for (int i = 0; i < data.length / result.length; i++) {
stream.readFully(result);
assertTrue("Wrong data read: " + i, rangeEquals(data, i * result.length, result, 0, result.length));
}
}
public void testReadSkip() throws IOException {
byte[] data = new byte[1024 * 14];
mRandom.nextBytes(data);
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(data);
assertEquals("Data length should be same as stream length", data.length, stream.length());
byte[] result = new byte[7];
for (int i = 0; i < data.length / result.length; i += 2) {
stream.readFully(result);
stream.skipBytes(result.length);
assertTrue("Wrong data read: " + i, rangeEquals(data, i * result.length, result, 0, result.length));
}
}
public void testReadSeek() throws IOException {
byte[] data = new byte[1024 * 18];
mRandom.nextBytes(data);
ByteArrayImageInputStream stream = new ByteArrayImageInputStream(data);
assertEquals("Data length should be same as stream length", data.length, stream.length());
byte[] result = new byte[9];
for (int i = 0; i < data.length / result.length; i++) {
// Read backwards
long newPos = stream.length() - result.length - i * result.length;
stream.seek(newPos);
assertEquals("Wrong stream position", newPos, stream.getStreamPosition());
stream.readFully(result);
assertTrue("Wrong data read: " + i, rangeEquals(data, (int) newPos, result, 0, result.length));
}
}
}
@@ -0,0 +1,140 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.util;
import com.twelvemonkeys.io.InputStreamAbstractTestCase;
import javax.imageio.stream.MemoryCacheImageInputStream;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
/**
* IIOInputStreamAdapter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: IIOInputStreamAdapter.java,v 1.0 Apr 11, 2008 1:04:42 PM haraldk Exp$
*/
public class IIOInputStreamAdapterTestCase extends InputStreamAbstractTestCase {
public IIOInputStreamAdapterTestCase(String name) {
super(name);
}
protected InputStream makeInputStream(byte[] pBytes) {
return new IIOInputStreamAdapter(new MemoryCacheImageInputStream(new ByteArrayInputStream(pBytes)), pBytes.length);
}
public void testReadSubstreamOpenEnd() throws IOException {
byte[] bytes = new byte[20];
MemoryCacheImageInputStream input = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
input.seek(10);
assertEquals(10, input.getStreamPosition());
IIOInputStreamAdapter stream = new IIOInputStreamAdapter(input);
for (int i = 0; i < 10; i++) {
assertTrue("Unexpected end of stream", -1 != stream.read());
}
assertEquals("Read value after end of stream", -1, stream.read());
assertEquals("Read value after end of stream", -1, stream.read());
// Make sure underlying stream is positioned at end of substream after close
stream.close();
assertEquals(20, input.getStreamPosition());
input.close();
}
public void testReadSubstream() throws IOException {
byte[] bytes = new byte[20];
MemoryCacheImageInputStream input = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
IIOInputStreamAdapter stream = new IIOInputStreamAdapter(input, 9);
for (int i = 0; i < 9; i++) {
assertTrue("Unexpected end of stream", -1 != stream.read());
}
assertEquals("Read value after end of stream", -1, stream.read());
assertEquals("Read value after end of stream", -1, stream.read());
// Make sure we don't read outside stream boundaries
assertTrue(input.getStreamPosition() <= 9);
input.close();
}
public void testReadSubstreamRepositionOnClose() throws IOException {
byte[] bytes = new byte[20];
MemoryCacheImageInputStream input = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
IIOInputStreamAdapter stream = new IIOInputStreamAdapter(input, 10);
for (int i = 0; i < 7; i++) {
assertTrue("Unexpected end of stream", -1 != stream.read());
}
// Make sure we don't read outside stream boundaries
assertTrue(input.getStreamPosition() <= 7);
// Make sure underlying stream is positioned at end of substream after close
stream.close();
assertEquals(10, input.getStreamPosition());
input.close();
}
public void testSeekBeforeStreamNoEnd() throws IOException {
byte[] bytes = new byte[20];
MemoryCacheImageInputStream input = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
input.seek(10);
assertEquals(10, input.getStreamPosition());
IIOInputStreamAdapter stream = new IIOInputStreamAdapter(input);
assertEquals("Should not skip backwards", 0, stream.skip(-5));
assertEquals(10, input.getStreamPosition());
}
public void testSeekBeforeStream() throws IOException {
byte[] bytes = new byte[20];
MemoryCacheImageInputStream input = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
input.seek(10);
assertEquals(10, input.getStreamPosition());
IIOInputStreamAdapter stream = new IIOInputStreamAdapter(input, 9);
assertEquals("Should not skip backwards", 0, stream.skip(-5));
assertEquals(10, input.getStreamPosition());
}
}
@@ -0,0 +1,322 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.util;
import org.jmock.Mock;
import org.jmock.cglib.MockObjectTestCase;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.event.IIOWriteProgressListener;
import java.awt.image.RenderedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
* ImageReaderAbstractTestCase class description.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: ImageReaderAbstractTestCase.java,v 1.0 18.nov.2004 17:38:33 haku Exp $
*/
public abstract class ImageWriterAbstractTestCase extends MockObjectTestCase {
protected abstract ImageWriter createImageWriter();
protected abstract RenderedImage getTestData();
public void testSetOutput() throws IOException {
// Should just pass with no exceptions
ImageWriter writer = createImageWriter();
assertNotNull(writer);
writer.setOutput(ImageIO.createImageOutputStream(new ByteArrayOutputStream()));
}
public void testSetOutputNull() {
// Should just pass with no exceptions
ImageWriter writer = createImageWriter();
assertNotNull(writer);
writer.setOutput(null);
}
public void testWrite() throws IOException {
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(buffer));
try {
writer.write(getTestData());
}
catch (IOException e) {
fail(e.getMessage());
}
assertTrue("No image data written", buffer.size() > 0);
}
public void testWrite2() {
// Note: There's a difference between new ImageOutputStreamImpl and
// ImageIO.createImageOutputStream... Make sure writers handle both
// cases
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try {
writer.setOutput(ImageIO.createImageOutputStream(buffer));
writer.write(getTestData());
}
catch (IOException e) {
fail(e.getMessage());
}
assertTrue("No image data written", buffer.size() > 0);
}
public void testWriteNull() throws IOException {
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(buffer));
try {
writer.write((RenderedImage) null);
}
catch(IllegalArgumentException ignore) {
}
catch (IOException e) {
fail(e.getMessage());
}
assertTrue("Image data written", buffer.size() == 0);
}
public void testWriteNoOutput() {
ImageWriter writer = createImageWriter();
try {
writer.write(getTestData());
}
catch (IllegalStateException ignore) {
}
catch (IOException e) {
fail(e.getMessage());
}
}
public void testGetDefaultWriteParam() {
ImageWriter writer = createImageWriter();
ImageWriteParam param = writer.getDefaultWriteParam();
assertNotNull("Default ImageWriteParam is null", param);
}
// TODO: Test writing with params
// TODO: Source region and subsampling at least
public void testAddIIOWriteProgressListener() {
ImageWriter writer = createImageWriter();
Mock mockListener = new Mock(IIOWriteProgressListener.class);
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListener.proxy());
}
public void testAddIIOWriteProgressListenerNull() {
ImageWriter writer = createImageWriter();
writer.addIIOWriteProgressListener(null);
}
public void testAddIIOWriteProgressListenerCallbacks() throws IOException {
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(buffer));
Mock mockListener = new Mock(IIOWriteProgressListener.class);
String started = "Started";
mockListener.expects(once()).method("imageStarted").withAnyArguments().id(started);
mockListener.stubs().method("imageProgress").withAnyArguments().after(started);
mockListener.expects(once()).method("imageComplete").withAnyArguments().after(started);
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListener.proxy());
try {
writer.write(getTestData());
}
catch (IOException e) {
fail("Could not write image");
}
// At least imageStarted and imageComplete, plus any number of imageProgress
mockListener.verify();
}
public void testMultipleAddIIOWriteProgressListenerCallbacks() throws IOException {
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(buffer));
Mock mockListener = new Mock(IIOWriteProgressListener.class);
String started = "Started";
mockListener.expects(once()).method("imageStarted").withAnyArguments().id(started);
mockListener.stubs().method("imageProgress").withAnyArguments().after(started);
mockListener.expects(once()).method("imageComplete").withAnyArguments().after(started);
Mock mockListenerToo = new Mock(IIOWriteProgressListener.class);
String startedToo = "Started Two";
mockListenerToo.expects(once()).method("imageStarted").withAnyArguments().id(startedToo);
mockListenerToo.stubs().method("imageProgress").withAnyArguments().after(startedToo);
mockListenerToo.expects(once()).method("imageComplete").withAnyArguments().after(startedToo);
Mock mockListenerThree = new Mock(IIOWriteProgressListener.class);
String startedThree = "Started Three";
mockListenerThree.expects(once()).method("imageStarted").withAnyArguments().id(startedThree);
mockListenerThree.stubs().method("imageProgress").withAnyArguments().after(startedThree);
mockListenerThree.expects(once()).method("imageComplete").withAnyArguments().after(startedThree);
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListener.proxy());
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListenerToo.proxy());
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListenerThree.proxy());
try {
writer.write(getTestData());
}
catch (IOException e) {
fail("Could not write image");
}
// At least imageStarted and imageComplete, plus any number of imageProgress
mockListener.verify();
mockListenerToo.verify();
mockListenerThree.verify();
}
public void testRemoveIIOWriteProgressListenerNull() {
ImageWriter writer = createImageWriter();
writer.removeIIOWriteProgressListener(null);
}
public void testRemoveIIOWriteProgressListenerNone() {
ImageWriter writer = createImageWriter();
Mock mockListener = new Mock(IIOWriteProgressListener.class);
writer.removeIIOWriteProgressListener((IIOWriteProgressListener) mockListener.proxy());
}
public void testRemoveIIOWriteProgressListener() throws IOException {
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(buffer));
Mock mockListener = new Mock(IIOWriteProgressListener.class);
IIOWriteProgressListener listener = (IIOWriteProgressListener) mockListener.proxy();
writer.addIIOWriteProgressListener(listener);
writer.removeIIOWriteProgressListener(listener);
try {
writer.write(getTestData());
}
catch (IOException e) {
fail("Could not write image");
}
// Should not have called any methods...
mockListener.verify();
}
public void testRemoveIIOWriteProgressListenerMultiple() throws IOException {
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(buffer));
Mock mockListener = new Mock(IIOWriteProgressListener.class);
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListener.proxy());
Mock mockListenerToo = new Mock(IIOWriteProgressListener.class);
mockListenerToo.stubs().method("imageStarted").withAnyArguments();
mockListenerToo.stubs().method("imageProgress").withAnyArguments();
mockListenerToo.stubs().method("imageComplete").withAnyArguments();
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListenerToo.proxy());
writer.removeIIOWriteProgressListener((IIOWriteProgressListener) mockListener.proxy());
try {
writer.write(getTestData());
}
catch (IOException e) {
fail("Could not write image");
}
// Should not have called any methods...
mockListener.verify();
mockListenerToo.verify();
}
public void testRemoveAllIIOWriteProgressListeners() throws IOException {
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(buffer));
Mock mockListener = new Mock(IIOWriteProgressListener.class);
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListener.proxy());
writer.removeAllIIOWriteProgressListeners();
try {
writer.write(getTestData());
}
catch (IOException e) {
fail("Could not write image");
}
// Should not have called any methods...
mockListener.verify();
}
public void testRemoveAllIIOWriteProgressListenersMultiple() throws IOException {
ImageWriter writer = createImageWriter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(buffer));
Mock mockListener = new Mock(IIOWriteProgressListener.class);
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListener.proxy());
Mock mockListenerToo = new Mock(IIOWriteProgressListener.class);
writer.addIIOWriteProgressListener((IIOWriteProgressListener) mockListenerToo.proxy());
writer.removeAllIIOWriteProgressListeners();
try {
writer.write(getTestData());
}
catch (IOException e) {
fail("Could not write image");
}
// Should not have called any methods...
mockListener.verify();
mockListenerToo.verify();
}
}
@@ -0,0 +1,28 @@
package com.twelvemonkeys.imageio.util;
import junit.framework.TestCase;
import java.awt.image.DataBuffer;
import java.awt.image.IndexColorModel;
/**
* IndexedImageTypeSpecifierTestCase
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: IndexedImageTypeSpecifierTestCase.java,v 1.0 Jun 9, 2008 2:42:03 PM haraldk Exp$
*/
public class IndexedImageTypeSpecifierTestCase extends TestCase {
public void testEquals() {
IndexColorModel cm = new IndexColorModel(1, 2, new int[]{0xffffff, 0x00}, 0, false, -1, DataBuffer.TYPE_BYTE);
IndexedImageTypeSpecifier spec = new IndexedImageTypeSpecifier(cm);
IndexedImageTypeSpecifier other = new IndexedImageTypeSpecifier(cm);
assertEquals(spec, other);
assertEquals(other, spec);
assertTrue(spec.equals(other));
assertTrue(other.equals(spec));
}
}
Binary file not shown.