You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by cm...@apache.org on 2009/09/12 19:41:54 UTC
svn commit: r814209 - in /commons/proper/sanselan/trunk/src:
main/java/org/apache/sanselan/ test/java/org/apache/sanselan/
test/java/org/apache/sanselan/common/byteSources/
test/java/org/apache/sanselan/formats/png/
Author: cmchen
Date: Sat Sep 12 17:41:53 2009
New Revision: 814209
URL: http://svn.apache.org/viewvc?rev=814209&view=rev
Log:
* Fixed a couple of platform-dependent paths in the tests.
* Constant-ized the magic numbers used when guessing formats.
* Added a test for the format guessing.
Added:
commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java (with props)
commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java (with props)
Modified:
commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/Sanselan.java
commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTest.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/formats/png/PngMultipleRoundtripTest.java
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/Sanselan.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/Sanselan.java?rev=814209&r1=814208&r2=814209&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/Sanselan.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/Sanselan.java Sat Sep 12 17:41:53 2009
@@ -134,6 +134,29 @@
return guessFormat(new ByteSourceFile(file));
}
+ private static final int[] MAGIC_NUMBERS_GIF = { 0x47, 0x49, };
+ private static final int[] MAGIC_NUMBERS_PNG = { 0x89, 0x50, };
+ private static final int[] MAGIC_NUMBERS_JPEG = { 0xff, 0xd8, };
+ private static final int[] MAGIC_NUMBERS_BMP = { 0x42, 0x4d, };
+ private static final int[] MAGIC_NUMBERS_TIFF_MOTOROLA = { 0x4D, 0x4D, };
+ private static final int[] MAGIC_NUMBERS_TIFF_INTEL = { 0x49, 0x49, };
+ private static final int[] MAGIC_NUMBERS_PSD = { 0x38, 0x42, };
+ private static final int[] MAGIC_NUMBERS_PBM_A = { 0x50, 0x31, };
+ private static final int[] MAGIC_NUMBERS_PBM_B = { 0x50, 0x34, };
+ private static final int[] MAGIC_NUMBERS_PGM_A = { 0x50, 0x32, };
+ private static final int[] MAGIC_NUMBERS_PGM_B = { 0x50, 0x35, };
+ private static final int[] MAGIC_NUMBERS_PPM_A = { 0x50, 0x33, };
+ private static final int[] MAGIC_NUMBERS_PPM_B = { 0x50, 0x36, };
+ private static final int[] MAGIC_NUMBERS_JBIG2_1 = { 0x97, 0x4A, };
+ private static final int[] MAGIC_NUMBERS_JBIG2_2 = { 0x42, 0x32, };
+
+ private static boolean compareBytePair(int[] a, int b[]) {
+ if (a.length != 2 && b.length != 2) {
+ throw new RuntimeException("Invalid Byte Pair.");
+ }
+ return (a[0] == b[0]) && (a[1] == b[1]);
+ }
+
public static ImageFormat guessFormat(ByteSource byteSource)
throws ImageReadException, IOException {
InputStream is = null;
@@ -149,42 +172,40 @@
int b1 = i1 & 0xff;
int b2 = i2 & 0xff;
+ int bytePair[] = { b1, b2, };
- if (b1 == 0x47 && b2 == 0x49) {
+ if (compareBytePair(MAGIC_NUMBERS_GIF, bytePair)) {
return ImageFormat.IMAGE_FORMAT_GIF;
}
- // else if (b1 == 0x00 && b2 == 0x00) // too similar to tga
+ // else if (b1 == 0x00 && b2 == 0x00) // too similar to TGA
// {
// return ImageFormat.IMAGE_FORMAT_ICO;
// }
- else if (b1 == 0x89 && b2 == 0x50) {
+ else if (compareBytePair(MAGIC_NUMBERS_PNG, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PNG;
- } else if (b1 == 0xff && b2 == 0xd8) {
+ } else if (compareBytePair(MAGIC_NUMBERS_JPEG, bytePair)) {
return ImageFormat.IMAGE_FORMAT_JPEG;
- } else if (b1 == 0x42 && b2 == 0x4d) {
+ } else if (compareBytePair(MAGIC_NUMBERS_BMP, bytePair)) {
return ImageFormat.IMAGE_FORMAT_BMP;
- } else if (b1 == 0x4D && b2 == 0x4D) // Motorola byte order TIFF
- {
+ } else if (compareBytePair(MAGIC_NUMBERS_TIFF_MOTOROLA, bytePair)) {
return ImageFormat.IMAGE_FORMAT_TIFF;
- } else if (b1 == 0x49 && b2 == 0x49) // Intel byte order TIFF
- {
+ } else if (compareBytePair(MAGIC_NUMBERS_TIFF_INTEL, bytePair)) {
return ImageFormat.IMAGE_FORMAT_TIFF;
- } else if (b1 == 0x38 && b2 == 0x42) {
+ } else if (compareBytePair(MAGIC_NUMBERS_PSD, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PSD;
- } else if (b1 == 0x50 && b2 == 0x31) {
+ } else if (compareBytePair(MAGIC_NUMBERS_PBM_A, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PBM;
- } else if (b1 == 0x50 && b2 == 0x34) {
+ } else if (compareBytePair(MAGIC_NUMBERS_PBM_B, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PBM;
- } else if (b1 == 0x50 && b2 == 0x32) {
+ } else if (compareBytePair(MAGIC_NUMBERS_PGM_A, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PGM;
- } else if (b1 == 0x50 && b2 == 0x35) {
+ } else if (compareBytePair(MAGIC_NUMBERS_PGM_B, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PGM;
- } else if (b1 == 0x50 && b2 == 0x33) {
+ } else if (compareBytePair(MAGIC_NUMBERS_PPM_A, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PPM;
- } else if (b1 == 0x50 && b2 == 0x36) {
+ } else if (compareBytePair(MAGIC_NUMBERS_PPM_B, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PPM;
- } else if (b1 == 0x97 && b2 == 0x4A) {
-
+ } else if (compareBytePair(MAGIC_NUMBERS_JBIG2_1, bytePair)) {
int i3 = is.read();
int i4 = is.read();
if ((i3 < 0) || (i4 < 0))
@@ -193,9 +214,10 @@
int b3 = i3 & 0xff;
int b4 = i4 & 0xff;
-
- if (b3 == 0x42 && b4 == 0x32)
+ int bytePair2[] = { b3, b4, };
+ if (compareBytePair(MAGIC_NUMBERS_JBIG2_2, bytePair2)) {
return ImageFormat.IMAGE_FORMAT_JBIG2;
+ }
}
return ImageFormat.IMAGE_FORMAT_UNKNOWN;
@@ -623,7 +645,6 @@
throw new ImageReadException("Can't parse this format.");
}
-
/**
* Determines the width and height of an image.
* <p>
@@ -718,7 +739,6 @@
return imageParser.getImageSize(byteSource, params);
}
-
/**
* Determines the width and height of an image.
@@ -728,7 +748,7 @@
* InputStream from which to read image data.
* @param filename
* Filename associated with image data (optional).
- * @return Xmp Xml as String, if present. Otherwise, returns null.
+ * @return Xmp Xml as String, if present. Otherwise, returns null.
*/
public static String getXmpXml(InputStream is, String filename)
throws ImageReadException, IOException {
@@ -745,10 +765,10 @@
* Filename associated with image data (optional).
* @param params
* Map of optional parameters, defined in SanselanConstants.
- * @return Xmp Xml as String, if present. Otherwise, returns null.
+ * @return Xmp Xml as String, if present. Otherwise, returns null.
*/
- public static String getXmpXml(InputStream is, String filename,
- Map params) throws ImageReadException, IOException {
+ public static String getXmpXml(InputStream is, String filename, Map params)
+ throws ImageReadException, IOException {
return getXmpXml(new ByteSourceInputStream(is, filename), params);
}
@@ -758,10 +778,10 @@
*
* @param bytes
* Byte array containing an image file.
- * @return Xmp Xml as String, if present. Otherwise, returns null.
+ * @return Xmp Xml as String, if present. Otherwise, returns null.
*/
- public static String getXmpXml(byte bytes[])
- throws ImageReadException, IOException {
+ public static String getXmpXml(byte bytes[]) throws ImageReadException,
+ IOException {
return getXmpXml(bytes, null);
}
@@ -773,7 +793,7 @@
* Byte array containing an image file.
* @param params
* Map of optional parameters, defined in SanselanConstants.
- * @return Xmp Xml as String, if present. Otherwise, returns null.
+ * @return Xmp Xml as String, if present. Otherwise, returns null.
*/
public static String getXmpXml(byte bytes[], Map params)
throws ImageReadException, IOException {
@@ -786,7 +806,7 @@
*
* @param file
* File containing image data.
- * @return Xmp Xml as String, if present. Otherwise, returns null.
+ * @return Xmp Xml as String, if present. Otherwise, returns null.
*/
public static String getXmpXml(File file) throws ImageReadException,
IOException {
@@ -801,7 +821,7 @@
* File containing image data.
* @param params
* Map of optional parameters, defined in SanselanConstants.
- * @return Xmp Xml as String, if present. Otherwise, returns null.
+ * @return Xmp Xml as String, if present. Otherwise, returns null.
*/
public static String getXmpXml(File file, Map params)
throws ImageReadException, IOException {
@@ -816,7 +836,7 @@
* File containing image data.
* @param params
* Map of optional parameters, defined in SanselanConstants.
- * @return Xmp Xml as String, if present. Otherwise, returns null.
+ * @return Xmp Xml as String, if present. Otherwise, returns null.
*/
public static String getXmpXml(ByteSource byteSource, Map params)
throws ImageReadException, IOException {
Added: 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=814209&view=auto
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java (added)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java Sat Sep 12 17:41:53 2009
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sanselan;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.sanselan.util.Debug;
+
+public class SanselanGuessFormatTest extends SanselanTest {
+
+ public static final File BMP_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "bmp\\1\\Oregon Scientific DS6639 - DSC_0307 - small.bmp".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File PNG_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "png\\1\\Oregon Scientific DS6639 - DSC_0307 - small.png".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File GIF_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "gif\\1\\Oregon Scientific DS6639 - DSC_0307 - small.gif".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File ICO_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "ico\\1\\Oregon Scientific DS6639 - DSC_0307 - small.ico".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File TIFF_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "tiff\\1\\Oregon Scientific DS6639 - DSC_0307 - small.tif".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File JPEG_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "jpg\\1\\Oregon Scientific DS6639 - DSC_0307 - small.jpg".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File PSD_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "psd\\1\\Oregon Scientific DS6639 - DSC_0307 - small.psd".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File PBM_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.pbm".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File PGM_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.pgm".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File PPM_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "pxm\\1\\Oregon Scientific DS6639 - DSC_0307 - small.ppm".replace(
+ "\\", System.getProperty("file.separator")));
+ public static final File TGA_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "tga\\1\\Oregon Scientific DS6639 - DSC_0307 - small.tga".replace(
+ "\\", System.getProperty("file.separator")));
+
+ public void testGuess_all() throws IOException, ImageReadException,
+ ImageWriteException {
+ 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 File UNKNOWN_IMAGE_FILE = new File(TEST_IMAGE_FOLDER,
+ "jpg\\1\\info.txt".replace("\\", System
+ .getProperty("file.separator")));
+
+ public void testGuess_unknown() throws IOException, ImageReadException,
+ ImageWriteException {
+ testGuess(ImageFormat.IMAGE_FORMAT_UNKNOWN, UNKNOWN_IMAGE_FILE);
+ }
+
+ public void testGuess(ImageFormat expectedFormat, File imageFile)
+ throws IOException, ImageReadException, ImageWriteException {
+ assertTrue(imageFile.exists());
+ assertTrue(imageFile.isFile());
+ ImageFormat guessedFormat = Sanselan.guessFormat(imageFile);
+ assertNotNull(guessedFormat);
+ assertEquals(guessedFormat, expectedFormat);
+ }
+}
Propchange: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanGuessFormatTest.java
------------------------------------------------------------------------------
svn:eol-style = native
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=814209&r1=814208&r2=814209&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 Sat Sep 12 17:41:53 2009
@@ -28,12 +28,10 @@
import org.apache.sanselan.util.Debug;
public abstract class SanselanTest extends TestCase implements
- SanselanConstants
-{
+ SanselanTestConstants, SanselanConstants {
protected File createTempFile(String prefix, String suffix)
- throws IOException
- {
+ throws IOException {
File tempFolder = new File("tmp");
if (!tempFolder.exists())
tempFolder.mkdirs();
@@ -44,32 +42,24 @@
return result;
}
- public void compareByteArrays(byte a[], byte b[])
- {
+ 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
- {
+ protected void purgeMemory() {
+ try {
System.gc();
Thread.sleep(50);
System.runFinalization();
Thread.sleep(50);
- } catch (Exception e)
- {
+ } catch (Exception e) {
Debug.debug(e);
}
}
- private static final File PHIL_HARVEY_TEST_IMAGE_FOLDER = new File(
- "src\\test\\data\\images\\exif\\philHarvey\\");
-
- protected boolean isPhilHarveyTestImage(File file)
- {
+ protected boolean isPhilHarveyTestImage(File file) {
// Debug.debug("isPhilHarveyTestImage file", file.getAbsolutePath());
// Debug.debug("isPhilHarveyTestImage folder",
// PHIL_HARVEY_TEST_IMAGE_FOLDER.getAbsolutePath());
@@ -77,19 +67,16 @@
PHIL_HARVEY_TEST_IMAGE_FOLDER.getAbsolutePath());
}
- public static interface ImageFilter
- {
+ public static interface ImageFilter {
public boolean accept(File file) throws IOException, ImageReadException;
}
- protected File getTestImage() throws IOException, ImageReadException
- {
+ protected File getTestImage() throws IOException, ImageReadException {
return getTestImage(null);
}
protected File getTestImage(ImageFilter filter) throws IOException,
- ImageReadException
- {
+ ImageReadException {
List images = getTestImages(filter, 1);
assertTrue(images.size() > 0);
@@ -97,39 +84,31 @@
return (File) images.get(0);
}
- protected List getTestImages() throws IOException, ImageReadException
- {
+ protected List getTestImages() throws IOException, ImageReadException {
return getTestImages(null, -1);
}
protected List getTestImages(ImageFilter filter) throws IOException,
- ImageReadException
- {
+ ImageReadException {
return getTestImages(filter, -1);
}
private static final List ALL_IMAGES = new ArrayList();
- static
- {
- File srcFolder = new File("src");
- File testFolder = new File(srcFolder, "test");
- File dataFolder = new File(testFolder, "data");
- File imagesFolder = new File(dataFolder, "images");
+ static {
+ File imagesFolder = TEST_IMAGE_FOLDER;
// imagesFolder = new File(
// "C:\\personal\\apache\\sanselan\\src\\test\\data\\images\\bmp\\2");
imagesFolder = imagesFolder.getAbsoluteFile();
- assertTrue(imagesFolder.exists());
-
Debug.debug("imagesFolder", imagesFolder);
+ assertTrue(imagesFolder.exists());
FSTraversal.Visitor visitor = new FSTraversal.Visitor() {
- public boolean visit(File file, double progressEstimate)
- {
+ public boolean visit(File file, double progressEstimate) {
if (!Sanselan.hasImageFileExtension(file))
return true;
ALL_IMAGES.add(file);
@@ -140,13 +119,11 @@
}
protected List getTestImages(final ImageFilter filter, final int max)
- throws IOException, ImageReadException
- {
+ throws IOException, ImageReadException {
final List images = new ArrayList();
int counter = 0;
-
- for (int i = 0; i < ALL_IMAGES.size(); i++)
- {
+
+ for (int i = 0; i < ALL_IMAGES.size(); i++) {
File file = (File) ALL_IMAGES.get(i);
if (!Sanselan.hasImageFileExtension(file))
@@ -172,8 +149,7 @@
return images;
}
- protected boolean isInvalidPNGTestFile(File file)
- {
+ protected boolean isInvalidPNGTestFile(File file) {
return (file.getParentFile().getName().equalsIgnoreCase("pngsuite") && file
.getName().toLowerCase().startsWith("x"));
}
Added: 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=814209&view=auto
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java (added)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java Sat Sep 12 17:41:53 2009
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sanselan;
+
+import java.io.File;
+
+public interface SanselanTestConstants {
+
+ static final File PHIL_HARVEY_TEST_IMAGE_FOLDER = new File(
+ "src\\test\\data\\images\\exif\\philHarvey\\".replace("\\", System
+ .getProperty("file.separator")));
+
+ 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");
+}
Propchange: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/SanselanTestConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
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=814209&r1=814208&r2=814209&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 Sat Sep 12 17:41:53 2009
@@ -48,7 +48,7 @@
List imageFiles = getTestImages();
for (int i = 0; i < imageFiles.size(); i++)
{
- if (i % 10 == 0)
+ if (i % 1 == 0)
Debug.purgeMemory();
File imageFile = (File) imageFiles.get(i);
@@ -101,11 +101,14 @@
assertTrue(imageFile != null);
assertTrue(imageFile.getWidth() > 0);
assertTrue(imageFile.getHeight() > 0);
+ int imageFileWidth = imageFile.getWidth();
+ int imageFileHeight = imageFile.getHeight();
+ imageFile = null;
BufferedImage imageBytes = Sanselan.getBufferedImage(bytes);
assertTrue(imageBytes != null);
- assertTrue(imageFile.getWidth() == imageBytes.getWidth());
- assertTrue(imageFile.getHeight() == imageBytes.getHeight());
+ assertTrue(imageFileWidth == imageBytes.getWidth());
+ assertTrue(imageFileHeight == imageBytes.getHeight());
}
public void checkGetImageSize(File imageFile, byte[] imageFileBytes)
Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngMultipleRoundtripTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngMultipleRoundtripTest.java?rev=814209&r1=814208&r2=814209&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngMultipleRoundtripTest.java (original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/sanselan/formats/png/PngMultipleRoundtripTest.java Sat Sep 12 17:41:53 2009
@@ -35,7 +35,8 @@
public void test() throws IOException, ImageReadException,
ImageWriteException
{
- File imagesFolder = new File("src\\test\\data\\images\\png\\3");
+ String imagesFolderPath = "src\\test\\data\\images\\png\\3".replace("\\", System.getProperty("file.separator"));
+ File imagesFolder = new File(imagesFolderPath);
assertTrue(imagesFolder.exists() && imagesFolder.isDirectory());
File files[] = imagesFolder.listFiles();