commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r995634 [1/6] - in /commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan: ./ common/ common/byteSources/ formats/bmp/ formats/gif/ formats/ico/ formats/jpeg/ formats/jpeg/exif/ formats/jpeg/iptc/ formats/jpeg/xmp/ formats/png/ fo...
Date Fri, 10 Sep 2010 01:35:52 GMT
Author: sebb
Date: Fri Sep 10 01:35:50 2010
New Revision: 995634

URL: http://svn.apache.org/viewvc?rev=995634&view=rev
Log:
Tab police

Modified:
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/RationalNumberTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceDataTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceImageTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpReadTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpRoundtripTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifReadTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoReadTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoRoundtripTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/JpegBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/JpegReadTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/JpegWithJpegThumbnailTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/AsciiFieldTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/ExifBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/ExifDumpTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/ExifRewriteTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/GpsTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/MakerNoteFieldTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/SpecificExifTagTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/TextFieldTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/exif/WriteExifMetadataExampleTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/iptc/IptcBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/iptc/IptcDumpTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/iptc/IptcUpdateTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/xmp/JpegXmpBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/xmp/JpegXmpDumpTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/jpeg/xmp/JpegXmpRewriteTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/ConvertPngToGifTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngMultipleRoundtripTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngReadTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngTextTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngWriteForceTrueColorText.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngWriteReadTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/tiff/TiffBaseTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/tiff/TiffLZWTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/tiff/TiffReadTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/tiff/TiffRoundtripTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/xmp/XmpDumpTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/xmp/XmpUpdateTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/roundtrip/RoundtripTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/ImageReadExample.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/ImageWriteExample.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/MetadataExample.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/SampleUsage.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/WriteExifMetadataExample.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/test/util/FSTraversal.java

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java Fri Sep 10 01:35:50 2010
@@ -23,52 +23,52 @@ import org.apache.commons.io.FilenameUti
 
 public class SanselanGuessFormatTest extends SanselanTest {
 
-	public static final String BMP_IMAGE_FILE = "bmp\\1\\Oregon Scientific DS6639 - DSC_0307 - small.bmp";
-	public static final String PNG_IMAGE_FILE = "png\\1\\Oregon Scientific DS6639 - DSC_0307 - small.png";
-	public static final String GIF_IMAGE_FILE = "gif\\1\\Oregon Scientific DS6639 - DSC_0307 - small.gif";
-	public static final String ICO_IMAGE_FILE = "ico\\1\\Oregon Scientific DS6639 - DSC_0307 - small.ico";
-	public static final String TIFF_IMAGE_FILE = "tiff\\1\\Oregon Scientific DS6639 - DSC_0307 - small.tif";
-	public static final String JPEG_IMAGE_FILE = "jpg\\1\\Oregon Scientific DS6639 - DSC_0307 - small.jpg";
-	public static final String PSD_IMAGE_FILE = "psd\\1\\Oregon Scientific DS6639 - DSC_0307 - small.psd";
-	public static final String PBM_IMAGE_FILE = "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.pbm";
-	public static final String PGM_IMAGE_FILE = "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.pgm";
-	public static final String PPM_IMAGE_FILE = "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.ppm";
-	public static final String TGA_IMAGE_FILE = "tga\\1\\Oregon Scientific DS6639 - DSC_0307 - small.tga";
-
-	public void testGuess_all() throws IOException, ImageReadException {
-		testGuess(ImageFormat.IMAGE_FORMAT_PNG, PNG_IMAGE_FILE);
-		testGuess(ImageFormat.IMAGE_FORMAT_GIF, GIF_IMAGE_FILE);
-		// TODO(cmchen): add ability to sniff ICOs if possible.
-		// testGuess(ImageFormat.IMAGE_FORMAT_ICO, ICO_IMAGE_FILE);
-		testGuess(ImageFormat.IMAGE_FORMAT_TIFF, TIFF_IMAGE_FILE);
-		testGuess(ImageFormat.IMAGE_FORMAT_JPEG, JPEG_IMAGE_FILE);
-		testGuess(ImageFormat.IMAGE_FORMAT_BMP, BMP_IMAGE_FILE);
-		testGuess(ImageFormat.IMAGE_FORMAT_PSD, PSD_IMAGE_FILE);
-		testGuess(ImageFormat.IMAGE_FORMAT_PBM, PBM_IMAGE_FILE);
-		testGuess(ImageFormat.IMAGE_FORMAT_PGM, PGM_IMAGE_FILE);
-		testGuess(ImageFormat.IMAGE_FORMAT_PPM, PPM_IMAGE_FILE);
-		// TODO(cmchen): add ability to sniff TGAs if possible.
-		// testGuess(ImageFormat.IMAGE_FORMAT_TGA, TGA_IMAGE_FILE);
-		// TODO(cmchen): Add test images for these formats.
-		// testGuess(ImageFormat.IMAGE_FORMAT_PNM, PNM_IMAGE_FILE);
-		// testGuess(ImageFormat.IMAGE_FORMAT_JBIG2, JBIG2_IMAGE_FILE);
-	}
-
-	public static final String UNKNOWN_IMAGE_FILE = "jpg\\1\\info.txt";
-
-	public void testGuess_unknown() throws IOException, ImageReadException {
-		testGuess(ImageFormat.IMAGE_FORMAT_UNKNOWN, UNKNOWN_IMAGE_FILE);
-	}
-
-	public void testGuess(ImageFormat expectedFormat, String imagePath)
-			throws IOException, ImageReadException {
-		imagePath = FilenameUtils.separatorsToSystem(imagePath);
-		File imageFile = new File(TEST_IMAGE_FOLDER, imagePath);
-
-		assertTrue(imageFile.exists());
-		assertTrue(imageFile.isFile());
-		ImageFormat guessedFormat = Sanselan.guessFormat(imageFile);
-		assertNotNull(guessedFormat);
-		assertEquals(guessedFormat, expectedFormat);
-	}
+    public static final String BMP_IMAGE_FILE = "bmp\\1\\Oregon Scientific DS6639 - DSC_0307 - small.bmp";
+    public static final String PNG_IMAGE_FILE = "png\\1\\Oregon Scientific DS6639 - DSC_0307 - small.png";
+    public static final String GIF_IMAGE_FILE = "gif\\1\\Oregon Scientific DS6639 - DSC_0307 - small.gif";
+    public static final String ICO_IMAGE_FILE = "ico\\1\\Oregon Scientific DS6639 - DSC_0307 - small.ico";
+    public static final String TIFF_IMAGE_FILE = "tiff\\1\\Oregon Scientific DS6639 - DSC_0307 - small.tif";
+    public static final String JPEG_IMAGE_FILE = "jpg\\1\\Oregon Scientific DS6639 - DSC_0307 - small.jpg";
+    public static final String PSD_IMAGE_FILE = "psd\\1\\Oregon Scientific DS6639 - DSC_0307 - small.psd";
+    public static final String PBM_IMAGE_FILE = "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.pbm";
+    public static final String PGM_IMAGE_FILE = "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.pgm";
+    public static final String PPM_IMAGE_FILE = "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.ppm";
+    public static final String TGA_IMAGE_FILE = "tga\\1\\Oregon Scientific DS6639 - DSC_0307 - small.tga";
+
+    public void testGuess_all() throws IOException, ImageReadException {
+        testGuess(ImageFormat.IMAGE_FORMAT_PNG, PNG_IMAGE_FILE);
+        testGuess(ImageFormat.IMAGE_FORMAT_GIF, GIF_IMAGE_FILE);
+        // TODO(cmchen): add ability to sniff ICOs if possible.
+        // testGuess(ImageFormat.IMAGE_FORMAT_ICO, ICO_IMAGE_FILE);
+        testGuess(ImageFormat.IMAGE_FORMAT_TIFF, TIFF_IMAGE_FILE);
+        testGuess(ImageFormat.IMAGE_FORMAT_JPEG, JPEG_IMAGE_FILE);
+        testGuess(ImageFormat.IMAGE_FORMAT_BMP, BMP_IMAGE_FILE);
+        testGuess(ImageFormat.IMAGE_FORMAT_PSD, PSD_IMAGE_FILE);
+        testGuess(ImageFormat.IMAGE_FORMAT_PBM, PBM_IMAGE_FILE);
+        testGuess(ImageFormat.IMAGE_FORMAT_PGM, PGM_IMAGE_FILE);
+        testGuess(ImageFormat.IMAGE_FORMAT_PPM, PPM_IMAGE_FILE);
+        // TODO(cmchen): add ability to sniff TGAs if possible.
+        // testGuess(ImageFormat.IMAGE_FORMAT_TGA, TGA_IMAGE_FILE);
+        // TODO(cmchen): Add test images for these formats.
+        // testGuess(ImageFormat.IMAGE_FORMAT_PNM, PNM_IMAGE_FILE);
+        // testGuess(ImageFormat.IMAGE_FORMAT_JBIG2, JBIG2_IMAGE_FILE);
+    }
+
+    public static final String UNKNOWN_IMAGE_FILE = "jpg\\1\\info.txt";
+
+    public void testGuess_unknown() throws IOException, ImageReadException {
+        testGuess(ImageFormat.IMAGE_FORMAT_UNKNOWN, UNKNOWN_IMAGE_FILE);
+    }
+
+    public void testGuess(ImageFormat expectedFormat, String imagePath)
+            throws IOException, ImageReadException {
+        imagePath = FilenameUtils.separatorsToSystem(imagePath);
+        File imageFile = new File(TEST_IMAGE_FOLDER, imagePath);
+
+        assertTrue(imageFile.exists());
+        assertTrue(imageFile.isFile());
+        ImageFormat guessedFormat = Sanselan.guessFormat(imageFile);
+        assertNotNull(guessedFormat);
+        assertEquals(guessedFormat, expectedFormat);
+    }
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTest.java Fri Sep 10 01:35:50 2010
@@ -28,138 +28,138 @@ import org.apache.sanselan.test.util.FST
 import org.apache.sanselan.util.Debug;
 
 public abstract class SanselanTest extends TestCase implements
-		SanselanTestConstants, SanselanConstants {
+        SanselanTestConstants, SanselanConstants {
 
-	protected File createTempFile(String prefix, String suffix)
-			throws IOException {
-		File tempFolder = new File("tmp");
-		if (!tempFolder.exists())
-			tempFolder.mkdirs();
-		assertTrue(tempFolder.isDirectory());
-
-		File result = File.createTempFile(prefix, suffix, tempFolder);
-		result.deleteOnExit();
-		return result;
-	}
-
-	public void compareByteArrays(byte a[], byte b[]) {
-		assertTrue(a.length == b.length);
-		for (int i = 0; i < b.length; i++)
-			assertTrue(b[i] == a[i]);
-	}
-
-	protected void purgeMemory() {
-		try {
-			System.gc();
-			Thread.sleep(50);
-			System.runFinalization();
-			Thread.sleep(50);
-		} catch (Exception e) {
-			Debug.debug(e);
-		}
-	}
-
-	protected boolean isPhilHarveyTestImage(File file) {
-		// Debug.debug("isPhilHarveyTestImage file", file.getAbsolutePath());
-		// Debug.debug("isPhilHarveyTestImage folder",
-		// PHIL_HARVEY_TEST_IMAGE_FOLDER.getAbsolutePath());
-		return file.getAbsolutePath().startsWith(
-				PHIL_HARVEY_TEST_IMAGE_FOLDER.getAbsolutePath());
-	}
-
-	public static interface ImageFilter {
-		public boolean accept(File file) throws IOException, ImageReadException;
-	}
-
-	protected File getTestImage() throws IOException, ImageReadException {
-		return getTestImage(null);
-	}
-
-	protected File getTestImageByName(final String filename) 
-			throws IOException, ImageReadException {
-		return getTestImage(new ImageFilter() {
-			public boolean accept(File file) throws IOException, ImageReadException {
-				return file.getName().equals(filename);
-			}
-		});
-	}
-
-	protected File getTestImage(ImageFilter filter) throws IOException,
-			ImageReadException {
-		List images = getTestImages(filter, 1);
-
-		assertTrue(images.size() > 0);
-
-		return (File) images.get(0);
-	}
-
-	protected List getTestImages() throws IOException, ImageReadException {
-		return getTestImages(null, -1);
-	}
-
-	protected List getTestImages(ImageFilter filter) throws IOException,
-			ImageReadException {
-		return getTestImages(filter, -1);
-	}
-
-	private static final List ALL_IMAGES = new ArrayList();
-
-	static {
-		File imagesFolder = TEST_IMAGE_FOLDER;
-
-		// imagesFolder = new File(
-		// "C:\\personal\\apache\\sanselan\\src\\test\\data\\images\\bmp\\2");
-
-		imagesFolder = imagesFolder.getAbsoluteFile();
-
-		Debug.debug("imagesFolder", imagesFolder);
-		assertTrue(imagesFolder.exists());
-
-		FSTraversal.Visitor visitor = new FSTraversal.Visitor() {
-
-			public boolean visit(File file, double progressEstimate) {
-				if (!Sanselan.hasImageFileExtension(file))
-					return true;
-				ALL_IMAGES.add(file);
-				return true;
-			}
-		};
-		new FSTraversal().traverseFiles(imagesFolder, visitor);
-	}
-
-	protected List getTestImages(final ImageFilter filter, final int max)
-			throws IOException, ImageReadException {
-		final List images = new ArrayList();
-		int counter = 0;
-
-		for (int i = 0; i < ALL_IMAGES.size(); i++) {
-			File file = (File) ALL_IMAGES.get(i);
-
-			if (!Sanselan.hasImageFileExtension(file))
-				continue;
-
-			if (counter++ % 10 == 0)
-				Debug.purgeMemory();
-
-			if (file.getParentFile().getName().toLowerCase().equals("@broken"))
-				continue;
-
-			if (filter != null && !filter.accept(file))
-				continue;
-
-			images.add(file);
-
-			if (max > 0 && images.size() >= max)
-				break;
-		}
-
-		assertTrue(images.size() > 0);
-
-		return images;
-	}
-
-	protected boolean isInvalidPNGTestFile(File file) {
-		return (file.getParentFile().getName().equalsIgnoreCase("pngsuite") && file
-				.getName().toLowerCase().startsWith("x"));
-	}
+    protected File createTempFile(String prefix, String suffix)
+            throws IOException {
+        File tempFolder = new File("tmp");
+        if (!tempFolder.exists())
+            tempFolder.mkdirs();
+        assertTrue(tempFolder.isDirectory());
+
+        File result = File.createTempFile(prefix, suffix, tempFolder);
+        result.deleteOnExit();
+        return result;
+    }
+
+    public void compareByteArrays(byte a[], byte b[]) {
+        assertTrue(a.length == b.length);
+        for (int i = 0; i < b.length; i++)
+            assertTrue(b[i] == a[i]);
+    }
+
+    protected void purgeMemory() {
+        try {
+            System.gc();
+            Thread.sleep(50);
+            System.runFinalization();
+            Thread.sleep(50);
+        } catch (Exception e) {
+            Debug.debug(e);
+        }
+    }
+
+    protected boolean isPhilHarveyTestImage(File file) {
+        // Debug.debug("isPhilHarveyTestImage file", file.getAbsolutePath());
+        // Debug.debug("isPhilHarveyTestImage folder",
+        // PHIL_HARVEY_TEST_IMAGE_FOLDER.getAbsolutePath());
+        return file.getAbsolutePath().startsWith(
+                PHIL_HARVEY_TEST_IMAGE_FOLDER.getAbsolutePath());
+    }
+
+    public static interface ImageFilter {
+        public boolean accept(File file) throws IOException, ImageReadException;
+    }
+
+    protected File getTestImage() throws IOException, ImageReadException {
+        return getTestImage(null);
+    }
+
+    protected File getTestImageByName(final String filename)
+            throws IOException, ImageReadException {
+        return getTestImage(new ImageFilter() {
+            public boolean accept(File file) throws IOException, ImageReadException {
+                return file.getName().equals(filename);
+            }
+        });
+    }
+
+    protected File getTestImage(ImageFilter filter) throws IOException,
+            ImageReadException {
+        List images = getTestImages(filter, 1);
+
+        assertTrue(images.size() > 0);
+
+        return (File) images.get(0);
+    }
+
+    protected List getTestImages() throws IOException, ImageReadException {
+        return getTestImages(null, -1);
+    }
+
+    protected List getTestImages(ImageFilter filter) throws IOException,
+            ImageReadException {
+        return getTestImages(filter, -1);
+    }
+
+    private static final List ALL_IMAGES = new ArrayList();
+
+    static {
+        File imagesFolder = TEST_IMAGE_FOLDER;
+
+        // imagesFolder = new File(
+        // "C:\\personal\\apache\\sanselan\\src\\test\\data\\images\\bmp\\2");
+
+        imagesFolder = imagesFolder.getAbsoluteFile();
+
+        Debug.debug("imagesFolder", imagesFolder);
+        assertTrue(imagesFolder.exists());
+
+        FSTraversal.Visitor visitor = new FSTraversal.Visitor() {
+
+            public boolean visit(File file, double progressEstimate) {
+                if (!Sanselan.hasImageFileExtension(file))
+                    return true;
+                ALL_IMAGES.add(file);
+                return true;
+            }
+        };
+        new FSTraversal().traverseFiles(imagesFolder, visitor);
+    }
+
+    protected List getTestImages(final ImageFilter filter, final int max)
+            throws IOException, ImageReadException {
+        final List images = new ArrayList();
+        int counter = 0;
+
+        for (int i = 0; i < ALL_IMAGES.size(); i++) {
+            File file = (File) ALL_IMAGES.get(i);
+
+            if (!Sanselan.hasImageFileExtension(file))
+                continue;
+
+            if (counter++ % 10 == 0)
+                Debug.purgeMemory();
+
+            if (file.getParentFile().getName().toLowerCase().equals("@broken"))
+                continue;
+
+            if (filter != null && !filter.accept(file))
+                continue;
+
+            images.add(file);
+
+            if (max > 0 && images.size() >= max)
+                break;
+        }
+
+        assertTrue(images.size() > 0);
+
+        return images;
+    }
+
+    protected boolean isInvalidPNGTestFile(File file) {
+        return (file.getParentFile().getName().equalsIgnoreCase("pngsuite") && file
+                .getName().toLowerCase().startsWith("x"));
+    }
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java Fri Sep 10 01:35:50 2010
@@ -22,13 +22,13 @@ import org.apache.commons.io.FilenameUti
 
 public interface SanselanTestConstants {
 
-	static final File PHIL_HARVEY_TEST_IMAGE_FOLDER = new File(
-			FilenameUtils.separatorsToSystem("src\\test\\data\\images\\exif\\philHarvey\\"));
+    static final File PHIL_HARVEY_TEST_IMAGE_FOLDER = new File(
+            FilenameUtils.separatorsToSystem("src\\test\\data\\images\\exif\\philHarvey\\"));
 
-	static final File SOURCE_FOLDER = new File("src");
-	static final File TEST_SOURCE_FOLDER = new File(SOURCE_FOLDER, "test");
-	static final File TEST_DATA_SOURCE_FOLDER = new File(TEST_SOURCE_FOLDER,
-			"data");
-	static final File TEST_IMAGE_FOLDER = new File(TEST_DATA_SOURCE_FOLDER,
-			"images");
+    static final File SOURCE_FOLDER = new File("src");
+    static final File TEST_SOURCE_FOLDER = new File(SOURCE_FOLDER, "test");
+    static final File TEST_DATA_SOURCE_FOLDER = new File(TEST_SOURCE_FOLDER,
+            "data");
+    static final File TEST_IMAGE_FOLDER = new File(TEST_DATA_SOURCE_FOLDER,
+            "images");
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/RationalNumberTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/RationalNumberTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/RationalNumberTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/RationalNumberTest.java Fri Sep 10 01:35:50 2010
@@ -25,100 +25,100 @@ import org.apache.sanselan.util.Debug;
 
 public class RationalNumberTest extends SanselanTest
 {
-	//	public RationalNumberTest()
-	//	{
-	//		super("Rational Number Test");
-	//	}
-
-	public void test()
-	{
-		double testValues[] = {
-				0, //
-				0.1, //
-				0.01, //
-				0.001, //
-				0.0001, //
-				0.00001, //
-				0.000001, //
-				0.0000001, //
-				0.123456789, //
-				1, //
-				0.9, //
-				1.1, //
-				2.0, //
-				123.123, //
-				123123123.123, //
-
-				(double) 123 / 45678, //
-				(double) 12 / 34, //
-				(double) 1 / 2, //
-				(double) 1 / 3, //
-				(double) 1 / 4, //
-				(double) 1 / 5, //
-				(double) 1 / 6, //
-				(double) 1 / 7, //
-				(double) 1 / 8, //
-				(double) 1 / 9, //
-				(double) 3 / 2, //
-				(double) 2 / 3, //
-				(double) 3 / 4, //
-				(double) 4 / 5, //
-				(double) 5 / 6, //
-				(double) 6 / 7, //
-				(double) 7 / 8, //
-				(double) 8 / 9, //
-				(double) 3 / 5, //
-				(double) 3 / 6, //
-				(double) 3 / 7, //
-				(double) 3 / 8, //
-				(double) 3 / 9, //
-
-				-0.1, //
-				-0.01, //
-				-0.001, //
-				-0.0001, //
-				-0.00001, //
-				-0.000001, //
-				-0.0000001, //
-				-0.123456789, //
-				-1, //
-				-0.9, //
-				-1.1, //
-				-2.0, //
-				-123.123, //
-				-123123123.123, //
-
-				34, //
-
-				Integer.MAX_VALUE, //
-				Integer.MAX_VALUE + 0.1, //
-				Integer.MAX_VALUE - 0.1, //
-				-(Integer.MAX_VALUE ), //
-				-(Integer.MAX_VALUE + 0.1), //
-				-(Integer.MAX_VALUE - 0.1), //
-
-				Long.MAX_VALUE, //
-				Long.MAX_VALUE + 0.1, //
-				Long.MAX_VALUE - 0.1, //
-				-(Long.MAX_VALUE ), //
-				-(Long.MAX_VALUE + 0.1), //
-				-(Long.MAX_VALUE - 0.1), //
-		};
-
-		for (int i = 0; i < testValues.length; i++)
-		{
-			double value = testValues[i];
-			RationalNumber rational = RationalNumberUtilities
-					.getRationalNumber(value);
-			double difference = Math.abs(value - rational.doubleValue());
-
-			NumberFormat nf = DecimalFormat.getInstance();
-			nf.setMaximumFractionDigits(15);
-
-			Debug.debug("value", nf.format(value));
-			Debug.debug("rational", rational);
-			Debug.debug("difference", difference);
-			Debug.debug();
-		}
-	}
+    //    public RationalNumberTest()
+    //    {
+    //        super("Rational Number Test");
+    //    }
+
+    public void test()
+    {
+        double testValues[] = {
+                0, //
+                0.1, //
+                0.01, //
+                0.001, //
+                0.0001, //
+                0.00001, //
+                0.000001, //
+                0.0000001, //
+                0.123456789, //
+                1, //
+                0.9, //
+                1.1, //
+                2.0, //
+                123.123, //
+                123123123.123, //
+
+                (double) 123 / 45678, //
+                (double) 12 / 34, //
+                (double) 1 / 2, //
+                (double) 1 / 3, //
+                (double) 1 / 4, //
+                (double) 1 / 5, //
+                (double) 1 / 6, //
+                (double) 1 / 7, //
+                (double) 1 / 8, //
+                (double) 1 / 9, //
+                (double) 3 / 2, //
+                (double) 2 / 3, //
+                (double) 3 / 4, //
+                (double) 4 / 5, //
+                (double) 5 / 6, //
+                (double) 6 / 7, //
+                (double) 7 / 8, //
+                (double) 8 / 9, //
+                (double) 3 / 5, //
+                (double) 3 / 6, //
+                (double) 3 / 7, //
+                (double) 3 / 8, //
+                (double) 3 / 9, //
+
+                -0.1, //
+                -0.01, //
+                -0.001, //
+                -0.0001, //
+                -0.00001, //
+                -0.000001, //
+                -0.0000001, //
+                -0.123456789, //
+                -1, //
+                -0.9, //
+                -1.1, //
+                -2.0, //
+                -123.123, //
+                -123123123.123, //
+
+                34, //
+
+                Integer.MAX_VALUE, //
+                Integer.MAX_VALUE + 0.1, //
+                Integer.MAX_VALUE - 0.1, //
+                -(Integer.MAX_VALUE ), //
+                -(Integer.MAX_VALUE + 0.1), //
+                -(Integer.MAX_VALUE - 0.1), //
+
+                Long.MAX_VALUE, //
+                Long.MAX_VALUE + 0.1, //
+                Long.MAX_VALUE - 0.1, //
+                -(Long.MAX_VALUE ), //
+                -(Long.MAX_VALUE + 0.1), //
+                -(Long.MAX_VALUE - 0.1), //
+        };
+
+        for (int i = 0; i < testValues.length; i++)
+        {
+            double value = testValues[i];
+            RationalNumber rational = RationalNumberUtilities
+                    .getRationalNumber(value);
+            double difference = Math.abs(value - rational.doubleValue());
+
+            NumberFormat nf = DecimalFormat.getInstance();
+            nf.setMaximumFractionDigits(15);
+
+            Debug.debug("value", nf.format(value));
+            Debug.debug("rational", rational);
+            Debug.debug("difference", difference);
+            Debug.debug();
+        }
+    }
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceDataTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceDataTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceDataTest.java Fri Sep 10 01:35:50 2010
@@ -30,130 +30,130 @@ import org.apache.sanselan.util.IOUtils;
 
 public class ByteSourceDataTest extends ByteSourceTest
 {
-	//	public ByteSourceDataTest()
-	//	{
-	//		super(ByteSourceDataTest.class.getName());
-	//	}
-
-	/**
-	 * @return the suite of tests being tested
-	 */
-	public static Test suite()
-	{
-		return new TestSuite(ByteSourceDataTest.class);
-	}
-
-	private interface ByteSourceFactory
-	{
-		public ByteSource getByteSource(byte src[]) throws IOException;
-	}
-
-	private class ByteSourceFileFactory implements ByteSourceFactory
-	{
-		public ByteSource getByteSource(byte src[]) throws IOException
-		{
-			File file = createTempFile(src);
-
-			// test that all bytes written to file.
-			assertTrue(src.length == file.length());
-
-			ByteSource byteSource = new ByteSourceFile(file);
-			return byteSource;
-		}
-	}
-
-	private class ByteSourceInputStreamFileFactory implements ByteSourceFactory
-	{
-		public ByteSource getByteSource(byte src[]) throws IOException
-		{
-			File file = createTempFile(src);
-
-			FileInputStream is = new FileInputStream(file);
-
-			ByteSource byteSource = new ByteSourceInputStream(is, null);
-			return byteSource;
-		}
-	}
-
-	private class ByteSourceInputStreamRawFactory implements ByteSourceFactory
-	{
-		public ByteSource getByteSource(byte src[]) throws IOException
-		{
-			ByteArrayInputStream is = new ByteArrayInputStream(src);
-
-			ByteSource byteSource = new ByteSourceInputStream(is, null);
-			return byteSource;
-		}
-
-	}
-
-	protected void writeAndReadBytes(ByteSourceFactory byteSourceFactory,
-			byte src[]) throws IOException
-	{
-		ByteSource byteSource = byteSourceFactory.getByteSource(src);
-
-		// test cache during interrupted read cache by reading only first N bytes.
-		{
-			InputStream is = byteSource.getInputStream();
-			byte prefix[] = new byte[256];
-			int read = is.read(prefix);
-
-			assertTrue(read <= src.length);
-			for (int i = 0; i < read; i++)
-				assertTrue(src[i] == prefix[i]);
-		}
-
-		// test cache by completely reading InputStream N times.
-		for (int j = 0; j < 5; j++)
-		{
-			InputStream is = byteSource.getInputStream();
-			byte dst[] = IOUtils.getInputStreamBytes(is);
-
-			compareByteArrays(src, dst);
-		}
-
-		{
-			// test getAll() method.
-			byte all[] = byteSource.getAll();
-			compareByteArrays(src, all);
-		}
-
-		if (src.length > 2)
-		{
-			// test optional start param to getInputStream()
-
-			int start = src.length / 2;
-
-			InputStream is = byteSource.getInputStream(start);
-			byte dst[] = IOUtils.getInputStreamBytes(is);
-
-			assertTrue(src.length == dst.length + start);
-			for (int i = 0; i < dst.length; i++)
-				assertTrue(dst[i] == src[i + start]);
-		}
-
-	}
-
-	public void test() throws IOException
-	{
-		ByteSourceFactory byteSourceFactories[] = {
-				new ByteSourceFileFactory(),
-				new ByteSourceInputStreamFileFactory(),
-				new ByteSourceInputStreamRawFactory(),
-		};
-
-		byte testByteArrays[][] = getTestByteArrays();
-
-		for (int i = 0; i < testByteArrays.length; i++)
-		{
-			byte testByteArray[] = testByteArrays[i];
-
-			for (int j = 0; j < byteSourceFactories.length; j++)
-			{
-				ByteSourceFactory byteSourceFactory = byteSourceFactories[j];
-
-				writeAndReadBytes(byteSourceFactory, testByteArray);
-			}
-		}
-	}
+    //    public ByteSourceDataTest()
+    //    {
+    //        super(ByteSourceDataTest.class.getName());
+    //    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite(ByteSourceDataTest.class);
+    }
+
+    private interface ByteSourceFactory
+    {
+        public ByteSource getByteSource(byte src[]) throws IOException;
+    }
+
+    private class ByteSourceFileFactory implements ByteSourceFactory
+    {
+        public ByteSource getByteSource(byte src[]) throws IOException
+        {
+            File file = createTempFile(src);
+
+            // test that all bytes written to file.
+            assertTrue(src.length == file.length());
+
+            ByteSource byteSource = new ByteSourceFile(file);
+            return byteSource;
+        }
+    }
+
+    private class ByteSourceInputStreamFileFactory implements ByteSourceFactory
+    {
+        public ByteSource getByteSource(byte src[]) throws IOException
+        {
+            File file = createTempFile(src);
+
+            FileInputStream is = new FileInputStream(file);
+
+            ByteSource byteSource = new ByteSourceInputStream(is, null);
+            return byteSource;
+        }
+    }
+
+    private class ByteSourceInputStreamRawFactory implements ByteSourceFactory
+    {
+        public ByteSource getByteSource(byte src[]) throws IOException
+        {
+            ByteArrayInputStream is = new ByteArrayInputStream(src);
+
+            ByteSource byteSource = new ByteSourceInputStream(is, null);
+            return byteSource;
+        }
+
+    }
+
+    protected void writeAndReadBytes(ByteSourceFactory byteSourceFactory,
+            byte src[]) throws IOException
+    {
+        ByteSource byteSource = byteSourceFactory.getByteSource(src);
+
+        // test cache during interrupted read cache by reading only first N bytes.
+        {
+            InputStream is = byteSource.getInputStream();
+            byte prefix[] = new byte[256];
+            int read = is.read(prefix);
+
+            assertTrue(read <= src.length);
+            for (int i = 0; i < read; i++)
+                assertTrue(src[i] == prefix[i]);
+        }
+
+        // test cache by completely reading InputStream N times.
+        for (int j = 0; j < 5; j++)
+        {
+            InputStream is = byteSource.getInputStream();
+            byte dst[] = IOUtils.getInputStreamBytes(is);
+
+            compareByteArrays(src, dst);
+        }
+
+        {
+            // test getAll() method.
+            byte all[] = byteSource.getAll();
+            compareByteArrays(src, all);
+        }
+
+        if (src.length > 2)
+        {
+            // test optional start param to getInputStream()
+
+            int start = src.length / 2;
+
+            InputStream is = byteSource.getInputStream(start);
+            byte dst[] = IOUtils.getInputStreamBytes(is);
+
+            assertTrue(src.length == dst.length + start);
+            for (int i = 0; i < dst.length; i++)
+                assertTrue(dst[i] == src[i + start]);
+        }
+
+    }
+
+    public void test() throws IOException
+    {
+        ByteSourceFactory byteSourceFactories[] = {
+                new ByteSourceFileFactory(),
+                new ByteSourceInputStreamFileFactory(),
+                new ByteSourceInputStreamRawFactory(),
+        };
+
+        byte testByteArrays[][] = getTestByteArrays();
+
+        for (int i = 0; i < testByteArrays.length; i++)
+        {
+            byte testByteArray[] = testByteArrays[i];
+
+            for (int j = 0; j < byteSourceFactories.length; j++)
+            {
+                ByteSourceFactory byteSourceFactory = byteSourceFactories[j];
+
+                writeAndReadBytes(byteSourceFactory, testByteArray);
+            }
+        }
+    }
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceImageTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceImageTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceImageTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceImageTest.java Fri Sep 10 01:35:50 2010
@@ -38,180 +38,180 @@ import org.apache.sanselan.util.IOUtils;
 public class ByteSourceImageTest extends ByteSourceTest
 {
 
-	public void test() throws IOException, ImageReadException,
-			IllegalAccessException, IllegalArgumentException,
-			InvocationTargetException
-	{
-		List imageFiles = getTestImages();
-		for (int i = 0; i < imageFiles.size(); i++)
-		{
-			if (i % 1 == 0)
-				Debug.purgeMemory();
-
-			File imageFile = (File) imageFiles.get(i);
-			Debug.debug("imageFile", imageFile);
-			assertNotNull(imageFile);
-
-			byte imageFileBytes[] = IOUtils.getFileBytes(imageFile);
-			assertNotNull(imageFileBytes);
-			assertTrue(imageFileBytes.length == imageFile.length());
-
-			if (imageFile.getName().toLowerCase().endsWith(".ico")
-					|| imageFile.getName().toLowerCase().endsWith(".tga")
-					|| imageFile.getName().toLowerCase().endsWith(".jb2")
-					|| imageFile.getName().toLowerCase().endsWith(".psd"))
-			{
-				// these formats can't be parsed without a filename hint.
-				// they have ambiguous "magic number" signatures.
-				continue;
-			}
-
-			checkGuessFormat(imageFile, imageFileBytes);
-
-			if (imageFile.getName().toLowerCase().endsWith(".png")
-					&& imageFile.getParentFile().getName().equalsIgnoreCase(
-							"pngsuite")
-					&& imageFile.getName().toLowerCase().startsWith("x"))
-				continue;
-
-			checkGetICCProfileBytes(imageFile, imageFileBytes);
-
-			if (!imageFile.getParentFile().getName().toLowerCase().equals(
-					"@broken"))
-				checkGetImageInfo(imageFile, imageFileBytes);
-
-			checkGetImageSize(imageFile, imageFileBytes);
-
-			ImageFormat imageFormat = Sanselan.guessFormat(imageFile);
-			if (ImageFormat.IMAGE_FORMAT_JPEG == imageFormat
-					|| ImageFormat.IMAGE_FORMAT_UNKNOWN == imageFormat)
-				;
-			else
-				checkGetBufferedImage(imageFile, imageFileBytes);
-		}
-	}
-
-	public void checkGetBufferedImage(File file, byte[] bytes)
-			throws IOException, ImageReadException
-	{
-		BufferedImage imageFile = Sanselan.getBufferedImage(file);
-		assertNotNull(imageFile);
-		assertTrue(imageFile.getWidth() > 0);
-		assertTrue(imageFile.getHeight() > 0);
-		int imageFileWidth = imageFile.getWidth();
-		int imageFileHeight = imageFile.getHeight();
-		imageFile = null;
-
-		BufferedImage imageBytes = Sanselan.getBufferedImage(bytes);
-		assertNotNull(imageBytes);
-		assertTrue(imageFileWidth == imageBytes.getWidth());
-		assertTrue(imageFileHeight == imageBytes.getHeight());
-	}
-
-	public void checkGetImageSize(File imageFile, byte[] imageFileBytes)
-			throws IOException, ImageReadException
-	{
-		Dimension imageSizeFile = Sanselan.getImageSize(imageFile);
-		assertNotNull(imageSizeFile);
-		assertTrue(imageSizeFile.width > 0);
-		assertTrue(imageSizeFile.height > 0);
-
-		Dimension imageSizeBytes = Sanselan.getImageSize(imageFileBytes);
-		assertNotNull(imageSizeBytes);
-		assertTrue(imageSizeFile.width == imageSizeBytes.width);
-		assertTrue(imageSizeFile.height == imageSizeBytes.height);
-	}
-
-	public void checkGuessFormat(File imageFile, byte[] imageFileBytes)
-			throws IOException, ImageReadException
-	{
-		// check guessFormat()
-		ImageFormat imageFormatFile = Sanselan.guessFormat(imageFile);
-		assertNotNull(imageFormatFile);
-		assertTrue(imageFormatFile != ImageFormat.IMAGE_FORMAT_UNKNOWN);
-		// Debug.debug("imageFormatFile", imageFormatFile);
-
-		ImageFormat imageFormatBytes = Sanselan.guessFormat(imageFileBytes);
-		assertNotNull(imageFormatBytes);
-		assertTrue(imageFormatBytes != ImageFormat.IMAGE_FORMAT_UNKNOWN);
-		// Debug.debug("imageFormatBytes", imageFormatBytes);
-
-		assertTrue(imageFormatBytes == imageFormatFile);
-	}
-
-	public void checkGetICCProfileBytes(File imageFile, byte[] imageFileBytes)
-			throws IOException, ImageReadException
-	{
-		// check guessFormat()
-		byte iccBytesFile[] = Sanselan.getICCProfileBytes(imageFile);
-
-		byte iccBytesBytes[] = Sanselan.getICCProfileBytes(imageFileBytes);
-
-		assertTrue((iccBytesFile != null) == (iccBytesBytes != null));
-
-		if (iccBytesFile == null)
-			return;
-
-		compareByteArrays(iccBytesFile, iccBytesBytes);
-	}
-
-	public void checkGetImageInfo(File imageFile, byte[] imageFileBytes)
-			throws IOException, ImageReadException, IllegalAccessException,
-			IllegalArgumentException, InvocationTargetException
-	{
-		Map params = new HashMap();
-		boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
-		ImageFormat imageFormat = Sanselan.guessFormat(imageFile);
-		if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_TIFF)
-				|| imageFormat.equals(ImageFormat.IMAGE_FORMAT_JPEG))
-			params
-					.put(PARAM_KEY_READ_THUMBNAILS, new Boolean(
-							!ignoreImageData));
-
-		ImageInfo imageInfoFile = Sanselan.getImageInfo(imageFile, params);
-
-		ImageInfo imageInfoBytes = Sanselan
-				.getImageInfo(imageFileBytes, params);
-
-		assertNotNull(imageInfoFile);
-		assertNotNull(imageInfoBytes);
-
-		Method methods[] = ImageInfo.class.getMethods();
-		for (int i = 0; i < methods.length; i++)
-		{
-			Method method = methods[i];
-			method.getModifiers();
-			if (!Modifier.isPublic(method.getModifiers()))
-				continue;
-			if (!method.getName().startsWith("get"))
-				continue;
-			if (method.getName().equals("getClass"))
-				continue;
-			// if (method.getGenericParameterTypes().length > 0)
-			// continue;
-
-			Object valueFile = method.invoke(imageInfoFile, null);
-			Object valueBytes = method.invoke(imageInfoBytes, null);
-
-			assertTrue(valueFile.equals(valueBytes));
-		}
-
-		// only have to test values from imageInfoFile; we already know values
-		// match.
-		assertTrue(imageInfoFile.getBitsPerPixel() > 0);
-
-		assertNotNull(imageInfoFile.getFormat());
-		assertTrue(imageInfoFile.getFormat() != ImageFormat.IMAGE_FORMAT_UNKNOWN);
-
-		assertNotNull(imageInfoFile.getFormatName());
-
-		assertTrue(imageInfoFile.getWidth() > 0);
-		assertTrue(imageInfoFile.getHeight() > 0);
+    public void test() throws IOException, ImageReadException,
+            IllegalAccessException, IllegalArgumentException,
+            InvocationTargetException
+    {
+        List imageFiles = getTestImages();
+        for (int i = 0; i < imageFiles.size(); i++)
+        {
+            if (i % 1 == 0)
+                Debug.purgeMemory();
+
+            File imageFile = (File) imageFiles.get(i);
+            Debug.debug("imageFile", imageFile);
+            assertNotNull(imageFile);
+
+            byte imageFileBytes[] = IOUtils.getFileBytes(imageFile);
+            assertNotNull(imageFileBytes);
+            assertTrue(imageFileBytes.length == imageFile.length());
+
+            if (imageFile.getName().toLowerCase().endsWith(".ico")
+                    || imageFile.getName().toLowerCase().endsWith(".tga")
+                    || imageFile.getName().toLowerCase().endsWith(".jb2")
+                    || imageFile.getName().toLowerCase().endsWith(".psd"))
+            {
+                // these formats can't be parsed without a filename hint.
+                // they have ambiguous "magic number" signatures.
+                continue;
+            }
+
+            checkGuessFormat(imageFile, imageFileBytes);
+
+            if (imageFile.getName().toLowerCase().endsWith(".png")
+                    && imageFile.getParentFile().getName().equalsIgnoreCase(
+                            "pngsuite")
+                    && imageFile.getName().toLowerCase().startsWith("x"))
+                continue;
+
+            checkGetICCProfileBytes(imageFile, imageFileBytes);
+
+            if (!imageFile.getParentFile().getName().toLowerCase().equals(
+                    "@broken"))
+                checkGetImageInfo(imageFile, imageFileBytes);
+
+            checkGetImageSize(imageFile, imageFileBytes);
+
+            ImageFormat imageFormat = Sanselan.guessFormat(imageFile);
+            if (ImageFormat.IMAGE_FORMAT_JPEG == imageFormat
+                    || ImageFormat.IMAGE_FORMAT_UNKNOWN == imageFormat)
+                ;
+            else
+                checkGetBufferedImage(imageFile, imageFileBytes);
+        }
+    }
+
+    public void checkGetBufferedImage(File file, byte[] bytes)
+            throws IOException, ImageReadException
+    {
+        BufferedImage imageFile = Sanselan.getBufferedImage(file);
+        assertNotNull(imageFile);
+        assertTrue(imageFile.getWidth() > 0);
+        assertTrue(imageFile.getHeight() > 0);
+        int imageFileWidth = imageFile.getWidth();
+        int imageFileHeight = imageFile.getHeight();
+        imageFile = null;
+
+        BufferedImage imageBytes = Sanselan.getBufferedImage(bytes);
+        assertNotNull(imageBytes);
+        assertTrue(imageFileWidth == imageBytes.getWidth());
+        assertTrue(imageFileHeight == imageBytes.getHeight());
+    }
+
+    public void checkGetImageSize(File imageFile, byte[] imageFileBytes)
+            throws IOException, ImageReadException
+    {
+        Dimension imageSizeFile = Sanselan.getImageSize(imageFile);
+        assertNotNull(imageSizeFile);
+        assertTrue(imageSizeFile.width > 0);
+        assertTrue(imageSizeFile.height > 0);
+
+        Dimension imageSizeBytes = Sanselan.getImageSize(imageFileBytes);
+        assertNotNull(imageSizeBytes);
+        assertTrue(imageSizeFile.width == imageSizeBytes.width);
+        assertTrue(imageSizeFile.height == imageSizeBytes.height);
+    }
+
+    public void checkGuessFormat(File imageFile, byte[] imageFileBytes)
+            throws IOException, ImageReadException
+    {
+        // check guessFormat()
+        ImageFormat imageFormatFile = Sanselan.guessFormat(imageFile);
+        assertNotNull(imageFormatFile);
+        assertTrue(imageFormatFile != ImageFormat.IMAGE_FORMAT_UNKNOWN);
+        // Debug.debug("imageFormatFile", imageFormatFile);
+
+        ImageFormat imageFormatBytes = Sanselan.guessFormat(imageFileBytes);
+        assertNotNull(imageFormatBytes);
+        assertTrue(imageFormatBytes != ImageFormat.IMAGE_FORMAT_UNKNOWN);
+        // Debug.debug("imageFormatBytes", imageFormatBytes);
+
+        assertTrue(imageFormatBytes == imageFormatFile);
+    }
+
+    public void checkGetICCProfileBytes(File imageFile, byte[] imageFileBytes)
+            throws IOException, ImageReadException
+    {
+        // check guessFormat()
+        byte iccBytesFile[] = Sanselan.getICCProfileBytes(imageFile);
+
+        byte iccBytesBytes[] = Sanselan.getICCProfileBytes(imageFileBytes);
+
+        assertTrue((iccBytesFile != null) == (iccBytesBytes != null));
+
+        if (iccBytesFile == null)
+            return;
+
+        compareByteArrays(iccBytesFile, iccBytesBytes);
+    }
+
+    public void checkGetImageInfo(File imageFile, byte[] imageFileBytes)
+            throws IOException, ImageReadException, IllegalAccessException,
+            IllegalArgumentException, InvocationTargetException
+    {
+        Map params = new HashMap();
+        boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
+        ImageFormat imageFormat = Sanselan.guessFormat(imageFile);
+        if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_TIFF)
+                || imageFormat.equals(ImageFormat.IMAGE_FORMAT_JPEG))
+            params
+                    .put(PARAM_KEY_READ_THUMBNAILS, new Boolean(
+                            !ignoreImageData));
+
+        ImageInfo imageInfoFile = Sanselan.getImageInfo(imageFile, params);
+
+        ImageInfo imageInfoBytes = Sanselan
+                .getImageInfo(imageFileBytes, params);
+
+        assertNotNull(imageInfoFile);
+        assertNotNull(imageInfoBytes);
+
+        Method methods[] = ImageInfo.class.getMethods();
+        for (int i = 0; i < methods.length; i++)
+        {
+            Method method = methods[i];
+            method.getModifiers();
+            if (!Modifier.isPublic(method.getModifiers()))
+                continue;
+            if (!method.getName().startsWith("get"))
+                continue;
+            if (method.getName().equals("getClass"))
+                continue;
+            // if (method.getGenericParameterTypes().length > 0)
+            // continue;
+
+            Object valueFile = method.invoke(imageInfoFile, null);
+            Object valueBytes = method.invoke(imageInfoBytes, null);
+
+            assertTrue(valueFile.equals(valueBytes));
+        }
+
+        // only have to test values from imageInfoFile; we already know values
+        // match.
+        assertTrue(imageInfoFile.getBitsPerPixel() > 0);
+
+        assertNotNull(imageInfoFile.getFormat());
+        assertTrue(imageInfoFile.getFormat() != ImageFormat.IMAGE_FORMAT_UNKNOWN);
+
+        assertNotNull(imageInfoFile.getFormatName());
+
+        assertTrue(imageInfoFile.getWidth() > 0);
+        assertTrue(imageInfoFile.getHeight() > 0);
 
-		assertNotNull(imageInfoFile.getMimeType());
+        assertNotNull(imageInfoFile.getMimeType());
 
-		// TODO: not all adapters count images yet.
-		// assertTrue(imageInfoFile.getNumberOfImages() > 0);
+        // TODO: not all adapters count images yet.
+        // assertTrue(imageInfoFile.getNumberOfImages() > 0);
 
-	}
+    }
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/common/byteSources/ByteSourceTest.java Fri Sep 10 01:35:50 2010
@@ -28,46 +28,46 @@ import org.apache.sanselan.SanselanTest;
 
 public abstract class ByteSourceTest extends SanselanTest
 {
-	protected File createTempFile(byte src[]) throws IOException
-	{
-		File file = createTempFile("raw_", ".bin");
-
-		// write test bytes to file.
-		OutputStream os = new FileOutputStream(file);
-		os = new BufferedOutputStream(os);
-		os.write(src);
-		os.close();
-
-		// test that all bytes written to file.
-		assertTrue(src.length == file.length());
-
-		return file;
-	}
-
-	protected byte[][] getTestByteArrays()
-	{
-		byte emptyArray[] = (new byte[0]);
-
-		byte single[] = new byte[1];
-		for (int i = 0; i < single.length; i++)
-			single[i] = (byte) i;
-
-		byte simple[] = new byte[256];
-		for (int i = 0; i < simple.length; i++)
-			simple[i] = (byte) i;
-
-		byte zeroes[] = new byte[256];
-		for (int i = 0; i < zeroes.length; i++)
-			zeroes[i] = 0;
-
-		ByteArrayOutputStream baos = new ByteArrayOutputStream();
-		for (int i = 0; i < 256 * 256; i++)
-		{
-			baos.write(0xff & i);
-			baos.write(0xff & (i >> 8));
-		}
-		byte longArray[] = (baos.toByteArray());
+    protected File createTempFile(byte src[]) throws IOException
+    {
+        File file = createTempFile("raw_", ".bin");
+
+        // write test bytes to file.
+        OutputStream os = new FileOutputStream(file);
+        os = new BufferedOutputStream(os);
+        os.write(src);
+        os.close();
+
+        // test that all bytes written to file.
+        assertTrue(src.length == file.length());
+
+        return file;
+    }
+
+    protected byte[][] getTestByteArrays()
+    {
+        byte emptyArray[] = (new byte[0]);
+
+        byte single[] = new byte[1];
+        for (int i = 0; i < single.length; i++)
+            single[i] = (byte) i;
+
+        byte simple[] = new byte[256];
+        for (int i = 0; i < simple.length; i++)
+            simple[i] = (byte) i;
+
+        byte zeroes[] = new byte[256];
+        for (int i = 0; i < zeroes.length; i++)
+            zeroes[i] = 0;
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        for (int i = 0; i < 256 * 256; i++)
+        {
+            baos.write(0xff & i);
+            baos.write(0xff & (i >> 8));
+        }
+        byte longArray[] = (baos.toByteArray());
 
-		return new byte[][] { emptyArray, single, simple, zeroes, longArray, };
-	}
+        return new byte[][] { emptyArray, single, simple, zeroes, longArray, };
+    }
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpBaseTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpBaseTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpBaseTest.java Fri Sep 10 01:35:50 2010
@@ -29,24 +29,24 @@ import org.apache.sanselan.SanselanTest;
 public abstract class BmpBaseTest extends SanselanTest
 {
 
-	private static boolean isBmp(File file) throws IOException,
-			ImageReadException
-	{
-		ImageFormat format = Sanselan.guessFormat(file);
-		return format == ImageFormat.IMAGE_FORMAT_BMP;
-	}
+    private static boolean isBmp(File file) throws IOException,
+            ImageReadException
+    {
+        ImageFormat format = Sanselan.guessFormat(file);
+        return format == ImageFormat.IMAGE_FORMAT_BMP;
+    }
 
-	private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
-		public boolean accept(File file) throws IOException, ImageReadException
-		{
-			return isBmp(file);
-		}
-	};
+    private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
+        public boolean accept(File file) throws IOException, ImageReadException
+        {
+            return isBmp(file);
+        }
+    };
 
-	protected List getBmpImages() throws IOException, ImageReadException
-	{
-		return getTestImages(IMAGE_FILTER);
-	}
+    protected List getBmpImages() throws IOException, ImageReadException
+    {
+        return getTestImages(IMAGE_FILTER);
+    }
 
 
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpReadTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpReadTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpReadTest.java Fri Sep 10 01:35:50 2010
@@ -33,30 +33,30 @@ import org.apache.sanselan.util.Debug;
 public class BmpReadTest extends BmpBaseTest
 {
 
-	public void test() throws IOException, ImageReadException
-	{
-		Debug.debug("start");
-
-		List images = getBmpImages();
-		for (int i = 0; i < images.size(); i++)
-		{
-			if (i % 10 == 0)
-				Debug.purgeMemory();
-
-			File imageFile = (File) images.get(i);
-			Debug.debug("imageFile", imageFile);
-
-			IImageMetadata metadata = Sanselan.getMetadata(imageFile);
-			// assertNotNull(metadata);
-
-			Map params = new HashMap();
-//			params.put(PARAM_KEY_VERBOSE, Boolean.TRUE);
-			ImageInfo imageInfo = Sanselan.getImageInfo(imageFile, params);
-			assertNotNull(imageInfo);
-
-			BufferedImage image = Sanselan.getBufferedImage(imageFile);
-			assertNotNull(image);
-		}
-	}
+    public void test() throws IOException, ImageReadException
+    {
+        Debug.debug("start");
+
+        List images = getBmpImages();
+        for (int i = 0; i < images.size(); i++)
+        {
+            if (i % 10 == 0)
+                Debug.purgeMemory();
+
+            File imageFile = (File) images.get(i);
+            Debug.debug("imageFile", imageFile);
+
+            IImageMetadata metadata = Sanselan.getMetadata(imageFile);
+            // assertNotNull(metadata);
+
+            Map params = new HashMap();
+//            params.put(PARAM_KEY_VERBOSE, Boolean.TRUE);
+            ImageInfo imageInfo = Sanselan.getImageInfo(imageFile, params);
+            assertNotNull(imageInfo);
+
+            BufferedImage image = Sanselan.getBufferedImage(imageFile);
+            assertNotNull(image);
+        }
+    }
 
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpRoundtripTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpRoundtripTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpRoundtripTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/bmp/BmpRoundtripTest.java Fri Sep 10 01:35:50 2010
@@ -34,173 +34,173 @@ import org.apache.sanselan.util.IOUtils;
 public class BmpRoundtripTest extends BmpBaseTest
 {
 
-	private int[][] getSimpleRawData(int width, int height, int value)
-	{
-		int[][] result = new int[height][width];
-		for (int y = 0; y < height; y++)
-			for (int x = 0; x < width; x++)
-				result[y][x] = value;
-		return result;
-	}
-
-	private int[][] getAscendingRawData(int width, int height)
-	{
-		int[][] result = new int[height][width];
-		for (int y = 0; y < height; y++)
-			for (int x = 0; x < width; x++)
-			{
-				int alpha = (x + y) % 256;
-				int value = (x + y) % 256;
-				int argb = (0xff & alpha) << 24 | (0xff & value) << 16
-						| (0xff & value) << 8 | (0xff & value) << 0;
-
-				result[y][x] = argb;
-			}
-		return result;
-	}
-
-	private int[][] randomRawData(int width, int height)
-	{
-		Random random = new Random();
-		int[][] result = new int[height][width];
-		for (int y = 0; y < height; y++)
-			for (int x = 0; x < width; x++)
-			{
-				int argb = random.nextInt();
-				result[y][x] = argb;
-			}
-		return result;
-	}
-
-	 public void testSmallBlackPixels() throws IOException,
-	 ImageReadException,
-	 ImageWriteException
-	 {
-	 int[][] smallBlackPixels = getSimpleRawData(256, 256, 0);
-	 writeAndReadImageData(smallBlackPixels);
-	 }
-	
-	public void testSingleBlackPixel() throws IOException, ImageReadException,
-			ImageWriteException
-	{
-		int[][] singleBlackPixel = getSimpleRawData(1, 1, 0);
-		writeAndReadImageData(singleBlackPixel);
-	}
-
-	
-	 public void testSmallRedPixels() throws IOException, ImageReadException,
-	 ImageWriteException
-	 {
-	 int[][] smallRedPixels = getSimpleRawData(256, 256, 0xffff0000);
-	 writeAndReadImageData(smallRedPixels);
-	 }
-	
-	 public void testSingleRedPixel() throws IOException, ImageReadException,
-	 ImageWriteException
-	 {
-	 int[][] singleRedPixel = getSimpleRawData(1, 1, 0xffff0000);
-	 writeAndReadImageData(singleRedPixel);
-	 }
-	
-	 public void testSmallAscendingPixels() throws IOException,
-	 ImageReadException, ImageWriteException
-	 {
-	 int[][] smallAscendingPixels = getAscendingRawData(256, 256);
-	 writeAndReadImageData(smallAscendingPixels);
-	 }
-	
-	 public void testSmallRandomPixels() throws IOException,
-	 ImageReadException,
-	 ImageWriteException
-	 {
-	 int[][] smallRandomPixels = randomRawData(256, 256);
-	 writeAndReadImageData(smallRandomPixels);
-	 }
-
-	private BufferedImage imageDataToBufferedImage(int[][] rawData)
-	{
-		int width = rawData[0].length;
-		int height = rawData.length;
-		BufferedImage image = new BufferedImage(width, height,
-				BufferedImage.TYPE_INT_ARGB);
-		for (int y = 0; y < height; y++)
-			for (int x = 0; x < width; x++)
-			{
-				image.setRGB(x, y, rawData[y][x]);
-			}
-		return image;
-	}
-
-	private int[][] bufferedImageToImageData(BufferedImage image)
-	{
-		int width = image.getWidth();
-		int height = image.getHeight();
-		int[][] result = new int[height][width];
-
-		for (int y = 0; y < height; y++)
-			for (int x = 0; x < width; x++)
-			{
-				result[y][x] = image.getRGB(x, y);
-			}
-		return result;
-	}
-
-	private void writeAndReadImageData(int[][] rawData) throws IOException,
-			ImageReadException, ImageWriteException
-	{
-		BufferedImage srcImage = imageDataToBufferedImage(rawData);
-
-		Map writeParams = new HashMap();
-		// writeParams.put(SanselanConstants.PARAM_KEY_FORMAT,
-		// ImageFormat.IMAGE_FORMAT_BMP);
-		// writeParams.put(PngConstants.PARAM_KEY_BMP_FORCE_TRUE_COLOR,
-		// Boolean.TRUE);
-
-		byte bytes[] = Sanselan.writeImageToBytes(srcImage,
-				ImageFormat.IMAGE_FORMAT_BMP, writeParams);
-
-		// Debug.debug("bytes", bytes);
-
-		File tempFile = createTempFile("temp", ".bmp");
-		IOUtils.writeToFile(bytes, tempFile);
-
-		BufferedImage dstImage = Sanselan.getBufferedImage(bytes);
-
-		assertNotNull(dstImage);
-		assertTrue(srcImage.getWidth() == dstImage.getWidth());
-		assertTrue(srcImage.getHeight() == dstImage.getHeight());
-
-		int dstData[][] = bufferedImageToImageData(dstImage);
-		compare(rawData, dstData);
-	}
-
-	private void compare(int[][] a, int[][] b)
-	{
-		assertNotNull(a);
-		assertNotNull(b);
-		assertTrue(a.length == b.length);
-
-		for (int y = 0; y < a.length; y++)
-		{
-			assertTrue(a[y].length == b[y].length);
-			// make sure row lengths consistent.
-			assertTrue(a[0].length == b[y].length);
-			for (int x = 0; x < a[y].length; x++)
-			{
-				// ignore alpha channel - BMP has no transparency.
-				int rgbA = 0xffffff & a[y][x];
-				int rgbB = 0xffffff & b[y][x];
-
-				if (rgbA != rgbB)
-				{
-					Debug.debug("x: " + x + ", y: " + y + ", rgbA: " + rgbA
-							+ " (0x" + Integer.toHexString(rgbA) + ")"
-							+ ", rgbB: " + rgbB + " (0x"
-							+ Integer.toHexString(rgbB) + ")");
-				}
-				assertTrue(rgbA == rgbB);
-			}
-		}
-	}
+    private int[][] getSimpleRawData(int width, int height, int value)
+    {
+        int[][] result = new int[height][width];
+        for (int y = 0; y < height; y++)
+            for (int x = 0; x < width; x++)
+                result[y][x] = value;
+        return result;
+    }
+
+    private int[][] getAscendingRawData(int width, int height)
+    {
+        int[][] result = new int[height][width];
+        for (int y = 0; y < height; y++)
+            for (int x = 0; x < width; x++)
+            {
+                int alpha = (x + y) % 256;
+                int value = (x + y) % 256;
+                int argb = (0xff & alpha) << 24 | (0xff & value) << 16
+                        | (0xff & value) << 8 | (0xff & value) << 0;
+
+                result[y][x] = argb;
+            }
+        return result;
+    }
+
+    private int[][] randomRawData(int width, int height)
+    {
+        Random random = new Random();
+        int[][] result = new int[height][width];
+        for (int y = 0; y < height; y++)
+            for (int x = 0; x < width; x++)
+            {
+                int argb = random.nextInt();
+                result[y][x] = argb;
+            }
+        return result;
+    }
+
+     public void testSmallBlackPixels() throws IOException,
+     ImageReadException,
+     ImageWriteException
+     {
+     int[][] smallBlackPixels = getSimpleRawData(256, 256, 0);
+     writeAndReadImageData(smallBlackPixels);
+     }
+
+    public void testSingleBlackPixel() throws IOException, ImageReadException,
+            ImageWriteException
+    {
+        int[][] singleBlackPixel = getSimpleRawData(1, 1, 0);
+        writeAndReadImageData(singleBlackPixel);
+    }
+
+
+     public void testSmallRedPixels() throws IOException, ImageReadException,
+     ImageWriteException
+     {
+     int[][] smallRedPixels = getSimpleRawData(256, 256, 0xffff0000);
+     writeAndReadImageData(smallRedPixels);
+     }
+
+     public void testSingleRedPixel() throws IOException, ImageReadException,
+     ImageWriteException
+     {
+     int[][] singleRedPixel = getSimpleRawData(1, 1, 0xffff0000);
+     writeAndReadImageData(singleRedPixel);
+     }
+
+     public void testSmallAscendingPixels() throws IOException,
+     ImageReadException, ImageWriteException
+     {
+     int[][] smallAscendingPixels = getAscendingRawData(256, 256);
+     writeAndReadImageData(smallAscendingPixels);
+     }
+
+     public void testSmallRandomPixels() throws IOException,
+     ImageReadException,
+     ImageWriteException
+     {
+     int[][] smallRandomPixels = randomRawData(256, 256);
+     writeAndReadImageData(smallRandomPixels);
+     }
+
+    private BufferedImage imageDataToBufferedImage(int[][] rawData)
+    {
+        int width = rawData[0].length;
+        int height = rawData.length;
+        BufferedImage image = new BufferedImage(width, height,
+                BufferedImage.TYPE_INT_ARGB);
+        for (int y = 0; y < height; y++)
+            for (int x = 0; x < width; x++)
+            {
+                image.setRGB(x, y, rawData[y][x]);
+            }
+        return image;
+    }
+
+    private int[][] bufferedImageToImageData(BufferedImage image)
+    {
+        int width = image.getWidth();
+        int height = image.getHeight();
+        int[][] result = new int[height][width];
+
+        for (int y = 0; y < height; y++)
+            for (int x = 0; x < width; x++)
+            {
+                result[y][x] = image.getRGB(x, y);
+            }
+        return result;
+    }
+
+    private void writeAndReadImageData(int[][] rawData) throws IOException,
+            ImageReadException, ImageWriteException
+    {
+        BufferedImage srcImage = imageDataToBufferedImage(rawData);
+
+        Map writeParams = new HashMap();
+        // writeParams.put(SanselanConstants.PARAM_KEY_FORMAT,
+        // ImageFormat.IMAGE_FORMAT_BMP);
+        // writeParams.put(PngConstants.PARAM_KEY_BMP_FORCE_TRUE_COLOR,
+        // Boolean.TRUE);
+
+        byte bytes[] = Sanselan.writeImageToBytes(srcImage,
+                ImageFormat.IMAGE_FORMAT_BMP, writeParams);
+
+        // Debug.debug("bytes", bytes);
+
+        File tempFile = createTempFile("temp", ".bmp");
+        IOUtils.writeToFile(bytes, tempFile);
+
+        BufferedImage dstImage = Sanselan.getBufferedImage(bytes);
+
+        assertNotNull(dstImage);
+        assertTrue(srcImage.getWidth() == dstImage.getWidth());
+        assertTrue(srcImage.getHeight() == dstImage.getHeight());
+
+        int dstData[][] = bufferedImageToImageData(dstImage);
+        compare(rawData, dstData);
+    }
+
+    private void compare(int[][] a, int[][] b)
+    {
+        assertNotNull(a);
+        assertNotNull(b);
+        assertTrue(a.length == b.length);
+
+        for (int y = 0; y < a.length; y++)
+        {
+            assertTrue(a[y].length == b[y].length);
+            // make sure row lengths consistent.
+            assertTrue(a[0].length == b[y].length);
+            for (int x = 0; x < a[y].length; x++)
+            {
+                // ignore alpha channel - BMP has no transparency.
+                int rgbA = 0xffffff & a[y][x];
+                int rgbB = 0xffffff & b[y][x];
+
+                if (rgbA != rgbB)
+                {
+                    Debug.debug("x: " + x + ", y: " + y + ", rgbA: " + rgbA
+                            + " (0x" + Integer.toHexString(rgbA) + ")"
+                            + ", rgbB: " + rgbB + " (0x"
+                            + Integer.toHexString(rgbB) + ")");
+                }
+                assertTrue(rgbA == rgbB);
+            }
+        }
+    }
 
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifBaseTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifBaseTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifBaseTest.java Fri Sep 10 01:35:50 2010
@@ -29,23 +29,23 @@ import org.apache.sanselan.SanselanTest;
 public abstract class GifBaseTest extends SanselanTest
 {
 
-	private static boolean isGif(File file) throws IOException,
-			ImageReadException
-	{
-		ImageFormat format = Sanselan.guessFormat(file);
-		return format == ImageFormat.IMAGE_FORMAT_GIF;
-	}
+    private static boolean isGif(File file) throws IOException,
+            ImageReadException
+    {
+        ImageFormat format = Sanselan.guessFormat(file);
+        return format == ImageFormat.IMAGE_FORMAT_GIF;
+    }
 
-	private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
-		public boolean accept(File file) throws IOException, ImageReadException
-		{
-			return isGif(file);
-		}
-	};
+    private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
+        public boolean accept(File file) throws IOException, ImageReadException
+        {
+            return isGif(file);
+        }
+    };
 
-	protected List getGifImages() throws IOException, ImageReadException
-	{
-		return getTestImages(IMAGE_FILTER);
-	}
+    protected List getGifImages() throws IOException, ImageReadException
+    {
+        return getTestImages(IMAGE_FILTER);
+    }
 
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifReadTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifReadTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/gif/GifReadTest.java Fri Sep 10 01:35:50 2010
@@ -31,28 +31,28 @@ import org.apache.sanselan.util.Debug;
 public class GifReadTest extends GifBaseTest
 {
 
-	public void test() throws IOException, ImageReadException
-	{
-		Debug.debug("start");
-
-		List images = getGifImages();
-		for (int i = 0; i < images.size(); i++)
-		{
-			if (i % 10 == 0)
-				Debug.purgeMemory();
-
-			File imageFile = (File) images.get(i);
-			Debug.debug("imageFile", imageFile);
-
-			IImageMetadata metadata = Sanselan.getMetadata(imageFile);
-//			assertNotNull(metadata);
-
-			ImageInfo imageInfo = Sanselan.getImageInfo(imageFile);
-			assertNotNull(imageInfo);
-
-			BufferedImage image = Sanselan.getBufferedImage(imageFile);
-			assertNotNull(image);
-		}
-	}
+    public void test() throws IOException, ImageReadException
+    {
+        Debug.debug("start");
+
+        List images = getGifImages();
+        for (int i = 0; i < images.size(); i++)
+        {
+            if (i % 10 == 0)
+                Debug.purgeMemory();
+
+            File imageFile = (File) images.get(i);
+            Debug.debug("imageFile", imageFile);
+
+            IImageMetadata metadata = Sanselan.getMetadata(imageFile);
+//            assertNotNull(metadata);
+
+            ImageInfo imageInfo = Sanselan.getImageInfo(imageFile);
+            assertNotNull(imageInfo);
+
+            BufferedImage image = Sanselan.getBufferedImage(imageFile);
+            assertNotNull(image);
+        }
+    }
 
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoBaseTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoBaseTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoBaseTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoBaseTest.java Fri Sep 10 01:35:50 2010
@@ -27,23 +27,23 @@ import org.apache.sanselan.SanselanTest;
 public abstract class IcoBaseTest extends SanselanTest
 {
 
-	private static boolean isIco(File file)
-	{
-		return file.getName().toLowerCase().endsWith(".ico") ||
-			file.getName().toLowerCase().endsWith(".cur");
-	}
+    private static boolean isIco(File file)
+    {
+        return file.getName().toLowerCase().endsWith(".ico") ||
+            file.getName().toLowerCase().endsWith(".cur");
+    }
 
-	private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
-		public boolean accept(File file) throws IOException, ImageReadException
-		{
-			return isIco(file);
-		}
-	};
+    private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
+        public boolean accept(File file) throws IOException, ImageReadException
+        {
+            return isIco(file);
+        }
+    };
 
-	protected List getIcoImages() throws IOException, ImageReadException
-	{
-		return getTestImages(IMAGE_FILTER);
-	}
+    protected List getIcoImages() throws IOException, ImageReadException
+    {
+        return getTestImages(IMAGE_FILTER);
+    }
 
 
 }

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoReadTest.java?rev=995634&r1=995633&r2=995634&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoReadTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/ico/IcoReadTest.java Fri Sep 10 01:35:50 2010
@@ -33,29 +33,29 @@ import org.apache.sanselan.util.Debug;
 public class IcoReadTest extends IcoBaseTest
 {
 
-	public void test() throws IOException, ImageReadException
-	{
-		Debug.debug("start");
-
-		List images = getIcoImages();
-		for (int i = 0; i < images.size(); i++)
-		{
-			if (i % 10 == 0)
-				Debug.purgeMemory();
-
-			File imageFile = (File) images.get(i);
-			Debug.debug("imageFile", imageFile);
-
-			IImageMetadata metadata = Sanselan.getMetadata(imageFile);
-			// assertNotNull(metadata);
-
-			Map params = new HashMap();
-			ImageInfo imageInfo = Sanselan.getImageInfo(imageFile, params);
-			// assertNotNull(imageInfo);
-
-			BufferedImage image = Sanselan.getBufferedImage(imageFile);
-			assertNotNull(image);
-		}
-	}
+    public void test() throws IOException, ImageReadException
+    {
+        Debug.debug("start");
+
+        List images = getIcoImages();
+        for (int i = 0; i < images.size(); i++)
+        {
+            if (i % 10 == 0)
+                Debug.purgeMemory();
+
+            File imageFile = (File) images.get(i);
+            Debug.debug("imageFile", imageFile);
+
+            IImageMetadata metadata = Sanselan.getMetadata(imageFile);
+            // assertNotNull(metadata);
+
+            Map params = new HashMap();
+            ImageInfo imageInfo = Sanselan.getImageInfo(imageFile, params);
+            // assertNotNull(imageInfo);
+
+            BufferedImage image = Sanselan.getBufferedImage(imageFile);
+            assertNotNull(image);
+        }
+    }
 
 }



Mime
View raw message