commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1537238 [2/2] - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/ main/java/org/apache/commons/imaging/common/ main/java/org/apache/commons/imaging/common/bytesource/ main/java/org/apache/commons/imaging/common/it...
Date Wed, 30 Oct 2013 18:45:51 GMT
Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java?rev=1537238&r1=1537237&r2=1537238&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
Wed Oct 30 18:45:50 2013
@@ -75,6 +75,7 @@ public class ByteSourceDataTest extends 
         // bytes.
         {
             InputStream is = null;
+            boolean canThrow = false;
             try {
                 is = byteSource.getInputStream();
                 final byte prefix[] = new byte[256];
@@ -84,10 +85,9 @@ public class ByteSourceDataTest extends 
                 for (int i = 0; i < read; i++) {
                     assertTrue(src[i] == prefix[i]);
                 }
+                canThrow = false;
             } finally {
-                if (is != null) {
-                    is.close();
-                }
+                IoUtils.closeQuietly(canThrow, is);
             }
         }
 
@@ -111,6 +111,7 @@ public class ByteSourceDataTest extends 
             final int start = src.length / 2;
 
             InputStream is = null;
+            boolean canThrow = false;
             try {
                 is = byteSource.getInputStream(start);
                 final byte dst[] = IoUtils.getInputStreamBytes(is);
@@ -119,10 +120,9 @@ public class ByteSourceDataTest extends 
                 for (int i = 0; i < dst.length; i++) {
                     assertTrue(dst[i] == src[i + start]);
                 }
+                canThrow = true;
             } finally {
-                if (is != null) {
-                    is.close();
-                }
+                IoUtils.closeQuietly(canThrow, is);
             }
         }
 

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java?rev=1537238&r1=1537237&r2=1537238&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java
Wed Oct 30 18:45:50 2013
@@ -25,16 +25,23 @@ import java.io.IOException;
 import java.io.OutputStream;
 
 import org.apache.commons.imaging.ImagingTest;
