harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r695539 - in /harmony/enhanced/classlib/trunk/modules: archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ awt/src/test/impl/boot/java/awt/ awt/src/test/impl/boot/java/awt/datatransfer/
Date Mon, 15 Sep 2008 16:37:54 GMT
Author: tellison
Date: Mon Sep 15 09:37:53 2008
New Revision: 695539

URL: http://svn.apache.org/viewvc?rev=695539&view=rev
Log:
Ensure temporary files are deleted after running tests.

Modified:
    harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/ComponentSerialize.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/datatransfer/DataFlavorRTest.java

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java?rev=695539&r1=695538&r2=695539&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java
Mon Sep 15 09:37:53 2008
@@ -232,6 +232,9 @@
         } catch (IndexOutOfBoundsException e) {
             // expected
         }
+
+        // Close stream because ZIP is invalid
+        stream.close();
     }
 
     /**
@@ -262,6 +265,8 @@
         } catch (IOException e2) {
             // expected
         }
+        
+        zip1.close();
     }
 
     @Override

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/ComponentSerialize.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/ComponentSerialize.java?rev=695539&r1=695538&r2=695539&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/ComponentSerialize.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/ComponentSerialize.java
Mon Sep 15 09:37:53 2008
@@ -91,6 +91,7 @@
     private Component writeAndRead(Component original)
                 throws IOException, ClassNotFoundException {
         File tempFile = File.createTempFile("save", ".object");
+        tempFile.deleteOnExit();
 
         FileOutputStream fos = new FileOutputStream(tempFile);
 
@@ -103,7 +104,8 @@
         ObjectInputStream ois = new ObjectInputStream(fis);
 
         Component restored = (Component)ois.readObject();
-        tempFile.delete();
+        ois.close();
+
         return restored;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/datatransfer/DataFlavorRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/datatransfer/DataFlavorRTest.java?rev=695539&r1=695538&r2=695539&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/datatransfer/DataFlavorRTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/impl/boot/java/awt/datatransfer/DataFlavorRTest.java
Mon Sep 15 09:37:53 2008
@@ -32,35 +32,29 @@
 
 public class DataFlavorRTest extends TestCase {
 
-    public void testSerializeDefaultDataFlavor() {
+    public void testSerializeDefaultDataFlavor() throws IOException,
+            ClassNotFoundException {
         DataFlavor flavor = new DataFlavor();
-        DataFlavor restored = (DataFlavor)writeAndRead(flavor);
+        DataFlavor restored = (DataFlavor) writeAndRead(flavor);
         assertEquals(restored, flavor);
     }
 
-
-    private Serializable writeAndRead(Serializable original) {
-
-        try {
-            File tempFile = File.createTempFile("save", ".object");
-
-            FileOutputStream fos = new FileOutputStream(tempFile);
-
-            ObjectOutputStream oos = new ObjectOutputStream(fos);
-            oos.writeObject(original);
-            oos.close();
-
-            FileInputStream fis = new FileInputStream(tempFile);
-            ObjectInputStream ois = new ObjectInputStream(fis);
-
-            Serializable restored = (Serializable) ois.readObject();
-            tempFile.delete();
-            return restored;
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        } catch (ClassNotFoundException e) {
-            throw new RuntimeException(e);
-        }
+    private Serializable writeAndRead(Serializable original)
+            throws IOException, ClassNotFoundException {
+        File tempFile = File.createTempFile("save", ".object");
+        tempFile.deleteOnExit();
+
+        FileOutputStream fos = new FileOutputStream(tempFile);
+
+        ObjectOutputStream oos = new ObjectOutputStream(fos);
+        oos.writeObject(original);
+        oos.close();
+
+        FileInputStream fis = new FileInputStream(tempFile);
+        ObjectInputStream ois = new ObjectInputStream(fis);
+
+        Serializable restored = (Serializable) ois.readObject();
+        ois.close();
+        return restored;
     }
-
 }
\ No newline at end of file



Mime
View raw message