harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r633510 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests: ArchiveTest.java SegmentTest.java
Date Tue, 04 Mar 2008 15:15:54 GMT
Author: sjanuary
Date: Tue Mar  4 07:15:52 2008
New Revision: 633510

URL: http://svn.apache.org/viewvc?rev=633510&view=rev
Log:
Change pack200 tests to delete temporary files when the test is finished

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java?rev=633510&r1=633509&r2=633510&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
Tue Mar  4 07:15:52 2008
@@ -33,11 +33,13 @@
 
     InputStream in;
     JarOutputStream out;
+    File file;
 
     public void testJustResourcesGZip() throws Exception {
-       in = Archive.class
+        in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("Just", "ResourcesGz.jar")));
+        file = File.createTempFile("Just", "ResourcesGz.jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -46,7 +48,8 @@
     public void testWithSqlE1() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/sql-e1.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("sql-e1", ".jar")));
+        file = File.createTempFile("sql-e1", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -55,7 +58,8 @@
     public void testWithSql() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("sql", ".jar")));
+        file = File.createTempFile("sql", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -64,7 +68,8 @@
     public void testWithPack200E1() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/pack200-e1.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("pack", "200-e1.jar")));
+        file = File.createTempFile("p200-e1", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -73,7 +78,8 @@
     public void testWithPack200() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/pack200.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("pack", "200.jar")));
+        file = File.createTempFile("p200", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -82,7 +88,8 @@
     public void testWithJNDIE1() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/jndi-e1.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("jndi", "-e1.jar")));
+        file = File.createTempFile("jndi-e1", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -91,7 +98,8 @@
     public void testWithAnnotations() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/annotations.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("ann", "otations.jar")));
+        file = File.createTempFile("annotations", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -100,8 +108,8 @@
     public void testWithE0() throws Exception  {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/simple-E0.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile(
-                "simpleE0", ".jar")));
+        file = File.createTempFile("simple-e0", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
@@ -111,31 +119,29 @@
     public void testWithLargeClass() throws Exception {
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/LargeClass.pack.gz");
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile(
-                "largeclass", ".jar")));
+        file = File.createTempFile("largeClass", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
     }
 
     protected void tearDown() throws Exception {
         super.tearDown();
-        try {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        } finally {
+        if (in != null) {
             try {
-                if (out != null) {
-                    out.close();
-                }
+                in.close();
             } catch (IOException e) {
                 e.printStackTrace();
             }
         }
+        try {
+            if (out != null) {
+                out.close();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        file.delete();
     }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java?rev=633510&r1=633509&r2=633510&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
Tue Mar  4 07:15:52 2008
@@ -36,13 +36,14 @@
 
     InputStream in;
     JarOutputStream out;
+    File file;
 
     public void testHelloWorld() throws Exception {
         in = Segment.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack");
         Segment segment = Segment.parse(in);
         assertNotNull(segment);
-        File file = File.createTempFile("hello", "world.jar");
+        file = File.createTempFile("HelloWorld", ".jar");
         out = new JarOutputStream(new FileOutputStream(file));
         segment.writeJar(out);
         out.close();
@@ -54,6 +55,7 @@
         BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
         String line = reader.readLine();
         assertEquals(line, "Hello world");
+        file.deleteOnExit();
     }
 
     public void testJustResources() throws Exception {
@@ -61,7 +63,8 @@
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack");
         Segment segment = Segment.parse(in);
         assertNotNull(segment);
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("just", "resources.jar")));
+        file = File.createTempFile("JustResources", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         segment.writeJar(out);
     }
 
@@ -70,7 +73,8 @@
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/InterfaceOnly.pack");
         Segment segment = Segment.parse(in);
         assertNotNull(segment);
-        out = new JarOutputStream(new FileOutputStream(File.createTempFile("Interface", "Only.jar")));
+        file = File.createTempFile("InterfaceOnly", ".jar");
+        out = new JarOutputStream(new FileOutputStream(file));
         segment.writeJar(out);
     }
 
@@ -83,6 +87,9 @@
         } finally {
             if (out != null) {
                 out.close();
+            }
+            if (file != null) {
+                file.delete();
             }
         }
     }



Mime
View raw message