+import org.apache.commons.imaging.util.IoUtils;
 
 public abstract class ByteSourceTest extends ImagingTest {
     protected File createTempFile(final byte src[]) throws IOException {
         final File file = createTempFile("raw_", ".bin");
 
         // write test bytes to file.
-        OutputStream os = new FileOutputStream(file);
-        os = new BufferedOutputStream(os);
-        os.write(src);
-        os.close();
+        OutputStream os = null;
+        boolean canThrow = false;
+        try {
+            os = new FileOutputStream(file);
+            os = new BufferedOutputStream(os);
+            os.write(src);
+            canThrow = true;
+        } finally {
+            IoUtils.closeQuietly(canThrow, os);
+        }
 
         // test that all bytes written to file.
         assertTrue(src.length == file.length());

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ApacheImagingSpeedAndMemoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ApacheImagingSpeedAndMemoryTest.java?rev=1537238&r1=1537237&r2=1537238&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ApacheImagingSpeedAndMemoryTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/ApacheImagingSpeedAndMemoryTest.java
Wed Oct 30 18:45:50 2013
@@ -263,8 +263,6 @@ public class ApacheImagingSpeedAndMemory
             } catch (final IOException ioex) {
                 ioex.printStackTrace();
                 System.exit(-1);
-            } finally {
-            	fmt.close();            	
             }
 
             try {

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java?rev=1537238&r1=1537237&r2=1537238&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java
Wed Oct 30 18:45:50 2013
@@ -39,15 +39,15 @@ public class WriteExifMetadataExample {
     public void removeExifMetadata(final File jpegImageFile, final File dst)
             throws IOException, ImageReadException, ImageWriteException {
         OutputStream os = null;
+        boolean canThrow = false;
         try {
             os = new FileOutputStream(dst);
             os = new BufferedOutputStream(os);
 
             new ExifRewriter().removeExifMetadata(jpegImageFile, os);
+            canThrow = true;
         } finally {
-            if (os != null) {
-                os.close();
-            }
+            IoUtils.closeQuietly(canThrow, os);
         }
     }
 
@@ -65,6 +65,7 @@ public class WriteExifMetadataExample {
     public void changeExifMetadata(final File jpegImageFile, final File dst)
             throws IOException, ImageReadException, ImageWriteException {
         OutputStream os = null;
+        boolean canThrow = false;
         try {
             TiffOutputSet outputSet = null;
 
@@ -141,12 +142,9 @@ public class WriteExifMetadataExample {
             new ExifRewriter().updateExifMetadataLossless(jpegImageFile, os,
                     outputSet);
 
-            os.close();
-            os = null;
+            canThrow = true;
         } finally {
-            if (os != null) {
-                os.close();
-            }
+            IoUtils.closeQuietly(canThrow, os);
         }
     }
 
@@ -168,6 +166,7 @@ public class WriteExifMetadataExample {
     public void removeExifTag(final File jpegImageFile, final File dst) throws IOException,
             ImageReadException, ImageWriteException {
         OutputStream os = null;
+        boolean canThrow = false;
         try {
             TiffOutputSet outputSet = null;
 
@@ -229,10 +228,9 @@ public class WriteExifMetadataExample {
 
             new ExifRewriter().updateExifMetadataLossless(jpegImageFile, os,
                     outputSet);
+            canThrow = true;
         } finally {
-            if (os != null) {
-                os.close();
-            }
+            IoUtils.closeQuietly(canThrow, os);
         }
     }
 
@@ -250,6 +248,7 @@ public class WriteExifMetadataExample {
     public void setExifGPSTag(final File jpegImageFile, final File dst) throws IOException,
             ImageReadException, ImageWriteException {
         OutputStream os = null;
+        boolean canThrow = false;
         try {
             TiffOutputSet outputSet = null;
 
@@ -296,10 +295,9 @@ public class WriteExifMetadataExample {
 
             new ExifRewriter().updateExifMetadataLossless(jpegImageFile, os,
                     outputSet);
+            canThrow = true;
         } finally {
-            if (os != null) {
-                os.close();
-            }
+            IoUtils.closeQuietly(canThrow, os);
         }
     }
 

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java?rev=1537238&r1=1537237&r2=1537238&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java
Wed Oct 30 18:45:50 2013
@@ -34,6 +34,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.jpeg.iptc.JpegIptcRewriter;
 import org.apache.commons.imaging.formats.jpeg.iptc.PhotoshopApp13Data;
 import org.apache.commons.imaging.util.Debug;
+import org.apache.commons.imaging.util.IoUtils;
 
 public class IptcUpdateTest extends IptcBaseTest {
     private List<File> imagesWithIptcData;
@@ -83,15 +84,14 @@ public class IptcUpdateTest extends Iptc
                 // test remove
 
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(noIptcFile);
                     os = new BufferedOutputStream(os);
                     new JpegIptcRewriter().removeIPTC(byteSource, os);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 final JpegPhotoshopMetadata outMetadata = new JpegImageParser()
@@ -136,15 +136,14 @@ public class IptcUpdateTest extends Iptc
                 // test remove
 
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(noIptcFile);
                     os = new BufferedOutputStream(os);
                     new JpegIptcRewriter().removeIPTC(byteSource, os);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 // Debug.debug("Source Segments:");
@@ -180,15 +179,14 @@ public class IptcUpdateTest extends Iptc
                 final File updated = createTempFile(imageFile.getName()
                         + ".iptc.update.", ".jpg");
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(updated);
                     os = new BufferedOutputStream(os);
                     new JpegIptcRewriter().writeIPTC(byteSource, os, newData);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 // Debug.debug("Source Segments:");
@@ -223,15 +221,14 @@ public class IptcUpdateTest extends Iptc
                 final File updated = createTempFile(imageFile.getName()
                         + ".iptc.update.", ".jpg");
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(updated);
                     os = new BufferedOutputStream(os);
                     new JpegIptcRewriter().writeIPTC(byteSource, os, newData);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 // Debug.debug("Source Segments:");
@@ -266,16 +263,15 @@ public class IptcUpdateTest extends Iptc
                 final File updated = createTempFile(imageFile.getName()
                         + ".iptc.insert.", ".jpg");
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(updated);
                     os = new BufferedOutputStream(os);
                     new JpegIptcRewriter().writeIPTC(new ByteSourceFile(
                             noIptcFile), os, newData);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 // Debug.debug("Source Segments:");
@@ -360,15 +356,14 @@ public class IptcUpdateTest extends Iptc
                 final File updated = createTempFile(imageFile.getName()
                         + ".iptc.add.", ".jpg");
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(updated);
                     os = new BufferedOutputStream(os);
                     new JpegIptcRewriter().writeIPTC(byteSource, os, newData);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 // Debug.debug("Destination Segments:");

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriteTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriteTest.java?rev=1537238&r1=1537237&r2=1537238&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriteTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriteTest.java
Wed Oct 30 18:45:50 2013
@@ -30,6 +30,7 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.formats.jpeg.JpegImageParser;
 import org.apache.commons.imaging.formats.jpeg.xmp.JpegXmpRewriter;
 import org.apache.commons.imaging.util.Debug;
+import org.apache.commons.imaging.util.IoUtils;
 
 public class JpegXmpRewriteTest extends JpegXmpBaseTest {
 
@@ -63,15 +64,14 @@ public class JpegXmpRewriteTest extends 
                 // test remove
 
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(noXmpFile);
                     os = new BufferedOutputStream(os);
                     new JpegXmpRewriter().removeXmpXml(byteSource, os);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 // Debug.debug("Source Segments:");
@@ -88,16 +88,15 @@ public class JpegXmpRewriteTest extends 
                 final String newXmpXml = "test";
                 final File updated = createTempFile(imageFile.getName() + ".", ".jpg");
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(updated);
                     os = new BufferedOutputStream(os);
                     new JpegXmpRewriter().updateXmpXml(byteSource, os,
                             newXmpXml);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 // Debug.debug("Source Segments:");
@@ -115,16 +114,15 @@ public class JpegXmpRewriteTest extends 
                 final String newXmpXml = "test";
                 final File updated = createTempFile(imageFile.getName() + ".", ".jpg");
                 OutputStream os = null;
+                boolean canThrow = false;
                 try {
                     os = new FileOutputStream(updated);
                     os = new BufferedOutputStream(os);
                     new JpegXmpRewriter().updateXmpXml(new ByteSourceFile(
                             noXmpFile), os, newXmpXml);
+                    canThrow = true;
                 } finally {
-                    if (os != null) {
-                        os.close();
-                    }
-                    os = null;
+                    IoUtils.closeQuietly(canThrow, os);
                 }
 
                 // Debug.debug("Source Segments:");



Mime
View raw message